1(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([["public-containers-WriteReview-components-GlobalWriteReviewForm","shared_components_SelectSingleListingTree_SelectSingleListingTree_tsx"],{90910(e,t,r){"use strict";r.d(t,{D:()=>i});var i=(e=>(e.RATINGS="ratings",e.CUMULATIVE_RATINGS="cumulative_ratings",e.BOOLEAN="boolean",e.TERMS="terms",e.NESTED_TERMS="nested_terms",e.RANGE="range",e.STATS="stats",e.NUMERIC_OPTIONS="numeric_options",e.DATE_HISTOGRAM="date_histogram",e.FILTERS="filters",e.BRANDS="brands",e.UNKNOWN="unknown",e.ASPECTS="aspects",e.UNIQUE="unique",e.MIN_MAX="min_max",e))(i||{})},36922(e,t,r){"use strict";r.d(t,{A:()=>VideoAttachmentThumbnail});var i=r(33803),n=r(19363),a=r(62227),s=r(85816),o=r(55279),c=r(42673),d=r(14202);const l={height:180,width:320};function VideoAttachmentThumbnail(e){const{attachment:t,usePlaceholder:r,responsiveSizes:u,...h}=e,f=(0,o.A)();function m(e,r){if("cloudflare_stream"===t.source){const i=new URL(f.generate("cdn.cloudflare_stream_thumbnail",{id:t.id,width:e,fit:"fill"})),n=new URL(f.generate("cdn.cloudflare_stream_thumbnail",{id:t.id,width:2*e,fit:"fill"}));return r&&(i.searchParams.set("height",r.toString()),n.searchParams.set("height",(2*r).toString())),{src:i.toString(),srcSet:`${n.toString()} 2x`}}return(r??e)>=180?{src:f.generate("cdn.youtube_video_thumbnail",{id:t.id,size:"mqdefault"})}:{src:f.generate("cdn.youtube_video_thumbnail",{id:t.id,size:"default"}),srcSet:f.generate("cdn.youtube_video_thumbnail",{id:t.id,size:"mqdefault"})+" 2x"}}return r?(0,d.jsx)(n.h,{style:{width:h.width,height:h.height},display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"secondary",borderRadius:!0,children:(0,d.jsx)(a.A,{name:"play"})}):u?(0,d.jsx)(s.A,{alt:"Thumbnail",...h,responsiveSizes:(0,i.A)(u,e=>({width:e.width,height:e.height,...m(e.width,e.height)}))}):(0,d.jsx)(s.A,{alt:"Thumbnail",...m(l.width,l.height),...(0,c.A)(h,{onMouseEnter:e=>{"cloudflare_stream"===t.source&&(e.currentTarget.setAttribute("data-original-src",e.currentTarget.getAttribute("src")??""),e.currentTarget.setAttribute("data-original-srcset",e.currentTarget.getAttribute("srcset")??""),e.currentTarget.setAttribute("src",f.generate("cdn.cloudflare_stream_thumbnail_gif",{id:t.id,width:l.width,height:l.height,fit:"fill",duration:"5s"})),e.currentTarget.removeAttribute("srcset"))},onMouseLeave:e=>{"cloudflare_stream"===t.source&&(e.currentTarget.setAttribute("src",e.currentTarget.getAttribute("data-original-src")??""),e.currentTarget.setAttribute("srcset",e.currentTarget.getAttribute("data-original-srcset")??""))},style:{objectPosition:"50% 50%"}})})}},96545(e,t,r){"use strict";r.d(t,{A:()=>AttachmentsField});var i=r(85906),n=r(19363),a=r(72194),s=r(87094),o=r(2063),c=r(30145),d=r(74954),l=r(63197),u=r(97075),h=r(7471),f=r(36349),m=r(45919),p=r(23481),g=r(4484),y=r(12732),b=r(62227),w=r(57259),v=r(52905),k=r(35447),T=r(78801),x=r.n(T),S=r(98379),C=r(41677),P=r(4169),A=r(55279),E=r(73442),I=r(49075);var $=r(14202);const _=x().bind({"video-editor":"DZHyOG","video-editor-preview":"QIOQUE","video-editor-volume":"MD9RZ8"});function TrimmedVideo({videoUrl:e,trimRange:t,volumeGain:r,onLoadedMetadata:n}){const a=(0,i.useRef)(null),s=(0,i.useRef)(null),o=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=a.current;if(!e||"undefined"==typeof AudioContext)return;const t=new AudioContext,i=t.createMediaElementSource(e),n=t.createGain();return i.connect(n).connect(t.destination),n.gain.value=r,s.current=n,o.current=t,()=>{i.disconnect(),n.disconnect(),t.close(),s.current=null,o.current=null}},[e]),(0,i.useEffect)(()=>{const e=o.current,t=s.current;e&&t&&t.gain.setTargetAtTime(r,e.currentTime,.01)},[r]);const c=e=>{e.currentTime<t[0]&&(e.currentTime=t[0]),e.currentTime>=t[1]&&(e.pause(),e.currentTime=t[0])};return(0,$.jsx)("video",{ref:a,className:_("video-editor-preview"),controls:!0,autoPlay:!0,playsInline:!0,src:e,onLoadedMetadata:e=>{n(e.currentTarget.duration),e.currentTarget.currentTime=t[0]},onPlay:e=>{o.current?.resume(),(e.currentTarget.currentTime<t[0]||e.currentTarget.currentTime>=t[1])&&(e.currentTarget.currentTime=t[0])},onTimeUpdate:e=>c(e.currentTarget),onSeeking:e=>c(e.currentTarget)})}function VideoEditor_VideoEditor({videoId:e,resolve:t,reject:r}){const a=(0,E.A)(),s=(0,A.A)(),[o,c]=(0,i.useState)(),[d,l]=(0,i.useState)(),[u,h]=(0,i.useState)(0),[f,p]=(0,i.useState)([0,0]),[g,y]=(0,i.useState)(1),[b,v]=(0,i.useState)(!1),[T,x]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{let t=!1;const r=s.generate("api.integrations.cloudflare_stream.video_download",{videoId:e},A.i.ABSOLUTE_URL);return a.get(r,{shouldRetry:(e,t)=>
1202===t.status||e,retry:{retries:20,minTimeout:1e3}}).then(e=>fetch(e.url)).then(e=>{if(!e.ok)throw new Error("Video download failed");return e.blob()}).then(e=>{if(t)return;const r=URL.createObjectURL(e);l(e),c(r)}).catch(()=>{t||x(!0)}),()=>{t=!0}},[a,s,e]),(0,i.useEffect)(()=>()=>{o&&URL.revokeObjectURL(o)},[o]),T)return(0,$.jsx)(n.h,{padding:4,children:(0,$.jsx)(k.A,{textStyle:"danger",children:"Unable to download this video for editing."})});if(!o||!d)return(0,$.jsx)(n.h,{alignItems:"center",display:"flex",justifyContent:"center",padding:4,style:{minHeight:300},children:(0,$.jsx)(w.A,{size:"medium",textStyle:"primary"})});return(0,$.jsxs)(n.h,{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",position:"relative",children:[(0,$.jsx)(TrimmedVideo,{videoUrl:o,trimRange:f,volumeGain:g,onLoadedMetadata:e=>{h(e),p(t=>0===t[1]?[0,e]:t)}}),u>0&&(0,$.jsx)(P.A,{duration:u,value:f,videoUrl:o,onChange:p}),(0,$.jsxs)(n.h,{display:"flex",flexDirection:"column",gap:1,marginX:3,className:_("video-editor-volume"),children:[(0,$.jsxs)(n.h,{alignItems:"baseline",display:"flex",justifyContent:"between",children:[(0,$.jsx)(k.A,{fontWeight:"bold",children:"Volume"}),(0,$.jsxs)(k.A,{fontSize:"small",monoSpaceNumber:!0,textStyle:"muted",children:[Math.round(100*g),"%"]})]}),(0,$.jsx)("input",{"aria-label":"Volume",type:"range",min:"0",max:"2",step:"0.05",value:g,onChange:e=>y(Number(e.target.value))})]}),(0,$.jsxs)(S.A,{gap:1,justifyContent:"end",margin:3,children:[(0,$.jsx)(m.A.Reset,{onClick:()=>r(new I.A),isDisabled:b,children:"Cancel"}),(0,$.jsx)(m.A.Submit,{onClick:async()=>{v(!0);try{const e=await(0,C.A)(d,{trimRange:{start:f[0],end:f[1]},volumeGain:g});t({blob:e.blob})}catch{v(!1),x(!0)}},isLoading:b,children:"Save video"})]})]})}function N(e){return{title:"Edit video",closeable:!0,size:"xlarge",bodyProps:{display:"flex",flexDirection:"column",overflowY:"hidden",padding:0},dialogProps:{justifyContent:"stretch",className:_("video-editor")},headerProps:{noBorder:!0},content:(t,r)=>(0,$.jsx)(VideoEditor_VideoEditor,{videoId:e,resolve:t,reject:r})}}var R=r(53552),O=r(58222),F=r(86490),B=r(47806),D=r(24082),M=r(16940),j=r(39646),L=r(25343),U=r(37225);function Image(e){const{getCdnImageSrc:t}=(0,c.A)();return e.image.remoteId?(0,$.jsx)(L.A.Static,{openNewTab:!0,to:t({collection:e.collection,id:e.image.remoteId}),title:"Open full-size image in new tab",children:(0,$.jsx)(j.A,{collection:e.collection,width:80,height:80,cdnImageWidth:720,withoutEnlargement:!0,cdnVersion:4,fit:"cover",id:e.image.remoteId,style:{objectPosition:(()=>{if(e.image.metadata&&e.image.metadata.focalBox)return(0,U.H)(e.image.metadata.width,e.image.metadata.height,80,80,e.image.metadata.focalBox)})()}})}):(0,$.jsx)(n.h,{style:{width:80,height:80}})}var z=r(19107),W=r(71536),V=r(53712),q=r.n(V),H=r(36922),G=r(55315),K=r(12765),Y=r(74702),X=r(83115),Q=r(49739),J=r(9680),Z=r(33965);const ee=1e3,te=6e4,re=36e5,ie=24*re,ne=7*ie,ae=30*ie,se=365*ie;const oe={"attachment-video":"ao9ARZ","attachment-video-thumbnail":"u4cSwz","attachment-video-play":"bYKIkw"},ce=x().bind(oe);function CloudflareStreamVideo(e){const{locale:t}=(0,i.useContext)(J.A),r=function(){const e=(0,Z.A)();return(0,i.useCallback)(t=>{const{quantity:r,unit:i}=t.milliseconds>se?{quantity:Math.floor(t.milliseconds/se),unit:"year"}:t.milliseconds>ae?{quantity:Math.floor(t.milliseconds/ae),unit:"month"}:t.milliseconds>ne?{quantity:Math.floor(t.milliseconds/ne),unit:"week"}:t.milliseconds>ie?{quantity:Math.floor(t.milliseconds/ie),unit:"day"}:t.milliseconds>re?{quantity:Math.floor(t.milliseconds/re),unit:"hour"}:t.milliseconds>te?{quantity:Math.floor(t.milliseconds/te),unit:"minute"}:t.milliseconds>ee?{quantity:Math.floor(t.milliseconds/ee),unit:"second"}:{quantity:t.milliseconds,unit:"millisecond"};return e.formatMessage({id:"shared.intl.format_duration",defaultMessage:"{format, select,\n long {{quantity} {unit, select,\n millisecond {{quantity, plural, =1 {millisecond} other {milliseconds}}}\n second {{quantity, plural, =1 {second} other {seconds}}}\n minute {{quantity, plural, =1 {minute} other {minutes}}}\n hour {{quantity, plural, =1 {hour} other {hours}}}\n day {{quantity, plural, =1 {day} other {days}}}\n week {{quantity, plural, =1 {week} other {weeks}}}\n month {{quantity, plural, =1 {month} other {months}}}\n year {{quantity, plural, =1 {year} other {years}}}\n }}\n short {{quantity}{unit, select,\n millisecond {ms}\n second {s}\n minute {m}\n hour {h}\n day {d}\n week {w}\n month {mon}\n year {y}\n }}\n}"},{format:t.format||"long",quantity:r,unit:i})},[e])}(),a=(0,d.tz)(),s=(0,F.A)(D.Jj),{showModal:o}=(0,O.A)(),c=s.context.role===M.Xh.STAFF&&Boolean(e.onEdit),l=(0,$.jsxs)(n.h,{cursor:"pointer",flexShrink:0,position:"relative",title:a.formatMessage({id:c?"shared.attachments.video.cloudflare_stream.thumbnail.edit_title":"shared.attachments.video.cloudflare_stream.thumbnail.title",defaultMessage:c?"Edit video":"Preview video"}),tracking:{id:`cloudflare_stream_video_play.${e.videoId}`},onClick:c?()=>{o(N(e.videoId)).then(({blob:t})=>e.onEdit?.(t)).catch(I.O)}:void 0,children:[(0,$.jsx)(H.A,{attachment:{id:e.videoId,type:"video",source:"cloudflare_stream"},height:100,width:176,fit:"cover",className:ce("attachment-video-thumbnail")}),(0,$.jsx)(b.A,{name:"play",height:18,width:18,margin:"auto",position:"absolute-center",textStyle:"white",className:ce("attachment-video-play")})]});
1return(0,$.jsxs)(Y.A,{alignItems:"stretch",flexDirection:e.forceVerticalLayout?"column":void 0,className:ce("attachment-video"),children:[c?l:(0,$.jsx)(Q.A,{content:(0,$.jsx)(G.A,{id:e.videoId}),size:"fullscreen",children:l}),(0,$.jsx)(Y.A.Body,{fontSize:"small",lineHeight:"small",paddingX:3,paddingY:2,textAlign:e.forceVerticalLayout?"center":void 0,textStyle:"muted",style:{minWidth:0},children:(0,$.jsx)(K.A,{items:(0,W.A)([e.videoDetails.duration&&e.videoDetails.duration>0&&r({milliseconds:1e3*e.videoDetails.duration,format:"short"}),q()(e.videoDetails.size,{locale:t,base:2})]),renderListItem:e=>(0,$.jsx)(k.A,{nowrap:!0,children:e}),defaultSeparator:(0,$.jsx)(X.A,{}),defaultSeparatorAsLast:!0})})]})}var de=r(49329);function UnreadyCloudflareStreamVideo({videoId:e}){const{isLoading:t,error:r,value:n,retry:a}=function(e){const t=(0,A.A)(),r=(0,E.A)(),[n,a]=(0,i.useState)({isLoading:!0}),[s,o]=(0,i.useState)(0),c=(0,i.useRef)(void 0);return(0,i.useEffect)(()=>(a({isLoading:!0}),r.get(t.generate("api.integrations.cloudflare_stream.video_details",{videoId:e}),{memoizeFor:6e4,shouldRetry:async(e,t)=>200===t.status&&!(await t.clone().json()).readyToStream||e,retry:{retries:10,minTimeout:5e3},cancelToken:c.current}).then(e=>{a({isLoading:!1,value:e})}).catch(e=>{a({isLoading:!1,error:e})}),()=>{c.current?.cancel()}),[e,s]),{...n,retry:()=>o(e=>e+1)}}(e);return t?(0,$.jsx)(z.A,{label:(0,$.jsx)(k.A,{fontSize:"small",textStyle:"muted",children:"Loading video previewâ¦"})}):r||!n?(0,$.jsx)(k.A,{onClick:()=>a(),cursor:"pointer",textDecoration:"underline",children:(0,$.jsx)(d.sA,{id:"cloudflare_stream.video.failed_to_load",defaultMessage:"Couldn't load video preview. Click here to try again",returnType:"string",children:e=>(0,$.jsx)(de.A,{source:e,initialParser:"inline"})})}):(0,$.jsx)(CloudflareStreamVideo,{videoId:e,videoDetails:n})}var le=r(4155),ue=r.n(le);const he=new(r(11106).default);var fe=r(85816),me=r(6265);const pe=x().bind(oe);function YoutubeVideo({videoId:e}){const t=(0,A.A)(),r=(0,me.A)(()=>function(e,t){const r=e.generate("api.integrations.youtube.video.metadata",{videoId:t});return he.get(r,{query:{key:ue().google.apiKey,part:"statistics,snippet"}}).then(e=>{const r=e.items[0];if(!r)throw new Error(`Youtube video with ID ${t} was not found`);const{snippet:i,statistics:n}=r;return{title:i.title,excerpt:i.description,thumbnails:i.thumbnails,publishedAt:i.publishedAt,numberOfViews:parseInt(n.viewCount,10)}})}(t,e),[e]);return r.isLoading?(0,$.jsx)(z.A,{style:{width:80,height:80}}):r.error||!r.value?(0,$.jsx)(k.A,{padding:3,textStyle:"danger",children:"Error"}):(0,$.jsxs)(L.A.Static,{to:t.generate("cdn.youtube_video",{id:e}),external:!0,title:r.value.title,position:"relative",children:[(0,$.jsx)(b.A,{name:"play",height:18,width:18,margin:"auto",position:"absolute-center",textStyle:"white",className:pe("attachment-video-play")}),(0,$.jsx)(fe.A,{src:r.value.thumbnails.medium.url,srcSet:`${r.value.thumbnails.high.url} 2x`,alt:e,height:80,width:80,fit:"cover",flexShrink:0,borderRadius:!0})]})}function Video_Video(e){const t=e.video.remoteId;return t?"cloudflare_stream"===e.video.source?e.video.metadata?.cloudflareStreamVideoDetails?(0,$.jsx)(CloudflareStreamVideo,{videoId:t,videoDetails:e.video.metadata?.cloudflareStreamVideoDetails,forceVerticalLayout:e.forceVerticalLayout,onEdit:e.onEdit}):(0,$.jsx)(UnreadyCloudflareStreamVideo,{videoId:t}):(0,$.jsx)(YoutubeVideo,{videoId:t}):(0,$.jsx)(z.A,{label:(0,$.jsx)(k.A,{fontSize:"small",textStyle:"muted",children:(0,$.jsx)(d.sA,{id:"attachments.video.uploading",defaultMessage:"Uploading {hasFileName, select, true {{fileName}} false {video}}â¦",values:{hasFileName:Boolean(e.video.file),fileName:e.video.file?.name}})})})}const OverlayContainer=({children:e})=>(0,$.jsx)(n.h,{alignItems:"center",display:"flex",flexDirection:"column",justifyContent:"center",position:"absolute-center",children:e});function AttachmentObject(e){const t=(0,B.A)(),{showModal:r}=(0,O.A)(),a=(0,F.A)(D.Jj),s=(0,A.A)(),{object:o}=e,c=a.context.role===M.Xh.STAFF;function l(r){const i=Date.now(),n=new File([r],`${i}.mp4`,{type:r.type||"video/mp4",lastModified:i});e.uploader.setObjectAttributes(o.internalId,{id:t(),remoteId:void 0,uploadUrl:void 0,isRemote:!1,isUploaded:!1,isUploading:!1,progress:0,error:void 0,file:n})}function u(n){return(0,$.jsxs)(i.Fragment,{children:["image"===o.type&&(0,$.jsx)(i.Fragment,{children:(0,$.jsx)(g.A.Item,{onClick:()=>{o.remoteId&&(r((0,R.A)({onCrop:r=>{const i=Date.now(),n=new File([r.blob],`${i}.png`,{type:"image/png",lastModified:+i});e.uploader.setObjectAttributes(o.internalId,{id:t(),isRemote:!1,isUploaded:!1,file:n})},src:s.generate("api.integrations.cdn.image_to_be_edited",{collection:e.collection,uuid:o.remoteId,resourceType:e.resource.type,resourceId:e.resource.id},A.i.ABSOLUTE_URL)},{backdrop:"static",closeable:!0,pullToClose:!1})).catch(I.O),n())},isDisabled:!o.isUploaded&&!o.isRemote,children:(0,$.jsxs)(k.A,{display:"flex",gap:2,children:[(0,$.jsx)(b.A,{name:"crop",flexShrink:0}),"Edit"]})})}),c&&"video"===o.type&&"cloudflare_stream"===o.source&&(0,$.jsx)(g.A.Item,{onClick:()=>{o.remoteId&&function(e){o.remoteId&&(r(N(o.remoteId)).then(({blob:e})=>l(e)).catch(I.O),e())}(n)},isDisabled:!o.isUploaded&&!o.isRemote,children:(0,$.jsxs)(k.A,{display:"flex",gap:2,children:[(0,$.jsx)(b.A,{name:"crop",flexShrink:0}),"Edit"]})}),e.renderExtraDropdownItems?.(o,n),(0,$.jsx)(g.A.Item,{onClick:()=>e.onRemove(o.internalId),textStyle:"danger",children:(0,$.jsxs)(k.A,{display:"flex",gap:2,textStyle:"danger",children:[(0,$.jsx)(b.A,{name:"trash",flexShrink:0}),"Remove"]})},"remove")]})}const h=(0,$.jsxs)(i.Fragment,{children:[(0,$.jsx)(v.A,{modalOptions:{title:"Edit attachment",content:u,bodyProps:{paddingY:2},headerProps:{padding:2,paddingLeft:4}},popoverOptions:{content:e=>(0,$.jsx)(n.h,{paddingY:1,children:u(e)}),placement:"top-end",trigger:"click"},children:e=>(0,$.jsxs)(m.A,{buttonSize:"xsmall",buttonStyle:"dark",icon:!0,isActive:e,pill:!0,elevation:1,margin:1,noBorder:!0,position:"absolute-top-right",children:[(0,$.jsx)(b.A,{name:"ellipsis-horizontal"}),(0,$.jsx)(k.A,{srOnly:!0,children:"More actions"})]})}),o.error&&(0,$.jsxs)(OverlayContainer,{children:[(0,$.jsx)(b.A,{name:"exclamation-circle",textStyle:"danger"}),(0,$.jsx)(k.A,{fontSize:"xsmall",lineHeight:"small",textStyle:"danger",children:(0,$.jsx)(y.A,{error:o.error})})]}),"image"===o.type?(0,$.jsxs)(i.Fragment,{children:[o.isUploading&&(0,$.jsxs)(OverlayContainer,{children:[(0,$.jsx)(w.A,{size:"medium",textStyle:"primary"}),(0,$.jsx)(k.A,{fontSize:"xsmall",textStyle:"muted",children:(0,$.jsx)(d.Gr,{value:o.progress/100,options:{style:"percent"}})})]}),(0,$.jsx)(Image,{image:o,collection:e.collection})]}):(0,$.jsx)(Video_Video,{video:o,forceVerticalLayout:Boolean(e.renderAttachmentDetails),onEdit:"cloudflare_stream"===o.source?l:void 0})]});if(e.renderAttachmentDetails)return(0,$.jsx)(p.A,{overflow:"hidden",position:"relative",children:(0,$.jsxs)(p.A.Block,{breakWord:!0,alignItems:"start",display:"flex",fontSize:"small",gap:3,lineHeight:"small",padding:1,children:[h,e.renderAttachmentDetails(o)]})});const f="cloudflare_stream"===o.source?{flexBasis:100,flexGrow:1,flexShrink:0,className:"enable-container-query"}:{};return(0,$.jsx)(n.h,{backgroundColor:"white",borderRadius:!0,overflow:"hidden",position:"relative",...f,children:h})}function Attachments(e){if(0===e.objects.length)return null;const t=e.objects.filter(e=>"image"===e.type),r=e.objects.filter(e=>"video"===e.type).sort((e,t)=>
1Number("cloudflare_stream"===e.source)-Number("cloudflare_stream"===t.source)),i=e.renderAttachmentDetails?{display:"grid",gap:2,style:{gridTemplateColumns:"repeat(auto-fit, minmax(400px, 1fr))"}}:{display:"flex",flexWrap:"wrap",gap:2};return(0,$.jsxs)(n.h,{...i,children:[t.map(t=>(0,$.jsx)(AttachmentObject,{resource:e.resource,object:t,collection:e.collection,onRemove:e.onRemove,uploader:e.uploader,renderExtraDropdownItems:e.renderExtraDropdownItems,renderAttachmentDetails:e.renderAttachmentDetails},t.internalId)),r.map(t=>(0,$.jsx)(AttachmentObject,{resource:e.resource,object:t,collection:e.collection,onRemove:e.onRemove,uploader:e.uploader,renderExtraDropdownItems:e.renderExtraDropdownItems,renderAttachmentDetails:e.renderAttachmentDetails},t.internalId))]})}function AttachmentsFieldComponent(e){const{control:t}=(0,o.xW)(),{getCdnImageSrc:r}=(0,c.A)();return e.wrap((0,$.jsx)(s.A,{objects:e.input.value,onChange:t=>{e.input.onChange(void 0,t)},autoUpload:!0,mode:"multiple",order:"prepend",withCloudflareStream:!0,validation:{itemsLimit:10,acceptFiles:`${u.ZS},${u.ng}`,maxFileSize:{[u.ZS]:104857600,[u.ng]:1073741824}},handlerConfig:{collection:e.componentProps.collection,getObjectPreviewUrl:(t,i)=>{if("image"===t.type&&i)return r({collection:e.componentProps.collection,id:i,width:80,height:80,fit:"cover"})}},generateObjectMetadata:e=>{const t=e.type.startsWith("video/")?"video":"image";return{type:t,source:"video"===t?"cloudflare_stream":void 0}},resource:e.componentProps.resource,onStartUpload:e.componentProps.onStartUpload,onFinishUpload:e.componentProps.onFinishUpload,onCancelUpload:e.componentProps.onCancelUpload,onError:e.componentProps.onError,onInternalStateChanged:e.componentProps.onInternalStateChanged,children:r=>(e.componentProps.uploaderRef&&(e.componentProps.uploaderRef.current=r),(0,$.jsxs)(n.h,{display:"flex",flexDirection:"column",gap:4,children:[(0,$.jsx)(a.A,{id:e.meta.htmlId,testId:"dropzone",uploaderProps:r,renderError:e=>{if(e instanceof f.A){const r="proofOfPurchaseId"in t.store.state.fieldsState.registeredFields;return(0,$.jsx)(d.sA,{id:"shared.attachments_field.error.invalidFileType",defaultMessage:"File {fileName} is of invalid type. {hasProofOfPurchaseField, select,\n true {Try uploading it as a proof of purchase down below.}\n false {}\n}",values:{fileName:e.file.name,hasProofOfPurchaseField:String(r)}})}return(0,$.jsx)(h.A,{error:e,mode:r.mode,validation:r.validation})}}),(0,$.jsx)(Attachments,{resource:e.componentProps.resource,uploader:r,objects:r.objects,onRemove:r.removeObject,collection:e.componentProps.collection,renderExtraDropdownItems:e.componentProps.renderExtraDropdownItems,renderAttachmentDetails:e.componentProps.renderAttachmentDetails})]}))}))}function AttachmentsField(e){(0,d.tz)();const{name:t,label:r,required:n=!1,...a}=e,s=(0,o.xW)(),{logger:c}=(0,i.useContext)(l.A);return(0,$.jsx)(o.D0,{name:t,label:r??"Attach public photos and videos",component:AttachmentsFieldComponent,componentProps:a,format:e=>{if(Array.isArray(e))return e.map(e=>({...e,internalId:e.id,remoteId:e.id,isRemote:!0,isUploaded:!0}))},normalize:e=>Array.isArray(e)?e.filter(e=>!!e.remoteId||(c.error("AttachmentObjectWithoutRemoteIdException ",{metadata:{formContext:s}}),!1)).map(e=>({id:e.remoteId,type:e.type,source:e.source,metadata:e.metadata})):[],required:n})}},26730(e,t,r){"use strict";r.d(t,{A:()=>PromisifiedButton});var i=r(85906),n=r(19738),a=r(45919),s=r(12732);r(74954);var o=r(49075),c=r(12960),d=r(26084),l=r(14202);const u="Error! Try again",h="Done!";function PromisifiedButton(e){const{onClick:t,onSuccess:r,onError:f,reactToError:m,reactToSuccess:p,errorLabel:g=u,successLabel:y=h,isReadOnly:b,showSuccessMessageForMs:w=3e3,...v}=e,{callback:k,isLoading:T,error:x,response:S}=function(e){const[t,r]=(0,i.useState)({isLoading:!1,error:null}),n=(0,i.useRef)(!1);return(0,i.useEffect)(()=>(n.current=!0,()=>{n.current=!1})),{...t,callback:async(...t)=>{try{const a=e(...t);if((i=a)&&"function"==typeof i.then){r({isLoading:!0});const e=await a;return n.current&&r({response:e,isLoading:!1}),e}return console.error(`useAsyncCallback(fn, ...args): fn did not return a promise. fn: ${e.toString()}`),a}catch(e){throw n.current&&r({isLoading:!1,error:e}),e}var i}}}(t),{showNotification:C}
1=(0,d.A)(),[P,A]=(0,i.useState)(!1),E=x&&!(x instanceof n.AL)&&!(x instanceof o.A);return(0,i.useEffect)(()=>{void 0!==S&&(p&&A(!0),r&&r(S))},[S]),(0,i.useEffect)(()=>{let e;return P&&(e=window.setTimeout(()=>{A(!1)},w)),()=>{e&&clearTimeout(e)}},[P]),(0,i.useEffect)(()=>{E&&(f?f(x):m&&C({message:(0,l.jsx)(s.A,{error:x}),level:c.S.ERROR}))},[x]),(0,l.jsx)(a.A.Button,{...v,onClick:b?void 0:k,buttonStyle:E&&m?"danger":v.buttonStyle,isDisabled:v.isDisabled||T,isLoading:T,children:P?y:E&&m?g:v.children})}},90419(e,t,r){"use strict";r.d(t,{A:()=>CollapsibleContent});var i=r(85906),n=r(35447),a=(r(74954),r(14202));function CollapsibleContent(e){const{children:t,doNotRender:r=!1,expandLinkLabel:s="Read Moreâ¦"}=e,[o,c]=(0,i.useState)(!1),d={onClick:()=>c(!o),children:s,cursor:"pointer",textDecorationHover:"underline",textStyle:"link"};return r?o?t:(0,a.jsx)(n.A,{stretchedLink:!0,...d}):(0,a.jsxs)(i.Fragment,{children:[!o&&(0,a.jsx)(n.A,{...d,caret:"down",display:"block",marginBottom:4}),(0,a.jsx)(i.Activity,{mode:o?"visible":"hidden",children:t})]})}},70009(e,t,r){"use strict";r.d(t,{A:()=>a});var i=r(85906),n=r(87855);function a(){const e=(0,i.useContext)(n.A);if(e)return e;throw new Error("useCollator: make sure it is inside a CollatorContext")}},55315(e,t,r){"use strict";r.d(t,{A:()=>EmbedCloudflareStreamVideo});var i=r(19363),n=r(55279),a=r(14202);function EmbedCloudflareStreamVideo(e){const{id:t,...r}=e,s=(0,n.A)();return(0,a.jsx)(i.h,{...r,element:"iframe",src:s.generate("cdn.cloudflare_stream_video_embed",{id:t,autoplay:!0}),allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture;",allowFullScreen:!0,frameBorder:"0",height:"100%",title:"Video",tracking:{id:`cloudflare_stream_video_play.${t}`},width:"100%"})}},57623(e,t,r){"use strict";r.d(t,{A:()=>GenericFormErrorMessage});var i=r(36171),n=r(12732),a=r(2063),s=r(49075),o=r(14202);function GenericFormErrorMessage(e){const{error:t,form:r,...c}=e,{control:d}=(0,a.xW)();return t instanceof s.A?null:(0,o.jsx)(i.A,{"data-form-error-for":r??d?.name,alertStyle:"danger",...c,children:(0,o.jsx)(n.A,{error:t})})}},49739(e,t,r){"use strict";r.d(t,{A:()=>ModalTrigger});var i=r(85906),n=r(10014),a=r(14202);function ModalTrigger(e){const{children:t,isOpen:r=!1,onChange:s,...o}=e,[c,d]=(0,i.useState)(r),l=()=>{d(!1),s&&s(!1)};return(0,i.useEffect)(()=>{d(r||!1)},[r]),(0,a.jsxs)(i.Fragment,{children:[(0,i.cloneElement)(t,{onClick:e=>{e.preventDefault(),"function"==typeof t.props.onClick&&t.props.onClick(e),d(!0),s&&s(!0)}}),c&&(0,a.jsx)(n.A,{...o,resolve:l,reject:l})]})}},40299(e,t,r){"use strict";r.d(t,{A:()=>Popover});var i=r(85906),n=r(79400),a=r.n(n),s=r(19363),o=r(88367),c=r(73469),d=r(42673),l=r(14202);function Popover(e){const{content:t,placement:r="top",trackingId:n,trigger:u="click",children:h,bodyProps:f,...m}=e,p=(e,r,i)=>(0,l.jsx)(s.h,{ref:e,...(0,d.A)(r,{className:a()("bs-popover-auto","popover")}),children:(0,l.jsx)(s.h,{appContext:n?{namespace:`${n}.popover`}:void 0,overflow:"hidden",...f,className:a()("popover-body",f?.className),children:"function"==typeof t?t(i,i):t})});return n?(0,l.jsx)(c.A,{id:`${n}.popover`,triggerEvent:"onOpen",children:e=>(0,l.jsx)(c.A,{id:n,triggerEvent:"onClose",children:t=>(0,l.jsx)(o.A,{content:p,placement:r,trigger:u,...(0,d.A)((0,d.A)(m,t),e),children:(e,t,r)=>{const n="function"==typeof h?h(r):h;return(0,i.cloneElement)(n,(0,d.A)({ref:e},(0,d.A)(n.props,t)))}})})}):(0,l.jsx)(o.A,{content:p,placement:r,trigger:u,...m,children:(e,t,r)=>{const n="function"==typeof h?h(r):h;return(0,i.cloneElement)(n,(0,d.A)({ref:e},(0,d.A)(n.props,t)))}})}},52905(e,t,r){"use strict";r.d(t,{A:()=>ResponsivePopover});var i=r(49739),n=r(40299),a=r(3921),s=r(14202);function ResponsivePopover(e){return(0,a.A)()?(0,s.jsx)(i.A,{...e.modalOptions,children:"function"==typeof e.children?e.children():e.children}):(0,s.jsx)(n.A,{...e.popoverOptions,children:t=>"function"==typeof e.children?e.children(t):e.children})}},80579(e,t,r){"use strict";r.d(t,{A:()=>Price});var i=r(74954),n=r(14202);function Price(e){const{amount:t,currency:r,isInCents:a=!1,hideCentsIfWhole:s}=e;let o=Number(t),c=2;return a&&(o/=100),s&&o%1==0&&(c=0),(0,n.jsx)(i.Gr,{value:o,options:{style:"currency",currency:r,minimumFractionDigits:c,maximumFractionDigits:2}}
1)}},37225(e,t,r){"use strict";function i(e,t,r){return Math.min(r,Math.max(t,e))}function n(e,t,r,n,a){const s=Math.max(r/e,n/t),o=e*s,c=t*s,d=Math.max(0,o-r),l=Math.max(0,c-n),u=a.x*s,h=a.y*s,f=a.width*s,m=a.height*s,p=e>=t;function g(e,t,r,n,a,s){const o=t+r-n,c=t,d=Math.max(0,o),l=Math.min(a,c);return d<=l?i(e,d,l):i(null!==s?s:e,0,a)}const y=h+m/2;let b;b=m<=n?y-n/2:p?h:y-n/2;const w=g(f<=r?u+f/2-r/2:u,u,f,r,d,null),v=g(b,h,m,n,l,!p&&m>n?h:null),k=0===l?50:v/l*100;return`${i(0===d?50:w/d*100,0,100).toFixed(2)}% ${i(k,0,100).toFixed(2)}%`}function a(e,t,r,i,a){return n(e,t,i*r,i,a)}r.d(t,{H:()=>n,k:()=>a})},28e3(e,t,r){"use strict";r.d(t,{A:()=>Mt});var i=r.cw(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},a=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),s=c(n()),o=c(r(65794));function c(e){return e&&e.__esModule?e:{default:e}}var d=function(e){function FontAwesome(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,FontAwesome);var e=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(FontAwesome.__proto__||Object.getPrototypeOf(FontAwesome)).call(this));return e.displayName="FontAwesome",e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(FontAwesome,e),a(FontAwesome,[{key:"render",value:function(){var e=this.props,t=e.border,r=e.cssModule,n=e.className,a=e.fixedWidth,o=e.flip,c=e.inverse,d=e.name,l=e.pulse,u=e.rotate,h=e.size,f=e.spin,m=e.stack,p=e.tag,g=void 0===p?"span":p,y=e.ariaLabel,b=function(e,t){var r={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i]);return r}(e,["border","cssModule","className","fixedWidth","flip","inverse","name","pulse","rotate","size","spin","stack","tag","ariaLabel"]),w=y?{"aria-label":y}:{"aria-hidden":!0},v=[];return r?(v.push(r.fa),v.push(r["fa-"+d]),h&&v.push(r["fa-"+h]),f&&v.push(r["fa-spin"]),l&&v.push(r["fa-pulse"]),t&&v.push(r["fa-border"]),a&&v.push(r["fa-fw"]),c&&v.push(r["fa-inverse"]),o&&v.push(r["fa-flip-"+o]),u&&v.push(r["fa-rotate-"+u]),m&&v.push(r["fa-stack-"+m])):(v.push("fa"),v.push("fa-"+d),h&&v.push("fa-"+h),f&&v.push("fa-spin"),l&&v.push("fa-pulse"),t&&v.push("fa-border"),a&&v.push("fa-fw"),c&&v.push("fa-inverse"),o&&v.push("fa-flip-"+o),u&&v.push("fa-rotate-"+u),m&&v.push("fa-stack-"+m)),n&&v.push(n),s.default.createElement(g,i({},b,w,{className:v.join(" ")}))}}]),FontAwesome}(s.default.Component);d.propTypes={ariaLabel:o.default.string,border:o.default.bool,className:o.default.string,cssModule:o.default.object,fixedWidth:o.default.bool,flip:o.default.oneOf(["horizontal","vertical"]),inverse:o.default.bool,name:o.default.string.isRequired,pulse:o.default.bool,rotate:o.default.oneOf([90,180,270]),size:o.default.oneOf(["lg","2x","3x","4x","5x"]),spin:o.default.bool,stack:o.default.oneOf(["1x","2x"]),tag:o.default.string},t.default=d,e.exports=t.default}),n=()=>r(85906),a=r.cw(function(e,t){const i=r.p+"checkmark_6ffd9f35.png";e.exports=i}),s=r.cw(function(e,t){const i=r.p+"star-filled_884acc12.png";e.exports=i}),o=r.cw(function(e,t){const i=r.p+"to-do-list_909c0b43.png";e.exports=i}),c=r(78026),d=r(13281),l=r(31362),u=r(22551);n();var h=r(78801),f=r.n(h),m=r(99856),p=r(36171),g=r(96545),y=r(19363),b=r(45919),w=r(98379),v=r(23481),k=r(32475),T=r(11242),x=r(58646),S=r(63805),C=r(34496);class P{constructor(e,t=Date){this._Date=t,this.control=e,this.initializedAt=this._Date.now(),this.explicitlyRegisteredFieldNames=[],this.fields={}}control;explicitlyRegisteredFieldNames;fields;currentActiveRangeFieldName;lastChangedRangeFieldName;initializedAt;submittedAt;subscribe(){const e=this.handleFocus.bind(this),t=this.handleBlur.bind(this),r=this.handleChange.bind(this),i=this.handlePaste.bind(this);return this.control.eventEmitter.addListener("focus",e),this.control.eventEmitter.addListener("blur",t),this.control.eventEmitter.addListener("change",r),this.control.eventEmitter.addListener("paste",i),()=>{this.control.eventEmitter.removeListener("focus",e),this.control.eventEmitter.removeListener("blur",t),this.control.eventEmitter.removeListener("change",r),this.control.eventEmitter.removeListener("paste",i)}}initializeField(e){return this.fields[e]={activeTimeRange:[],registeredAt:this._Date.now()},this}newActiveTimeRangeItem(){const e=this._Date.now();return{from:e,to:e,numberOfChanges:0}}deleteField(e){delete this.fields[e]}ensureFieldIsInitialized(e){e in this.fields||this.initializeField(e)}ensureLastActiveTimeRangeItemExists(e){this.fields[e].activeTimeRange.length||this.fields[e].activeTimeRange.push(this.newActiveTimeRangeItem())}addNewActiveTimeRange(e){this.fields[e].activeTimeRange.push(this.newActiveTimeRangeItem())}getLastActiveTimeRangeItem(e){return this.fields[e].activeTimeRange[this.fields[e].activeTimeRange.length-1]}startActiveTimeRange(e){const t=this.fields[e].activeTimeRange.pop();t&&(t.to||(t.to=this._Date.now()),this.fields[e].activeTimeRange.push(t)),this.fields[e].activeTimeRange.push(this.newActiveTimeRangeItem())}expandLastActiveTimeRange(e){this.getLastActiveTimeRangeItem(e).to=this._Date.now()}handleFocus(e){return this.lastChangedRangeFieldName===e||(this.ensureFieldIsInitialized(e),this.startActiveTimeRange(e),this.currentActiveRangeFieldName=e),this}handleBlur(e){return this.ensureFieldIsInitialized(e),this.ensureLastActiveTimeRangeItemExists(e),this.expandLastActiveTimeRange(e),this.currentActiveRangeFieldName=void 0,this}prepareLastTimeRangeForActivity(e){this.ensureFieldIsInitialized(e),this.lastChangedRangeFieldName!==e&&(this.currentActiveRangeFieldName?this.currentActiveRangeFieldName!==e?(this.addNewActiveTimeRange(e),this.currentActiveRangeFieldName=e):this.ensureLastActiveTimeRangeItemExists(e):(this.ensureLastActiveTimeRangeItemExists(e),this.currentActiveRangeFieldName=e),this.lastChangedRangeFieldName=e),this.expandLastActiveTimeRange(e)}handleChange(e){return this.prepareLastTimeRangeForActivity(e),this.getLastActiveTimeRangeItem(e).numberOfChanges++,this}handlePaste(e,t){if(!t?.clipboardData)return this;const r=t.clipboardData.getData("text").length;if(!r)return this;this.prepareLastTimeRangeForActivity(e);const i=this.getLastActiveTimeRangeItem(e);return i.pastedCharacters=i.pastedCharacters?i.pastedCharacters+r:r,this}handleRegister(e){return this.registerFieldByName(e),this}handleUnregister(e){return this.unregisterFieldByName(e),this}handleSubmit(){return this.submittedAt=this._Date.now(),this}registerFieldByName(...e){this.explicitlyRegisteredFieldNames=[...this.explicitlyRegisteredFieldNames,...e];const t=Object.keys(this.fields);
1return this.explicitlyRegisteredFieldNames.forEach(e=>{t.includes(e)||this.initializeField(e)}),this}unregisterFieldByName(...e){return this.explicitlyRegisteredFieldNames=this.explicitlyRegisteredFieldNames.filter(t=>!e.includes(t)),Object.keys(this.fields).forEach(e=>{this.explicitlyRegisteredFieldNames.includes(e)||this.deleteField(e)}),this}setRegisteredFields(e){this.explicitlyRegisteredFieldNames=e;const t=Object.keys(this.fields);return t.forEach(e=>{this.explicitlyRegisteredFieldNames.includes(e)||this.deleteField(e)}),this.explicitlyRegisteredFieldNames.forEach(e=>{t.includes(e)||this.initializeField(e)}),this}build(){if(0===this.explicitlyRegisteredFieldNames.length||0===Object.keys(this.fields).length)return{form:null,fields:null};let e=0,t=-1;return{fields:Object.fromEntries((0,C.di)(Object.entries(this.fields)).asc(([,e])=>{if(e.activeTimeRange.length>0)return e.activeTimeRange[0].from}).filter(([e])=>this.explicitlyRegisteredFieldNames.includes(e)).map(([r,i])=>{const n=i.activeTimeRange.filter(e=>0!==e.numberOfChanges||void 0!==e.pastedCharacters&&e.pastedCharacters>0),a=n.reduce((e,t)=>e+t.numberOfChanges,0);return e+=a,[r,{totalNumberOfChanges:a,activeTimeRange:n.filter(e=>0!==e.numberOfChanges||void 0!==e.pastedCharacters&&e.pastedCharacters>0),registeredAt:i.registeredAt,totalDuration:n.reduce((e,t)=>e+(t.to-t.from),0),usageIndex:n.length?++t:null,positionIndex:this.explicitlyRegisteredFieldNames.indexOf(r)}]})),form:{initializedAt:this.initializedAt,submittedAt:this.submittedAt||this.initializedAt,totalDuration:(this.submittedAt||this.initializedAt)-this.initializedAt,totalNumberOfChanges:e,lastPositionIndex:this.explicitlyRegisteredFieldNames.length-1,lastUsageIndex:t}}}}var A=r(57623),E=r(62227),I=r(85816),$=r(90419),_=r(49329),N=r(14202);function ListingWriteReviewFormHelpMarkdown(e){return(0,N.jsx)(_.A,{...e,componentsAvailable:{Alert:p.A,CollapsibleContent:e=>(0,N.jsx)($.A,{...e})}})}var R=r(59940),O=r(19107),F=r(12765),B=r(10014),D=r(94083),M=r(41125),j=r(52477),L=r(66307),U=r(86922),z=r(35447),W=r(90853),V=r(45714),q=r(74702),H=r(83115),G=r(74954),K=r(16940),Y=r(71526);
1function WriteReviewSubjectContext(e){if(e.subjectContext.type===K.PQ.KNOWN_INTERNAL_ENTRY||e.subjectContext.type===K.PQ.UNKNOWN_INTERNAL_ENTRY){const t=e.isEditing?e.subjectContext.listing:e.subjectContext.listing?.tree??e.subjectContext.listing;return t?e.children((0,N.jsxs)(q.A,{gap:3,children:[(0,N.jsx)(V.A,{entry:t,size:"xsmall",flexShrink:0}),(0,N.jsx)(q.A.Body,{alignSelf:"center",children:(0,N.jsxs)(M.A,{level:4,fontSize:"large",children:[(0,Y.A)({listing:t}),t.isDiscontinued&&(0,N.jsxs)(z.A,{fontSize:"small",fontWeight:"normal",textStyle:"muted",children:[(0,N.jsx)(H.A,{}),"Discontinued"]})]})})]})):e.subjectContext.type===K.PQ.UNKNOWN_INTERNAL_ENTRY&&e.subjectContext.unknownEntry?e.children((0,N.jsx)(M.A,{level:4,children:e.subjectContext.unknownEntry.entryName})):null}return e.subjectContext.type!==K.PQ.KNOWN_EXTERNAL_ENTRY&&e.subjectContext.type!==K.PQ.UNKNOWN_EXTERNAL_ENTRY||!e.subjectContext.externalEntry?.name?null:e.children((0,N.jsxs)(q.A,{gap:3,children:[e.subjectContext.externalEntry.pictureUrl&&(0,N.jsx)(I.A,{src:e.subjectContext.externalEntry.pictureUrl,alt:e.subjectContext.externalEntry.name,height:48,width:48,flexShrink:0,fit:"contain"}),(0,N.jsx)(q.A.Body,{alignSelf:"center",children:(0,N.jsx)(M.A,{level:4,children:e.subjectContext.externalEntry.name})})]}))}var X=r(2063),Q=r(89348),J=r(73518),Z=r(58222),ee=r(67572),te=r(86490),re=r(6431),ie=r(45756),ne=r(47806),ae=r(57483),se=r(76015),oe=r(50194),ce=r(55156),de=r(25808);function le(e){switch(e.condition){case"exactly":return m.YO(m.bz()).length(e.value,{message:e.error});case"min":return m.YO(m.bz()).min(e.value,{message:e.error});case"max":return m.YO(m.bz()).max(e.value,{message:e.error});default:return}}function ue(){}function he(e){switch(e.condition){case"min":return m.Yj().min(e.value,{message:e.error});case"max":return m.Yj().max(e.value,{message:e.error});default:return}}function fe(e){const t=(()=>{switch(e.condition){case"gt":return m.ai().refine(t=>t>Number(e.value),{message:e.error});case"gte":return m.ai().min(Number(e.value),{message:e.error});case"lt":return m.ai().refine(t=>t<Number(e.value),{message:e.error});case"lte":return m.ai().max(Number(e.value),{message:e.error});case"e":return m.ai().refine(t=>t===Number(e.value),{message:e.error});case"ne":return m.ai().refine(t=>t!==Number(e.value),{message:e.error});case"between":return m.ai().min(Number(e.value1)).max(Number(e.value2),{message:e.error});case"not_between":return m.ai().refine(t=>t<Number(e.value1)||t>Number(e.value2),{message:e.error});case"int":return m.ai().int({message:e.error});case"float":return m.ai({message:e.error});case"multipleOf":return m.ai().multipleOf(Number(e.value),{message:e.error});default:return m.ai()}})();return(0,de.zo)(t)}function me(e){return m.PV([m.ai().min(Number(e.value1)),m.ai().max(Number(e.value2))],{message:e.error})}function pe(e){switch(e.condition){case"match":return m.Yj().regex(new RegExp(e.value),{message:e.error});case"not_match":return m.Yj().refine(t=>!new RegExp(e.value).test(t),{message:e.error});default:return}}function ge(e){switch(e.condition){case"contains":return m.Yj().includes(e.value,{message:e.error});case"excludes":return m.Yj().refine(t=>!t.includes(e.value),{message:e.error});case"email":return e.error?m.bz().refine(e=>de.Rp.safeParse(e).success,{message:e.error}):de.Rp;case"url":return m.OZ({message:e.error});default:return m.Yj({message:e.error})}}function ye(e){switch(e){case"count":return le;case"date":return ue;case"length":return he;case"number":return fe;case"range":return me;case"regex":return pe;case"text":return ge;default:throw new Error("getValidationValidator: No validation of type => "+e)}}function be(e,t=!1){const r={};let i=!1;return e.fields.forEach(function e(n){if("group"===n.type)return void n.fields.forEach(e);if("facet_reference"===n.type)return void n.facet?.fields.forEach(e);const a=n.required&&!t;let s;if(a&&(i=!0),n.validators&&0!==n.validators.length)for(const e of n.validators){const t=ye(e.type)(e.options,n);t&&(s=s?m.E$(s,t):t)}else"number"===n.type&&(s=(0,de.zo)());s?r[n.id]=a?(0,de.mw)(s):(0,de.vy)(s):a&&(r[n.id]=(0,de.mw)(m.bz()))}),i?m.Ik(r).catchall(m.bz()).prefault({}):m.Ik(r).catchall(m.bz()).optional()}var we=r(70725),ve=r(49075),ke=r(62279),Te=r(97075);var xe=r(673),Se=r(32928),Ce=r(14901),Pe=r(57220),Ae=r(63197);const Ee=r.p+"countdown_b4dde430.mp3";function Countdown({onCountdownEnd:e}){const[t,r]=(0,n().useState)(3);return(0,n().useEffect)(()=>{let i=t;const n=new Audio(Ee);try{n.play()}catch{}const a=setInterval(()=>{i-=1,r(i),0===i&&(e(),clearInterval(a),n.pause())},1e3);return()=>{clearInterval(a),n.pause()}},[]),t}var Ie=r(98161);var $e=r(41677),_e=r(53774),Ne=r(4169);const Re=f().bind(_e.A);function VolumeIndicator({level:e}
1){const t=Math.max(0,Math.min(1,e)),r=Math.round(100*t);return(0,N.jsx)(y.h,{role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,"aria-label":"Microphone volume level",className:Re("volume-indicator"),children:(0,N.jsx)(y.h,{className:Re("volume-indicator-fill"),style:{width:`${r}%`}})})}const Oe=f().bind(_e.A),Fe={status:"idle",recordingTime:0};function Be(e,t){switch(t.type){case"SET_STATUS":return"acquire-permission"===t.payload||"idle"===t.payload?{...e,status:t.payload,recordingTime:0,video:null,processedVideo:null}:{...e,status:t.payload};case"TICK_RECORDING":return{...e,recordingTime:e.recordingTime+.1};case"SET_VIDEO":return{...e,video:t.payload};case"SET_PROCESSED_VIDEO":return{...e,processedVideo:t.payload};default:return e}}function VideoRecorder_VideoRecorder({onFinish:e}){const{logger:t}=(0,n().useContext)(Ae.A),[r,i]=(0,n().useReducer)(Be,Fe),{captureUsingMediaRecorder:a}=(0,Ie.A)()?/iP(ad|od|hone)/i.test(window.navigator.userAgent)?{captureUsingMediaRecorder:!1}:{captureUsingMediaRecorder:!0}:{captureUsingMediaRecorder:void 0},s=(0,n().useRef)(void 0),o=(0,n().useRef)(void 0),c=(0,n().useRef)(void 0),d=(0,n().useRef)(void 0),l=(0,n().useRef)([]),u=(0,n().useRef)(void 0),h=(0,n().useRef)(void 0),f=(0,n().useRef)(void 0),[m,p]=(0,n().useState)(0),[g,v]=(0,n().useState)([0,0]),[k,T]=(0,n().useState)(!1),{level:x,start:S,stop:C}=function(){const e=(0,n().useRef)(void 0),t=(0,n().useRef)(void 0),r=(0,n().useRef)(void 0),i=(0,n().useRef)(void 0),a=(0,n().useRef)(void 0),[s,o]=(0,n().useState)(0),c=(0,n().useCallback)(()=>{a.current&&(window.cancelAnimationFrame(a.current),a.current=void 0),t.current&&(t.current.disconnect(),t.current=void 0),e.current&&(e.current.close().catch(()=>{}),e.current=void 0),r.current=void 0,i.current=void 0,o(0)},[]),d=(0,n().useCallback)(n=>{if(c(),!window?.AudioContext)return;const s=new window.AudioContext;e.current=s;const d=s.createMediaStreamSource(n),l=s.createAnalyser();l.fftSize=512;const u=new Uint8Array(l.frequencyBinCount);d.connect(l),t.current=d,r.current=l,i.current=u;const h=()=>{if(!r.current||!i.current)return;r.current.getByteTimeDomainData(i.current);let e=0;for(const t of i.current){const r=t-128;e+=r*r}const t=Math.sqrt(e/i.current.length),n=Math.min(1,Math.max(0,t/128));o(n),a.current=window.requestAnimationFrame(h)};s.resume().catch(()=>{}),h()},[c]);return(0,n().useEffect)(()=>()=>{c()},[c]),{level:s,start:d,stop:c}}(),P=(0,G.tz)(),A=()=>{s.current&&(i({type:"SET_STATUS",payload:"acquire-permission"}),navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:1080,height:1440,frameRate:30},audio:!0}).then(e=>{if(0!==e.getVideoTracks().length&&0!==e.getAudioTracks().length){if(c.current=e,S(e),!o.current)throw new Error("Video element not found");o.current.srcObject=e,i({type:"SET_STATUS",payload:"countdown"})}else i({type:"SET_STATUS",payload:"permission-denied"})},()=>{i({type:"SET_STATUS",payload:"permission-denied"})}))},I=()=>{if(c.current)for(const e of c.current.getTracks())e.stop();d.current&&d.current.stop(),C(),clearInterval(u.current),"recording"===r.status?i({type:"SET_STATUS",payload:"preview"}):i({type:"SET_STATUS",payload:"idle"})},$=()=>{if(!c.current)return;const e=new MediaRecorder(c.current);d.current=e,l.current=[],e.ondataavailable=e=>{e.data.size>0&&l.current.push(e.data)},e.onstop=()=>{if(c.current)for(const e of c.current.getTracks())e.stop();const t=e.mimeType.split(";")[0].includes("mp4")?"video/mp4":"video/webm",r=new Blob(l.current,{type:t}),n=URL.createObjectURL(r);i({type:"SET_VIDEO",payload:{blob:r,url:n,mimeType:t}}),i({type:"SET_STATUS",payload:"preview"})},e.start(100),i({type:"SET_STATUS",payload:"recording"}),u.current=window.setInterval(()=>{i({type:"TICK_RECORDING"})},100)};(0,n().useEffect)(()=>{if(p(0),v([0,0]),!r.video?.blob)return;const e=r.video;(0,$e.A)(e.blob).then(({blob:e,mimeType:t,analysis:r})=>{i({type:"SET_PROCESSED_VIDEO",payload:{blob:e,url:URL.createObjectURL(e),mimeType:t,analysis:r}})},r=>{t.error(r),i({type:"SET_PROCESSED_VIDEO",payload:{blob:e.blob,url:URL.createObjectURL(e.blob),mimeType:e.mimeType,analysis:{isSilent:!1,durationInSeconds:10}}})})},[r.video?.blob]);return(0,n().useEffect)(()=>{r.recordingTime>=1200&&(I(),i({type:"SET_STATUS",payload:"preview"}))},[r.recordingTime]),(0,n().useEffect)(()=>()=>{if(c.current)for(const e of c.current.getTracks())e.stop();d.current&&d.current.stop(),C(),u.current&&clearInterval(u.current)},[]),(0,N.jsxs)(y.h,{ref:s,display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",position:"relative",children:["idle"===r.status&&(0,N.jsx)(y.h,{display:"flex",flexDirection:"column",flexGrow:1,flexShrink:0,justifyContent:"center",padding:3,textAlign:"center",trimY:!0,children:(0,N.jsx)(_.A,{source:"<Lead>This process only takes few seconds</Lead>\n\nA short 15-second video speaks louder than a lengthy text review.\n<br />\nState facts, be yourself, and don't overthink\n\n- How was your experience with this product/service?\n- What do you love or dislike most about it?\n- Would you recommend it to others? Why?",componentsAvailable:{Lead:e=>(0,N.jsx)(j.A,{marginBottom:4,...e})}})}),"permission-denied"===r.status&&(0,N.jsxs)(y.h,{alignItems:"center",justifyContent:"center",display:"flex",flexDirection:"column",flexGrow:1,padding:3,textAlign:"center",className:Oe("video-recorder-center-content"),children:[(0,N.jsx)(Ce.A,{marginBottom:4,children:"We need access to your camera and microphone to record a video."}),(0,N.jsx)(b.A.Button,{onClick:()=>A(),buttonStyle:"primary",tracking:{id:"video_recorder.grant_permission"},children:"Grant permission"}),(0,N.jsx)(Ce.A,{italic:!0,marginTop:1,textStyle:"muted",children:"Or reload the page to try again"})]}),"idle"!==r.status&&"permission-denied"!==r.status&&(0,N.jsxs)(y.h,{"data-status":r.status,display:"preview"===r.status?"none":void 0,flexGrow:1,position:"relative",overflow:"hidden",className:Oe("real-time-video-container"),children:[(0,N.jsx)(y.h,{element:"video",ref:o,autoPlay:!0,muted:!0,playsInl
1ine:!0,textStyle:"white"}),(0,N.jsx)(E.A,{name:"camera",height:96,width:96,display:["acquire-permission","idle"].includes(r.status)?void 0:"none",margin:"auto",position:"absolute-center",className:Oe("camera-icon")}),"countdown"===r.status&&(0,N.jsx)(M.A,{level:1,fake:!0,alignSelf:"center",justifySelf:"center",margin:"auto",position:"absolute-center",textAlign:"center",textStyle:"white",className:Oe("countdown"),children:(0,N.jsx)(Countdown,{onCountdownEnd:()=>$()})})]}),"preview"===r.status&&(0,N.jsxs)(n().Fragment,{children:[(()=>{const e=r.processedVideo??r.video;return e?(0,N.jsxs)(y.h,{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",className:Oe("preview-video-container"),children:[(0,N.jsx)(y.h,{element:"video",ref:f,controls:!0,autoPlay:!0,playsInline:!0,onPlay:e=>{const t=e.currentTarget;(t.currentTime<g[0]||t.currentTime>=g[1])&&(t.currentTime=g[0])},onTimeUpdate:e=>{const t=e.currentTarget;(t.currentTime<g[0]||t.currentTime>=g[1])&&(t.pause(),t.currentTime=g[0])},onSeeking:e=>{const t=e.currentTarget;(t.currentTime<g[0]||t.currentTime>g[1])&&(t.currentTime=g[0])},onLoadedMetadata:e=>{const t=e.currentTarget.duration;Number.isFinite(t)&&(p(t),v(e=>0===e[1]?[0,t]:e),e.currentTarget.currentTime=g[0])},flexGrow:1,children:(0,N.jsx)("source",{src:e.url,type:e.mimeType})},e.url),(0,N.jsx)(Ne.A,{duration:m,value:g,videoUrl:e.url,onChange:e=>{v(e),f.current&&(f.current.currentTime=e[0])}})]}):null})(),(0,N.jsxs)(y.h,{display:"flex",flexDirection:"column",flexShrink:0,gap:2,padding:3,children:[r.processedVideo?.analysis?.isSilent&&(0,N.jsxs)(z.A,{alignSelf:"center",display:"flex",gap:1,textStyle:"danger",children:[(0,N.jsx)(E.A,{name:"exclamation-circle",height:24,width:20,flexShrink:0}),"It looks like your video is silent."]}),(0,N.jsxs)(w.A,{gap:1,children:[(0,N.jsx)(b.A.Button,{onClick:()=>i({type:"SET_STATUS",payload:"idle"}),flexBasis:100,flexGrow:1,tracking:{id:"video_recorder.retake_video"},children:"Try again"}),(0,N.jsx)(b.A.Button,{onClick:()=>{if(!r.video?.blob)throw new Error("Video not found");T(!0),(0,$e.A)(r.video.blob,{trimRange:{start:g[0],end:g[1]}}).then(({blob:t})=>e(t),e=>{t.error(e),T(!1)})},buttonStyle:"primary",flexBasis:100,flexGrow:1,isDisabled:!r.processedVideo?.blob||!m||k,tracking:{id:"video_recorder.use_this_video"},children:P.formatMessage({id:"video_recorder.preview.try_again",defaultMessage:"{isFinishing, select, true {Preparing videoâ¦} false {Use this video}}"},{isFinishing:k})})]})]})]}),a&&["acquire-permission","countdown","recording"].includes(r.status)&&(0,N.jsxs)(y.h,{alignItems:"center",display:"flex",flexDirection:"column",gap:2,margin:3,children:[(0,N.jsxs)(z.A,{fontWeight:r.recordingTime>15?"semi-bold":void 0,monoSpaceNumber:!0,children:[r.recordingTime.toFixed(1),"s"]}),(0,N.jsx)(VolumeIndicator,{level:x})]}),"preview"!==r.status&&(0,N.jsx)(Pe.A,{content:["countdown","recording"].includes(r.status)?"Stop recording":"Start recording",children:(0,N.jsx)(y.h,{onClick:()=>{if(a)return"acquire-permission"===r.status||"recording"===r.status||"countdown"===r.status?void I():void A();h.current?.click()},"data-status":r.status,role:"button",alignSelf:"center",borderRadius:"circle",cursor:"pointer",display:"inline-block",flexShrink:0,margin:3,position:"relative",className:Oe("record-button"),tracking:{id:"video_recorder.record_video"}})}),!a&&(0,N.jsx)(y.h,{element:"input",onChange:e=>{const t=e.target.files?.[0];if(!t)return;const r=URL.createObjectURL(t);i({type:"SET_VIDEO",payload:{blob:t,url:r,mimeType:t.type}}),i({type:"SET_STATUS",payload:"preview"})},ref:h,type:"file",accept:"video/*",capture:"user",className:Oe("video-input")})]})}var De=r(82176),Me=r(51753);const je=new De.A;function AlertAboutMissingSpecificationFields(e){const{control:t}=(0,X.xW)(),r=(0,G.tz)(),i=(0,n().useMemo)(()=>t.getValues().specificationValues||{},[t.name]),a=(0,n().useMemo)(()=>{const t=[];return je.visitFields(e.primarySpecifications,e=>{const r=i[e.id];(0,Me.Ay)(r)||t.push(e)}),je.visitFields(e.secondarySpecifications,e=>{const r=i[e.id];(0,Me.Ay)(r)||t.push(e)}),t},[i]);return 0===a.length?null:(0,N.jsx)(p.A,{id:"ask-for-specifications",alertStyle:"warning",children:(0,N.jsx)(_.A,{source:r.formatMessage({id:"write_review_form.alert_about_missing_specification_fields",defaultMessage:"Thank y
1ou, your review has been published but it's **missing a few details**. It will only take a minute to fill them in and you'll be helping thousands of Australian consumers researching {listingFullName}.\n\n<MissingSpecificationFieldsList />"},{listingFullName:(0,Y.A)({listing:e.listing})}),componentsAvailable:{MissingSpecificationFieldsList:()=>(0,N.jsx)(L.A,{children:a.map(e=>(0,N.jsx)(L.A.Item,{children:e.question||e.label},e.id))})}})})}var Le=r(25343),Ue=r(55279);function BrandCustomerServiceEntryLink({brand:e}){const{customerServiceEntry:t}=e,r=(0,G.tz)(),i=(0,Ue.A)();return t?(0,N.jsx)(p.A,{alertStyle:"warning",children:(0,N.jsx)(_.A,{source:r.formatMessage({id:"write_review_form.brand_customer_service_entry_link",defaultMessage:"Is your review mostly about **{brandName}'s customer service**? <CustomerServiceEntryLink>Submit your review here instead</CustomerServiceEntryLink>."},{brandName:e.name}),componentsAvailable:{CustomerServiceEntryLink:(0,ae.A)(e=>(0,N.jsx)(Le.A,{to:i.generate("www.public.write_review_form",{listingSlug:t.slug}),textDecorationHover:"underline",textStyle:"link",...e}))},initialParser:"inline"})}):null}var ze=r(50560);function GlobalReviewSubjectStep({onFinish:e}){const{control:t}=(0,X.xW)(),r=(0,G.tz)(),[i,a]=(0,n().useState)(!1),[s,o]=(0,n().useState)(!1),c="What is your review about?",d=(0,N.jsxs)(n().Fragment,{children:[(0,N.jsx)(X.D0,{name:"subject.entryName",label:c,component:T.ks,componentProps:{autoFocus:!0}}),(0,N.jsx)(X.D0,{name:"subject.entryType",label:"Type of review",labelProps:{display:"block"},component:T.qU,componentProps:{options:[{value:"product",label:"Product review"},{value:"service",label:"Service review"}],inline:!0}}),(0,N.jsx)(t.FormValueSelector,{fieldName:"subject.entryType",children:i=>i?(0,N.jsxs)(n().Fragment,{children:[(0,N.jsx)(X.D0,{name:"subject.categoryName",label:"Category",component:T.ks,componentProps:{placeholder:r.formatMessage({id:"public.write_review.global.field_category.product.placeholder",defaultMessage:"Example: {entryType, select, product {Mobile Phone} service {Home Builder}}"},{entryType:i})}}),"service"===i?(0,N.jsx)(X.D0,{name:"subject.locationName",label:"Service location",component:T.ks,componentProps:{placeholder:"Example: Bondi, Sydney"},required:!1}):(0,N.jsxs)(n().Fragment,{children:[(0,N.jsx)(X.D0,{name:"subject.brandName",label:"Brand",component:T.ks,componentProps:{placeholder:"Example: Apple"},required:!1}),(0,N.jsx)(X.D0,{name:"subject.model",label:"Model number",component:T.ks,componentProps:{placeholder:"Example: 7s Plus"},required:!1})]}),(0,N.jsx)(X.D0,{name:"subject.webLink",label:"Weblink",component:T.ks,componentProps:{placeholder:r.formatMessage({id:"public.write_review.global.field_weblink.product.placeholder",defaultMessage:"Example: {entryType, select, product {https://www.apple.com/au/iphone} service {https://www.harveynorman.com.au}}"},{entryType:i})},required:!1}),!s&&(0,N.jsx)(b.A.Button,{onClick:async()=>{await t.validateFields("onChange",{fieldPath:"subject.entryType",shouldTouch:!0}),await t.validateFields("onChange",{fieldPath:"subject.entryName",shouldTouch:!0}),await t.validateFields("onChange",{fieldPath:"subject.categoryName",shouldTouch:!0}),setTimeout(()=>{const r=Object.keys(t.store.state.fieldsState.validationErrors);for(const e of r)if(e.startsWith("subject."))return;a(!0),o(!0),e()})},buttonStyle:"primary",tracking:{id:"start_review_button"},children:"Start your review"})]}):null})]});if(i)return(0,N.jsx)(t.FormValueSelector,{fieldName:"subject",children:e=>(0,N.jsxs)(n().Fragment,{children:[(0,N.jsx)(ze.A,{disableHtmlFor:!0,negativeMarginBottom:2,children:c}),(0,N.jsx)(y.h,{display:"none",children:d}),(0,N.jsx)(v.A,{children:(0,N.jsxs)(v.A.Block,{alignItems:"start",display:"flex",children:[(0,N.jsxs)(y.h,{flexGrow:1,children:[(0,N.jsx)(M.A,{level:3,marginBottom:2,children:e.entryName}),(0,N.jsxs)(L.A,{unstyled:!0,children:[(0,N.jsx)(L.A.Item,{children:(0,N.jsx)(G.sA,{id:"public.write_review.global.entry_type",defaultMessage:"{entryType, select, product {Product} service {Service} other {{entryType}}} ({categoryName})",values:{entryType:e.entryType,categoryName:e.categoryName}})}),e.brandName&&(0,N.jsx)(L.A.Item,{children:e.brandName}),e.model&&(0,N.jsx)(L.A.Item,{children:e.model}),e.locationName&&(0,N.jsx)(L.A.Item,{children:e.locationName}),e.webLink&&(0,N.jsx)(L.A.Item,{children:e.webLink})]})]}),(0,N.jsx)(z.A,{onClick:()=>a(!1),cursor:"pointer",marginLeft:"auto",textDecorationHover:"underline",textStyle:"link",children:"Edit"})]})})]})});const l={appContext:{namespace:"global_review_subject"},children:d,display:"flex",flexDirection:"column",gap:4};return s?(0,N.jsx)(v.A,{children:(0,N.jsx)(v.A.Block,{...l})}):(0,N.jsx)(y.h,{...l})}var We=r(14505),Ve=r(48275),qe=r(23766);function InlineAuthFields(e){(0,G.tz)();const t=(0,ie.A)(),r=(0,te.A)(se.l5),[i,a]=(0,n().useState)(Boolean(e.initialEmailAddress));return(0,N.jsxs)(y.h,{display:"flex",flexDirection:"column",gap:1,style:{maxWidth:320},children:[(0,N.jsx)(We.A,{onAuthenticate:e=>t.dispatch((0,qe.a5)({token:e,roleIntention:{type:K.Xh.CONSUMER}},{preventReload:!0})),isLoading:r}),(0,N.jsx)(Ve.A,{onAuthenticate:e=>t.dispatch((0,qe.XL)({credentialResponse:e,roleIntention:{type:K.Xh.CONSUMER}},{preventReload:!0})),isLoading:r,prompt:!0}),(0,N.jsxs)(y.h,{display:"flex",justifyContent:"center",marginY:2,position:"relative",children:[(0,N.jsx)(k.A,{margin:"auto",position:"absolute-center"}),(0,N.jsx)(z.A,{backgroundColor:"white",paddingX:4,position:"relative",textStyle:"muted-secondary",children:"or"})]}),(0,N.jsx)(b.A.Button,{onClick:()=>a(!0),buttonStyle:"primary",isDisabled:i,tracking:{id:"use_email_login"},children:"Continue with your email"}),i&&(0,N.jsxs)(y.h,{display:"flex",flexDirection:"column",gap:4,paddingY:4,children:[(0,N.jsx)(X.D0,{name:"emailAddress",label:"Email address",component:T.pX,componentProps:{autoFocus:!e.initialEmailAddress,placeholder:"[email protected]"}}),!0===e.isRegisteredState.isEmailAddressRegistered?(0,N.jsxs)(q.A,{gap:2,children:[(0,N.jsx)(E.A,{name:"check",backgroundColor:"success",borderRadius:"circle",flexShrink:0,padding:1,textStyle:"white"}),(0,N.jsx)(q.A.Body,{textStyle:"success",children:"We successfully found your email address in our system. You can now submit your review."})]}):(0,N.jsx)(X.D0,{name:"displayName",label:"Display name",component:T.ks,componentProps:{placeholder:"example: John D."}})]})]})}
1var He=r(24082),Ge=r(73909);const Ke=n().lazy(()=>r.e("shared_containers_modals_ProofOfPurchaseInstructionsModal_tsx-static_proof_of_purchase_example_png").then(()=>r(80243)));function ProofOfPurchaseField(e){const{showModal:t}=(0,Z.A)(),r=(0,te.A)(He.bV),i=(0,Ue.A)();return(0,N.jsx)(X.D0,{id:"proof-of-purchase",name:"proofOfPurchaseId",label:"Attach your proof of purchase",help:(0,N.jsx)(G.sA,{id:"write_review_form.proofOfPurchaseId_field.help",defaultMessage:"Can be an invoice, a contract{isService, select,\n true {}\n false {, a photo including the product and your name}\n}, or an email exchange with the company. {learnMoreLink}",values:{learnMoreLink:(0,N.jsx)(z.A,{onClick:()=>{t({title:"Proof of purchase",content:()=>(0,N.jsx)(Ke,{isRequired:e.isRequired,isService:Boolean(e.isService)}),bodyProps:{padding:4,trimY:!0},size:"large"})},cursor:"pointer",textDecorationHover:"underline",textStyle:"link",tracking:{id:"learn_more_link"},children:"Learn more"}),isService:Boolean(e.isService)}}),component:T.dJ,componentProps:{resource:e.resource,collection:Te.pM.proofOfPurchase,buildObjectUrl:t=>t.file?URL.createObjectURL(t.file):t.isRemote&&t.remoteId&&e.reviewBeingEdited?i.generate("api.public.review.proof_of_purchase",{reviewId:e.reviewBeingEdited.id,catalogId:(0,Ge.A)(e.reviewBeingEdited.subject),proofOfPurchaseId:t.remoteId,actorContext:r.context,_protocol:"https"},Ue.i.ABSOLUTE_URL):null,...e.uploaderProps},isVisibleToBrandManager:!1,isVisibleToGuest:!1,required:e.isRequired})}var Ye=r(90849);function ReviewBodyWordCount(e){const{control:t}=(0,X.xW)(),r=(0,Ye.A)(t.watch("body"));return r>=e.min?null:(0,N.jsx)(z.A,{fontSize:"small",fontWeight:"normal",monoSpaceNumber:!0,textStyle:"muted",children:(i={count:r,min:e.min},(0,N.jsxs)(N.Fragment,{children:[i.count,"/",i.min," words minimum"]}))});var i}var Xe=r(89819),Qe=r(94874);function Je(){return Je.c||(Je.c=r.n(i()))}i();var Ze=r(40299);function ModerationEmptyArrayWarning(){(0,G.tz)();return(0,N.jsx)(Ze.A,{trigger:"hover",content:(0,N.jsx)(_.A,{source:'#### Value is an empty list\n\nIf you want this field to inherit the parent value, make sure to clear its value completely by clicking on "Clear" and then saving the form.'}),bodyProps:{padding:2,trimY:!1},children:(0,N.jsxs)(z.A,{alignItems:"center",display:"flex",gap:1,textStyle:"danger",children:[(0,N.jsx)(Je()(),{name:"exclamation-triangle"}),"Warning"]})})}function SpecificationValueField(e){const{control:t}=(0,X.xW)(),{field:r,options:i,...a}=e,s=(0,G.tz)(),o=(0,X.KU)(i?.fieldNamePrefix,r.id);if(i&&"treeEditTable"===i.context)return(0,N.jsxs)(y.h,{display:"flex",flexDirection:"column",gap:1,children:[(0,N.jsx)(t.FormValueSelector,{fieldName:o,children:e=>Array.isArray(e)&&0===e.length?(0,N.jsx)(ModerationEmptyArrayWarning,{}):null}),(0,N.jsx)(X.D0,{name:o,clearable:!0,clearOnUnmount:!0,...(0,c.A)(a,"label","labelProps")})]});if(i&&"writeReviewForm"===i.context){const e=r;return(0,N.jsx)(X.D0,{name:o,label:e.question||e.label,help:e.helper,clearable:e.clearable,applicable:e.applicable,required:e.required||!1,clearOnUnmount:!0,isVisibleToBrandManager:e.visibilitySettings?.groups.includes("brand_manager"),isVisibleToGuest:e.visibilitySettings?.groups.includes("guest"),...a})}if(i&&"reviewModerationForm"===i.context){const e=r;return(0,N.jsxs)(n().Fragment,{children:[e.moderationTips&&(0,N.jsx)(p.A,{alertStyle:"warning",fontSize:"small",lineHeight:"small",paddingX:3,paddingY:2,children:(0,N.jsx)(_.A,{source:s.formatMessage({id:"shared.specification_value_field.moderation.moderation_tips",defaultMessage:"**Moderation Tips:**\n\n{moderationTips}"},{moderationTips:e.moderationTips})})}),(0,N.jsx)(X.D0,{name:o,label:e.question||e.label,help:e.helper,clearable:!0,applicable:e.applicable,required:e.required||!1,clearOnUnmount:!0,isVisibleToBrandManager:e.visibilitySettings?.groups.includes("brand_manager"),isVisibleToGuest:e.visibilitySettings?.groups.includes("guest"),...a})]})}return(0,N.jsx)(X.D0,{name:o,label:r.label,help:r.helper,clearable:r.clearable,applicable:r.applicable,required:r.required,clearOnUnmount:!0,...a})}function et(e){if(!e)return{};const{placeholder:t,suffix:r,prefix:i}=e;return{placeholder:t,suffix:r,prefix:i}}var tt=r(64856),rt=r(87384);var it=r(61322);var nt=r(60887);function at(e){if("number"===e.type||"unique_choice"===e.type||"multi_choice"===e.type)return e.properties?.placeholder}function st(e){const t={min:0,max:100,prefixVisibility:"both",suffixVisibility:"both",currency:e.currency};return void 0!==e.multipleOf&&""!==e.multipleOf&&null!==e.multipleOf&&(t.step=Number(e.multipleOf)),void 0!==e.min&&""!==e.min&&null!==e.min&&(t.min=Number(e.min)),void 0!==e.max&&""!==e.max&&null!==e.max&&(t.max=Number(e.max)),void 0!==e.prefix&&""!==e.prefix&&null!==e.prefix&&(t.prefix=e.prefix),void 0!==e.prefixVisibility&&null!==e.prefixVisibility&&(t.prefixVisibility=e.prefixVisibility),void 0!==e.suffix&&""!==e.suffix&&null!==e.suffix&&(t.suffix=e.suffix),void 0!==e.suffixVisibility&&null!==e.suffixVisibility&&(t.suffixVisibility=e.suffixVisibility),t}function ot(e){return"number"===e.field.type?e.field.properties?.options?e.field.properties.options.map(e=>({value:Number(e),label:String(e)})):[]:e.field.properties.options}const ct={PrTextInputFormWidget:function PrTextInputFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.ks,componentProps:{...et(e.field.properties),mask:e.field.properties?.mask,maxLength:"writeReviewForm"===e.options?.context||"reviewModerationForm"===e.options?.context?256:void 0}})},PrTextareaFormWidget:function PrTextareaFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.TM,componentProps:{placeholder:e.field.properties?.placeholder}})},PrTextWithRadioOptionsFormWidget:function PrTextWithRadioOptionsFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.mW,componentProps:{...et(e.field.properties),options:(e.field.properties?.options||[]).map(e=>({value:e,label:e})),optionLabelRenderer:t=>(0,N.jsx)(rt.rJ,{value:t.label,field:e.field}),mask:e.field.properties?.mask}})},PrRadioFormWidget:function PrRadioFormWidget(e){let t;return"number"===e.field.type&&(t=tt.A),(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.qU,componentProps:{options:"number"===e.field.type?e.field.properties?.options?e.field.properties.options.map(t=>({value:String(t),label:(0,N.jsx)(rt.rJ,{field:e.field,value:t})})):[]:e.field.properties.options},normalize:t})},PrNumberFormWidget:function PrNumberFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.ks,componentProps:{type:"number",...et(e.field.properties),currency:e.field.properties?.currency,mask:e.field.properties?.mask,min:e.field.properties?.min,max:e.field.properties?.max,step:e.field.properties?.multipleOf}})},PrSliderFormWidget:function PrSliderFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.Ap,componentProps:{...st(e.field.properties||{}),tipFormatter:t=>(0,N.jsx)(rt.rJ,{value:t,field:e.field}),label:e.field.label}})},PrStarRatingFormWidget:function PrStarRatingFormWidget(e){const{labelFor0Star:t,labelFor1Star:r,labelFor2Star:i,labelFor3Star:n,labelFor4Star:a,labelFor5Star:s}=e.field.properties?.starRatingLabelsMap||{};return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.GW,componentProps:{type:"circles",getLabelForRating:e=>{switch(Math.ceil(e)){case 1:return r;case 2:return i;case 3:return n;case 4:return a;case 5:return s;default:return t}}}})},PrSelectFormWidget:function PrSelectFormWidget(e){let t;return"number"===e.field.type&&(t=tt.A),(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.j9,componentProps:{name:e.field.id,multi:"multi_choice"===e.field.type,placeholder:e.field.properties?.placeholder,options:ot(e),optionRenderer:t=>(0,N.jsx)(rt.rJ,{value:t.label,field:e.field}),valueRenderer:t=>(0,N.jsx)(rt.rJ,{value:t.label,field:e.field})},normalize:t})},PrButtonListFormWidget:function PrButtonListFormWidget(e){let t;return"number"===e.field.type&&(t=tt.A),(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.Fu,componentProps:{listType:"toolbar",multi:"multi_choice"===e.field.type,options:"number"===e.field.type?e.field.properties?.options?e.field.properties.options.map(e=>({value:Number(e),label:String(e)})):[]:e.field.properties.options,optionLabelRenderer:t=>(0,N.jsx)(rt.rJ,{value:t.label,field:e.field})},normalize:t})},PrNativeSelectFormWidget:function PrNativeSelectFormWidget(e){let t;return(0,G.tz)(),"boolean"===e.field.type?t=nt.A:"number"===e.field.type&&(t=tt.A),(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.l6,componentProps:{options:[{value:"",label:at(e.field)||"Select"}].concat((r=e.field,"number"===r.type?r.properties?.options?r.properties.options.map(e=>({value:String(e),label:String(e)})):[]:"boolean"===r.type?[{value:"true",label:r.properties?.labels?.positive||"Yes"},{value:"false",label:r.properties?.labels?.negative||"No"}]:r.properties.options))},normalize:t});var r},PrDateFormWidget:function PrDateFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.R,componentProps:e.field.properties})},PrTimeFormWidget:function PrTimeFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.AG,componentProps:e.field.properties})},PrDateTimeFormWidget:function PrDateTimeFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.K7})},PrResourceReferenceFormWidget:function PrResourceReferenceFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.dE,componentProps:e.field.properties})},PrBooleanButtonsFormWidget:function PrBooleanButtonsFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.BI,componentProps:{allowDeselect:!0,labels:e.field.properties?.labels,getItemTracking:(e,t)=>
1({gaContext:{action:t?"uncheck":"check",label:e}})}})},PrBooleanSwitchFormWidget:function PrBooleanSwitchFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.dO,componentProps:{label:e.field.label,position:"start"}})},PrAddressFormWidget:function PrAddressFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.zt,componentProps:et(e.field.properties)})},PrCheckboxesFormWidget:function PrCheckboxesFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.J$,componentProps:{options:e.field.properties.options},normalize:it.A})},PrRangeSliderFormWidget:function PrRangeSliderFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.F1,componentProps:{...st(e.field.properties||{}),tipFormatter:t=>(0,N.jsx)(rt.rJ,{value:t,field:e.field})}})},PrRangeInputFormWidget:function PrRangeInputFormWidget(e){return(0,N.jsx)(SpecificationValueField,{field:e.field,options:e.options,component:T.sq,componentProps:st(e.field.properties||{})})}};function dt(e){const t=e.valueFormWidget?.widget;if(t){if(t in ct)return ct[t];(0,Qe.A)(`resolveValueFormWidget(field: ${e.id}): unknown valueFormWidget "${t}"`,{metadata:{field:e}})}}var lt=r(62082),ut=r.n(lt),ht=r(51308),ft=r.n(ht),mt=r(9891),pt=r(61829),gt=r(23795),yt=r(71536),bt=r(57830);function FieldManipulationTimeline(e){if(!e.statistics||!e.statistics.fields)return null;const t=e.statistics.fields[e.name];if(!t||0===t.totalNumberOfChanges)return null;const r=ut()((0,mt.A)(e.statistics.fields,e=>(0,gt.A)(e.activeTimeRange)?.from)),i=ft()((0,mt.A)(e.statistics.fields,e=>(0,pt.A)(e.activeTimeRange)?.to))-r,n=(0,yt.A)(t.activeTimeRange.map((e,t)=>{if(0===e.numberOfChanges)return null;const n=e.to-e.from,a=(e.from-r)/i,s=n/i,o=Math.round(n/1e3)||"0";return(0,N.jsx)(Pe.A,{content:e.pastedCharacters?`Pasted ${e.pastedCharacters} characters and ${e.numberOfChanges} changes in ${o}s`:`${e.numberOfChanges} changes in ${o}s`,children:(0,N.jsx)(y.h,{backgroundColor:e.pastedCharacters?"warning":"success",borderRadius:!0,cursor:"help",position:"absolute-left",style:{left:100*a+"%",width:100*s+"%"}})},t)}));return 0===n.length?null:(0,N.jsxs)(y.h,{alignItems:"center",display:"flex",gap:1,children:["number"==typeof t.usageIndex&&(0,N.jsx)(bt.A,{flexShrink:0,monoSpaceNumber:!0,children:(0,N.jsx)(z.A,{display:"block",style:{width:"2ch"},children:t.usageIndex+1})}),(0,N.jsx)(y.h,{alignSelf:"stretch",backgroundColor:"secondary",borderRadius:!0,flexGrow:1,position:"relative",style:{height:20},children:n})]})}function wt(e){return!0===e||"yes"===e||"true"===e}function vt(e){return Number(e)}function kt(e,t){const{dependencyTree:r}=e;return!(r&&r.length>0)||r.every(e=>{const{operator:r,children:i}=e,n=i.map(e=>{const{fieldId:r,rule:i}=e;if(r in t){const e=t[r];if("exists"===i.type)return function(e){return null!=e}(e);if("is"===i.type)return n=e,a=i.value,"boolean"==typeof n||"boolean"==typeof a?wt(a)===wt(n):"number"==typeof n||"number"==typeof a?vt(a)===vt(n):(0,d.A)(a,n);if("contains"===i.type){if("string"==typeof e)return e.includes(i.value);if(Array.isArray(e))return e.includes(i.value)}}var n,a;return!1});return"or"===r?n.some(e=>!0===e):n.every(e=>!0===e)})}function ReviewSpecificationValueField(e){const{isVisible:t}=function(e){const{control:t}=(0,X.xW)();return{isVisible:kt(e,t.watch("specificationValues")||{})}}(e.field),r=(0,n().useCallback)(t=>"group"===t.type?(0,N.jsxs)(n().Fragment,{children:[(0,N.jsx)(M.A,{level:3,marginBottom:2,children:t.label}),t.fields.map(r)]},t.id):(0,n().createElement)(ReviewSpecificationValueField,{...e,key:t.id,field:t}),[e.field,e.context]);if(!t)return null;if("group"===e.field.type)return r(e.field);if("facet_reference"===e.field.type)return e.field.facet?e.field.facet.fields.map(r):null;const i=dt(e.field);if(!i)return null;const a=(0,N.jsx)(i,{field:e.field,options:{context:e.context,fieldNamePrefix:e.fieldNamePrefix}});return e.submissionStatistics?(0,N.jsxs)(y.h,{display:"flex",doNotRenderIfEmpty:!0,flexDirection:"column",gap:2,children:[(0,N.jsx)(FieldManipulationTimeline,{name:(0,X.KU)(e.fieldNamePrefix,e.field.id),statistics:e.submissionStatistics}),a]}):a}function ReviewFormSpecificationFields(e){return e.fields.map(t=>(0,N.jsx)(ReviewSpecificationValueField,{field:t,context:e.context,submissionStatistics:e.submissionStatistics,fieldNamePrefix:"specificationValues"},t.id))}var Tt=r(5513),xt=r(4484),St=r(53439);const Ct=(0,r(26357).A)();function SelectTree(e){const{closeOnSelectingLeaf:t=!0,selectLeavesOnly:r=!0}=e,i=(0,ee.A)(),[a,s]=(0,n().useState)(!1),[o,c]=(0,n().useState)(void 0);return(0,n().useEffect)(()=>{i.current&&o&&(a?e.onFocus&&e.onFocus():e.onBlur&&e.onBlur())},[a]),(0,n().useEffect)(()=>{c(function(e){if(e.selectedId)return Ct(e.selectedId,{...e.listing,children:e.selectableBranches})}(e))},[e.selectedId,e.selectableBranches]),(0,N.jsx)(xt.A,{content:(0,N.jsx)(St.default,{name:e.name,branches:e.selectableBranches,listing:e.listing,selectLeavesOnly:r,selectListingId:o?.id,onChange:i=>{const n=i.isLeaf&&t||Boolean(r&&e.onChange);n&&e.onChange&&e.onChange(i),s(!n),c(i)},onClickButton:()=>{e.onChange&&o&&e.onChange(o),s(!1)}}),dropdownMenuProps:{display:"flex",flexDirection:"column",gap:2,paddingBottom:r?1:3,paddingX:3},fullWidth:!0,isOpen:a,lockPlacement:!0,onChange:e=>{s(e)},onClickOutside:()=>{e.onClose&&o&&e.onClose(o),s(!1)},children:t=>(0,N.jsxs)(xt.A.Select,{testId:"select_tree",tabIndex:0,isActive:t,textStyle:o?void 0:"muted",id:e.id,pointerEvents:e.isLoading?"none":void 0,children:[o?(0,N.jsx)(z.A,{testId:"select_tree_selected_option",breakWord:!0,children:(0,Y.A)({listing:o,currentListing:e.listing})}):e.placeholder,e.isLoading&&(0,N.jsx)(z.A,{textStyle:"muted",italic:!0,fontSize:"small",marginLeft:2,children:"Loading..."})]})})}function SelectListingTree(e){const t=(0,G.tz)();const r=[e.componentProps.listingWithTree.tree],i=function e(r,i){const n=r.map(t=>t.children&&t.children.length>0?{...t,children:e(t.children,t)}:t);return i?n.concat({...(0,c.A)(i,"children"),parent:i,id:`other-${i.id}`,fullName:t.formatMessage({id:"write_review_form.select_listing_tree.option.other.fullName",defaultMessage:"Other {listingName} listing"},{listingName:i.fullName}),shortName:t.formatMessage({id:"write_review_form.select_listing_tree.option.other.shortName",defaultMessage:"Other {listingName} listing"}
1,{listingName:i.shortName}),isOther:!0,isLeaf:!0}):n}(r[0].children||[],r[0]);return e.wrap((0,N.jsx)(SelectTree,{selectableBranches:i,listing:e.componentProps.listingWithTree,name:e.componentProps.listingWithTree.id,isLoading:e.componentProps.isLoading,placeholder:"Choose an option",selectedId:(()=>{if(e.input.value)return e.input.value.type===K.PQ.UNKNOWN_INTERNAL_ENTRY?`other-${e.input.value.entryId}`:e.input.value.entryId})(),onChange:t=>{t.id.startsWith("other-")?e.input.onChange(void 0,{...e.input.value,type:K.PQ.UNKNOWN_INTERNAL_ENTRY,entryId:t.id.replace("other-","")}):e.input.onChange(void 0,{...e.input.value,type:K.PQ.KNOWN_INTERNAL_ENTRY,entryId:t.id}),e.componentProps.onSelectBranchItem?.(t)},onFocus:e.input.onFocus,onBlur:e.input.onBlur}),{labelPointsToCustomElement:!0})}function ReviewSubjectRefinementField({listingWithTree:e}){const{control:t}=(0,X.xW)(),r=((0,G.tz)(),(0,n().useRef)(void 0)),i=(0,te.A)(Tt.KS);return(0,N.jsxs)(n().Fragment,{children:[(0,N.jsx)(X.D0,{name:"subject",label:(()=>{const t=e.categories?.map(e=>e.hook)??[];return(0,N.jsx)(G.sA,{id:"write_review_form.review_subject_refinement.subject_field.label",defaultMessage:"Which {hasRootListing, select, true {{rootListingFullName}} false {listing}} {categoryHooks, contains, services {{categoryHooks, contains, shops {store} home-builders {office} other {service} }} cars {variant} other {} } specifically?",values:{hasRootListing:Boolean(e.tree),rootListingFullName:e.tree?.fullName,categoryHooks:t}})})(),component:SelectListingTree,componentProps:{isLoading:i,listingWithTree:e,onSelectBranchItem:e=>{e.id.startsWith("other-")?(t.setValue("subject.type",K.PQ.UNKNOWN_INTERNAL_ENTRY),setTimeout(()=>r.current?.focus(),1)):t.setValue("subject.type",K.PQ.KNOWN_INTERNAL_ENTRY)}}}),(0,N.jsx)(t.FormValueSelector,{fieldName:"subject",children:t=>{return t&&t.type===K.PQ.UNKNOWN_INTERNAL_ENTRY&&t.entryId?(0,N.jsx)(X.D0,{name:"subject.entryName",label:(i={listingFullName:e.fullName},(0,N.jsxs)(N.Fragment,{children:["Which other ",i.listingFullName," are you reviewing?"]})),component:T.ks,componentProps:{ref:r,placeholder:"Be as specific as possible"}}):null;var i}})]})}function Pt(e){const t=[];for(const r of e)"group"===r.type?t.push({...r,fields:Pt(r.fields)}):dt(r)&&t.push(r);return t}function At(e,t){let r=Pt(e.fields);t?.tags?.includes("hide_purchase_location_field")&&(r=r.filter(e=>"group"===e.type||(!e.tags||!e.tags.includes("transaction_details.purchase_location"))));const i=[];return(new De.A).visitFields({fields:r},e=>{i.push(e.id)}),{...e,allFieldIds:i,fields:r}}function Et(e,t){return"optional"!==t.proofOfPurchaseFieldState?t.proofOfPurchaseFieldState:void 0===e?"optional":e>=3?"hidden":t.listing&&t.listing.statistics.numberOfReviews<10&&"services"===t.listing.categories?.[0]?.hook?"required":"optional"}const It=f().bind({reviewForm:"umEvUI","reviewForm-videoRecorder":"TrA3fp"}),$t=(0,G.YK)({proofOfPurchaseRequired:{id:"write_review.form.validation.proof_of_purchase_required",defaultMessage:"A proof of purchase is required"}}),_t=(0,n().lazy)(()=>r.e("shared_components_ReviewForm_components_ConsumerAuthenticatedSuccessfully_tsx").then(()=>r(82232))),Nt=(0,n().lazy)(()=>r.e("shared_components_ReviewForm_components_ReviewFormPreview_tsx").then(()=>r(74484))),Rt=(0,n().lazy)(()=>r.e("shared_components_ReviewForm_components_ReviewFormResolution_tsx").then(()=>r(928)));function Ot(e){return!(e.type!==K.PQ.UNKNOWN_INTERNAL_ENTRY||!e.unknownEntry)||!(e.type!==K.PQ.UNKNOWN_EXTERNAL_ENTRY||!e.unknownExternalEntry)}function Ft(e,t,r){if(r)return!0;const i=[];for(const e of t.fields)"group"!==e.type&&e.required&&i.push(`specificationValues.${e.id}`);const n=["subject","rating","body",...i],a=e.getValues();return!!n.every(t=>{const r=(0,u.A)(a,t);return null!=r&&""!==r||!!e.store.state.fieldsState.touchedFields[t]})}const Bt=(0,X.O3)()({name:"reviewForm",shouldRebuildSchema:(e,t)=>e.proofOfPurchaseFieldState!==t.proofOfPurchaseFieldState||e.subjectContext!==t.subjectContext||e.specifications!==t.specifications||e.categoryMinNumberOfWords!==t.categoryMinNumberOfWords||e.isLoggedIn!==t.isLoggedIn,schemaFactory:new X.DF((e,t)=>{const r=e.isLoggedIn?(0,xe.A)(e,t.phoneNumber):function(e,t){return m.Yj().superRefine((0,X.bB)(e,t,{type:"PhoneNumber"}))}
1(e,t.phoneNumber);return m.Ik({body:(0,de.mw)((0,de.Nx)(e.categoryMinNumberOfWords)),title:(0,de.vy)(m.Yj().min(5).max(120)),rating:(0,de.mw)(m.ai().int().min(1).max(5)),isEmailAddressRegistered:m.zM().optional(),isPhoneNumberRegistered:m.zM().optional(),proofOfPurchaseId:m.Yj().optional(),newFollowUpBody:(0,de.vy)(m.Yj().min(30)),followUps:m.YO(m.Ik({id:m.uR(),body:(0,de.vy)(m.Yj()),submittedAt:m.Yj()})).optional(),emailAddress:e.isLoggedIn?(0,de.vy)(m.Yj()):(0,de.vy)(de.Rp),phoneNumber:e.requiresPhoneNumber?(0,de.mw)(r):(0,de.vy)(r),displayName:(0,de.vy)(m.Yj()),attachments:m.YO(m.Ie()).optional(),specificationValues:e.specifications?be(e.specifications):m._H({}).optional(),encodedJourneyCustomisation:m.Yj().optional(),subject:e.subjectContext.type!==K.PQ.UNKNOWN_INTERNAL_ENTRY||e.subjectContext.listing?(0,de.mw)(m.gM("type",[m.Ik({type:m.eu(K.PQ.KNOWN_INTERNAL_ENTRY),catalogId:m.Yj().optional(),entryId:m.uR()}),m.Ik({type:m.eu(K.PQ.UNKNOWN_INTERNAL_ENTRY),catalogId:m.Yj().optional(),entryId:m.uR(),entryName:(0,de.mw)()}),m.Ik({type:m.eu(K.PQ.KNOWN_EXTERNAL_ENTRY),catalogId:m.Yj().optional(),externalCatalogId:m.uR(),externalEntryId:m.uR(),externalId:m.Yj(),externalEntryName:(0,de.vy)(m.Yj()),url:(0,de.vy)(m.Yj().url()),pictureUrl:(0,de.vy)(m.Yj().url())}),m.Ik({type:m.eu(K.PQ.OPTIMISTIC_KNOWN_EXTERNAL_ENTRY),catalogId:m.Yj().optional(),externalCatalogId:m.uR(),externalId:m.Yj(),externalEntryId:(0,de.vy)(m.uR()),externalEntryName:(0,de.vy)(m.Yj()),url:(0,de.vy)(m.Yj().url()),pictureUrl:(0,de.vy)(m.Yj().url())}),m.Ik({type:m.eu(K.PQ.UNKNOWN_EXTERNAL_ENTRY),catalogId:m.Yj().optional(),externalCatalogId:m.uR(),externalId:(0,de.vy)(m.Yj()),externalEntryId:(0,de.vy)(m.uR()),externalEntryName:(0,de.vy)(m.Yj()),url:(0,de.vy)(m.Yj().url()),pictureUrl:(0,de.vy)(m.Yj().url())})])):(0,de.mw)(m.Ik({type:m.eu(K.PQ.UNKNOWN_INTERNAL_ENTRY).default(K.PQ.UNKNOWN_INTERNAL_ENTRY),catalogId:m.Yj().optional(),entryType:(0,de.mw)(),entryName:(0,de.mw)(),categoryName:(0,de.mw)(),brandName:(0,de.vy)(m.Yj()),model:(0,de.vy)(m.Yj()),locationName:(0,de.vy)(m.Yj()),webLink:(0,de.vy)(de.Zk)}))}).superRefine((t,r)=>{if(t.proofOfPurchaseId||"required"!==Et(t.rating,{...e,listing:e.subjectContext.listing})||r.addIssue({code:"custom",message:$t.proofOfPurchaseRequired.defaultMessage,path:["proofOfPurchaseId"]}),!e.isLoggedIn&&(t.emailAddress||r.addIssue({code:"custom",path:["emailAddress"],message:de.nl.required.defaultMessage}),!t.isEmailAddressRegistered))if(t.displayName){const e=Se.A.safeParse(t.displayName);if(!e.success)for(const t of e.error.issues)r.addIssue({...t,path:["displayName"]})}else r.addIssue({code:"custom",path:["displayName"],message:de.nl.required.defaultMessage});t.subject.type===K.PQ.UNKNOWN_INTERNAL_ENTRY&&e.subjectContext.listing&&!t.subject.entryName&&r.addIssue({code:"custom",message:de.nl.required.defaultMessage,path:["subject","entryName"]})})}),transformSubmitValues:e=>{const{proofOfPurchaseId:t,specificationValues:r,...i}=e,n=r?(0,ke.A)(r):void 0;return{...i,proofOfPurchaseIds:e.proofOfPurchaseId?[e.proofOfPurchaseId]:void 0,specificationValues:(0,l.A)(n)?void 0:n}}})(function ReviewForm(e){(0,G.tz)();const{primarySpecifications:t,secondarySpecifications:r}=(0,n().useMemo)(()=>function(e){const t={fields:[],allFieldIds:[]},r={fields:[],allFieldIds:[]};return e?((new De.A).visitFields(e,e=>{e.valueFormWidget?.widget&&(e.required||e.tags?.includes("visible_by_default_on_review_form")?(t.fields.push(e),t.allFieldIds.push(e.id)):(r.fields.push(e),r.allFieldIds.push(e.id)))}),{primarySpecifications:t,secondarySpecifications:r}):{primarySpecifications:t,secondarySpecifications:r}}(e.specifications),[e.specifications]),{showModal:i}=(0,Z.A)(),[c,d]=(0,n().useState)(Ot(e.subjectContext)||e.subjectContext.type===K.PQ.KNOWN_INTERNAL_ENTRY||e.subjectContext.type===K.PQ.KNOWN_EXTERNAL_ENTRY),[l,u]=(0,n().useState)(!1),[h,f]=(0,n().useState)(!1),[m,C]=(0,n().useState)(!1),$=(0,ee.A)(),V=(0,ce.zy)(),q=e.control.watch("emailAddress"),H=e.control.watch("phoneNumber"),te=Et(e.control.watch("rating"),{...e,listing:e.subjectContext.listing}),{isRegisteredState:re}=(0,J.A)(q,H),ie=re.isPending?"loading":e.isLoggedIn||re.numberOfEmailChecks>0?"ready":"not-provided",[ne,se]=(0,n().useState)(!1),[oe,de]=(0,n().useState)({isOpen:!1,hasEverBeenOpened:!1}),le=(0,n().useRef)(void 0),[ue,he]=(0,n().useState)(()=>Ft(e.control,t,e.isEditing)),fe="00000000-0000-0000-0000-000000000000";(0,n().useEffect)(()=>
1{if(!ue)return e.control.eventEmitter.addListener("setValue",r),()=>{e.control.eventEmitter.removeListener("setValue",r)};function r(){he(Ft(e.control,t,e.isEditing))}},[e.control,ue]);const me=function(e){const t=(0,n().useMemo)(()=>new P(e),[e.name]);return(0,n().useEffect)(()=>{t.subscribe()},[t]),(0,S.A)(()=>{t.setRegisteredFields(Object.keys(e.store.state.fieldsState.registeredFields))},[t,Object.keys(e.store.state.fieldsState.registeredFields)]),t}(e.control);e.formFieldActivityTrackerRef.current=me,(0,n().useEffect)(()=>{re.isPending||(e.control.setValue("isEmailAddressRegistered",re.isEmailAddressRegistered),e.control.setValue("isPhoneNumberRegistered",re.isPhoneNumberRegistered))},[re.isEmailAddressRegistered]),(0,X.jE)(e.control,{disablePersistentState:e.disablePersistentState,exclude:["emailAddress","displayName","phoneNumber"],transformRehydratedValues:e.transformRehydratedValues}),(0,n().useEffect)(()=>{se(!1)},[V.key]);const pe=t=>{if(oe.hasEverBeenOpened)return;const r=e.subjectContext.listing;r&&(r.tags.includes("push_video_reviews")||r.brand?.tags.includes("push_video_reviews")||r.categories?.some(e=>e.tags.includes("push_video_reviews")))&&(t.preventDefault(),de({isOpen:!0,hasEverBeenOpened:!0}))};(0,n().useEffect)(()=>{e.isEditing&&e.control.submit({isFakeSubmit:!0})},[]),(0,n().useEffect)(()=>{Ot(e.subjectContext)&&d(!0)},[e.subjectContext]),(0,n().useEffect)(()=>{e.dirty&&!l&&e.onceFormIsDirty&&(u(!0),e.onceFormIsDirty())},[e.dirty]),(0,n().useEffect)(()=>{$.current&&e.isLoggedIn&&(f(!0),e.control.setValue("emailAddress",void 0),e.control.setValue("displayName",void 0))},[e.isLoggedIn]);const ge=e.error||re.error;return(0,N.jsxs)(x.A,{onSubmit:e.handleSubmit,id:"review-form-wrapper",className:It("reviewForm"),children:[(0,N.jsx)("iframe",{"aria-hidden":"true",src:"https://apps.rokt.com/wsdk/preload/index.html",sandbox:"allow-scripts allow-same-origin",style:{border:0,display:"none",width:"100%"}}),(0,N.jsx)(v.A,{full:{xs:!0},marginBottom:3,negativeMarginTop:{xs:3,sm:0},children:(0,N.jsxs)(v.A.Block,{display:"flex",doNotRenderIfEmpty:!0,flexDirection:"column",gap:4,children:[e.subjectContext.type===K.PQ.UNKNOWN_INTERNAL_ENTRY&&!e.subjectContext.listing&&(0,N.jsx)(GlobalReviewSubjectStep,{onFinish:()=>d(!0)}),oe.isOpen&&(0,N.jsx)(B.A,{reject:()=>de(e=>({...e,isOpen:!1})),resolve:()=>de(e=>({...e,isOpen:!1})),title:"Short review video",content:e=>(0,N.jsx)(VideoRecorder_VideoRecorder,{onFinish:t=>{e();const r=new File([t],"video.mp4",{type:"video/mp4"});le.current?.selectFiles([r])}}),bodyProps:{display:"flex",flexDirection:"column",overflowY:"hidden",padding:0},dialogProps:{justifyContent:"stretch",className:It("reviewForm-videoRecorder")},headerProps:{noBorder:!0},pullToClose:!1,backdrop:"static",size:{mobile:"fullscreen",desktop:"large"}}),ne&&(0,N.jsx)(B.A,{reject:()=>se(!1),resolve:()=>se(!1),content:e=>(0,N.jsx)(W.A,{onClose:e}),dialogProps:{justifyContent:{xs:"stretch",sm:"start"}},hideCloseButton:!0,size:{desktop:"large",mobile:"fullscreen"}}),e.subjectContext&&(e.subjectContext.type!==K.PQ.UNKNOWN_INTERNAL_ENTRY||e.subjectContext.listing)?(0,N.jsx)(WriteReviewSub
1jectContext,{subjectContext:e.subjectContext,isEditing:e.isEditing,children:t=>{const{listing:r}=e.subjectContext;return(0,N.jsxs)(n().Fragment,{children:[(0,N.jsxs)(y.h,{alignItems:"start",display:"flex",flexWrap:"wrap",gap:2,justifyContent:"between",children:[t,!e.isEditing&&(e.subjectContext.type===K.PQ.KNOWN_INTERNAL_ENTRY||e.subjectContext.type===K.PQ.UNKNOWN_INTERNAL_ENTRY)&&(0,N.jsx)(b.A,{onClick:()=>se(!0),buttonStyle:"link",breakWord:!0,flexShrink:0,negativeMarginY:2,tabIndex:0,tracking:{id:"write_review_form.review_something_else"},children:"Review something else"})]}),r&&r.superseders.length>0&&(0,N.jsx)(p.A,{alertStyle:"warning",children:(0,N.jsx)(_.A,{source:"Suggestion: Do you want to review <Superseders /> instead?",componentsAvailable:{Superseders:(0,ae.A)(()=>(0,N.jsx)(F.A.WithTooltip,{items:r.superseders,operator:"or",renderListItem:e=>(0,N.jsx)(D.A,{routeName:"www.public.write_review_form",params:{listingSlug:e.slug},breakWord:!0,fontWeight:"bold",textDecorationHover:"underline",textStyle:"link",tracking:{id:"superseder"},children:(0,Y.A)({listing:e,currentListing:r})}),renderExtraListItem:e=>(0,N.jsx)(D.A,{routeName:"www.public.write_review_form",params:{listingSlug:e.slug},breakWord:!0,textDecorationHover:"underline",tracking:{id:"superseder_extra"},children:(0,Y.A)({listing:e,currentListing:r})}),truncateAfter:1}))},initialParser:"inline"})}),(e.subjectContext.type===K.PQ.KNOWN_INTERNAL_ENTRY||e.subjectContext.type===K.PQ.UNKNOWN_INTERNAL_ENTRY)&&(0,N.jsxs)(n().Fragment,{children:[!e.isEditing&&e.subjectContext.listing?.tree&&Boolean(e.subjectContext.listing?.tree?.children?.length)&&(0,N.jsx)(ReviewSubjectRefinementField,{listingWithTree:{...e.subjectContext.listing,tree:e.subjectContext.listing.tree}}),e.subjectContext.listing?.brand&&e.subjectContext.listing.brand.customerServiceEntry?.id!==e.subjectContext.listing.id&&(0,N.jsx)(BrandCustomerServiceEntryLink,{brand:e.subjectContext.listing.brand})]})]})}}):null,c&&(0,N.jsxs)(n().Fragment,{children:[e.subjectContext.listing?.writeReviewFormHelp&&(0,N.jsx)(y.h,{fontSize:"small",children:(0,N.jsx)(ListingWriteReviewFormHelpMarkdown,{source:e.subjectContext.listing.writeReviewFormHelp})}),(0,N.jsx)(X.D0,{name:"rating",label:"Rate your experience",component:T.GW,required:!0}),(0,N.jsx)(X.D0,{name:"body",label:(0,N.jsxs)(n().Fragment,{children:["Write your review",e.categoryMinNumberOfWords>0&&(0,N.jsx)(ReviewBodyWordCount,{min:e.categoryMinNumberOfWords})]}),labelProps:{alignItems:"center",display:"flex",justifyContent:"between"},component:T.TM,componentProps:{minRows:3,maxRows:1/0,paddingBottom:5,placeholder:"State accurate facts and be objective. No aggressive language or personal details.",testId:"textarea"},help:(0,N.jsx)(n().Fragment,{children:(0,N.jsx)(y.h,{marginX:3,textAlign:"right",children:(0,N.jsxs)(y.h,{onClick:e=>{e.stopPropagation(),de(e=>({...e,hasEverBeenOpened:!0,isOpen:!0}))},alignItems:"center",backgroundColor:"white",cursor:"pointer",display:"inline-flex",fontWeight:"semi-bold",gap:1,textDecoration:"underline",textDecorationHover:"none",textStyle:"dark",tracking:{id:"write_review_form.body_field.record_video"},children:[(0,N.jsx)(y.h,{element:"svg",width:"10",height:"10",children:(0,N.jsx)("circle",{cx:"5",cy:"5",r:"5",fill:"red"})}),"Record short video review"]})})}),helpProps:{display:"flex",flexDirection:"column",gap:2,marginTop:0,style:{marginTop:"-25px"}},onMouseDown:pe,onTouchStart:pe}),(0,N.jsxs)(y.h,{backgroundColor:"light",borderRadius:{xs:"none",md:!0},display:"flex",flexDirection:"column",gap:4,negativeMarginX:{xs:3,sm:4,md:0},padding:{xs:3,sm:4},style:{"--bs-light-rgb":"255, 229, 208","--bs-bg-opacity":.25},overflow:"hidden",children:[(0,N.jsxs)(y.h,{style:{clear:"both"},children:[(0,N.jsx)(I.A,{src:s(),height:80,width:80,negativeMargin:{xs:3,sm:4},negativeMarginLeft:0,style:{float:"right"}}),(0,N.jsx)(M.A,{level:3,marginBottom:1,children:(0,N.jsx)(_.A,{source:"<Accent.Inline>Stand out!</Accent.Inline> Increase the visibility of your review",componentsAvailable:{Accent:e=>(0,N.jsx)(U.A,{textStyle:"dark",style:{"--bs-dark-rgb":"214, 51, 132"},...e})},initialParser:"inline"})}),(0,N.jsx)(j.A,{fontSize:"medium",lineHeight:"small",children:(0,N.jsx)(_.A,{source:"Readers find reviews with pictures and videos more **trustworthy**",initialParser:"inline"})})]}),(0,N.jsx)(g.A,{name:"attachments",resource:{type:"review",id:fe},collection:Te.pM.reviewAttachment,isEditing:e.isEditing,uploaderRef
1:le,onInternalStateChanged:e=>{C(e.objects.some(e=>e.isUploading))}})]}),e.isEditing&&e.reviewBeingEdited?.title&&(0,N.jsx)(X.D0,{name:"title",normalizeEmptyStringToNull:!0,label:"Give your review a title",component:T.ks,componentProps:{placeholder:"The gist of your experience"},required:!1}),e.subjectContext.listing&&e.isEditing&&V.query.askForSpecifications?(0,N.jsx)(AlertAboutMissingSpecificationFields,{listing:e.subjectContext.listing,primarySpecifications:t,secondarySpecifications:r}):null,t.fields.length>0&&(0,N.jsx)(ReviewFormSpecificationFields,{context:"writeReviewForm",fields:t.fields}),r.fields.length>0&&ue&&(0,N.jsxs)(y.h,{backgroundColor:"light",borderRadius:{xs:"none",md:!0},display:"flex",flexDirection:"column",gap:4,negativeMarginX:{xs:3,sm:4,md:0},padding:{xs:3,sm:4},style:{"--bs-light-rgb":"226, 217, 243","--bs-bg-opacity":.25},children:[(0,N.jsxs)(y.h,{style:{clear:"both"},children:[(0,N.jsx)(I.A,{src:o(),height:80,width:80,negativeMargin:{xs:3,sm:4},negativeMarginLeft:0,style:{float:"right"}}),(0,N.jsx)(M.A,{level:3,marginBottom:1,children:(0,N.jsx)(_.A,{source:"<Accent.Inline>Share more</Accent.Inline> about your experience",componentsAvailable:{Accent:e=>(0,N.jsx)(U.A,{textStyle:"primary",...e})},initialParser:"inline"})}),(0,N.jsx)(j.A,{fontSize:"medium",lineHeight:"small",children:(0,N.jsx)(_.A,{source:"The following **fields are optional** but please tell us more and help more people",initialParser:"inline"})})]}),(0,N.jsx)(ReviewFormSpecificationFields,{context:"writeReviewForm",fields:r.fields})]}),"hidden"!==te&&(0,N.jsxs)(y.h,{backgroundColor:"light",borderRadius:{xs:"none",md:!0},display:"flex",flexDirection:"column",gap:4,negativeMarginX:{xs:3,sm:4,md:0},padding:{xs:3,sm:4},style:{"--bs-light-rgb":"226, 217, 243","--bs-bg-opacity":.25},overflow:"hidden",children:[(0,N.jsxs)(y.h,{style:{clear:"both"},children:[(0,N.jsx)(I.A,{src:a(),height:80,width:80,flexShrink:0,negativeMargin:{xs:3,sm:4},negativeMarginLeft:0,style:{float:"right"}}),(0,N.jsx)(M.A,{level:3,marginBottom:1,children:(0,N.jsx)(_.A,{source:"Help us fight fake reviews",initialParser:"inline"})}),(0,N.jsx)(j.A,{fontSize:"medium",lineHeight:"small",children:(0,N.jsx)(_.A,{source:"ProductReview is committed to publishing genuine reviews, **positive** or **negative**",initialParser:"inline"})})]}),(0,N.jsx)(e.control.FormValueSelector,{fieldName:"subject.entryType",children:t=>(0,N.jsx)(ProofOfPurchaseField,{resource:{type:"review",id:fe},isRequired:"required"===te,isService:"service"===t||e.subjectContext.type===K.PQ.KNOWN_INTERNAL_ENTRY&&"services"===e.subjectContext.listing?.categories?.[0]?.hook,uploaderProps:{onInternalStateChanged:e=>{C(e.objects.some(e=>e.isUploading))}},reviewBeingEdited:e.reviewBeingEdited})})]}),!!e.requiresPhoneNumber&&(0,N.jsxs)(n().Fragment,{children:[(0,N.jsx)(k.A,{margin:0}),(0,N.jsx)(X.D0,{name:"phoneNumber",label:"Phone number",help:(0,N.jsx)(G.sA,{id:"write_review.form.verification_section.phone_number.help",defaultMessage:"{isPhoneNumberRegistered, select,\n true {{checkmarkIcon} You're already registered! Continue with your e-mail address down below.}\n false {Your phone number is used for verification. It will not be displayed publicly.}\n}",values:{checkmarkIcon:(0,N.jsx)(E.A,{name:"check-circle",width:21,height:21,textStyle:"success"}),isPhoneNumberRegistered:Boolean(re.isPhoneNumberRegistered)}}),component:T.yL,required:e.requiresPhoneNumber})]})]})]})}),(()=>{if(!e.reviewBeingEdited)return null;if(!e.reviewBeingEdited.followUps?.length)return null;const{reviewBeingEdited:t}=e,r=t.followUps.reduce((e,t)=>new Date(t.submittedAt)>new Date(e.submittedAt)?t:e),i=new Date(r.submittedAt),n=new Date;return n.setDate(n.getDate()-1),(0,N.jsx)(v.A,{full:{xs:!0},id:"follow_ups",marginBottom:c?3:void 0,children:(0,N.jsxs)(v.A.Block,{display:"flex",flexDirection:"column",gap:4,children:[(0,N.jsx)(M.A,{level:3,negativeMarginBottom:1,children:"Follow-ups"}),(0,N.jsx)(Xe.A,{withNewFollowUpField:t.approvalStatus===K.Gw.APPROVED&&n>i,suggestedFollowUpQuestions:t.suggestedFollowUpQuestions})]})})})(),c&&(0,N.jsx)(v.A,{full:{xs:!0},testId:"authentication_card",children:(0,N.jsxs)(v.A.Block,{display:"flex",doNotRenderIfEmpty:!0,flexDirection:"column",gap:3,children:[!e.isEditing&&h&&(0,N.jsx)(n().Suspense,{fallback:(0,N.jsx)(O.A,{}),children:(0,N.jsx)(_t,{})}),!e.isLoggedIn&&(0,N.jsxs)(y.h,{alignItems:"center",display:"flex",flexDirection:"column",gap:4,children:[(0,N.jsx)(M.A,{level:3,textAlign:"center",children:"Submit your review"}
1),(0,N.jsx)(InlineAuthFields,{initialEmailAddress:e.initialValues?.emailAddress,isRegisteredState:re})]}),(()=>{if(!ge)return null;if((0,Q.c)(ge)&&400===ge.response.status&&400401===ge.response.data?.code&&ge.response.data?.extended_message?.errors&&e.specifications){const t=ge.response.data.extended_message.errors,r=[],i=(0,we.T)(e.specifications);for(const e of t){const t=i[e.fieldId];t&&r.push((0,N.jsxs)(L.A.Item,{children:[(0,N.jsxs)(z.A,{fontWeight:"semi-bold",children:[t.question??t.label,": "]}),(0,N.jsx)(z.A,{children:e.message})]},e.fieldId))}return 0===r.length?(0,N.jsx)(A.A,{error:ge}):(0,N.jsxs)(p.A,{alertStyle:"danger",children:["Some fields require your attention:",(0,N.jsx)(L.A,{children:r})]})}return(0,N.jsx)(A.A,{error:ge})})(),"not-provided"!==ie&&(0,N.jsxs)(R.A,{isLoading:"loading"===ie,children:[(0,N.jsx)(_.A,{source:"By submitting this review, I accept ProductReview's [Posting Guidelines](/i/posting-guidelines) and [Terms of Use](/i/terms-of-use) Policy"}),(0,N.jsxs)(w.A,{flexDirection:{xs:"column",sm:"row"},gap:1,children:[(0,N.jsx)(b.A.Button,{onClick:async()=>{const t=await e.control.submit({isFakeSubmit:!0});t.isValid&&i({title:"Review Preview",content:r=>(0,N.jsx)(n().Suspense,{fallback:(0,N.jsx)(O.A,{}),children:(0,N.jsx)(Nt,{isEditing:e.isEditing,handleSubmit:e.handleSubmit,closeModal:()=>r(),reviewSpecifications:e.specifications,values:{...t.values,subject:(()=>{if(e.subjectContext.type===K.PQ.KNOWN_INTERNAL_ENTRY)return e.subjectContext;if(e.subjectContext.type===K.PQ.UNKNOWN_INTERNAL_ENTRY)return{...e.subjectContext,unknownEntry:t.values.subject};if(e.subjectContext.type===K.PQ.KNOWN_EXTERNAL_ENTRY)return e.subjectContext;if(e.subjectContext.type===K.PQ.UNKNOWN_EXTERNAL_ENTRY)return{...e.subjectContext,unknownExternalEntry:t.values.subject};throw new Error("Invalid subject")})()}})}),bodyProps:{padding:3},size:"large"}).catch(ve.O)},isDisabled:re.isPending,isLoading:e.submitting||m,flexBasis:100,flexGrow:1,tracking:{id:"write_review_form.preview_review"},children:"Preview your review"}),(0,N.jsx)(b.A.Submit,{isLoading:e.submitting||m||re.isPending,flexBasis:100,flexGrow:1,tracking:{id:"write_review_form.submit_button",gaContext:{action:e.isEditing?"update":"submit"}},children:(0,N.jsx)(G.sA,{id:"write_review.form.submit_button.label",defaultMessage:"{isEditing, select, true {Update your review} false {Submit your review}}",values:{isEditing:e.isEditing}})})]}),m&&(0,N.jsx)(y.h,{italic:!0,textAlign:"center",marginTop:2,textStyle:"muted",children:"File upload in progressâ¦"})]})]})})]})});function Dt(e,t){const{initialValues:r={},isEditing:i=!1}=e,n={...(0,c.A)(r,"proofOfPurchaseIds"),proofOfPurchaseId:r.proofOfPurchaseIds?r.proofOfPurchaseIds[0]:void 0};let a,s=30;return e.subjectContext.type===K.PQ.KNOWN_EXTERNAL_ENTRY||e.subjectContext.type===K.PQ.UNKNOWN_EXTERNAL_ENTRY?s=10:e.subjectContext.listing?.reviewMinNumberOfWords&&(s=e.subjectContext.listing.reviewMinNumberOfWords),e.subjectContext.listing?.specifications&&(a=At(e.subjectContext.listing.specifications,e.subjectContext.listing)),{specifications:a,isEditing:i,initialValues:n,categoryMinNumberOfWords:s}}function ReviewFormContainer(e){const{showModal:t,showAlert:r}=(0,Z.A)(),{collectSmsOtpToken:i}=(0,re.A)(),a=(0,ie.A)(),s=(0,te.A)(se.wz),o=!s.isGuest,[c,d]=(0,n().useState)(Dt(e)),l=(0,ne.A)(),[u,h]=(0,n().useState)(l()),f=(0,n().useRef)(void 0);(0,n().useEffect)(()=>{d(Dt(e))},[e]),(0,n().useEffect)(()=>{e.reviewBeingEdited&&(window.cachedResolvedReferences=e.reviewBeingEdited.resolvedReferences)},[e.reviewBeingEdited]),(0,n().useEffect)(()=>{T.BI.preload(),T.Fu.preload(),T.pX.preload(),T.dE.preload(),T.R.preload()},[]);const{subjectContext:m,persistentId:p,onSubmitReview:g,...y}=e;return(0,N.jsx)(Bt,{formFieldActivityTrackerRef:f,reviewBeingEdited:e.reviewBeingEdited,enableReinitialize:!0,subjectContext:m,...y,isLoggedIn:o,isEditing:c.isEditing,specifications:c.specifications,name:`reviewForm-${p||"global"}`,onSubmit:async c=>{const{emailAddress:d,phoneNumber:l,isEmailAddressRegistered:h,isPhoneNumberRegistered:m,displayName:p,...g}=c;let y;if(o){if(l&&l!==s.consumerData?.phoneNumberDetails?.phoneNumberE164){const e=await i(l);
1await a.dispatch((0,oe.Gv)({consumerId:s.id,phoneNumber:l,phoneNumberVerificationToken:e}))}}else{if(!d)return r("Please enter an email address",{title:"Validation error"});if(h){const e=l?await i(l):void 0;y={isRegistered:!0,emailAddress:d,phoneNumberVerification:l&&e?{phoneNumber:l,phoneNumberVerificationToken:e}:void 0}}else{if(!p)return r("Please enter a display name",{title:"Validation error"});const e=l?await i(l):void 0;y={isRegistered:!1,emailAddress:d,displayName:p,roleIntention:{type:K.Xh.CONSUMER,phoneNumber:l,phoneNumberVerificationToken:e}}}}const b=g,w=f.current?f.current.handleSubmit().build():void 0;return e.subjectContext?.listing?.isManageableByBrandManagers&&e.subjectContext.listing.brand&&e.subjectContext.listing.brand.permissions&&e.subjectContext.listing.brand.permissions.reviewMediation&&!e.isEditing&&!e.reviewBeingEdited?.isMediationCompleted&&([K.PQ.KNOWN_INTERNAL_ENTRY,K.PQ.KNOWN_EXTERNAL_ENTRY].includes(b.subject.type)||b.subject.type===K.PQ.UNKNOWN_INTERNAL_ENTRY&&"entryId"in b.subject&&b.subject.entryId)&&b.rating<4?t(function(e){return{size:"large",title:(t={brandName:e.brand?.name},(0,N.jsxs)(N.Fragment,{children:["Give ",t.brandName," the opportunity to resolve your issue privately"]})),content:t=>(0,N.jsx)(n().Suspense,{fallback:(0,N.jsx)(O.A,{}),children:(0,N.jsx)(Rt,{onSelect:t,listing:e})}),bodyProps:{padding:4}};var t}(e.subjectContext.listing)).then(t=>e.onSubmitReview({...b,mediationStrategy:t,submissionStatistics:w},e.reviewBeingEdited?.id??u,y)):e.onSubmitReview({...b,submissionStatistics:w},e.reviewBeingEdited?.id??u,y)},onSubmitError:e=>{(0,Q.c)(e)&&409===e.status&&h(l())},categoryMinNumberOfWords:c.categoryMinNumberOfWords,initialValues:c.initialValues})}const Mt=(0,n().memo)(ReviewFormContainer,(e,t)=>!(t.subjectContext!==e.subjectContext||t.isEditing!==e.isEditing||t.onSubmitReview!==e.onSubmitReview||t.reviewBeingEdited!==e.reviewBeingEdited||t.proofOfPurchaseFieldState!==e.proofOfPurchaseFieldState||t.requiresPhoneNumber!==e.requiresPhoneNumber||!(0,d.A)(t.initialValues,e.initialValues)))},89819(e,t,r){"use strict";r.d(t,{A:()=>ReviewFormFollowUps});var i=r(85906),n=r(19363),a=r(11242),s=r(49329),o=r(66307),c=r(2063),d=r(74954),l=r(57623),u=r(14202);function ReviewFormFollowUps(e){const{control:t}=(0,c.xW)(),{withNewFollowUpField:r=!1,suggestedFollowUpQuestions:h}=e,f=((0,d.tz)(),t.getValues("followUps")??[]);return(0,u.jsxs)(i.Fragment,{children:[(0,u.jsx)(c.ED,{name:"followUps",children:({fields:e,touched:t,errors:r,accessibilityProps:i})=>(0,u.jsxs)(n.h,{...i,display:"flex",doNotRenderIfEmpty:!0,flexDirection:"column",gap:4,children:[e.map((e,t)=>(0,u.jsx)(c.D0,{name:`followUps.${t}.body`,label:(0,u.jsx)(d.sA,{id:"public.write_review.form.follow_ups.body_field.label",defaultMessage:"{submittedAt, date, long} follow-up",values:{submittedAt:e.value.submittedAt}}),component:a.TM,componentProps:{minRows:3,maxRows:1/0},clearable:!0,normalizeEmptyStringToNull:!0},t)),t&&r&&(0,u.jsx)(l.A,{error:r})]})}),r&&(0,u.jsx)(c.D0,{name:"newFollowUpBody",label:(0,u.jsxs)(i.Fragment,{children:[(0,u.jsx)(d.sA,{id:"public.write_review.form.body.new_follow_up.body_field.label",defaultMessage:"How has your experience been since your {noFollowUps, select, true {original review} false {last follow-up}}?",values:{noFollowUps:!f?.length}}),Boolean(h?.length)&&(0,u.jsx)(n.h,{fontSize:"small",fontWeight:"normal",children:(0,u.jsx)(s.A,{source:"Top follow-up questions readers have asked about your review:\n\n<QuestionsList.Inline />",componentsAvailable:{QuestionsList:()=>(0,u.jsx)(o.A,{children:e.suggestedFollowUpQuestions.map(e=>(0,u.jsx)(o.A.Item,{children:e.body},e.id))})},initialParser:"inline"})})]}),component:a.TM,componentProps:{minRows:3,maxRows:1/0,placeholder:"Write your follow upâ¦"},clearable:!0})]})}},53439(e,t,r){"use strict";r.r(t),r.d(t,{default:()=>SelectSingleListingTree});var i=r(85906),n=r(45919),a=r(70009),s=r(83115),o=r(35447),c=r(6612),d=(r(74954),r(71526)),l=r(46370),u=r(14202);function SelectSingleListingTree(e){const t=(0,a.A)();return(0,u.jsxs)(i.Fragment,{children:[(0,u.jsx)(c.A,{name:e.name,branches:e.branches,selectedId:e.selectListingId,selectLeavesOnly:e.selectLeavesOnly,sortBranch:(r,i)=>l.A.compareWithCollator(t,e.listing,r,i),onChange:e.onChange,renderLine:t=>(0,u.jsxs)(o.A,{breakWord:!0,flexGrow:1,children:[(0,d.A)({listing:t,currentListing:e.listing,nameKey:"shortName"}),t.isDiscontinued&&(0,u.jsxs)(o.A,{fontSize:"small",textStyle:"muted",children:[(0,u.jsx)(s.A,{}),"Discontinued"]})]}),overflowY:"auto",visibleScrollbar:!0,style:{maxHeight:228}}),!e.selectLeavesOnly&&(0,u.jsx)(n.A.Button,{onClick:e.onClickButton,isDisabled:Boolean(!e.selectListingId),children:"Select"})]})}},6612(e,t,r){"use strict";r.d(t,{A:()=>SingleSelectionTree});var i=r(85906),n=r(78801),a=r.n(n),s=r(95467),o=r(62227),c=r(66307),d=r(19363);var l=r(14202);const u=a().bind({collapse:"XAA_Ox",isVisible:"iCmrED"});function Collapsible(e){return(0,l.jsx)(d.h,{className:u("collapse",{isVisible:e.show}),children:(0,l.jsx)(d.h,{overflow:"hidden",children:e.children})})}const h={"tree-branch":"pESV45","tree-leaf":"ZjYk1s","tree-leaf-icon":"ucAvLt",isOpen:"aLJXBj"},f=a().bind(h);function Tree_Tree(e){function t(t,r,i){return(0,l.jsxs)(c.A,{unstyled:!0,className:f("tree-branch"),children:[t,i&&e.renderOtherOptionLine&&(0,l.jsx)(c.A.Item,{className:f("tree-leaf"),children:e.renderOtherOptionLine(r)},"other")]})}function r(t,r=[]){const n=r.concat(t.id),a=e.openIdsTrails.some(e=>e.includes(t.id));return(0,l.jsxs)(c.A.Item,{children:[(0,l.jsx)(c.A,{unstyled:!0,className:f("tree-leaf"),children:e.renderLine(t,a,n)}),t.children&&t.children.length>0&&i(t.children,a,n)]},t.id)}function i(i,n,a){const s=e.disableCollapse||n,o=e.sortBranch?[...i].sort(e.sortBranch):i;return e.disableAnimation?s?t(o.map(e=>r(e,a)),a,s):null:t(o.map((e,t)=>(0,l.jsx)(Collapsible,{show:s,children:r(e,a)},t)),a,s)}return t((e.sortBranch?[...e.branches].sort(e.sortBranch):e.branches).map(e=>r(e,[])),[],!0)}var m=r(78569);const p=a().bind(h);function SingleSelectionTree(e){const[t,r]=(0,i.useState)({activeId:e.selectedId,openIdsTrail:e.selectedId?(0,m.A)(e.branches,e.selectedId).join("."):null});
1function n(e,t){return(0,l.jsx)(o.A,{name:"chevron-right",height:24,width:16,flexShrink:0,textStyle:"muted",className:p("tree-leaf-icon",{isOpen:e}),...t})}(0,i.useEffect)(()=>{r({activeId:e.selectedId,openIdsTrail:e.selectedId?(0,m.A)(e.branches,e.selectedId).join("."):null})},[e.selectedId]);const{name:a,onChange:d,renderLine:u,selectedId:h,selectLeavesOnly:f,...g}=e;return(0,l.jsx)(Tree_Tree,{openIdsTrails:t.openIdsTrail?[t.openIdsTrail]:[],renderLine:function(i,a,o){const d=i.children&&i.children.length>0,u=e.disableCollapse||a;return d&&e.selectLeavesOnly?(0,l.jsxs)(c.A.Item,{onClick:()=>{const e=o.join(".");t.openIdsTrail?.startsWith(e)?r(e=>({...e,openIdsTrail:o.length>1?o.slice(0,-1).join("."):null})):r(t=>({...t,openIdsTrail:e}))},alignItems:"start",cursor:"pointer",display:"flex",gap:2,testId:`tree_item_${i.id}`,children:[n(u),e.renderLine(i,u,o)]}):(0,l.jsxs)(c.A.Item,{onClick:()=>{r(()=>({activeId:i.id,openIdsTrail:o.join(".")})),e.onChange&&e.onChange(i)},alignItems:"start",cursor:"pointer",display:"flex",gap:2,paddingLeft:d||e.selectLeavesOnly?void 0:5,children:[d&&n(u),(0,l.jsx)(s.A,{name:e.name,id:`${e.name}.${i.id}`,value:i.id,checked:t.activeId===i.id,readOnly:!0,testId:`tree_item_radio_${i.id}`,children:e.renderLine(i,u,o)})]})}.bind(this),...g})}},90853(e,t,r){"use strict";r.d(t,{A:()=>WriteReviewListingSearch});var i=r(31362),n=r(85906),a=r(19363),s=r(45919),o=r(98379),c=r(22947),d=r(41125),l=r(74954),u=r(42673),h=r(5306),f=r(55156),m=r(14202);function WriteReviewListingSearchInput(e){(0,l.tz)();const t=(0,f.zy)(),r=(0,n.useRef)(null),{onChange:i,placeholder:a="Example: iPhone, Australia Post, Harvey Norman",...s}=e;return(0,n.useEffect)(()=>{!r.current||null!==document.activeElement&&/^(?:input|select|textarea|button)$/i.test(document.activeElement.nodeName)&&!document.activeElement.hasAttribute("contenteditable")||r.current.focus()},[r,t]),(0,m.jsx)(h.A,{ref:r,type:"search",autoComplete:"off",maxLength:100,placeholder:a,onChange:e=>i(e.target.value),onClear:()=>i(""),tracking:{id:"subject_input",triggerEvent:"onFocus"},...s})}var p=r(78026),g=r(61829),y=r(3633),b=r(36171),w=r(32475),v=r(4484),k=r(12732),T=r(62227),x=r(25343),S=r(59940),C=r(19107),P=r(49329),A=r(83115),E=r(14901),I=r(23978),$=r(35447),_=r(55279),N=r(61825),R=r(86490),O=r(57483),F=r(59091),B=r(71526);function PredefinedFilter({children:e,to:t}){(0,l.tz)();return(0,m.jsxs)(x.A,{to:t,element:s.A.Link,buttonStyle:"light",icon:"right",pill:!0,display:"inline-flex",overflowX:"hidden",title:"Click to remove",children:[(0,m.jsx)($.A,{flexGrow:1,fontWeight:"normal",textStyle:"body",truncate:!0,children:e}),(0,m.jsx)(T.A,{name:"close",alignSelf:"center",flexShrink:0,padding:1})]})}function WriteReviewListingSearchResults(e){const t=(0,l.tz)(),r=(0,R.A)(F.dl),[s,c]=(0,n.useState)(e.term),u=(0,_.A)(),{response:h,isLoading:f,error:T}=(0,N.A)(u.generate("api.search.universal",{catalogId:r,type:"listing",isStrict:"yes",limit:10,...e.query,q:s}),{isReady:s.length>1||!(0,i.A)(e.query),onSuccess:()=>{e.onResponseComplete?.(s)}}),$=(0,n.useMemo)(()=>(0,y.A)(e=>{c(e)},300),[c]);if((0,n.useEffect)(()=>($(e.term),()=>{$.cancel()}),[e.term]),T)return(0,m.jsx)(b.A,{alertStyle:"danger",margin:3,children:(0,m.jsx)(k.A,{error:T})});if(f&&!h)return(0,m.jsx)(C.A,{margin:3});const D=""===e.term.trim();return(0,m.jsx)(S.A,{delay:500,isLoading:f||e.term!==s,children:(()=>{if(h)return(0,m.jsxs)(n.Fragment,{children:[e.query&&(0,m.jsxs)(o.A,{doNotRenderIfEmpty:!0,flexWrap:"wrap",gap:1,margin:3,children:[e.query.brandName&&(0,m.jsx)(PredefinedFilter,{to:u.generate("www.public.write_review_search",(0,p.A)(e.query,"brandName")),children:(0,m.jsx)(P.A,{source:t.formatMessage({id:"public.write_review_listing_search.results.predefined_filters.brand",defaultMessage:"<Small>Brand:</Small> {brandName}"},{brandName:e.query.brandName}),componentsAvailable:{Small:(0,O.A)(e=>(0,m.jsx)(I.A,{fontSize:"small",textStyle:"muted",...e}))},initialParser:"inline"})}),e.query.categoryName&&(0,m.jsx)(PredefinedFilter,{to:u.generate("www.public.write_review_search",(0,p.A)(e.query,"categoryName")),children:(0,m.jsx)(P.A,{source:t.formatMessage({id:"public.write_review_listing_search.results.predefined_filters.category",defaultMessage:"<Small>Category:</Small>
1 {categoryName}"},{categoryName:e.query.categoryName}),componentsAvailable:{Small:(0,O.A)(e=>(0,m.jsx)(I.A,{fontSize:"small",textStyle:"muted",...e}))},initialParser:"inline"})})]}),0===h.hits.length?(0,m.jsx)(E.A,{italic:!0,margin:5,textAlign:"center",textStyle:"muted",children:"No results"}):(0,m.jsxs)(n.Fragment,{children:[0===s.length&&!(0,i.A)(e.query)&&(0,m.jsx)(d.A,{level:3,fake:!0,fontWeight:"medium",margin:3,marginBottom:1,children:"Some popular suggestions:"}),h.hits.map((t,r)=>{const i=t._source,a=(0,g.A)(i.categoryNames);return(0,m.jsx)(v.A.Item,{children:(0,m.jsxs)(x.A,{to:u.generate("www.public.write_review_form",{listingSlug:i.slug,...(0,p.A)(e.query,"brandName","categoryName")}),rel:"nofollow",fontSize:"large",lineHeight:"smallest",marginBottom:r===h.hits.length-1?3:void 0,paddingX:3,testId:i.id,tracking:{id:"search_result",gaContext:{label:i.fullName,dimensions:{listing:i.slug}}},style:{"--bs-dropdown-item-padding-y":"calc((40px - 1.125rem) / 2)"},children:[(0,B.A)({listing:i}),(a||i.isDiscontinued)&&(0,m.jsxs)(I.A,{fontSize:"small",textStyle:"muted",children:[a&&(s={categoryName:a},(0,m.jsxs)(m.Fragment,{children:[" in ",s.categoryName]})),i.isDiscontinued&&(0,m.jsxs)(n.Fragment,{children:[(0,m.jsx)(A.A,{}),"Discontinued"]})]})]})},i.id);var s})]}),!D&&(0,m.jsxs)(a.h,{borderRadius:"bottom",marginTop:3,overflow:"hidden",position:"sticky-bottom",textAlign:"center",children:[(0,m.jsx)(w.A,{margin:0}),(0,m.jsx)(a.h,{backgroundColor:"body",display:"block",paddingX:3,paddingY:5,textStyle:"dark",children:(0,m.jsx)(P.A,{source:t.formatMessage({id:"public.write_review_listing_search.start_a_global_review_cta",defaultMessage:"Canât find what youâre looking for? <Link>Start a review for «{term}»</Link>"},{term:e.term}),componentsAvailable:{Link:(0,O.A)(t=>(0,m.jsx)(x.A,{to:u.generate("www.public.global_write_review_form",{term:e.term}),fontWeight:"bold",stretchedLink:!0,textDecorationHover:"underline",textStyle:"link",...t}))},initialParser:"inline"})})]})]})})()})}function WriteReviewListingSearch(e){(0,l.tz)();const[t,r]=(0,n.useState)(e.inputProps?.value||""),[h,f]=(0,n.useState)(!1),p=""===t.trim();return(0,n.useEffect)(()=>{e.withSuggestions&&p?f(!0):f(!1)},[t]),(0,m.jsxs)(n.Fragment,{children:[(0,m.jsxs)(a.h,{alignItems:"center",display:"flex",gap:3,margin:3,children:[(0,m.jsx)(WriteReviewListingSearchInput,{...(0,u.A)(e.inputProps,{onChange:r}),value:t}),e.onClose&&(0,m.jsx)(c.A,{onClick:e.onClose})]}),h&&(0,m.jsxs)(a.h,{margin:3,children:[(0,m.jsx)(d.A,{level:6,marginBottom:1,children:"Suggestions:"}),(0,m.jsx)(o.A,{flexWrap:"wrap",gap:1,children:"iPhone, Washing Machines, Clothes Dryers, Vacuum Cleaners, TVs, Prams & Strollers, Tyres, Sedans".split(", ").map((t,i)=>(0,m.jsx)(s.A,{onClick:()=>{r(t),e.inputProps?.onChange?.(t)},buttonSize:"small",buttonStyle:"light",paddingX:2,tracking:{id:"search.suggestions",gaContext:{label:t}},children:t},i))})]}),(!(0,i.A)(e.query)||!p)&&(0,m.jsx)(WriteReviewListingSearchResults,{onResponseComplete:e.onResponseComplete,query:e.query,term:t})]})}},58646(e,t,r){"use strict";r.d(t,{A:()=>Form});var i=r(85906),n=r(6718),a=r(19363),s=r(14202);function Form(e){const{autocomplete:t=!0,noValidate:r=!0,...o}=e,c=(0,i.useContext)(n.A);return(0,s.jsx)(a.h,{element:"form",autoComplete:t?"on":"off",method:"POST",noValidate:r,id:c?.control?.name,...o})}},72810(e,t,r){"use strict";r.d(t,{A:()=>Label});var i=r(35447),n=r(14202);function Label(e){const{...t}=e;return(0,n.jsx)(i.A,{element:"label",...t})}},95467(e,t,r){"use strict";r.d(t,{A:()=>Radio});var i=r(79400),n=r.n(i),a=r(19363),s=r(95453),o=r(72810),c=r(14202);function Radio(e){const{children:t,inline:r,labelProps:i,help:d,verticallyCenteredIndicator:l,wrapperProps:u,className:h,...f}=e;return(0,c.jsxs)(a.h,{alignItems:l?"center":"start",display:r?"inline-flex":"flex",...u,children:[(0,c.jsx)(a.h,{element:"input",type:"radio",cursor:e.disabled?"not-allowed":"pointer",flexShrink:0,marginTop:l?0:void 0,className:n()(h,"form-check-input"),...f,value:null===f.value?void 0:f.value}),(0,c.jsxs)(o.A,{htmlFor:e.id,cursor:e.disabled?"not-allowed":"pointer",flexGrow:1,overflowX:"hidden",paddingLeft:2,className:n()("form-check-label"),...i,children:[t,d&&(0,c.jsx)(s.A,{children:d})]})]})}},69694(e,t,r){"use strict";r.d(t,{A:()=>Textarea});var i=r(79400),n=r.n(i),a=r(19363),s=r(85906),o=r(42673),c=r(14202);function TextareaAutosize(e){const{autoFocus:t,...r}=e,i=(0,s.useRef)(null),n=(0,s.useRef)(void 0),a=(0,s.useRef)(null),d=e.value??e.defaultValue;return(0,s.useEffect)(()=>{const e=i.current;if(!e)return;const t=null==d?"":String(d),r=n.current,s=void 0===r||t.length<r.length;return n.current=t,null!=a.current&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{a.current=null,function(e,{shrink:t}){if(e.scrollHeight)t?(e.style.height="auto",e.style.height=`${e.scrollHeight+2}px`):e.scrollHeight>e.clientHeight&&(e.style.height=`${e.scrollHeight+2}px`)}(e,{shrink:s})}),()=>{null!=a.current&&(cancelAnimationFrame(a.current),a.current=null)}},[d]),(0,s.useEffect)(()=>{t&&setTimeout(()=>{i.current?.focus(),i.current?.setSelectionRange(i.current.value.length,i.current.value.length)}
1,1)},[]),(0,c.jsx)("textarea",{...(0,o.A)({ref:i},r)})}const d={small:"sm",large:"lg",xlarge:"xl"};function l(e){return`calc(0.75em + ${1.5*e}em + 2px)`}function Textarea(e){const{value:t,size:r,minRows:i=4,maxRows:s=10,style:o,className:u,...h}=e,f=(t||"").split("\n").length,m=Math.max(i,s);return(0,c.jsx)(a.h,{element:TextareaAutosize,value:t||"",maxLength:65e3,rows:i,className:n()("form-control",r&&`form-control-${d[r]}`,u),style:{height:l(Math.max(i,f>m?m:f)),maxHeight:Number.isFinite(s)?24*s:void 0,...o},...h})}},11242(e,t,r){"use strict";r.d(t,{N7:()=>w,j9:()=>b,GS:()=>N,BI:()=>F,Fu:()=>S,Sc:()=>v,K7:()=>R,wF:()=>DropdownSelect,pX:()=>_,zt:()=>O,J$:()=>T,yL:()=>U,qU:()=>C,sq:()=>D,F1:()=>I,GW:()=>$,dE:()=>L,te:()=>A,l6:()=>P,R:()=>x,dJ:()=>j,Ap:()=>E,dO:()=>k,ks:()=>TextInput,mW:()=>M,TM:()=>Textarea_Textarea,AG:()=>B});var i=r(85906),n=r(34084),a=function(){return a=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},a.apply(this,arguments)};var SVG=function(e){var t=e.animate,r=void 0===t||t,n=e.backgroundColor,s=void 0===n?"#f5f6f7":n,o=e.backgroundOpacity,c=void 0===o?1:o,d=e.baseUrl,l=void 0===d?"":d,u=e.children,h=e.foregroundColor,f=void 0===h?"#eee":h,m=e.foregroundOpacity,p=void 0===m?1:m,g=e.gradientRatio,y=void 0===g?2:g,b=e.uniqueKey,w=e.rtl,v=void 0!==w&&w,k=e.speed,T=void 0===k?1.2:k,x=e.style,S=void 0===x?{}:x,C=e.title,P=void 0===C?"Loading...":C,A=e.beforeMask,E=void 0===A?null:A,I=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]])}return r}(e,["animate","backgroundColor","backgroundOpacity","baseUrl","children","foregroundColor","foregroundOpacity","gradientRatio","uniqueKey","rtl","speed","style","title","beforeMask"]),$=b||Math.random().toString(36).substring(6),_="".concat($,"-diff"),N="".concat($,"-animated-diff"),R="".concat($,"-aria"),O=v?{transform:"scaleX(-1)"}:null,F="".concat(T,"s"),B="".concat(-1*y," 0"),D="".concat(y," 0");return(0,i.createElement)("svg",a({"aria-labelledby":R,role:"img",style:a(a({},S),O)},I),P?(0,i.createElement)("title",{id:R},P):null,E&&(0,i.isValidElement)(E)?E:null,(0,i.createElement)("rect",{role:"presentation",x:"0",y:"0",width:"100%",height:"100%",clipPath:"url(".concat(l,"#").concat(_,")"),style:{fill:"url(".concat(l,"#").concat(N,")")}}),(0,i.createElement)("defs",null,(0,i.createElement)("clipPath",{id:_},u),(0,i.createElement)("linearGradient",{id:N,gradientTransform:"translate(".concat(B,")")},(0,i.createElement)("stop",{offset:"0%",stopColor:s,stopOpacity:c}),(0,i.createElement)("stop",{offset:"50%",stopColor:f,stopOpacity:p}),(0,i.createElement)("stop",{offset:"100%",stopColor:s,stopOpacity:c}),r&&(0,i.createElement)("animateTransform",{attributeName:"gradientTransform",type:"translate",values:"".concat(B,"; 0 0; ").concat(D),dur:F,repeatCount:"indefinite"}))))},ContentLoader=function(e){return e.children?(0,i.createElement)(SVG,a({},e)):(0,i.createElement)(ReactContentLoaderFacebook,a({},e))},ReactContentLoaderFacebook=function(e){return(0,i.createElement)(ContentLoader,a({viewBox:"0 0 476 124"},e),(0,i.createElement)("rect",{x:"48",y:"8",width:"88",height:"6",rx:"3"}),(0,i.createElement)("rect",{x:"48",y:"26",width:"52",height:"6",rx:"3"}),(0,i.createElement)("rect",{x:"0",y:"56",width:"410",height:"6",rx:"3"}),(0,i.createElement)("rect",{x:"0",y:"72",width:"380",height:"6",rx:"3"}),(0,i.createElement)("rect",{x:"0",y:"88",width:"178",height:"6",rx:"3"}),(0,i.createElement)("circle",{cx:"20",cy:"20",r:"20"}))};const s=ContentLoader;var o=r(14202);function FieldLoadingPlaceholder(){return(0,o.jsxs)(s,{speed:2,width:300,height:84,viewBox:"0 0 300 84",backgroundColor:"#f3f3f3",foregroundColor:"#ecebeb",uniqueKey:(0,i.useId)(),children:[(0,o.jsx)("rect",{x:"0",y:"0",rx:"3",ry:"3",width:"200",height:"11"}),(0,o.jsx)("rect",{x:"127",y:"48",rx:"3",ry:"3",width:"53",height:"11"}
1),(0,o.jsx)("rect",{x:"187",y:"48",rx:"3",ry:"3",width:"72",height:"11"}),(0,o.jsx)("rect",{x:"18",y:"48",rx:"3",ry:"3",width:"100",height:"11"}),(0,o.jsx)("rect",{x:"18",y:"23",rx:"3",ry:"3",width:"140",height:"11"}),(0,o.jsx)("rect",{x:"166",y:"23",rx:"3",ry:"3",width:"120",height:"11"})]})}var c=r(79400),d=r.n(c),l=r(5306),u=r(36389);function TextInput(e){const{currency:t,prefix:r,hidePrefix:i,suffix:n,hideSuffix:a,className:s,id:c,...h}=e.componentProps??{};return e.wrap((0,o.jsx)(u.A,{currency:t,prefix:r,hidePrefix:i,suffix:n,hideSuffix:a,children:(0,o.jsx)(l.A,{...e.input,...h,id:c??e.meta.htmlId,form:e.meta.form,className:d()(s,{"is-invalid":e.meta.invalid}),testId:"text_input"})}))}var h=r(4484),f=r(35447);r(74954);function DropdownSelect(e){const{dropdownToggleProps:t,...r}=e.componentProps,{label:i,...n}=t,a=e.componentProps.options.find(t=>t.value===e.input.value);return e.wrap((0,o.jsx)(h.A,{content:t=>e.componentProps.options.map(r=>(0,o.jsx)(h.A.Item,{testId:String(r.value),isActive:e.input.value===r.value,onClick:()=>{e.input.onChange(void 0,r.value),t()},tracking:e.componentProps.getItemTracking?e.componentProps.getItemTracking(r):void 0,children:(0,o.jsx)(f.A,{children:r.label})},r.value)),...r,children:t=>(0,o.jsx)(h.A.Toggle,{isActive:t,testId:"toggle",...n,id:e.meta.htmlId,children:i(a?a.label:"Select")})}),{labelPointsToCustomElement:!0})}var m=r(18579),p=r(42673),g=r(69694);function Textarea_Textarea(e){const{className:t,id:r,...i}=e.componentProps??{};return e.wrap((0,o.jsx)(m.A,{testId:"textarea",children:n=>(0,o.jsx)(g.A,{...e.input,...(0,p.A)(i,n),id:r??e.meta.htmlId,form:e.meta.form,className:d()(t,{"is-invalid":e.meta.invalid})})}))}function y(e,t){return(0,n.Ay)(e,{fallback:i.createElement(FieldLoadingPlaceholder),...t})}const b=y({resolved:{},chunkName:()=>"fields-AutoComplete",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-AutoComplete").then(()=>r(25325)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>25325}),w=y({resolved:{},chunkName:()=>"fields-AsyncAutoComplete",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-AsyncAutoComplete").then(()=>r(87233)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>87233}),v=y({resolved:{},chunkName:()=>"fields-CheckboxInput",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-CheckboxInput").then(()=>r(87496)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>87496}),k=y({resolved:{},chunkName:()=>"fields-Switch",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-Switch").then(()=>r(19493)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>19493}),T=y({resolved:{},chunkName:()=>"fields-MultiCheckbox",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-MultiCheckbox").then(()=>r(15514)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>15514}),x=(y({resolved:{},chunkName:()=>"fields-DatePicker",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-DatePicker").then(()=>r(47842)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>47842}),y({resolved:{},chunkName:()=>"fields-SimpleDatePicker",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-SimpleDatePicker").then(()=>r(15937)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>15937})),S=(y({resolved:{},chunkName:()=>"fields-DateRangePicker-DateRangePicker",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-DateRangePicker-DateRangePicker").then(()=>r(72422)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>72422}),y({resolved:{},chunkName:()=>"fields-ButtonList",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-ButtonList").then(()=>r(52657)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>52657})),C=y({resolved:{},chunkName:()=>"fields-RadioList",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-RadioList").then(()=>r(46096)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>46096}),P=y({resolved:{},chunkName:()=>"fields-Select",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-Select").then(()=>r(47357)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>47357}),A=y({resolved:{},chunkName:()=>"fields-RichTextarea",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-RichTextarea").then(()=>r(60472)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>60472}),E=(y({resolved:{},chunkName:()=>"fields-CodeEditorTextarea",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-CodeEditorTextarea").then(()=>r(94609)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>94609}),y({resolved:{},chunkName:()=>"fields-MaskedInput",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-MaskedInput").then(()=>r(87316)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>87316}),y({resolved:{},chunkName:()=>"fields-Slider-Slider",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-Slider-Slider").then(()=>r(38034)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>38034})),I=y({resolved:{},chunkName:()=>"fields-Slider-RangeSlider",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-Slider-RangeSlider").then(()=>r(30953)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>30953}),$=y({resolved:{},chunkName:()=>"fields-Rating",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-Rating").then(()=>r(33032)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>33032}),_=y({resolved:{},chunkName:()=>"fields-EmailSuggestion",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-EmailSuggestion").then(()=>r(65112)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>65112}),N=y({resolved:{},chunkName:()=>"fields-AvatarInput",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-AvatarInput").then(()=>r(61524)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>61524}),R=y({resolved:{},chunkName:()=>"fields-DateTimePicker",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-DateTimePicker").then(()=>r(35288)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>35288}),O=y({resolved:{},chunkName:()=>"fields-GoogleMapsAutocomplete-GoogleMapsAutocomplete",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-GoogleMapsAutocomplete-GoogleMapsAutocomplete").then(()=>r(43460)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>43460}),F=y({resolved:{},chunkName:()=>"fields-BooleanInput",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-BooleanInput").then(()=>r(42577)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>42577}),B=y({resolved:{},chunkName:()=>"fields-TimePicker-TimePicker",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-TimePicker-TimePicker").then(()=>r(60828)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>60828}),D=y({resolved:{},chunkName:()=>"fields-RangeInput",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-RangeInput").then(()=>r(56584)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>56584}),M=y({resolved:{},chunkName:()=>"fields-TextWithOptions",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-TextWithOptions").then(()=>r(24648)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>24648}),j=y({resolved:{},chunkName:()=>"fields-SingleDocumentUploadInput",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-SingleDocumentUploadInput").then(()=>r(27848)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>27848}),L=(y({resolved:{},chunkName:()=>"fields-SingleImageUploaderInput",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-SingleImageUploaderInput").then(()=>r(49962)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>49962}),y({resolved:{},chunkName:()=>"fields-TriStateInput",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-TriStateInput").then(()=>r(73647)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>73647}),y({resolved:{},chunkName:()=>"fields-DatePivotPicker",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-DatePivotPicker").then(()=>r(45979)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>45979}),y({resolved:{},chunkName:()=>"fields-ColorPicker-ColorPicker",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-ColorPicker-ColorPicker").then(()=>r(21302)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>21302}),y({resolved:{},chunkName:()=>"fields-ResourceSelect",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-ResourceSelect").then(()=>r(83565)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>83565})),U=(y({resolved:{},chunkName:()=>"fields-MarkdownEditor",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-MarkdownEditor").then(()=>r(63668)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>63668}),y({resolved:{},chunkName:()=>"fields-PhoneNumberInput",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("fields-PhoneNumberInput").then(()=>r(87504)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>87504}))},60887(e,t,r){"use strict";function i(e){return"true"===e||"false"!==e&&e}r.d(t,{A:()=>i})},64856(e,t,r){"use strict";function i(e){if("number"==typeof e)return e;if(""===e||null==e)return;if("-"===e)return e;if("string"!=typeof e)return e;const t=Number(e);return e.length!==String(t).length||Number.isNaN(t)?e:t}r.d(t,{A:()=>i})},61322(e,t,r){"use strict";r.d(t,{A:()=>n});var i=r(34496);function n(e){return Array.isArray(e)?(0,i.di)(e).asc():e}},57946(e,t,r){"use strict";r.d(t,{A:()=>DropzoneSelectFileMessage});var i=r(19363),n=r(62227),a=r(35447),s=(r(74954),r(14202));function DropzoneSelectFileMessage({invisible:e}){return(0,s.jsxs)(i.h,{alignItems:"center",display:"flex",gap:2,invisible:e,justifyContent:"center",children:[(0,s.jsx)(n.A,{name:"cloud-arrow-up",flexShrink:0}),(0,s.jsx)(a.A,{display:{xs:"none",md:"block"},children:"Click to select file(s) or drag & drop here"}),(0,s.jsx)(a.A,{display:{xs:"block",md:"none"},children:"Tap to select file(s)"})]})}},24979(e,t,r){"use strict";r.d(t,{A:()=>DuplicatedFileError});var i=r(17801);class DuplicatedFileError extends i.A{file;constructor(e){super("DuplicatedFileError"),this.file=e}}},96347(e,t,r){"use strict";r.d(t,{A:()=>EmptyFileError});var i=r(17801);class EmptyFileError extends i.A{file;constructor(e){super("EmptyFileError"),this.file=e}}},7471(e,t,r){"use strict";r.d(t,{A:()=>ErrorMessage});var i=r(85906),n=r(4155),a=r.n(n),s=r(53712),o=r.n(s),c=r(84945),d=r(12732),l=r(17801),u=r(30437),h=r(89348),f=r(74954),m=r(9680),p=r(24979),g=r(96347),y=r(82726),b=r(36349),w=r(14202);function ErrorMessage(e){const{locale:t}=(0,i.useContext)(m.A);if("string"==typeof e.error)return e.error;if(e.error instanceof l.A&&e.error.reason===l.r)return(0,w.jsx)(f.sA,{id:"uploader.validation.error.tooManyFiles",d
1efaultMessage:"Too many files. {mode, select,\n multiple {Maximum is {itemsLimit}}\n single {Please select 1 file only}\n}.",values:{itemsLimit:e.validation.itemsLimit,mode:e.mode}});if(e.error instanceof l.A){if(e.error instanceof y.A)return r={fileName:e.error.file.name,maxFileSize:o()(e.error.maxFileSize,{locale:t,base:2})},(0,w.jsxs)(w.Fragment,{children:["File ",r.fileName," is too big. Maximum allowed size is ",r.maxFileSize,"."]});if(e.error instanceof b.A)return(e=>(0,w.jsxs)(w.Fragment,{children:["File ",e.fileName," is of invalid type ",e.fileType,". ",e.friendlyAcceptedFilesMessage]}))({fileName:e.error.file.name,fileType:e.error.file.type,friendlyAcceptedFilesMessage:(()=>{if(e.validation.friendlyAcceptedFilesMessage)return(0,w.jsx)(f.sA,{...e.validation.friendlyAcceptedFilesMessage})})()});if(e.error instanceof p.A)return(e=>(0,w.jsxs)(w.Fragment,{children:["File ",e.fileName," is already selected. Duplicates are not allowed."]}))({fileName:e.error.file.name});if(e.error instanceof g.A)return(e=>(0,w.jsxs)(w.Fragment,{children:["File ",e.fileName," is empty. Empty files are not allowed."]}))({fileName:e.error.file.name})}var r;return(0,u.t)(e.error)||(0,h.c)(e.error)&&e.error.statusCode===c.v.REQUEST_TIMEOUT?"It seems like you are on a slow connection. You may cancel this operation and upload again later, or try with a smaller file.":(0,h.c)(e.error)&&e.error.statusCode===c.v.BAD_REQUEST?(0,w.jsx)(f.sA,{id:"uploader.validation.error.badRequest",defaultMessage:"{hasMessage, select,\n true {{message}}\n false {It seems like you're trying to upload a file that is not allowed.}\n}",values:{hasMessage:"string"==typeof e.error.response?.data?.message,message:e.error.response?.data?.message,supportEmail:a().contactInfo.supportEmail}}):(0,w.jsx)(d.A,{error:e.error,fallbackMessage:(e=>(0,w.jsxs)(w.Fragment,{children:["An unexpected problem occurred while trying to upload your file. Please, try again later or contact us at ",e.supportEmail," for further investigation."]}))({supportEmail:a().contactInfo.supportEmail})})}},82726(e,t,r){"use strict";r.d(t,{A:()=>FileSizeExceededError});var i=r(53712),n=r.n(i),a=r(17801);class FileSizeExceededError extends a.A{maxFileSize;file;constructor(e,t){super(`FileSizeExceededError: max file size is ${n()(t,{base:2})}, got ${n()(e.size,{base:2})}`),this.maxFileSize=t,this.file=e}toJSON(){return{name:this.name,message:this.message,maxFileSize:this.maxFileSize,file:{name:this.file.name,size:this.file.size,type:this.file.type}}}}},72194(e,t,r){"use strict";r.d(t,{A:()=>GenericUploaderDropzone_GenericUploaderDropzone});var i=r(85906),n=r(78801),a=r.n(n),s=r(64659),o=r(36171),c=r(19363),d=r(23481),l=r(57259),u=r(83115),h=r(35447),f=(r(74954),r(57946)),m=r(7471);var p=r(53975),g=r(28699),y=r(14202);const b=a().bind({dropzoneContainer:"yhEodg",isFocused:"PT3E4f",isDragActive:"ex8ynU",isUploading:"C6scGh",hasError:"Hs4DOr",isDragReject:"PcVesf"});function GenericUploaderDropzone_GenericUploaderDropzone(e){const t=e.uploaderProps.objects.find(e=>Boolean(e.error)),r=t?.error||e.uploaderProps.error,n=e.uploaderProps.objects.some(e=>e.isRetrying),a=e.uploaderProps.objects.some(e=>e.isUploading),w=(0,s.VB)({accept:(0,p.A)(e.uploaderProps.validation.acceptFiles),onDrop:(t,r)=>{e.uploaderProps.selectFiles(t.concat(r.map(e=>e.file)))},maxSize:(0,g.A)(e.uploaderProps.validation.maxFileSize),multiple:e.uploaderProps.validation.itemsLimit>1}),v=e.uploaderProps.objects.filter(e=>e.isUploading),k=v.reduce((e,t)=>e+t.progress,0);return(0,y.jsxs)(d.A,{...w.getRootProps(),testId:e.testId,className:b("dropzoneContainer",{hasError:e.hasError,isDragActive:w.isDragActive,isDragReject:w.isDragReject,isFocused:w.isFocused,isUploading:a}),children:[(0,y.jsx)("input",{...w.getInputProps({id:e.id})}),(0,y.jsxs)(d.A.Block,{display:"flex",flexDirection:"column",gap:2,padding:4,position:"relative",children:[e.children?e.children:(0,y.jsxs)(i.Fragment,{children:[a&&(0,y.jsxs)(c.h,{alignItems:"center",display:"flex",justifyContent:"center",position:"absolute-center",children:[(0,y.jsx)(l.A,{size:"medium",flexShrink:0,marginRight:3,textStyle:"primary"}),(0,y.jsxs)(h.A,{textStyle:"muted",children:[n?"Upload failed. Retryingâ¦":(T={progress:Math.floor(k/v.length)},(0,y.jsxs)(y.Fragment,{children:["Uploading... (",T.progress,"%)"]})),(0,y.jsx)(u.A,{})]}),(0,y.jsx)(h.A,{onClick:t=>{t.stopPropagation(),t.preventDefault(),e.uploaderProps.cancelAll()},textDecorationHover:"underline",textStyle:"danger",children:"Cancel"})]}),(0,y.jsx)(f.A,{invisible:a})]}),r&&!n&&(0,y.jsx)(o.A,{alertStyle:"danger",marginTop:4,children:e.renderError?e.renderError(r):(0,y.jsx)(m.A,{error:r,mode:e.uploaderProps.mode,validation:e.uploaderProps.validation})})]})]});var T}},36349(e,t,r){"use strict";r.d(t,{A:()=>InvalidFileTypeError});var i=r(17801);class InvalidFileTypeError extends i.A{mimeTypeExpression;file;constructor(e,t){super("InvalidFileTypeError"),this.mimeTypeExpression=t,this.file=e}toJSON(){return{name:this.name,message:this.message,mimeTypeExpression:this.mimeTypeExpression,file:{name:this.file.name,size:this.file.size,type:this.file.type}}}}},87094(e,t,r){"use strict";r.d(t,{A:()=>Uploader});var i=r.cw(function(e,t){t.A=function(e,t){if(e&&t){var r=Array.isArray(t)?t:t.split(",");if(0===r.length)return!0;var i=e.name||"",n=(e.type||"").toLowerCase(),a=n.replace(/\/.*$/,"");return r.some(function(e){var t=e.trim().toLowerCase();return"."===t.charAt(0)?i.toLowerCase().endsWith(t):t.endsWith("/*")?a===t.replace(/\/.*$/,""):n===t})}return!0}}),n=r.cw(function(e,t){const r=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);e.exports=e=>!r.has(e&&e.code)}),a=r(85906),s=r(63805),o=r(55279),c=r(67572),d=r(86490),l=r(47806),u=r(63197),h=r(24082),f=r(94865),m=r(74222),p=r(31273);n();const g="axios-retry";function y(e){return!e.response&&(!!e.code&&(!["ERR_CANCELED","ECONNABORTED"].includes(e.code)&&n()(e)))}const b=["get","head","options"],w=b.concat(["put","delete"]);function v(e){return"ECONNABORTED"!==e.code&&(!e.response||429===e.response.status||e.response.status>=500&&e.response.status<=599)}function k(e){return!!e.config?.method&&(v(e)&&-1!==w.indexOf(e.config.method))}function T(e){return y(e)||k(e)}function x(e=void 0){const t=e?.response?.headers["retry-after"];if(!t)return 0;let r=1e3*(Number(t)||0);return 0===r&&(r=(new Date(t).valueOf()||0)-Date.now()),Math.max(0,r)}const S={retries:3,retryCondition:T,retryDelay:function(e=0,t=void 0){return Math.max(0,x(t))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function C(e,t,r=!1){const i=function(e,t){return{...S,...t,...e[g]}}(e,t||{});return i.retryCount=i.retryCount||0,i.lastRequestTime&&!r||(i.lastRequestTime=
1Date.now()),e[g]=i,i}const P=(e,t)=>{const r=e.interceptors.request.use(e=>(C(e,t,!0),e[g]?.validateResponse&&(e.validateStatus=()=>!1),e)),i=e.interceptors.response.use(null,async r=>{const{config:i}=r;if(!i)return Promise.reject(r);const n=C(i,t);return r.response&&n.validateResponse?.(r.response)?r.response:await async function(e,t){const{retries:r,retryCondition:i}=e,n=(e.retryCount||0)<r&&i(t);if("object"==typeof n)try{return!1!==await n}catch(e){return!1}return n}(n,r)?async function(e,t,r,i){t.retryCount+=1;const{retryDelay:n,shouldResetTimeout:a,onRetry:s}=t,o=n(t.retryCount,r);if(function(e,t){e.defaults.agent===t.agent&&delete t.agent,e.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,e.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}(e,i),!a&&i.timeout&&t.lastRequestTime){const e=Date.now()-t.lastRequestTime,n=i.timeout-e-o;if(n<=0)return Promise.reject(r);i.timeout=n}return i.transformRequest=[e=>e],await s(t.retryCount,r,i),i.signal?.aborted?Promise.resolve(e(i)):new Promise(t=>{const r=()=>{clearTimeout(n),t(e(i))},n=setTimeout(()=>{t(e(i)),i.signal?.removeEventListener&&i.signal.removeEventListener("abort",r)},o);i.signal?.addEventListener&&i.signal.addEventListener("abort",r,{once:!0})})}(e,n,r,i):(await async function(e,t){e.retryCount>=e.retries&&await e.onMaxRetryTimesExceeded(t,e.retryCount)}(n,r),Promise.reject(r))});return{requestInterceptorId:r,responseInterceptorId:i}};P.isNetworkError=y,P.isSafeRequestError=function(e){return!!e.config?.method&&(v(e)&&-1!==b.indexOf(e.config.method))},P.isIdempotentRequestError=k,P.isNetworkOrIdempotentRequestError=T,P.exponentialDelay=function(e=0,t=void 0,r=100){const i=2**e*r,n=Math.max(i,x(t));return n+.2*n*Math.random()},P.linearDelay=function(e=100){return(t=0,r=void 0)=>{const i=t*e;return Math.max(i,x(r))}},P.isRetryableError=v;const A=P;var E=r(46698),I=r(89348),$=r(2298),_=r(69850),N=r(32811),R=r(35314);class O{settings;urlGenerator;requestActor;resource;axiosInstance;eventEmitter;
1constructor(e,t,r,i){this.settings=e,this.eventEmitter=new E.A,this.axiosInstance=p.A.create(),this.urlGenerator=t,this.requestActor=r,this.resource=i,A(this.axiosInstance,{retries:2,retryDelay:A.linearDelay(1e3),retryCondition:e=>409===e.response?.status||A.isNetworkOrIdempotentRequestError(e)}),this.axiosInstance.interceptors.request.use(e=>{if(!e.headers)return e;const t=e["axios-retry"]?.retryCount;return t&&this.eventEmitter.emit("retry",e.internalObjectId,{retryCount:t}),e})}async generateUploadInfo(e,t,r){if(this.settings.withCloudflareStream&&t.file.type.startsWith("video/")){if(!t.uploadUrl)throw new Error('Uploader object (video) does not have a "uploadUrl" defined');if(!t.remoteId)throw new Error('Uploader object (video) does not have a "remoteId" defined');const e=new FormData;return e.append("file",t.file),{remoteId:t.remoteId,axiosRequestParams:{method:"POST",url:t.uploadUrl,data:e,internalObjectId:t.internalId}}}if(!t.file.type)throw new Error('Uploader object does not have a "mimeType" defined');const i={fileName:t.file.name,contentType:t.file.type,collection:e.collection,referrer:document.location.href,resource:this.resource},n=await function(e,t,r,i,n,a){return t({method:"post",url:e.generate("api.integrations.s3.signature",{actorContext:a.context},o.i.ABSOLUTE_URL),timeout:2e4,data:i,cancelToken:n,internalObjectId:r,withCredentials:!0})}(this.urlGenerator,this.axiosInstance,t.internalId,i,r,this.requestActor);return{remoteId:n.data.remoteId,axiosRequestParams:{method:"PUT",url:n.data.presignedUploadUrl,data:t.file,headers:{"Content-Type":t.file.type},internalObjectId:t.internalId}}}async generateVideoUploadInfo(){const e=await this.axiosInstance.post(this.urlGenerator.generate("api.integrations.cloudflare_stream.one_time_upload_url",{},o.i.ABSOLUTE_URL),{resource:this.resource,meta:{stickyReferrer:(0,N.T_)(),entryPoint:(0,N.bP)()},scheduledDeletion:void 0});return{remoteId:e.data.uid,uploadUrl:e.data.uploadUrl}}async uploadFile(e,t){let r=m.A;const i=new p.A.CancelToken(e=>{r=e});return{requestPromise:this.generateUploadInfo(t,e,i).then(async({remoteId:r,axiosRequestParams:n})=>{const a=t.getObjectPreviewUrl?.(e,r);return await this.axiosInstance.request({...n,onUploadProgress:t=>{if(!t.total)return;const r=t.loaded/t.total*100;this.eventEmitter.emit("progress",e.internalId,a?r/2:r)},cancelToken:i}),a&&await this.axiosInstance.get(a,{onDownloadProgress:t=>{if(!t.total)return;const r=t.loaded/t.total*100;this.eventEmitter.emit("progress",e.internalId,50+r/2)}}),{remoteId:r??e.internalId}},e=>{if(p.A.isAxiosError(e)&&e.response&&e.config?.url)throw(0,_.A)(e.response)&&$.A.emit("commandDispatchLimitExceeded"),new I.A({headers:e.response.headers,status:e.response.status,statusText:e.response.statusText,data:e.response.data,url:e.config.url,redirected:!1});throw e}),abort:r}}}var F=(e=>(e.SET_OBJECTS="SET_OBJECTS",e.ADD_OBJECT="ADD_OBJECT",e.ADD_OBJECTS="ADD_OBJECTS",e.REMOVE_OBJECT_BY_ID="REMOVE_OBJECT_BY_ID",e.REMOVE_ALL="REMOVE_ALL",e.START_UPLOAD="START_UPLOAD",e.FINISH_OBJECT_UPLOAD="FINISH_OBJECT_UPLOAD",e.REMOVE_ALL_PENDING_ONES="REMOVE_ALL_PENDING_ONES",e.SWAP_OBJECTS_BY_INDEX="SWAP_OBJECTS_BY_INDEX",e.MOVE_OBJECT_BY_INDEX="MOVE_OBJECT_BY_INDEX",e.SET_OBJECT_ATTRIBUTES="SET_OBJECT_ATTRIBUTES",e.SET_ERROR="SET_ERROR",e.REVERT_SELECTION="REVERT_SELECTION",e))(F||{});function B(e,t,r){const i=e.length;if(t===r||t<0||t>i-1||r<0||r>i-1)return e;const n=e[t],a=e[r];return e.map((e,i)=>i===t?a:i===r?n:e)}function D(e,t,r){const i=e.length,n=e[t];if(t===r||t<0||t>i-1||r<0||r>i-1)return e;const a=e.filter((e,r)=>r!==t);return a.splice(r,0,n),a}function M(e){return(t,r)=>{const i=((e,t)=>{if(t.type===F.SET_ERROR)return{...e,error:t.payload.error};if(t.type===F.ADD_OBJECT){const r=t;return{...e,error:void 0,objects:"prepend"===r.payload.order?[r.payload.object,...e.objects]:[...e.objects,r.payload.object],previousObjects:e.objects}}if(t.type===F.ADD_OBJECTS){const r=t;return{...e,error:void 0,objects:"prepend"===r.payload.order?[...r.payload.objects,...e.objects]:[...e.objects,...r.payload.objects],previousObjects:e.objects}}return t.type===F.REMOVE_ALL?{...e,error:void 0,objects:[]}:t.type===F.REMOVE_OBJECT_BY_ID?{...e,error:void 0,objects:e.objects.filter(e=>e.internalId!==t.payload.internalId)}:t.type===F.SET_OBJECTS?{...e,error:void 0,objects:t.payload.objects,previousObjects:e.objects}:t.type===F.SET_OBJECT_ATTRIBUTES?{...e,objects:e.objects.map(e=>e.internalId===t.payload.internalId?{...e,...t.payload.attributes}:e)}:t.type===F.SWAP_OBJECTS_BY_INDEX?{...e,objects:B(e.objects,t.payload.indexA,t.payload.indexB)}:t.type===F.MOVE_OBJECT_BY_INDEX?{...e,objects:D(e.objects,t.payload.fromIndex,t.payload.toIndex)}:t.type===F.REMOVE_ALL_PENDING_ONES?{...e,objects:e.objects.filter(e=>!e.isUploading)}:t.type===F.START_UPLOAD?{...e,objects:e.objects.map(e=>e.isUploading||e.isUploaded?e:{...e,isUploading:!0,progress:0})}:t.type===F.FINISH_OBJECT_UPLOAD?{...e,objects:e.objects.map(e=>e.internalId!==t.payload.internalId?e:{...e,error:void 0,isRetrying:!1,isUploaded:!0,isUploading:!1,progress:100,remoteId:t.payload.remoteId,metadata:t.payload.metadata})}:t.type===F.REVERT_SELECTION?{...e,objects:e.previousObjects,previousObjects:[]}:e})(t,r);return e.current=i,i}}i();var j=r(24979),L=r(96347),U=r(82726),z=r(36349);r(48821);const W={128:"â¬",130:"â",131:"Æ",132:"â",133:"â¦",134:"â ",135:"â¡",136:"Ë",137:"â°",138:"Å ",139:"â¹",140:"Å",142:"Ž",145:"â",146:"â",147:"â",148:"â",149:"â¢",150:"â",151:"â",152:"Ë",153:"â¢",154:"Å¡",155:"âº",156:"Å",158:"ž",159:"Ÿ"},V={};for(const[e,t]of Object.entries(W))V[t]=Number.parseInt(e,10);let q;
1const H=32768,G=65533;function K(e,t="utf-8"){switch(t.toLowerCase()){case"utf-8":case"utf8":{const t=function(){if(void 0!==globalThis.TextDecoder)return null!=q?q:q=new globalThis.TextDecoder("utf-8")}();return t?t.decode(e):function(e){const t=[],r=[];let i=0;e.length>=3&&239===e[0]&&187===e[1]&&191===e[2]&&(i=3);for(;i<e.length;){const n=e[i];if(n<=127){X(t,r,n),i++;continue}if(n<194||n>244){X(t,r,G),i++;continue}if(n<=223){if(i+1>=e.length){X(t,r,G),i++;continue}const a=e[i+1];if(128!=(192&a)){X(t,r,G),i++;continue}X(t,r,(31&n)<<6|63&a),i+=2;continue}if(n<=239){if(i+2>=e.length){X(t,r,G),i++;continue}const a=e[i+1],s=e[i+2];if(!!(128!=(192&a)||128!=(192&s)||224===n&&a<160||237===n&&a>=160)){X(t,r,G),i++;continue}X(t,r,(15&n)<<12|(63&a)<<6|63&s),i+=3;continue}if(i+3>=e.length){X(t,r,G),i++;continue}const a=e[i+1],s=e[i+2],o=e[i+3];if(!!(128!=(192&a)||128!=(192&s)||128!=(192&o)||240===n&&a<144||244===n&&a>143)){X(t,r,G),i++;continue}Q(t,r,(7&n)<<18|(63&a)<<12|(63&s)<<6|63&o),i+=4}return Y(t,r),t.join("")}(e)}case"utf-16le":return function(e){const t=[],r=[],i=e.length;let n=0;for(;n+1<i;){const a=e[n]|e[n+1]<<8;if(n+=2,a>=55296&&a<=56319)if(n+1<i){const i=e[n]|e[n+1]<<8;i>=56320&&i<=57343?(X(t,r,a),X(t,r,i),n+=2):X(t,r,G)}else X(t,r,G);else X(t,r,a>=56320&&a<=57343?G:a)}n<i&&X(t,r,G);return Y(t,r),t.join("")}(e);case"us-ascii":case"ascii":return function(e){const t=[];for(let r=0;r<e.length;r+=H){const i=Math.min(e.length,r+H),n=new Array(i-r);for(let t=r,a=0;t<i;t++,a++)n[a]=127&e[t];t.push(String.fromCharCode.apply(null,n))}return t.join("")}(e);case"latin1":case"iso-8859-1":return function(e){const t=[];for(let r=0;r<e.length;r+=H){const i=Math.min(e.length,r+H),n=new Array(i-r);for(let t=r,a=0;t<i;t++,a++)n[a]=e[t];t.push(String.fromCharCode.apply(null,n))}return t.join("")}(e);case"windows-1252":return function(e){const t=[];let r="";for(let i=0;i<e.length;i++){const n=e[i],a=n>=128&&n<=159?W[n]:void 0;r+=null!=a?a:String.fromCharCode(n),r.length>=H&&(t.push(r),r="")}r&&t.push(r);return t.join("")}(e);default:throw new RangeError(`Encoding '${t}' not supported`)}}function Y(e,t){0!==t.length&&(e.push(String.fromCharCode.apply(null,t)),t.length=0)}function X(e,t,r){t.push(r),t.length>=H&&Y(e,t)}function Q(e,t,r){r<=65535?X(e,t,r):(X(e,t,55296+((r-=65536)>>10)),X(e,t,56320+(1023&r)))}function J(e){return new DataView(e.buffer,e.byteOffset)}const Z={len:1,get:(e,t)=>J(e).getUint8(t),put:(e,t,r)=>(J(e).setUint8(t,r),t+1)},ee={len:2,get:(e,t)=>J(e).getUint16(t,!0),put:(e,t,r)=>(J(e).setUint16(t,r,!0),t+2)},te={len:2,get:(e,t)=>J(e).getUint16(t),put:(e,t,r)=>(J(e).setUint16(t,r),t+2)},re={len:4,get:(e,t)=>J(e).getUint32(t,!0),put:(e,t,r)=>(J(e).setUint32(t,r,!0),t+4)},ie={len:4,get:(e,t)=>J(e).getUint32(t),put:(e,t,r)=>(J(e).setUint32(t,r),t+4)},ne={len:4,get:(e,t)=>J(e).getInt32(t),put:(e,t,r)=>(J(e).setInt32(t,r),t+4)},ae={len:8,get:(e,t)=>J(e).getBigUint64(t,!0),put:(e,t,r)=>(J(e).setBigUint64(t,r,!0),t+8)};class se{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){return K(e.subarray(t,t+this.len),this.encoding)}}class EndOfStreamError extends Error{constructor(){super("End-Of-Stream"),this.name="EndOfStreamError"}}class AbortError extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}}class oe{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){const r=await this.read(e,t);return this.peekQueue.push(e.subarray(0,r)),r}async read(e,t=!1){if(0===e.length)return 0;let r=this.readFromPeekBuffer(e);if(this.endOfStream||(r+=await this.readRemainderFromStream(e.subarray(r),t)),0===r&&!t)throw new EndOfStreamError;return r}readFromPeekBuffer(e){let t=e.length,r=0;for(;this.peekQueue.length>0&&t>0;){const i=this.peekQueue.pop();if(!i)throw new Error("peekData should be defined");const n=Math.min(i.length,t);e.set(i.subarray(0,n),r),r+=n,t-=n,n<i.length&&this.peekQueue.push(i.subarray(n))}return r}async readRemainderFromStream(e,t){let r=0;for(;r<e.length&&!this.endOfStream;){if(this.interrupted)throw new AbortError;const i=await this.readFromStream(e.subarray(r),t);if(0===i)break;r+=i}if(!t&&r<e.length)throw new EndOfStreamError;return r}}class ce extends oe{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}class de extends ce{async readFromStream(e,t){if(0===e.length)return 0;const r=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return r.done&&(this.endOfStream=r.done),r.value?(e.set(r.value),r.value.length):0}}class le extends oe{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){const r=Math.min(t.length,e.length);return e.set(t.subarray(0,r)),r<t.length?this.buffer=t.subarray(r):this.buffer=null,r}async readFromStream(e,t){if(0===e.length)return 0;let r=0;for(this.buffer&&(r+=this.writeChunk(e,this.buffer));r<e.length&&!this.endOfStream;){const t=await this.reader.read();if(t.done){this.endOfStream=!0;break}t.value&&(r+=this.writeChunk(e.subarray(r),t.value))}if(!t&&0===r&&this.endOfStream)throw new EndOfStreamError;return r}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}class ue{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}
1async readToken(e,t=this.position){const r=new Uint8Array(e.len);if(await this.readBuffer(r,{position:t})<e.len)throw new EndOfStreamError;return e.get(r,0)}async peekToken(e,t=this.position){const r=new Uint8Array(e.len);if(await this.peekBuffer(r,{position:t})<e.len)throw new EndOfStreamError;return e.get(r,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new EndOfStreamError;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new EndOfStreamError;return e.get(this.numBuffer,0)}async ignore(e){if(e<0)throw new RangeError("ignore length must be ⥠0 bytes");if(void 0!==this.fileInfo.size){const t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await(this.onClose?.())}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&void 0!==t.position&&t.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}}class he extends ue{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){const r=this.normalizeOptions(e,t),i=r.position-this.position;if(i>0)return await this.ignore(i),this.readBuffer(e,t);if(i<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(0===r.length)return 0;const n=await this.streamReader.read(e.subarray(0,r.length),r.mayBeLess);if(this.position+=n,(!t||!t.mayBeLess)&&n<r.length)throw new EndOfStreamError;return n}async peekBuffer(e,t){const r=this.normalizeOptions(e,t);let i=0;if(r.position){const t=r.position-this.position;if(t>0){const n=new Uint8Array(r.length+t);return i=await this.peekBuffer(n,{mayBeLess:r.mayBeLess}),e.set(n.subarray(t)),i-t}if(t<0)throw new Error("Cannot peek from a negative offset in a stream")}if(r.length>0){try{i=await this.streamReader.peek(e.subarray(0,r.length),r.mayBeLess)}catch(e){if(t?.mayBeLess&&e instanceof EndOfStreamError)return 0;throw e}if(!r.mayBeLess&&i<r.length)throw new EndOfStreamError}return i}async ignore(e){if(e<0)throw new RangeError("ignore length must be ⥠0 bytes");const t=Math.min(256e3,e),r=new Uint8Array(t);let i=0;for(;i<e;){const n=e-i,a=await this.readBuffer(r,{length:Math.min(t,n)});if(a<0)return a;i+=a}return i}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}class fe extends ue{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);const r=await this.peekBuffer(e,t);return this.position+=r,r}async peekBuffer(e,t){const r=this.normalizeOptions(e,t),i=Math.min(this.uint8Array.length-r.position,r.length);if(!r.mayBeLess&&i<r.length)throw new EndOfStreamError;return e.set(this.uint8Array.subarray(r.position,r.position+i)),i}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}class me extends ue{constructor(e,t){super(t),this.blob=e,this.fileInfo={...t?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,t){t?.position&&(this.position=t.position);const r=await this.peekBuffer(e,t);return this.position+=r,r}async peekBuffer(e,t){const r=this.normalizeOptions(e,t),i=Math.min(this.blob.size-r.position,r.length);if(!r.mayBeLess&&i<r.length)throw new EndOfStreamError;const n=await this.blob.slice(r.position,r.position+i).arrayBuffer();return e.set(new Uint8Array(n)),i}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}function pe(e,t){const r=function(e){try{const t=e.getReader({mode:"byob"});return t instanceof ReadableStreamDefaultReader?new le(t):new de(t)}catch(t){if(t instanceof TypeError)return new le(e.getReader());throw t}}(e),i=t??{},n=i.onClose;return i.onClose=async()=>{if(await r.close(),n)return n()},new he(r,i)}var ge=r(4515);const ye=67324752,be=134695760,we=33639248,ve=101010256,ke={get:e=>({signature:re.get(e,0),compressedSize:re.get(e,8),uncompressedSize:re.get(e,12)}),len:16},Te={get(e){const t=ee.get(e,6);return{signature:re.get(e,0),minVersion:ee.get(e,4),dataDescriptor:!!(8&t),compressedMethod:ee.get(e,8),compressedSize:re.get(e,18),uncompressedSize:re.get(e,22),filenameLength:ee.get(e,26),extraFieldLength:ee.get(e,28),filename:null}},len:30},xe={get:e=>({signature:re.get(e,0),nrOfThisDisk:ee.get(e,4),nrOfThisDiskWithTheStart:ee.get(e,6),nrOfEntriesOnThisDisk:ee.get(e,8),nrOfEntriesOfSize:ee.get(e,10),sizeOfCd:re.get(e,12),offsetOfStartOfCd:re.get(e,16),zipFileCommentLength:ee.get(e,20)}),len:22},Se={get(e){const t=ee.get(e,8);return{signature:re.get(e,0),minVersion:ee.get(e,6),dataDescriptor:!!(8&t),compressedMethod:ee.get(e,10),compressedSize:re.get(e,20),uncompressedSize:re.get(e,24),filenameLength:ee.get(e,28),extraFieldLength:ee.get(e,30),fileCommentLength:ee.get(e,32),relativeOffsetOfLocalHeader:re.get(e,42),filename:null}},len:46};function Ce(e){const t=new Uint8Array(re.len);return re.put(t,0,e),t}const Pe=ge("tokenizer:inflate"),Ae=262144,Ee=Ce(be),Ie=Ce(ve);class $e{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(Ae)}async isZip(){return await this.peekSignature()===ye}peekSignature(){return this.tokenizer.peekToken(re)}async findEndOfCentralDirectoryLocator(){const e=this.tokenizer,t=M
1ath.min(16384,e.fileInfo.size),r=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(r,{position:e.fileInfo.size-t});for(let i=r.length-4;i>=0;i--)if(r[i]===Ie[0]&&r[i+1]===Ie[1]&&r[i+2]===Ie[2]&&r[i+3]===Ie[3])return e.fileInfo.size-t+i;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess())return void Pe("Cannot reading central-directory without random-read support");Pe("Reading central-directory...");const e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){Pe("Central-directory 32-bit signature found");const r=await this.tokenizer.readToken(xe,t),i=[];this.tokenizer.setPosition(r.offsetOfStartOfCd);for(let e=0;e<r.nrOfEntriesOfSize;++e){const t=await this.tokenizer.readToken(Se);if(t.signature!==we)throw new Error("Expected Central-File-Header signature");t.filename=await this.tokenizer.readToken(new se(t.filenameLength,"utf-8")),await this.tokenizer.ignore(t.extraFieldLength),await this.tokenizer.ignore(t.fileCommentLength),i.push(t),Pe(`Add central-directory file-entry: n=${e+1}/${i.length}: filename=${i[e].filename}`)}return this.tokenizer.setPosition(e),i}this.tokenizer.setPosition(e)}async unzip(e){const t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,e);let r=!1;do{const t=await this.readLocalFileHeader();if(!t)break;const i=e(t);let n;if(r=!!i.stop,await this.tokenizer.ignore(t.extraFieldLength),t.dataDescriptor&&0===t.compressedSize){const e=[];let r=Ae;Pe("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let n=-1;for(;n<0&&r===Ae;){r=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),n=_e(this.syncBuffer.subarray(0,r),Ee);const t=n>=0?n:r;if(i.handler){const r=new Uint8Array(t);await this.tokenizer.readBuffer(r),e.push(r)}else await this.tokenizer.ignore(t)}Pe(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(t,Ne(e),i.handler)}else i.handler?(Pe(`Reading compressed-file-data: ${t.compressedSize} bytes`),n=new Uint8Array(t.compressedSize),await this.tokenizer.readBuffer(n),await this.inflate(t,n,i.handler)):(Pe(`Ignoring compressed-file-data: ${t.compressedSize} bytes`),await this.tokenizer.ignore(t.compressedSize));if(Pe(`Reading data-descriptor at pos=${this.tokenizer.position}`),t.dataDescriptor){if(134695760!==(await this.tokenizer.readToken(ke)).signature)throw new Error("Expected data-descriptor-signature at position "+(this.tokenizer.position-ke.len))}}while(!r)}async iterateOverCentralDirectory(e,t){for(const r of e){const e=t(r);if(e.handler){this.tokenizer.setPosition(r.relativeOffsetOfLocalHeader);const t=await this.readLocalFileHeader();if(t){await this.tokenizer.ignore(t.extraFieldLength);const i=new Uint8Array(r.compressedSize);await this.tokenizer.readBuffer(i),await this.inflate(t,i,e.handler)}}if(e.stop)break}}async inflate(e,t,r){if(0===e.compressedMethod)return r(t);if(8!==e.compressedMethod)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);Pe(`Decompress filename=${e.filename}
1, compressed-size=${t.length}`);return r(await $e.decompressDeflateRaw(t))}static async decompressDeflateRaw(e){const t=new ReadableStream({start(t){t.enqueue(e),t.close()}}),r=new DecompressionStream("deflate-raw"),i=t.pipeThrough(r);try{const e=new Response(i),t=await e.arrayBuffer();return new Uint8Array(t)}catch(e){const t=e instanceof Error?`Failed to deflate ZIP entry: ${e.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(t)}}async readLocalFileHeader(){const e=await this.tokenizer.peekToken(re);if(e===ye){const e=await this.tokenizer.readToken(Te);return e.filename=await this.tokenizer.readToken(new se(e.filenameLength,"utf-8")),e}if(e===we)return!1;if(3759263696===e)throw new Error("Encrypted ZIP");throw new Error("Unexpected signature")}}function _e(e,t){const r=e.length,i=t.length;if(i>r)return-1;for(let n=0;n<=r-i;n++){let r=!0;for(let a=0;a<i;a++)if(e[n+a]!==t[a]){r=!1;break}if(r)return n}return-1}function Ne(e){const t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t);let i=0;for(const t of e)r.set(t,i),i+=t.length;return r}class Re{constructor(e){this.tokenizer=e}inflate(){const e=this.tokenizer;return new ReadableStream({async pull(t){const r=new Uint8Array(1024),i=await e.readBuffer(r,{mayBeLess:!0});0!==i?t.enqueue(r.subarray(0,i)):t.close()}}).pipeThrough(new DecompressionStream("gzip"))}}const Oe=Object.prototype.toString;function Fe(e,t,r){return!!e&&(e.constructor===t||Oe.call(e)===r)}function Be(e){return Fe(e,Uint8Array,"[object Uint8Array]")}function De(e){if(!Be(e))throw new TypeError(`Expected \`Uint8Array\`, got \`${typeof e}\``)}new globalThis.TextDecoder("utf8");new globalThis.TextEncoder;Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Me(e){const{byteLength:t}=e;return 6===t?e.getUint16(0)*2**32+e.getUint32(2):5===t?e.getUint8(0)*2**32+e.getUint32(1):4===t?e.getUint32(0):3===t?65536*e.getUint8(0)+e.getUint16(1):2===t?e.getUint16(0):1===t?e.getUint8(0):void 0}const je={get:(e,t)=>127&e[t+3]|(127&e[t+2])<<7|(127&e[t+1])<<14|(127&e[t])<<21,len:4},Le=16777216;class ParserHardLimitError extends Error{}function Ue(e,t,r){if(!Number.isFinite(e)||e<0||e>t)throw new ParserHardLimitError(`${r} has invalid size ${e} (maximum ${t} bytes)`);return e}async function ze(e,t,{maximumLength:r=16777216,reason:i="skip"}={}){const n=Ue(t,r,i);await e.ignore(n)}async function We(e,t,r,{maximumLength:i=t.length,reason:n="read"}={}){const a=Ue(r?.length??t.length,i,n);return e.readBuffer(t,{...r,length:a})}function Ve(e,t,r){r={offset:0,...r};for(const[i,n]of t.entries())if(r.mask){if(n!==(r.mask[i]&e[i+r.offset]))return!1}else if(n!==e[i+r.offset])return!1;return!0}function qe(e){const t=e.fileInfo.size;return!Number.isFinite(t)||t===Number.MAX_SAFE_INTEGER}function He(e,t,r){return qe(e)&&e.position-t>r}const Ge=1048576,Ke=Ge,Ye=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),Xe=["ZIP entry count exceeds ","Unsupported ZIP compression method:","ZIP entry compressed data exceeds ","ZIP entry decompressed data exceeds ","Expected data-descriptor-signature at position "],Qe=new Set(["Z_BUF_ERROR","Z_DATA_ERROR","ERR_INVALID_STATE"]);function Je(e,t=1048576){const r=[e.compressedSize,e.uncompressedSize];for(const e of r)if(!Number.isFinite(e)||e<0||e>t)return!1;return!0}function Ze(e){if(e.hasDocumentEntry)return e.hasMasterSlideEntry?{ext:"key",mime:"application/vnd.apple.keynote"}:e.hasTablesEntry?{ext:"numbers",mime:"application/vnd.apple.numbers"}:{ext:"pages",mime:"application/vnd.apple.pages"}}function et(e){switch(e=e.toLowerCase()){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:e};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:e};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:e};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:e};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:e};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"}}}function tt(e){return e.hasWordDirectory?{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}:e.hasPresentationDirectory?{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}:e.hasSpreadsheetDirectory?{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}:e.hasThreeDimensionalModelEntry?{ext:"3mf",mime:"model/3mf"}:void 0}function rt(e){if(e.hasContentTypesEntry&&!e.hasUnparseableContentTypes&&!e.isParsingContentTypes&&!e.hasParsedContentTypesEntry)return tt(e)}const it=134695760;function nt(e,t){if(e.length<16)return-1;const r=e.length-16;for(let i=0;i<=r;i++)if(re.get(e,i)===it&&re.get(e,i+8)===t+i)return i;return-1}async function at(e,{shouldBuffer:t,maximumLength:r=1048576}={}){const{syncBuffer:i}=e,{length:n}=i,a=[];let s=0;for(;;){const o=await e.tokenizer.peekBuffer(i,{mayBeLess:!0}),c=nt(i.subarray(0,o),s),d=c>=0?0:o===n?Math.min(15,o-1):0,l=c>=0?c:o-d;if(0===l)break;if(s+=l,s>r)throw new Error(`ZIP entry compressed data exceeds ${r} bytes`);if(t){const t=new Uint8Array(l);await e.tokenizer.readBuffer(t),a.push(t)}else await e.tokenizer.ignore(l);if(c>=0)break}if(qe(e.tokenizer)||(e.knownSizeDescriptorScannedBytes+=s),t)return function(e,t){const r=new
1Uint8Array(t);let i=0;for(const t of e)r.set(t,i),i+=t.length;return r}(a,s)}function st(e,t){return qe(e.tokenizer)?Math.max(0,Le-(e.tokenizer.position-t)):Math.max(0,Ge-e.knownSizeDescriptorScannedBytes)}async function ot(e,t,{shouldBuffer:r,maximumDescriptorLength:i=1048576}={}){if(t.dataDescriptor&&0===t.compressedSize)return at(e,{shouldBuffer:r,maximumLength:i});if(!r)return void await ze(e.tokenizer,t.compressedSize,{maximumLength:qe(e.tokenizer)?Ge:e.tokenizer.fileInfo.size,reason:"ZIP entry compressed data"});const n=function(e){const t=e.fileInfo.size,r=Number.isFinite(t)?Math.max(0,t-e.position):Number.MAX_SAFE_INTEGER;return Math.min(r,2147483647)}(e.tokenizer);if(!Number.isFinite(t.compressedSize)||t.compressedSize<0||t.compressedSize>n)throw new Error(`ZIP entry compressed data exceeds ${n} bytes`);const a=new Uint8Array(t.compressedSize);return await e.tokenizer.readBuffer(a),a}async function ct(e){let t;const r={hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1},i={hasDocumentEntry:!1,hasMasterSlideEntry:!1,hasTablesEntry:!1,hasCalculationEngineEntry:!1};try{await new $e(e).unzip(e=>{if(function(e,t){t.startsWith("word/")&&(e.hasWordDirectory=!0),t.startsWith("ppt/")&&(e.hasPresentationDirectory=!0),t.startsWith("xl/")&&(e.hasSpreadsheetDirectory=!0),t.startsWith("3D/")&&t.endsWith(".model")&&(e.hasThreeDimensionalModelEntry=!0)}(r,e.filename),function(e,t){"Index/Document.iwa"===t&&(e.hasDocumentEntry=!0),t.startsWith("Index/MasterSlide")&&(e.hasMasterSlideEntry=!0),t.startsWith("Index/Tables/")&&(e.hasTablesEntry=!0),"Index/CalculationEngine.iwa"===t&&(e.hasCalculationEngineEntry=!0)}(i,e.filename),i.hasDocumentEntry&&(i.hasMasterSlideEntry||i.hasTablesEntry))return t=Ze(i),{stop:!0};const n="[Content_Types].xml"===e.filename,a=rt(r);if(!n&&a)return t=a,{stop:!0};switch(e.filename){case"META-INF/mozilla.rsa":return t={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return t={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return Je(e,Ke)?{async handler(e){const r=new TextDecoder("utf-8").decode(e).trim();t=et(r)},stop:!0}:{};case"[Content_Types].xml":return r.hasContentTypesEntry=!0,Je(e,Ke)?(r.isParsingContentTypes=!0,{async handler(e){const i=function(e){const t=e.indexOf('.main+xml"');if(-1===t){const t="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return e.includes(`ContentType="${t}"`)?t:void 0}const r=e.slice(0,t),i=r.lastIndexOf('"');return r.slice(i+1)}(new TextDecoder("utf-8").decode(e));i&&(t=et(i)),r.hasParsedContentTypesEntry=!0,r.isParsingContentTypes=!1},stop:!0}):(r.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/v.test(e.filename)?(t={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(e){if(!function(e){if(e instanceof EndOfStreamError)return!0;if(e instanceof ParserHardLimitError)return!0;if(!(e instanceof Error))return!1;if(Ye.has(e.message))return!0;if(Qe.has(e.code))return!0;for(const t of Xe)if(e.message.startsWith(t))return!0;return!1}(e))throw e;r.isParsingContentTypes&&(r.isParsingContentTypes=!1,r.hasUnparseableContentTypes=!0),!t&&e instanceof EndOfStreamError&&!r.hasContentTypesEntry&&(t=tt(r))}const n=!qe(e)||!i.hasDocumentEntry||i.hasMasterSlideEntry||i.hasTablesEntry||i.hasCalculationEngineEntry?Ze(i):void 0;return t??rt(r)??n??{ext:"zip",mime:"application/zip"}}$e.prototype.inflate=async function(e,t,r){if(0===e.compressedMethod)return r(t);if(8!==e.compressedMethod)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);return r(await async function(e,{maximumLength:t=1048576}={}){const r=new ReadableStream({start(t){t.enqueue(e),t.close()}}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(),i=[];let n=0;try{for(;;){const{done:e,value:a}=await r.read();if(e)break;if(n+=a.length,n>t)throw await r.cancel().catch(()=>{}),new Error(`ZIP entry decompressed data exceeds ${t} bytes`);i.push(a)}}catch(e){if("ERR_TRAILING_JUNK_AFTER_STREAM_END"!==e.code)throw e}finally{r.releaseLock()}const a=new Uint8Array(n);let s=0;for(const e of i)a.set(e,s),s+=e.length;return a}(t,{maximumLength:Ge}))},$e.prototype.unzip=async function(e){let t=!1,r=0;const i=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(He(this.tokenizer,i,Le))throw new ParserHardLimitError("ZIP stream probing exceeds 16777216 bytes");const n=await this.readLocalFileHeader();if(!n)break;if(r++,r>1024)throw new Error("ZIP entry count exceeds 1024");const a=e(n);t=Boolean(a.stop),await this.tokenizer.ignore(n.extraFieldLength);const s=await ot(this,n,{shouldBuffer:Boolean(a.handler),maximumDescriptorLength:Math.min(Ge,st(this,i))});if(a.handler&&await this.inflate(n,s,a.handler),n.dataDescriptor){const e=new Uint8Array(16);if(await this.tokenizer.readBuffer(e),re.get(e,0)!==it)throw new Error("Expected data-descriptor-signature at position "+(this.tokenizer.position-e.length))}if(He(this.tokenizer,i,Le))throw new ParserHardLimitError("ZIP stream probing exceeds 16777216 bytes")}while(!t)};const dt=1048576;const lt=1048576;function ut(e){return!!(32&e.codePointAt(0))}const ht=1048576;
1const ft=4100,mt=Le,pt=Le,gt=Le;function yt(e){return r(15333)(e)}function bt(e,t){return void 0===t?e.read():(t.throwIfAborted(),Promise.race([e.read(),new Promise((r,i)=>{t.addEventListener("abort",()=>{i(t.reason),e.cancel(t.reason).catch(()=>{})},{once:!0})})]))}class wt{constructor(e){const t=(r=e?.mpegOffsetTolerance,Number.isFinite(r)?Math.max(0,Math.min(4096,Math.trunc(r))):0);var r;this.options={...e,mpegOffsetTolerance:t},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(e){return pe(function(e){return e.pipeThrough(new TransformStream)}(e),this.getTokenizerOptions())}async parseTokenizer(e,t=0){this.detectionReentryCount=t;const r=e.position;for(const t of this.detectors){let i;try{i=await t.detect(e)}catch(e){if(e instanceof EndOfStreamError)return;if(e instanceof ParserHardLimitError)return;throw e}if(i)return i;if(r!==e.position)return}}async fromTokenizer(e){try{return await this.parseTokenizer(e)}finally{await e.close()}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);const t=e instanceof Uint8Array?e:new Uint8Array(e);var r,i;if(t?.length>1)return this.fromTokenizer((r=t,i=this.getTokenizerOptions(),new fe(r,i)))}async fromBlob(e){this.options.signal?.throwIfAborted();const t=function(e,t){return new me(e,t)}(e,this.getTokenizerOptions());return this.fromTokenizer(t)}async fromStream(e){this.options.signal?.throwIfAborted();const t=this.createTokenizerFromWebStream(e);return this.fromTokenizer(t)}async fromFile(e){this.options.signal?.throwIfAborted();const[{default:t},{FileTokenizer:r}]=await Promise.all([yt("node:fs/promises"),yt("strtok3")]),i=await t.open(e,t.constants.O_RDONLY|t.constants.O_NONBLOCK),n=await i.stat();if(!n.isFile())return void await i.close();const a=new r(i,{...this.getTokenizerOptions(),fileInfo:{path:e,size:n.size}});return this.fromTokenizer(a)}async toDetectionStream(e,t){this.options.signal?.throwIfAborted();const r=function(e){return Number.isFinite(e)?Math.max(1,Math.trunc(e)):ft}(t?.sampleSize??ft);let i,n=!1;const a=e.getReader(),s=[];let o=0;try{for(;o<r;){const{value:e,done:t}=await bt(a,this.options.signal);if(t||!e){n=!0;break}s.push(e),o+=e.length}if(!n&&o===r){const{value:e,done:t}=await bt(a,this.options.signal);t||!e?n=!0:(s.push(e),o+=e.length)}}finally{a.releaseLock()}if(o>0){const e=1===s.length?s[0]:function(e,t){if(0===e.length)return new Uint8Array(0);t??=e.reduce((e,t)=>e+t.length,0);const r=new Uint8Array(t);let i=0;for(const t of e)De(t),r.set(t,i),i+=t.length;return r}(s);try{i=await this.fromBuffer(e.subarray(0,r))}catch(e){if(!(e instanceof EndOfStreamError))throw e;i=void 0}n||"pages"!==i?.ext||(i={ext:"zip",mime:"application/zip"})}const c=new TransformStream({start(e){for(const t of s)e.enqueue(t)},transform(e,t){t.enqueue(e)}}),d=e.pipeThrough(c);return d.fileType=i,d}async detectGzip(e){if(this.gzipProbeDepth>=1)return{ext:"gz",mime:"application/gzip"};const t=function(e,t){const r=e.getReader();let i=0,n=!1,a=!1;const s=async e=>{n||a||(a=!0,await r.cancel(e))};return new ReadableStream({async pull(e){if(i>=t)return e.close(),void await s();const{done:a,value:o}=await r.read();if(a||!o)return n=!0,void e.close();const c=t-i;if(o.length>c)return e.enqueue(o.subarray(0,c)),i+=c,e.close(),void await s();e.enqueue(o),i+=o.length},async cancel(e){await s(e)}})}(new Re(e).inflate(),mt),r=qe(e);let i,n,a,s;if(r){const e=new AbortController;i=setTimeout(()=>{e.abort(new DOMException("Operation timed out after 100 ms","TimeoutError"))},100),n=void 0===this.options.signal?e.signal:AbortSignal.any([this.options.signal,e.signal]),a=new wt({...this.options,signal:n}),a.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{s=await(a??this).fromStream(t)}catch(e){if("AbortError"===e?.name&&"TimeoutError"!==n?.reason?.name)throw e}finally{clearTimeout(i),r||this.gzipProbeDepth--}return"tar"===s?.ext?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(e,t){return Ve(this.buffer,e,t)}checkString(e,t){return this.check(function(e,t){if("utf-16le"===t){const t=[];for(let r=0;r<e.length;r++){const i=e.charCodeAt(r);t.push(255&i,i>>8&255)}return t}if("utf-16be"===t){const t=[];for(let r=0;r<e.length;r++){const i=e.charCodeAt(r);t.push(i>>8&255,255&i)}return t}return[...e].map(e=>e.charCodeAt(0))}(e,t?.encoding),t)}detectConfident=async e=>{if(this.buffer=new Uint8Array(ft),void 0===e.fileInfo.size&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,qe(e)&&(await e.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(e);if(await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};
1if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191])){if(this.detectionReentryCount>=256)return;return this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(e)}if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(e);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await ze(e,6,{maximumLength:6,reason:"ID3 header prefix"});const t=await e.readToken(je),r=qe(e);if(!Number.isFinite(t)||t<0||r&&(t>pt||e.position+t>pt))return;if(e.position+t>e.fileInfo.size){if(r)return;return{ext:"mp3",mime:"audio/mpeg"}}try{await ze(e,t,{maximumLength:r?pt:e.fileInfo.size,reason:"ID3 payload"})}catch(e){if(e instanceof EndOfStreamError)return;throw e}if(this.detectionReentryCount>=256)return;return this.detectionReentryCount++,this.parseTokenizer(e,this.detectionReentryCount)}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((67===this.buffer[0]||70===this.buffer[0])&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4]))return ct(e);if(this.checkString("OggS")){await e.ignore(28);const t=new Uint8Array(8);return await e.readBuffer(t),Ve(t,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:Ve(t,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:Ve(t,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:Ve(t,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:Ve(t,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:Ve(t,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(3===this.buffer[2]||5===this.buffer[2]||7===this.buffer[2])&&(4===this.buffer[3]||6===this.buffer[3]||8===this.buffer[3]))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){const e=await this.readTiffHeader(!1);if(e)return e}if(this.check([77,77])){const e=await this.readTiffHeader(!0);if(e)return e}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163]))return async function(e){async function t(){const t=await e.peekNumber(Z);let r=128,i=0;for(;0===(t&r)&&0!==r;)++i,r>>=1;const n=new Uint8Array(i+1);return await We(e,n,void 0,{maximumLength:n.length,reason:"EBML field"}),n}async function r(){const e=await t(),r=await t();r[0]^=128>>r.length-1;const i=Math.min(6,r.length),n=new DataView(e.buffer),a=new DataView(r.buffer,r.length-i,i);return{id:Me(n),len:Me(a)}}const i=await r(),n=e.position;switch(await async function(t){let i=0;for(;t>0;){if(i++,i>256)return;if(He(e,n,Le))return;const a=e.position,s=await r();if(17026===s.id){if(s.len>64)return;const t=Ue(s.len,64,"EBML DocType");return(await e.readToken(new se(t))).replaceAll(/\0.*$/gv,"")}if(qe(e)&&(!Number.isFinite(s.len)||s.len<0||s.len>dt))return;if(await ze(e,s.len,{maximumLength:qe(e)?dt:e.fileInfo.size,reason:"EBML payload"}),--t,e.position<=a)return}}(i.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"}}}(e);if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};
1if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString(String.raw`{\rtf`))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){const e=ie.get(this.buffer,4),t=te.get(this.buffer,6);if(e>0&&e<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(t>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/x-ft-draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(0===this.buffer[6]||1===this.buffer[6]))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){const e=new se(4,"latin1").get(this.buffer,2);if(/^\d+$/v.test(e)&&e>=1e3&&e<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>")){await e.ignore(8);return"debian-binary"===await e.readToken(new se(13,"ascii"))?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"}}if(this.checkString("WEBVTT")&&["\n","\r","\t"," ","\0"].some(e=>this.checkString(e,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10]))return async function(e){const t={ext:"png",mime:"image/png"},r={ext:"apng",mime:"image/apng"};async function i(){return{length:await e.readToken(ne),type:await e.readToken(new se(4,"latin1"))}}await e.ignore(8);const n=qe(e),a=e.position;let s=0,o=!1;do{if(s++,s>512)break;if(He(e,a,16777216))break;const c=e.position,d=await i();if(d.length<0)return;if("IHDR"===d.type){if(13!==d.length)return;o=!0}switch(d.type){case"IDAT":return t;case"acTL":return r;default:if(!o&&"CgBI"!==d.type)return;if(n&&d.length>lt)return o&&ut(d.type)?t:void 0;try{await ze(e,d.length+4,{maximumLength:n?1048580:e.fileInfo.size,reason:"PNG chunk payload"})}catch(e){if(!n&&(e instanceof ParserHardLimitError||e instanceof EndOfStreamError))return t;throw e}}if(e.position<=c)break}while(e.position+8<e.fileInfo.size);return t}(e);if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&96&this.buffer[8]){const e=new se(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(e){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return e.startsWith("3g")?e.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString("REGEDIT4\r\n"))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-p
1anasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217]))return async function(e){let t=!1;try{async function r(){const t=new Uint8Array(16);return await We(e,t,void 0,{maximumLength:t.length,reason:"ASF header GUID"}),{id:t,size:Number(await e.readToken(ae))}}await ze(e,30,{maximumLength:30,reason:"ASF header prelude"});const i=qe(e),n=e.position;let a=0;for(;e.position+24<e.fileInfo.size&&(a++,!(a>512))&&!He(e,n,Le);){const s=e.position,o=await r();let c=o.size-24;if(!Number.isFinite(c)||c<0){t=!0;break}if(Ve(o.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){const d=new Uint8Array(16);if(c-=await We(e,d,void 0,{maximumLength:d.length,reason:"ASF stream type GUID"}),Ve(d,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(Ve(d,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}if(i&&c>ht){t=!0;break}if(await ze(e,c,{maximumLength:i?ht:e.fileInfo.size,reason:"ASF header payload"}),e.position<=s){t=!0;break}}}catch(l){if(!(l instanceof EndOfStreamError||l instanceof ParserHardLimitError))throw l;qe(e)&&(t=!0)}if(!t)return{ext:"asf",mime:"application/vnd.ms-asf"}}(e);if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10])){await e.ignore(20);switch(await e.readToken(new se(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){const e=new DataView(this.buffer.buffer).getUint32(12,!0);if(e>12&&this.buffer.length>=e+16)try{const t=(new TextDecoder).decode(this.buffer.subarray(16,e+16));if(JSON.parse(t).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x-ms-shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x-ft-apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x-ft-fbx"};
1if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&function(e,t=0){const r=Number.parseInt(new se(6).get(e,148).replace(/\0.*$/v,"").trim(),8);if(Number.isNaN(r))return!1;let i=256;for(let r=t;r<t+148;r++)i+=e[r];for(let r=t+156;r<t+512;r++)i+=e[r];return r===i}(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){const e="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:e})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:e})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString("Windows Registry Editor Version 5.00\r\n",{offset:2,encoding:e})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}return this.checkString("-----BEGIN PGP MESSAGE-----")?{ext:"pgp",mime:"application/pgp-encrypted"}:void 0};detectImprecise=async e=>{this.buffer=new Uint8Array(ft);const t=function(e){return Number.isFinite(e)?Math.max(0,e):Number.MAX_SAFE_INTEGER}(e.fileInfo.size);if(await e.peekBuffer(this.buffer,{length:Math.min(8,t),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(4+this.options.mpegOffsetTolerance,t),mayBeLess:!0}),this.buffer.length>=4+this.options.mpegOffsetTolerance)for(let e=0;e<=this.options.mpegOffsetTolerance;++e){const t=this.scanMpeg(e);if(t)return t}};async readTiffTag(e){const t=await this.tokenizer.readToken(e?te:ee);switch(await this.tokenizer.ignore(10),t){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(e){const t=await this.tokenizer.readToken(e?te:ee);if(!(t>512||qe(this.tokenizer)&&2+12*t>gt))for(let r=0;r<t;++r){const t=await this.readTiffTag(e);if(t)return t}}async readTiffHeader(e){const t={ext:"tif",mime:"image/tiff"},r=(e?te:ee).get(this.buffer,2),i=(e?ie:re).get(this.buffer,4);if(42===r){if(i>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(i>=8){const t=(e?te:ee).get(this.buffer,8),r=(e?te:ee).get(this.buffer,10);if(28===t&&254===r||31===t&&11===r)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(qe(this.tokenizer)&&i>1048576)return t;const r=qe(this.tokenizer)?gt:this.tokenizer.fileInfo.size;try{await ze(this.tokenizer,i,{maximumLength:r,reason:"TIFF IFD offset"})}catch(e){if(e instanceof EndOfStreamError)return;throw e}let n;try{n=await this.readTiffIFD(e)}catch(e){if(e instanceof EndOfStreamError)return;throw e}return n??t}if(43===r)return t}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return{ext:"aac",mime:"audio/aac"};if(this.check([255,254],{offset:e}))return;if(this.check([8],{offset:e+1,mask:[24]}))return;if(this.check([240],{offset:e+2,mask:[240]}))return;if(this.check([12],{offset:e+2,mask:[12]}))return;if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}}new Set(["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat","key","numbers","pages"]),new Set(["image/jpeg","image/png","image/gif","
1image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x-ms-shortcut","application/x-ft-apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x-ft-fbx","application/vnd.visio","application/vnd.android.package-archive","application/x-ft-draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data","application/vnd.apple.keynote","application/vnd.apple.numbers","application/vnd.apple.pages"]);async function vt(e){const t=await async function(e,t){return new wt(t).fromStream(e)}(e.stream());if(t)return"application/xml"===t.mime&&e.name.endsWith(".svg")?"image/svg+xml":t.mime}var kt=r(17801);async function Tt(e){const t=await vt(e);return t?new File([e],e.name,{type:t}):e}function xt(e,t,r){if(r.validation.acceptFiles&&!(0,i().A)(e,r.validation.acceptFiles))return new z.A(e,r.validation.acceptFiles);if(0===e.size)return new L.A(e);if(r.validation.maxFileSize){const t=function(e,t){if("number"==typeof t)return t;for(const r in t)if((0,i().A)(e,r))return t[r]}(e,r.validation.maxFileSize);if(t&&e.size>t)return new U.A(e,t)}return t.objects.find(t=>{if(!t.file)return!1;const r=t.file.name===e.name;let i=!0;return"number"==typeof t.file.size&&"number"==typeof e.size&&(i=t.file.size===e.size),r&&i})?new j.A(e):null}function St(e,t){return{internalId:e,file:t,isUploaded:!1,isUploading:!1,isRetrying:!1,progress:0}}function Ct(e){return e?e.map(e=>function(e){const t={isUploaded:Boolean(e.isRemote||e.remoteId),isUploading:!1,isRetrying:!1,progress:0,...e};return t.file&&t.file instanceof File||delete t.file,t}(e)):[]}function Uploader(e){const t=(0,d.A)(h.bV),r=(0,o.A)(),i=(0,l.A)(),n=(0,a.useMemo)(()=>new O({withCloudflareStream:e.withCloudflareStream},r,t,e.resource),[i,t,JSON.stringify(e.resource)]),m=Ct(e.objects),p={objects:m,previousObjects:m},g=(0,a.useRef)(p),y=(0,a.useMemo)(()=>M(g),[]),[b,w]=(0,a.useReducer)(y,p),v=e.mode||"single",k={itemsLimit:1,...e.validation},T=(0,a.useRef)({}),x=(0,c.A)(),{logger:S}=(0,a.useContext)(u.A),C=e.order||"append",P=(0,a.useCallback)(t=>{x.current&&(w(t),setTimeout(()=>{e.onChange&&g.current.objects.every(e=>e.isUploaded)&&e.onChange(g.current.objects),e.onInternalStateChanged?.(g.current)},5))},[w,b,e.onChange]);(0,s.A)(()=>
1{if(b.objects.map(e=>e.internalId).join(",")===(e.objects??[]).map(e=>e.internalId).join(","))return;const t=[];if(e.objects)for(const r of e.objects){const e=b.objects.find(e=>e.remoteId===r.remoteId);e?t.push({...r,file:e.file}):t.push(r)}P({type:F.SET_OBJECTS,payload:{objects:Ct(t)}})},[e.objects]),(0,a.useEffect)(()=>{const e=(e,t)=>{b.objects.some(t=>t.internalId===e)&&P({payload:{attributes:{progress:t},internalId:e},type:F.SET_OBJECT_ATTRIBUTES})};return n.eventEmitter.addListener("progress",e),()=>{n.eventEmitter.removeListener("progress",e)}},[b.objects,P]),(0,a.useEffect)(()=>{const e=e=>{P({payload:{attributes:{isRetrying:!0,isUploading:!0},internalId:e},type:F.SET_OBJECT_ATTRIBUTES})};return n.eventEmitter.addListener("retry",e),()=>{n.eventEmitter.removeListener("retry",e)}},[P]),(0,a.useEffect)(()=>()=>{for(const e in T.current){const t=T.current[e];"uploading"===t.status&&t.abort()}},[]);const A=(0,a.useCallback)(async t=>{if(!(t.internalId in T.current)&&t.file)try{if(T.current[t.internalId]={status:"preparing"},P({type:F.SET_OBJECT_ATTRIBUTES,payload:{attributes:{error:void 0,isRetrying:!1,isUploading:!0,progress:0},internalId:t.internalId}}),(0,f.B)(()=>e.onStartUpload?.({internalId:t.internalId},g.current)),e.withCloudflareStream&&!t.uploadUrl&&t.file?.type.startsWith("video/")){const{remoteId:e,uploadUrl:r}=await n.generateVideoUploadInfo();t.remoteId=e,t.uploadUrl=r,P({type:F.SET_OBJECT_ATTRIBUTES,payload:{attributes:{remoteId:e,uploadUrl:r},internalId:t.internalId}})}const r=await n.uploadFile(t,e.handlerConfig);T.current[t.internalId]={...r,status:"uploading"},P({type:F.SET_OBJECT_ATTRIBUTES,payload:{attributes:{error:void 0,isRetrying:!1,isUploading:!0,progress:0},internalId:t.internalId}});const i=await r.requestPromise;P({payload:{internalId:t.internalId,remoteId:i.remoteId},type:F.FINISH_OBJECT_UPLOAD}),(0,f.B)(()=>{e.onFinishUpload?.({internalId:t.internalId,remoteId:i.remoteId},g.current)})}catch(r){if(r instanceof R.k3)return;P({payload:{internalId:t.internalId},type:F.REMOVE_OBJECT_BY_ID}),P({payload:{error:r},type:F.SET_ERROR}),e.onError&&e.onError(r),S.error(r,{context:"Upload error",metadata:{object:{...t,file:t.file?{name:t.file.name,size:t.file.size,type:t.file.type}:void 0},validation:k}})}finally{delete T.current[t.internalId]}},[P,e.onStartUpload,e.onFinishUpload]),E=(0,a.useCallback)(async t=>{const r=[];for(const e of t)r.push(await Tt(e));const n=function(e,t,r){if("single"===r.mode&&e.length>1)return new kt.A(kt.r);
1if("multiple"===r.mode&&r.validation.itemsLimit&&t.objects.length+e.length>r.validation.itemsLimit)return new kt.A(kt.r);for(let i=0;i<e.length;i++){const n=xt(e[i],t,r);if(n)return n}return null}(r,b,{mode:v,validation:k});if(n)P({payload:{error:n},type:F.SET_ERROR}),S.error(n,{context:"Upload error",metadata:{validation:k}});else try{for(const t of r){const r=i(),n=e.generateObjectMetadata?e.generateObjectMetadata(t):void 0,a={...St(r,t),...n};P("single"===v?{payload:{objects:[a]},type:F.SET_OBJECTS}:{payload:{objects:[a],order:C},type:F.ADD_OBJECTS})}}catch(e){P({payload:{error:e},type:F.SET_ERROR})}},[P]),I=(0,a.useCallback)(e=>{P({payload:{object:e,order:C},type:F.ADD_OBJECT})},[P]),$=(0,a.useCallback)(t=>{P({payload:{internalId:t},type:F.REMOVE_OBJECT_BY_ID});const r=T.current[t];"uploading"===r?.status&&(r.abort(),e.onCancelUpload?.({internalId:t},g.current)),(0,f.B)(()=>e.onRemoveObject?.({internalId:t},g.current))},[P,e.onRemoveObject]),_=(0,a.useCallback)(()=>{P({type:F.REMOVE_ALL})},[P]),N=(0,a.useCallback)((e,t)=>{P({payload:{attributes:t,internalId:e},type:F.SET_OBJECT_ATTRIBUTES})},[P]),B=(0,a.useCallback)((t,r)=>{P({payload:{fromIndex:t,toIndex:r},type:F.MOVE_OBJECT_BY_INDEX}),(0,f.B)(()=>e.onSort?.({fromIndex:t,toIndex:r},g.current))},[P,e.onSort]),D=(0,a.useCallback)((t,r)=>{P({payload:{indexA:t,indexB:r},type:F.SWAP_OBJECTS_BY_INDEX}),(0,f.B)(()=>e.onSort?.({fromIndex:t,toIndex:r},g.current))},[P,e.onSort]),j=(0,a.useCallback)(()=>{P({type:F.REMOVE_ALL_PENDING_ONES});for(const t in T.current){const r=T.current[t];"uploading"===r.status&&(r.abort(),e.onCancelUpload?.({internalId:t},g.current))}},[P]),L=(0,a.useCallback)(()=>{if(P({type:F.REVERT_SELECTION}),e.onCancelUpload)for(const t of b.objects)e.onCancelUpload(t,g.current)},[P]);(0,a.useEffect)(()=>{if(!e.autoUpload)return;const t=b.objects.filter(e=>!(e.isUploaded||e.isUploading||e.isRemote||e.isRetrying||e.error));for(const e of t)A(e)},[A,b.objects]);const U={error:b.error,id:e.id,mode:v,objects:b.objects,validation:k,addObject:I,cancelAll:j,moveObjectByIndex:B,removeObject:$,removeAll:_,revertSelection:L,selectFiles:E,setObjectAttributes:N,swapObjectsByIndex:D};return e.ref&&("function"==typeof e.ref?e.ref(U):e.ref.current=U),e.children(U)}},17801(e,t,r){"use strict";r.d(t,{A:()=>ValidationError});var i=r(20975);class ValidationError extends i.A{reason;constructor(e){super("ValidationError"),this.reason=e}}r.d(t,["r",0,"TOO_MANY_FILES"])},53975(e,t,r){"use strict";function i(e){if(!e)return;const t={};let r;for(const i of e.split(",")){const e=i.trim();if(e)if(e.startsWith(".")){if(!r)continue;t[r].push(e)}else r=e,t[r]??=[]}return Object.keys(t).length>0?t:void 0}r.d(t,{A:()=>i})},28699(e,t,r){"use strict";function i(e){if(e){if("number"==typeof e)return e;if(0!==Object.keys(e).length)return Math.max(...Object.values(e))}}r.d(t,{A:()=>i})},4169(e,t,r){"use strict";r.d(t,{A:()=>VideoTrimTimeline});var i=r(85906),n=r(78801),a=r.n(n),s=r(19363),o=r(86922),c=r(35447),d=r(53774),l=r(14202);const u=a().bind(d.A),h=.1;function f(e,t,r,i){const n=t.videoWidth/t.videoHeight;let a=i,s=72;n>i/72?a=72*n:s=i/n,e.drawImage(t,r+(i-a)/2,(72-s)/2,a,s)}function VideoTrimTimeline({duration:e,value:t,videoUrl:r,onChange:n}){const a=(0,i.useRef)(null),d=(0,i.useRef)(null),[m,p]=(0,i.useState)(!0);(0,i.useEffect)(()=>{const t=a.current;if(!t)return;let i=!1;const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.preload="auto",n.src=r;return n.load(),(async()=>{if(p(!0),await(n.readyState>=1?Promise.resolve():new Promise((e,t)=>{n.addEventListener("loadedmetadata",()=>e(),{once:!0}),n.addEventListener("error",()=>t(new Error("Could not load video frames")),{once:!0})})),i)return;const r=t.getContext("2d");if(r){t.width=1344,t.height=72,r.fillStyle="#10231c",r.fillRect(0,0,t.width,t.height);for(let t=0;t<12;t+=1){if(i)return;if(n.currentTime=e*t/11,await new Promise(e=>n.addEventListener("seeked",()=>e(),{once:!0})),i)return;f(r,n,112*t,112)}p(!1)}})().catch(()=>p(!1)),()=>{i=!0,n.pause(),n.removeAttribute("src"),n.load()}},[e,r]);const g=(0,i.useCallback)((r,i)=>{const a=d.current;if(!a)return;const s=a.getBoundingClientRect(),o=Math.max(0,Math.min(1,(i-s.left)/s.width)),c=Math.round(o*e*10)/10;n("start"===r?[Math.min(c,t[1]-h),t[1]]:[t[0],Math.max(c,t[0]+h)])},[e,n,t]),y=t[0]/e*100,b=t[1]/e*100;return(0,l.jsxs)(s.h,{flexShrink:0,padding:3,children:[(0,l.jsxs)(s.h,{alignItems:"baseline",display:"flex",flexWrap:"wrap",gapX:3,justifyContent:"between",children:[(0,l.jsx)(o.A,{children:"Keep the best part"}),(0,l.jsx)(c.A,{fontSize:"small",monoSpaceNumber:!0,textStyle:"muted",children:`${t[0].toFixed(1)}s â ${t[1].toFixed(1)}s`})]}),(0,l.jsxs)(s.h,{"aria-label":"Video trim timeline",ref:d,backgroundColor:m?"primary-light":"secondary",borderRadius:!0,cursor:"pointer",marginBottom:2,marginTop:1,position:"relative",className:u("trim-timeline"),children:[(0,l.jsx)(s.h,{element:"canvas",ref:a,borderRadius:!0,display:"block",className:u("trim-filmstrip")}),(0,l.jsx)(s.h,{backgroundColor:"overlay",borderRadius:"left",position:"absolute-left",style:{width:`${y}%`}}),(0,l.jsx)(s.h,{backgroundColor:"overlay",borderRadius:"right",position:"absolute-right",style:{left:`${b}%`}}),(0,l.jsx)(s.h,{"aria-hidden":"true",borderRadius:!0,position:"absolute-center",className:u("trim-selection"),style:{left:`${y}%`,width:b-y+"%"}}),["start","end"].map(r=>{const i="start"===r,n=i?y:b,a=i?t[0]:t[1];return(0,l.jsx)(s.h,{role:"slider",tabIndex:0,"aria-label":i?"Trim start":"Trim end","aria-valuemin":i?0:t[0]+h,"aria-valuemax":i?t[1]-h:e,"aria-valuenow":a,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&g(r,e.clientX)},onPointerUp:e=>e.currentTarget.releasePointerCapture(e.pointerId),onPointerCancel:e=>e.currentTarget.releasePointerCapture(e.pointerId),onKeyDown:i=>((r,i)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(r.key))return;r.preventDefault();let n=("start"===i?t[0]:t[1])+("ArrowLeft"===r.key?-.1:.1);"Home"===r.key&&(n=0),"End"===r.key&&(n=e);const a=d.current?.getBoundingClientRect();a&&g(i,a.left+n/e*a.width)})(i,r),backgroundColor:"white",borderRadius:!0,cursor:"grab",position:"absolute-center",className:u("trim-handle"),style:{left:`${n}%`}},r)})]}),(0,l.jsxs)(s.h,{display:"flex",fontSize:"small",fontWeight:"semi-bold",gap:3,justifyContent:"between",lineHeight:"smallest",textStyle:"muted",children:[(0,l.jsx)(c.A,{fontSize:"xsmall",textTransform:"uppercase",textAlign:"left",children:"Start"}),(0,l.jsx)(c.A,{italic:!0,fontWeight:"normal",textAlign:"center",children:"Drag the handles to trim"}),(0,l.jsx)(c.A,{fontSize:"xsmall",textTransform:"uppercase",textAlign:"right",children:"End"})]})]})}},41677(e,t,r){"use strict";r.d(t,{A:()=>bl});class i{constructor(e){this.bytes=e,this.pos=0}seekToByte(e){this.pos=8*e}readBit(){const e=Math.floor(this.pos/8),t=this.bytes[e]??0,r=7-(7&this.pos),i=(t&1<<r)>>r;return this.pos++,i}readBits(e){if(1===e)return this.readBit();let t=0;for(let r=0;r<e;r++)t<<=1,t|=this.readBit();return t}writeBits(e,t){const r=this.pos+e;for(let e=this.pos;e<r;e++){const i=Math.floor(e/8);let n=this.bytes[i];const a=7-(7&e);n&=~(1<<a),n|=(t&1<<r-e-1)>>r-e-1<<a,this.bytes[i]=n}this.pos=r}readAlignedByte(){if(this.pos%8!=0)throw new Error("Bitstream is not byte-aligned.");const e=this.pos/8,t=this.bytes[e]??0;return this.pos+=8,t}skipBits(e){this.pos+=e}getBitsLeft(){return 8*this.bytes.length-this.pos}clone(){const e=new i(this.bytes);return e.pos=this.pos,e}}const n=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],a=[-1,1,2,3,4,5,6,8],s=e=>{if(!e||e.byteLength<2)throw new TypeError("AAC description must be at least 2 bytes long.");const t=new i(e);let r=t.readBits(5);31===r&&(r=32+t.readBits(6));const s=t.readBits(4);let o=null;15===s?o=t.readBits(24):s<n.length&&(o=n[s]);const c=t.readBits(4);let d=null;return c>=1&&c<=7&&(d=a[c]),{objectType:r,frequencyIndex:s,sampleRate:o,channelConfiguration:c,numberOfChannels:d}},o=e=>{let t=n.indexOf(e.sampleRate),r=null;-1===t&&(t=15,r=e.sampleRate);const s=a.indexOf(e.numberOfChannels);if(-1===s)throw new TypeError(`Unsupported number of channels: ${e.numberOfChannels}`);let o=13;e.objectType>=32&&(o+=6),15===t&&(o+=24);const c=Math.ceil(o/8),d=new Uint8Array(c),l=new i(d);return e.objectType<32?l.writeBits(5,e.objectType):(l.writeBits(5,31),l.writeBits(6,e.objectType-32)),l.writeBits(4,t),15===t&&l.writeBits(24,r),l.writeBits(4,s),d};var c;!function(e){e[e.Silent=0]="Silent",e[e.Errors=1]="Errors",e[e.Warnings=2]="Warnings",e[e.Info=3]="Info"}(c||(c={}));class d{constructor(){}static get level(){return d._level}static set level(e){if(e!==c.Silent&&e!==c.Errors&&e!==c.Warnings&&e!==c.Info)throw new TypeError("Invalid log level. Use one of the values of the LogLevel enum.");d._level=e}static get _emitter(){return d._emitterInstance??=new xe}static on(e,t,r){return d._emitter.on(e,t,r)}
1static _error(...e){d._emitter._emit("error",e),d._level>=c.Errors&&console.error(...e)}static _warn(...e){d._emitter._emit("warn",e),d._level>=c.Warnings&&console.warn(...e)}static _info(...e){d._emitter._emit("info",e),d._level>=c.Info&&console.info(...e)}}function l(e){if(!e)throw new Error("Assertion failed.")}d._level=c.Info,d._emitterInstance=null;const u=e=>{const t=(e%360+360)%360;if(0===t||90===t||180===t||270===t)return t;throw new Error(`Invalid rotation ${e}.`)},h=e=>e&&e[e.length-1],f=e=>e>=0&&e<2**32,m=e=>{let t=0;for(;0===e.readBits(1)&&t<32;)t++;if(t>=32)throw new Error("Invalid exponential-Golomb code.");return(1<<t)-1+e.readBits(t)},p=e=>{const t=m(e);return 1&t?t+1>>1:-(t>>1)},g=e=>e.constructor===Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),y=e=>e.constructor===DataView?e:ArrayBuffer.isView(e)?new DataView(e.buffer,e.byteOffset,e.byteLength):new DataView(e),b=new TextDecoder,w=new TextEncoder,v=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e])),k={bt709:1,bt470bg:5,smpte170m:6,bt2020:9,smpte432:12},T=v(k),x={bt709:1,smpte170m:6,linear:8,"iec61966-2-1":13,pq:16,hlg:18},S=v(x),C={rgb:0,bt709:1,bt470bg:5,smpte170m:6,"bt2020-ncl":9},P=v(C),A=e=>!!(e&&e.primaries&&e.transfer&&e.matrix&&void 0!==e.fullRange),E=e=>e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer||ArrayBuffer.isView(e);class I{constructor(){this.currentPromise=Promise.resolve(),this.pending=0}async acquire(){let e;const t=new Promise(t=>{let r=!1;e=()=>{r||(t(),this.pending--,r=!0)}}),r=this.currentPromise;return this.currentPromise=t,this.pending++,await r,e}}const $=/^[0-9a-fA-F]+$/,_=e=>[...e].map(e=>e.toString(16).padStart(2,"0")).join(""),N=e=>(e=(e=(e=(e=(e=e>>1&1431655765|(1431655765&e)<<1)>>2&858993459|(858993459&e)<<2)>>4&252645135|(252645135&e)<<4)>>8&16711935|(16711935&e)<<8)>>16&65535|(65535&e)<<16)>>>0,R=(e,t,r)=>{let i=0,n=e.length-1,a=-1;for(;i<=n;){const s=i+n>>1,o=r(e[s]);o===t?(a=s,n=s-1):o<t?i=s+1:n=s-1}return a},O=(e,t,r)=>{let i=0,n=e.length-1,a=-1;for(;i<=n;){const s=i+(n-i+1)/2|0;r(e[s])<=t?(a=s,i=s+1):n=s-1}return a},F=(e,t,r)=>{const i=O(e,r(t),r);e.splice(i+1,0,t)},B=()=>{let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}},D=(e,t)=>{const r=e.indexOf(t);-1!==r&&e.splice(r,1)},M=(e,t)=>{for(let r=e.length-1;r>=0;r--)if(t(e[r]))return e[r]},j=(e,t)=>{for(let r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1},L=e=>{throw new Error(`Unexpected value: ${e}`)},U=(e,t,r)=>{const i=e.getUint8(t),n=e.getUint8(t+1),a=e.getUint8(t+2);return r?i|n<<8|a<<16:i<<16|n<<8|a},z=(e,t,r,i)=>{r>>>=0,r&=16777215,i?(e.setUint8(t,255&r),e.setUint8(t+1,r>>>8&255),e.setUint8(t+2,r>>>16&255)):(e.setUint8(t,r>>>16&255),e.setUint8(t+1,r>>>8&255),e.setUint8(t+2,255&r))},W=(e,t,r)=>
1Math.max(t,Math.min(r,e)),V="und",q=e=>{const t=Math.round(e);return Math.abs(e/t-1)<10*Number.EPSILON?t:e},H=(e,t)=>Math.round(e/t)*t,G=(e,t)=>Math.round(e*t)/t,K=(e,t)=>Math.floor(e/t)*t,Y=(e,t)=>Math.floor(e*t)/t,X=/^[a-z]{3}$/,Q=e=>X.test(e),J=1e6*(1+Number.EPSILON);class Z{constructor(){this.currentPromise=Promise.resolve()}call(e){return this.currentPromise=this.currentPromise.then(e)}}let ee=null;const te=()=>null!==ee?ee:ee=!("undefined"==typeof navigator||!(navigator.vendor?.match(/apple/i)||/AppleWebKit/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)||/\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent)));let re=null;const ie=()=>null!==re?re:re="undefined"!=typeof navigator&&navigator.userAgent?.includes("Firefox");let ne=null;const ae=()=>null!==ne?ne:ne=!("undefined"==typeof navigator||!navigator.vendor?.includes("Google Inc")&&!/Chrome/.test(navigator.userAgent));let se=null;const oe=()=>{if(null!==se)return se;if("undefined"==typeof navigator)return null;const e=/\bChrome\/(\d+)/.exec(navigator.userAgent);return e?se=Number(e[1]):null},ce=(e,t)=>-1!==e?e:t,de=(e,t,r,i)=>e<=i&&r<=t,le=function*(e){for(const t in e){const r=e[t];void 0!==r&&(yield{key:t,value:r})}},ue=e=>{switch(e.toLowerCase()){case"image/jpeg":case"image/jpg":return".jpg";case"image/png":return".png";case"image/gif":return".gif";case"image/webp":return".webp";case"image/bmp":return".bmp";case"image/svg+xml":return".svg";case"image/tiff":return".tiff";case"image/avif":return".avif";case"image/x-icon":case"image/vnd.microsoft.icon":return".ico";default:return null}},he=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r},fe=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},me=()=>{Symbol.dispose??=Symbol("Symbol.dispose")},pe=e=>"number"==typeof e&&!Number.isNaN(e),ge=(e,t)=>{if(t.includes("://"))return t;if(e.includes("://")){const t=e.indexOf("?");-1!==t&&(e=e.slice(0,t))}let r;if(t.startsWith("/")){const i=e.indexOf("://");if(-1===i)r=t;else{const n=e.indexOf("/",i+3);r=-1===n?e+t:e.slice(0,n)+t}}else{const i=e.lastIndexOf("/");r=-1===i?t:e.slice(0,i+1)+t}let i="";const n=r.indexOf("://");if(-1!==n){const e=r.indexOf("/",n+3);-1!==e&&(i=r.slice(0,e),r=r.slice(e))}const a=r.split("/"),s=[];for(const e of a)".."===e?s.pop():"."!==e&&s.push(e);return i+s.join("/")},ye=(e,t)=>{let r=0;for(let i=0;i<e.length;i++)t(e[i])&&r++;return r},be=(e,t)=>{let r=-1,i=1/0;for(let n=0;n<e.length;n++){const a=t(e[n]);a<i&&(i=a,r=n)}return r},we=e=>{l(Number.isInteger(e.num)),l(Number.isInteger(e.den)),l(0!==e.den);let t=Math.abs(e.num),r=Math.abs(e.den);for(;0!==r;){const e=t%r;t=r,r=e}const i=t||1;return{num:e.num/i,den:e.den/i}},ve=(e,t)=>{if("object"!=typeof e||!e)throw new TypeError(`${t} must be an object.`);if(!Number.isInteger(e.left)||e.left<0)throw new TypeError(`${t}.left must be a non-negative integer.`);if(!Number.isInteger(e.top)||e.top<0)throw new TypeError(`${t}.top must be a non-negative integer.`);if(!Number.isInteger(e.width)||e.width<0)throw new TypeError(`${t}.width must be a non-negative integer.`);if(!Number.isInteger(e.height)||e.height<0)throw new TypeError(`${t}.height must be a non-negative integer.`)};new Map,new Map;const ke=e=>new Promise(t=>setTimeout(t,e)),Te=e=>Array.isArray(e)?e:[e];class xe{constructor(){this._listeners=new Map}on(e,t,r){this._listeners.has(e)||this._listeners.set(e,new Set);const i={fn:t,once:r?.once??!1};return this._listeners.get(e).add(i),()=>{this._listeners.get(e)?.delete(i)}}_emit(...e){const[t,r]=e,i=this._listeners.get(t);if(i)for(const e of i){try{e.fn(r)}catch(e){console.error(e)}e.once&&i.delete(e)}}}const Se=e=>2*Math.ceil(e/2);const Ce=e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).every(e=>"string"==typeof e);const Pe=["avc","hevc","vp9","av1","vp8"],Ae=["pcm-s16","pcm-s16be","pcm-s24","pcm-s24be","pcm-s32","pcm-s32be","pcm-f32","pcm-f32be","pcm-f64","pcm-f64be","pcm-u8","pcm-s8","ulaw","alaw"],Ee=["aac","opus","mp3","vorbis","flac","ac3","eac3"],Ie=[...Ee,...Ae],$e=["webvtt"],_e=[{maxMacroblocks:99,maxBitrate:64e3,maxDpbMbs:396,level:10},{maxMacroblocks:396,maxBitrate:192e3,maxDpbMbs:900,level:11},{maxMacroblocks:396,maxBitrate:384e3,maxDpbMbs:2376,level:12},{maxMacroblocks:396,maxBitrate:768e3,maxDpbMbs:2376,level:13},{maxMacroblocks:396,maxBitrate:2e6,maxDpbMbs:2376,level:20},{maxMacroblocks:792,maxBitrate:4e6,maxDpbMbs:4752,level:21},{maxMacroblocks:1620,maxBitrate:4e6,maxDpbMbs:8100,level:22},{maxMacroblocks:1620,maxBitrate:1e7,maxDpbMbs:8100,level:30},{maxMacroblocks:3600,maxBitrate:14e6,maxDpbMbs:18e3,level:31},{maxMacroblocks:5120,maxBitrate:2e7,maxDpbMbs:20480,level:32},{maxMacroblocks:8192,maxBitrate:2e7,maxDpbMbs:32768,level:40},{maxMacroblocks:8192,maxBitrate:5e7,maxDpbMbs:32768,level:41},{maxMacroblocks:8704,maxBitrate:5e7,maxDpbMbs:34816,level:42},{maxMacroblocks:22080,maxBitrate:135e6,maxDpbMbs:110400,level:50},{maxMacroblocks:36864,maxBitrate:24e7,maxDpbMbs:184320,level:51},{maxMacroblocks:36864,maxBitrate:24e7,maxDpbMbs:184320,level:52},{maxMacroblocks:139264,maxBitrate:24e7,maxDpbMbs:696320,level:60},{maxMacroblocks:139264,maxBitrate:48e7,maxDpbMbs:696320,level:61},{maxMacroblocks:139264,maxBitrate:8e8,maxDpbMbs:696320,level:62}],Ne=[{maxPictureSize:36864,maxBitrate:128e3,tier:"L",level:30},{maxPictureSize:122880,maxBitrate:15e5,tier:"L",level:60},{maxPictureSize:245760,maxBitrate:3e6,tier:"L",level:63},{maxPictureSize:552960,maxBitrate:6e6,tier:"L",level:90},{maxPictureSize:983040,maxBitrate:1e7,tier:"L",level:93},{maxPictureSize:2228224,maxBitrate:12e6,tier:"L",level:120},{maxPictureSize:2228224,maxBitrate:3e7,tier:"H",level:120},{maxPictureSize:2228224,maxBitrate:2e7,tier:"L",level:123},{maxPictureSize:2228224,maxBitrate:5e7,tier:"H",level:123},{maxPictureSize:8912896,maxBitrate:25e6,tier:"L",level:150},{maxPictureSize:8912896,maxBitrate:1e8,tier:"H",level:150},{maxPictureSize:8912896,maxBitrate:4e7,tier:"L",level:153},{maxPictureSize:8912896,maxBitrate:16e7,tier:"H",level:153},{maxPictureSize:8912896,maxBitrate:6e7,tier:"L",level:156},{maxPictureSize:8912896,maxBitrate:24e7,tier:"H",level:156},{maxPictureSize:35651584,maxBitrate:6e7,tier:"L",level:180},{maxPictureSize:35651584,maxBitrate:24e7,tier:"H",level:180},{maxPictureSize:35651584,maxBitrate:12e7,tier:"L",level:183},{maxPictureSize:35651584,maxBitrate:48e7,tier:"H",level:183},{maxPictureSize:35651584,maxBitrate:24e7,tier:"L",level:186},{maxPictureSize:35651584,maxBitrate:8e8,tier:"H",level:186}],Re=[{maxPictureSize:36864,maxBitrate:2e5,level:10},{maxPictureSize:73728,maxBitrate:8e5,level:11},{maxPictureSize:122880,maxBitrate:18e5,level:20},{maxPictureSize:245760,maxBitrate:36e5,level:21},{maxPictureSize:552960,maxBitrate:72e5,level:30},{maxPictureSize:983040,maxBitrate:12e6,level:31},{maxPictureSize:2228224,maxBitrate:18e6,level:40},{maxPictureSize:2228224,maxBitrate:3e7,level:41},{maxPictureSize:8912896,maxBitrate:6e7,level:50},{maxPictureSize:8912896,maxBitrate:12e7,level:51},{maxPictureSize:8912896,maxBitrate:18e7,level:52},{maxPictureSize:35651584,maxBitrate:18e7,level:60},{maxPictureSize:35651584,maxBitrate:24e7,level:61},{maxPictureSize:35651584,maxBitrate:48e7,level:62}],Oe=[{maxPictureSize:147456,maxBitrate:15e5,tier:"M",level:0},{maxPictureSize:278784,maxBitrate:3e6,tier:"M",level:1},{maxPictureSize:665856,maxBitrate:6e6,tier:"M",level:4},{maxPictureSize:1065024,maxBitrate:1e7,tier:"M",level:5},{maxPictureSize:2359296,maxBitrate:12e6,tier:"M",level:8},{maxPictureSize:2359296,maxBitrate:3e7,tier:"H",level:8},{maxPictureSize:2359296,maxBitrate:2e7,tier:"M",level:9},{maxPictureSize:2359296,maxBitrate:5e7,tier:"H",level:9},{maxPictureSize:8912896,maxBitrate:3e7,tier:"M",level:12},{maxPictureSize:8912896,maxBitrate:1e8,tier:"H",level:12},{maxPictureSize:8912896,maxBitrate:4e7,tier:"M",level:13},{maxPictureSize:8912896,maxBitrate:16e7,tier:"H",level:13},{maxPictureSize:8912896,maxBitrate:6e7,tier:"M",level:14},{maxPictureSize:8912896,maxBitrate:24e7,tier:"H",level:14},{maxPictureSize:35651584,maxBitrate:6e7,tier:"M",level:15},{maxPictureSize:35651584,maxBitrate:24e7,tier:"H",level:15},{maxPictureSize:35651584,maxBitrate:6e7,tier:"M",level:16},{maxPictureSize:35651584,maxBitrate:24e7,tier:"H",level:16},{maxPictureSize:35651584,maxBitrate:1e8,tier:"M",level:17},{maxPictureSize:35651584,maxBitrate:48e7,tier:"H",level:17},{maxPictureSize:35651584,maxBitrate:16e7,tier:"M",level:18},{maxPictureSize:35651584,maxBitrate:8e8,tier:"H",level:18},{maxPictureSize:35651584,maxBitrate:16e7,tier:"M",level:19},{maxPictureSize:35651584,maxBitrate:8e8,tier:"H",level:19}],Fe=".01.01.01.01.00",Be=".0.110.01.01.01.0",De=(e,t,r,i)=>{if("avc"===e){const e=100,n=Math.ceil(t/16)*Math.ceil(r/16),a=_e.find(e=>n<=e.maxMacroblocks&&i<=e.maxBitrate)??h(_e),s=a?a.level:0;return`avc1.${e.toString(16).padStart(2,"0")}${"00"}${s.toString(16).padStart(2,"0")}`}if("hevc"===e){const e="",n=1,a="6",s=t*r,o=Ne.find(e=>s<=e.maxPictureSize&&i<=e.maxBitrate)??h(Ne),c="B0";return`hev1.${e}${n}.${a}.${o.tier}${o.level}.${c}`}if("vp8"===e)return"vp8";if("vp9"===e){const e=t*r,n="08";return`vp09.${"00"}.${(Re.find(t=>e<=t.maxPictureSize&&i<=t.maxBitrate)??h(Re)).level.toString().padStart(2,"0")}.${n}`}if("av1"===e){const e=0,n=t*r,a=Oe.find(e=>n<=e.maxPictureSize&&i<=e.maxBitrate)??h(Oe),s="08";return`av01.${e}.${a.level.toString().padStart(2,"0")}${a.tier}.${s}`}throw new TypeError(`Unhandled codec '${e}'.`)},Me=e=>{const t=e.split(".");return[1,1,Number(t[1]),2,1,Number(t[2]),3,1,Number(t[3]),4,1,t[4]?Number(t[4]):1]},je=e=>{const t=e.split("."),r=Number(t[1]),i=t[2];return[129,(r<<5)+Number(i.slice(0,-1)),(("H"===i.slice(-1)?1:0)<<7)+((8===Number(t[3])?0:1)<<6)+0+((t[4]?Number(t[4]):0)<<4)+((t[5]?Number(t[5][0]):1)<<3)+((t[5]?Number(t[5][1]):1)<<2)+(t[5]?Number(t[5][2]):0),0]},Le=e=>{const{codec:t,codecDescription:r,colorSpace:i,avcCodecInfo:n,hevcCodecInfo:a,vp9CodecInfo:s,av1CodecInfo:o}=e;if("avc"===t){if(l(null!==e.avcType),n){const t=new Uint8Array([n.avcProfileIndication,n.profileCompatibility,n.avcLevelIndication]);return`avc${e.avcType}.${_(t)}`}if(!r||r.byteLength<4)throw new TypeError("AVC decoder description is not provided or is not at least 4 bytes long.");return`avc${e.avcType}.${_(r.subarray(1,4))}`}if("hevc"===t){let e,t,i,n,s,o;if(a)e=a.generalProfileSpace,t=a.generalProfileIdc,i=N(a.generalProfileCompatibilityFlags),n=a.generalTierFlag,s=a.generalLevelIdc,o=[...a.generalConstraintIndicatorFlags];else{if(!r||r.byteLength<23)throw new TypeError("HEVC decoder description is not provided or is not at least 23 bytes long.");const a=y(r),c=a.getUint8(1);e=c>>6&3,t=31&c,i=N(a.getUint32(2)),n=c>>5&1,s=a.getUint8(12),o=[];for(let e=0;e<6;e++)o.push(a.getUint8(6+e))}let c="hev1.";for(c+=["","A","B","C"][e]+t,c+=".",c+=i.toString(16).toUpperCase(),c+=".",c+=0===n?"
1L":"H",c+=s;o.length>0&&0===o[o.length-1];)o.pop();return o.length>0&&(c+=".",c+=o.map(e=>e.toString(16).toUpperCase()).join(".")),c}if("vp8"===t)return"vp8";if("vp9"===t){if(!s){const t=e.width*e.height;let r=h(Re).level;for(const e of Re)if(t<=e.maxPictureSize){r=e.level;break}return`vp09.00.${r.toString().padStart(2,"0")}.08`}let t=`vp09.${s.profile.toString().padStart(2,"0")}.${s.level.toString().padStart(2,"0")}.${s.bitDepth.toString().padStart(2,"0")}.${s.chromaSubsampling.toString().padStart(2,"0")}`;return t+=`.${s.colourPrimaries.toString().padStart(2,"0")}.${s.transferCharacteristics.toString().padStart(2,"0")}.${s.matrixCoefficients.toString().padStart(2,"0")}.${s.videoFullRangeFlag.toString().padStart(2,"0")}`,t.endsWith(Fe)&&(t=t.slice(0,-15)),t}if("av1"===t){if(!o){const t=e.width*e.height;let r=h(Re).level;for(const e of Re)if(t<=e.maxPictureSize){r=e.level;break}return`av01.0.${r.toString().padStart(2,"0")}M.08`}const t=o.profile,r=o.level.toString().padStart(2,"0"),n=o.tier?"H":"M",a=o.bitDepth.toString().padStart(2,"0"),s=o.monochrome?"1":"0",c=100*o.chromaSubsamplingX+10*o.chromaSubsamplingY+1*(o.chromaSubsamplingX&&o.chromaSubsamplingY?o.chromaSamplePosition:0),d=i?.primaries?k[i.primaries]:1,l=i?.transfer?x[i.transfer]:1,u=i?.matrix?C[i.matrix]:1,f=i?.fullRange?1:0;let m=`av01.${t}.${r}${n}.${a}`;return m+=`.${s}.${c.toString().padStart(3,"0")}`,m+=`.${d.toString().padStart(2,"0")}`,m+=`.${l.toString().padStart(2,"0")}`,m+=`.${u.toString().padStart(2,"0")}`,m+=`.${f}`,m.endsWith(Be)&&(m=m.slice(0,-17)),m}throw new TypeError(`Unhandled codec '${t}'.`)},Ue=(e,t,r)=>{if("aac"===e)return t>=2&&r<=24e3?"mp4a.40.29":r<=24e3?"mp4a.40.5":"mp4a.40.2";if("mp3"===e)return"mp3";if("opus"===e)return"opus";if("vorbis"===e)return"vorbis";if("flac"===e)return"flac";if("ac3"===e)return"ac-3";if("eac3"===e)return"ec-3";if(Ae.includes(e))return e;throw new TypeError(`Unhandled codec '${e}'.`)},ze=e=>{const{codec:t,codecDescription:r,aacCodecInfo:i}=e;if("aac"===t){if(!i)throw new TypeError("AAC codec info must be provided.");if(i.isMpeg2)return"mp4a.67";{let e;if(null!==i.objectType)e=i.objectType;else{e=s(r).objectType}return`mp4a.40.${e}`}}if("mp3"===t)return"mp3";if("opus"===t)return"opus";if("vorbis"===t)return"vorbis";if("flac"===t)return"flac";if("ac3"===t)return"ac-3";if("eac3"===t)return"ec-3";if(t&&Ae.includes(t))return t;throw new TypeError(`Unhandled codec '${t}'.`)},We=/^pcm-([usf])(\d+)(be)?$/,Ve=e=>{if(l(Ae.includes(e)),"ulaw"===e)return{dataType:"ulaw",sampleSize:1,littleEndian:!0,silentValue:255};if("alaw"===e)return{dataType:"alaw",sampleSize:1,littleEndian:!0,silentValue:213};const t=We.exec(e);let r;l(t),r="u"===t[1]?"unsigned":"s"===t[1]?"signed":"float";return{dataType:r,sampleSize:Number(t[2])/8,littleEndian:"be"!==t[3],silentValue:"pcm-u8"===e?128:0}},qe=e=>e.startsWith("avc1")||e.startsWith("avc3")?"avc":e.startsWith("hev1")||e.startsWith("hvc1")?"hevc":"vp8"===e?"vp8":e.startsWith("vp09")?"vp9":e.startsWith("av01")?"av1":"mp3"===e||"mp4a.69"===e||"mp4a.6B"===e||"mp4a.6b"===e||"mp4a.40.34"===e?"mp3":e.startsWith("mp4a.40.")||"mp4a.67"===e?"aac":"opus"===e?"opus":"vorbis"===e?"vorbis":"flac"===e?"flac":"ac-3"===e||"ac3"===e?"ac3":"ec-3"===e||"eac3"===e?"eac3":"ulaw"===e?"ulaw":"alaw"===e?"alaw":We.test(e)?e:"webvtt"===e?"webvtt":null,He=["avc1","avc3","hev1","hvc1","vp8","vp09","av01"],Ge=/^(avc1|avc3)\.[0-9a-fA-F]{6}$/,Ke=/^(hev1|hvc1)\.(?:[ABC]?\d+)\.[0-9a-fA-F]{1,8}\.[LH]\d+(?:\.[0-9a-fA-F]{1,2}){0,6}$/,Ye=/^vp09(?:\.\d{2}){3}(?:(?:\.\d{2}){5})?$/,Xe=/^av01\.\d\.\d{2}[MH]\.\d{2}(?:\.\d\.\d{3}\.\d{2}\.\d{2}\.\d{2}\.\d)?$/,Qe=e=>{if(!e)throw new TypeError("Video chunk metadata must be provided.");if("object"!=typeof e)throw new TypeError("Video chunk metadata must be an object.");if(!e.decoderConfig)throw new TypeError("Video chunk metadata must include a decoder configuration.");if("object"!=typeof e.decoderConfig)throw new TypeError("Video chunk metadata decoder configuration must be an object.");if("string"!=typeof e.decoderConfig.codec)throw new TypeError("Video chunk metadata decoder configuration must specify a codec string.");if(!He.some(t=>e.decoderConfig.codec.startsWith(t)))throw new TypeError("Video chunk metadata decoder configuration codec string must be a valid video codec string as specified in the Mediabunny Codec Registry.");if(!Number.isInteger(e.decoderConfig.codedWidth)||e.decoderConfig.codedWidth<=0)throw new TypeError("Video chunk metadata decoder configuration must specify a valid codedWidth (positive integer).");if(!Number.isInteger(e.decoderConfig.codedHeight)||e.decoderConfig.codedHeight<=0)throw new TypeError("Video chunk metadata decoder configuration must specify a valid codedHeight (positive integer).");if(void 0!==e.decoderConfig.displayAspectWidth&&(!Number.isInteger(e.decoderConfig.displayAspectWidth)||e.decoderConfig.displayAspectWidth<=0))throw new TypeError("Video chunk metadata decoder configuration displayAspectWidth, when defined, must be a positive integer.");if(void 0!==e.decoderConfig.displayAspectHeight&&(!Number.isInteger(e.decoderConfig.displayAspectHeight)||e.decoderConfig.displayAspectHeight<=0))throw new TypeError("Video chunk metadata decoder configuration displayAspectHeight, when defined, must be a positive integer.");if(void 0!==e.decoderConfig.displayAspectWidth!=(void 0!==e.decoderConfig.displayAspectHeight))throw new TypeError("Video chunk metadata decoder configuration must specify both displayAspectWidth and displayAspectHeight, or neither.");if(void 0!==e.decoderConfig.description&&!E(e.decoderConfig.description))throw new TypeError("Video chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");if(void 0!==e.decoderConfig.colorSpace){const{colorSpace:t}=e.decoderConfig;if("object"!=typeof t)throw new TypeError("Video chunk metadata decoder configuration colorSpace, when provided, must be an object.");const r=Object.keys(k);if(null!=t.primaries&&!r.includes(t.primaries))throw new TypeError(`Video chunk metadata decoder configuration colorSpace primaries, when defined, must be one of ${r.join(", ")}.`);const i=Object.keys(x);if(null!=t.transfer&&!i.includes(t.transfer))throw new TypeError(`Video chunk metadata decoder configuration colorSpace transfer, when defined, must be one of ${i.join(", ")}.`);const n=Object.keys(C);if(null!=t.matrix&&!n.includes(t.matrix))throw new TypeError(`Video chunk metadata decoder configuration colorSpace matrix, when defined, must be one of ${n.join(", ")}.`);
1if(null!=t.fullRange&&"boolean"!=typeof t.fullRange)throw new TypeError("Video chunk metadata decoder configuration colorSpace fullRange, when defined, must be a boolean.")}if(e.decoderConfig.codec.startsWith("avc1")||e.decoderConfig.codec.startsWith("avc3")){if(!Ge.test(e.decoderConfig.codec))throw new TypeError("Video chunk metadata decoder configuration codec string for AVC must be a valid AVC codec string as specified in Section 3.4 of RFC 6381.")}else if(e.decoderConfig.codec.startsWith("hev1")||e.decoderConfig.codec.startsWith("hvc1")){if(!Ke.test(e.decoderConfig.codec))throw new TypeError("Video chunk metadata decoder configuration codec string for HEVC must be a valid HEVC codec string as specified in Section E.3 of ISO 14496-15.")}else if(e.decoderConfig.codec.startsWith("vp8")){if("vp8"!==e.decoderConfig.codec)throw new TypeError('Video chunk metadata decoder configuration codec string for VP8 must be "vp8".')}else if(e.decoderConfig.codec.startsWith("vp09")){if(!Ye.test(e.decoderConfig.codec))throw new TypeError('Video chunk metadata decoder configuration codec string for VP9 must be a valid VP9 codec string as specified in Section "Codecs Parameter String" of https://www.webmproject.org/vp9/mp4/.')}else if(e.decoderConfig.codec.startsWith("av01")&&!Xe.test(e.decoderConfig.codec))throw new TypeError('Video chunk metadata decoder configuration codec string for AV1 must be a valid AV1 codec string as specified in Section "Codecs Parameter String" of https://aomediacodec.github.io/av1-isobmff/.')},Je=["mp4a","mp3","opus","vorbis","flac","ulaw","alaw","pcm","ac-3","ec-3"],Ze=e=>{if(!e)throw new TypeError("Audio chunk metadata must be provided.");if("object"!=typeof e)throw new TypeError("Audio chunk metadata must be an object.");if(!e.decoderConfig)throw new TypeError("Audio chunk metadata must include a decoder configuration.");if("object"!=typeof e.decoderConfig)throw new TypeError("Audio chunk metadata decoder configuration must be an object.");if("string"!=typeof e.decoderConfig.codec)throw new TypeError("Audio chunk metadata decoder configuration must specify a codec string.");if(!Je.some(t=>e.decoderConfig.codec.startsWith(t)))throw new TypeError("Audio chunk metadata decoder configuration codec string must be a valid audio codec string as specified in the Mediabunny Codec Registry.");if(!Number.isInteger(e.decoderConfig.sampleRate)||e.decoderConfig.sampleRate<=0)throw new TypeError("Audio chunk metadata decoder configuration must specify a valid sampleRate (positive integer).");if(!Number.isInteger(e.decoderConfig.numberOfChannels)||e.decoderConfig.numberOfChannels<=0)throw new TypeError("Audio chunk metadata decoder configuration must specify a valid numberOfChannels (positive integer).");if(void 0!==e.decoderConfig.description&&!E(e.decoderConfig.description))throw new TypeError("Audio chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");if(e.decoderConfig.codec.startsWith("mp4a")&&"mp4a.69"!==e.decoderConfig.codec&&"mp4a.6B"!==e.decoderConfig.codec&&"mp4a.6b"!==e.decoderConfig.codec){if(!["mp4a.40.2","mp4a.40.02","mp4a.40.5","mp4a.40.05","mp4a.40.29","mp4a.67"].includes(e.decoderConfig.codec))throw new TypeError("Audio chunk metadata decoder configuration codec string for AAC must be a valid AAC codec string as specified in https://www.w3.org/TR/webcodecs-aac-codec-registration/.")}else if(e.decoderConfig.codec.startsWith("mp3")||e.decoderConfig.codec.startsWith("mp4a")){if("mp3"!==e.decoderConfig.codec&&"mp4a.69"!==e.decoderConfig.codec&&"mp4a.6B"!==e.decoderConfig.codec&&"mp4a.6b"!==e.decoderConfig.codec)throw new TypeError('Audio chunk metadata decoder configuration codec string for MP3 must be "mp3", "mp4a.69" or "mp4a.6B".')}else if(e.decoderConfig.codec.startsWith("opus")){if("opus"!==e.decoderConfig.codec)throw new TypeError('Audio chunk metadata decoder configuration codec string for Opus must be "opus".');if(e.decoderConfig.description&&e.decoderConfig.description.byteLength<18)throw new TypeError("Audio chunk metadata decoder configuration description, when specified, is expected to be an Identification Header as specified in Section 5.1 of RFC 7845.")}else if(e.decoderConfig.codec.startsWith("vorbis")){if("vorbis"!==e.decoderConfig.codec)throw new TypeError('Audio chunk metadata decoder configuration codec string for Vorbis must be "vorbis".');if(!e.decoderConfig.description)throw new TypeError("Audio chunk metadata decoder configuration for Vorbis must include a description, which is expected to adhere to the format described
1in https://www.w3.org/TR/webcodecs-vorbis-codec-registration/.")}else if(e.decoderConfig.codec.startsWith("flac")){if("flac"!==e.decoderConfig.codec)throw new TypeError('Audio chunk metadata decoder configuration codec string for FLAC must be "flac".');const t=42;if(!e.decoderConfig.description||e.decoderConfig.description.byteLength<t)throw new TypeError("Audio chunk metadata decoder configuration for FLAC must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-flac-codec-registration/.")}else if(e.decoderConfig.codec.startsWith("ac-3")||e.decoderConfig.codec.startsWith("ac3")){if("ac-3"!==e.decoderConfig.codec)throw new TypeError('Audio chunk metadata decoder configuration codec string for AC-3 must be "ac-3".')}else if(e.decoderConfig.codec.startsWith("ec-3")||e.decoderConfig.codec.startsWith("eac3")){if("ec-3"!==e.decoderConfig.codec)throw new TypeError('Audio chunk metadata decoder configuration codec string for EC-3 must be "ec-3".')}else if((e.decoderConfig.codec.startsWith("pcm")||e.decoderConfig.codec.startsWith("ulaw")||e.decoderConfig.codec.startsWith("alaw"))&&!Ae.includes(e.decoderConfig.codec))throw new TypeError(`Audio chunk metadata decoder configuration codec string for PCM must be one of the supported PCM codecs (${Ae.join(", ")}).`)},et=e=>{if(!e)throw new TypeError("Subtitle metadata must be provided.");if("object"!=typeof e)throw new TypeError("Subtitle metadata must be an object.");if(!e.config)throw new TypeError("Subtitle metadata must include a config object.");if("object"!=typeof e.config)throw new TypeError("Subtitle metadata config must be an object.");if("string"!=typeof e.config.description)throw new TypeError("Subtitle metadata config description must be a string.")},tt=[48e3,44100,32e3],rt=[24e3,22050,16e3];var it,nt;!function(e){e[e.NON_IDR_SLICE=1]="NON_IDR_SLICE",e[e.SLICE_DPA=2]="SLICE_DPA",e[e.SLICE_DPB=3]="SLICE_DPB",e[e.SLICE_DPC=4]="SLICE_DPC",e[e.IDR=5]="IDR",e[e.SEI=6]="SEI",e[e.SPS=7]="SPS",e[e.PPS=8]="PPS",e[e.AUD=9]="AUD",e[e.SPS_EXT=13]="SPS_EXT"}(it||(it={})),function(e){e[e.RASL_N=8]="RASL_N",e[e.RASL_R=9]="RASL_R",e[e.BLA_W_LP=16]="BLA_W_LP",e[e.RSV_IRAP_VCL23=23]="RSV_IRAP_VCL23",e[e.VPS_NUT=32]="VPS_NUT",e[e.SPS_NUT=33]="SPS_NUT",e[e.PPS_NUT=34]="PPS_NUT",e[e.AUD_NUT=35]="AUD_NUT",e[e.PREFIX_SEI_NUT=39]="PREFIX_SEI_NUT",e[e.SUFFIX_SEI_NUT=40]="SUFFIX_SEI_NUT"}(nt||(nt={}));const at=function*(e){let t=0,r=-1;for(;t<e.length-2;){const i=e.indexOf(0,t);if(-1===i||i>=e.length-2)break;t=i;let n=0;t+3<e.length&&0===e[t+1]&&0===e[t+2]&&1===e[t+3]?n=4:0===e[t+1]&&1===e[t+2]&&(n=3),0!==n?(-1!==r&&t>r&&(yield{offset:r,length:t-r}),r=t+n,t=r):t++}-1!==r&&r<e.length&&(yield{offset:r,length:e.length-r})},st=function*(e,t){let r=0;const i=new DataView(e.buffer,e.byteOffset,e.byteLength);for(;r+t<=e.length;){let e;1===t?e=i.getUint8(r):2===t?e=i.getUint16(r,!1):3===t?e=U(i,r,!1):(l(4===t),e=i.getUint32(r,!1)),r+=t,yield{offset:r,length:e},r+=e}},ot=(e,t)=>{if(t.description){const r=3&g(t.description)[4];return st(e,r+1)}return at(e)},ct=e=>31&e,dt=e=>{const t=[],r=e.length;for(let i=0;i<r;i++)i+2<r&&0===e[i]&&0===e[i+1]&&3===e[i+2]?(t.push(0,0),i+=2):t.push(e[i]);return new Uint8Array(t)},lt=new Uint8Array([0,0,0,1]),ut=e=>{const t=e.reduce((e,t)=>e+lt.byteLength+t.byteLength,0),r=new Uint8Array(t);let i=0;for(const t of e)r.set(lt,i),i+=lt.byteLength,r.set(t,i),i+=t.byteLength;return r},ht=(e,t)=>{const r=e.reduce((e,r)=>e+t+r.byteLength,0),i=new Uint8Array(r);let n=0;for(const r of e){const e=new DataView(i.buffer,i.byteOffset,i.byteLength);switch(t){case 1:e.setUint8(n,r.byteLength);break;case 2:e.setUint16(n,r.byteLength,!1);break;case 3:z(e,n,r.byteLength,!1);break;case 4:e.setUint32(n,r.byteLength,!1)}n+=t,i.set(r,n),n+=r.byteLength}return i},ft=e=>{try{const t=[],r=[],i=[];for(const n of at(e)){const a=e.subarray(n.offset,n.offset+n.length),s=ct(a[0]);s===it.SPS?t.push(a):s===it.PPS?r.push(a):s===it.SPS_EXT&&i.push(a)}if(0===t.length)return null;if(0===r.length)return null;const n=t[0],a=gt(n);l(null!==a);const s=100===a.profileIdc||110===a.profileIdc||122===a.profileIdc||144===a.profileIdc;return{configurationVersion:1,avcProfileIndication:a.profileIdc,profileCompatibility:a.constraintFlags,avcLevelIndication:a.levelIdc,lengthSizeMinusOne:3,sequenceParameterSets:t,pictureParameterSets:r,chromaFormat:s?a.chromaFormatIdc:null,bitDepthLumaMinus8:s?a.bitDepthLumaMinus8:null,bitDepthChromaMinus8:s?a.bitDepthChromaMinus8:null,sequenceParameterSetExt:s?i:null}}catch(e){return d._error("Error building AVC Decoder Configuration Record:",e),null}},mt=e=>{try{const t=y(e);let r=0;const i=t.getUint8(r++),n=t.getUint8(r++),a=t.getUint8(r++),s=t.getUint8(r++),o=3&t.getUint8(r++),c=31&t.getUint8(r++),d=[];for(let i=0;i<c;i++){const i=t.getUint16(r,!1);r+=2,d.push(e.subarray(r,r+i)),r+=i}const l=t.getUint8(r++),u=[];for(let i=0;i<l;i++){const i=t.getUint16(r,!1);r+=2,u.push(e.subarray(r,r+i)),r+=i}const h={configurationVersion:i,avcProfileIndication:n,profileCompatibility:a,avcLevelIndication:s,lengthSizeMinusOne:o,sequenceParameterSets:d,pictureParameterSets:u,chromaFormat:null,bitDepthLumaMinus8:null,bitDepthChromaMinus8:null,sequenceParameterSetExt:null};if((100===n||110===n||122===n||144===n)&&r+4<=e.length){const i=3&t.getUint8(r++),n=7&t.getUint8(r++),a=7&t.getUint8(r++),s=t.getUint8(r++);h.chromaFormat=i,h.bitDepthLumaMinus8=n,h.bitDepthChromaMinus8=a;const o=[];for(let i=0;i<s;i++){const i=t.getUint16(r,!1);r+=2,o.push(e.subarray(r,r+i)),r+=i}h.sequenceParameterSetExt=o}return h}catch(e){return d._error("Error deserializing AVC Decoder Configuration Record:",e),null}},pt={1:{num:1,den:1},2:{num:12,den:11},3:{num:10,den:11},4:{num:16,den:11},5:{num:40,den:33},6:{num:24,den:11},7:{num:20,den:11},8:{num:32,den:11},9:{num:80,den:33},10:{num:18,den:11},11:{num:15,den:11},12:{num:64,den:33},13:{num:160,den:99},14:{num:4,den:3},15:{num:3,den:2},16:{num:2,den:1}},gt=e=>{try{const t=new i(dt(e));t.skipBits(1),t.skipBits(2);if(7!==t.readBits(5))return null;const r=t.readAlignedByte(),n=t.readAlignedByte(),a=t.readAlignedByte();m(t);let s=1,o=0,c=0,d=0;if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r){s=m(t),3===s&&(d=t.readBits(1)),o=m(t),c=m(t),t.skipBits(1);if(t.readBits(1))for(let e=0;e<(3!==s?8:12);e++){if(t.readBits(1)){const r=e<6?16:64;let i=8,n=8;for(let e=0;e<r;e++){if(0!==n){n=(i+p(t)+256)%256}i=0===n?i:n}}}}m(t);const u=m(t);if(0===u)m(t);else if(1===u){t.skipBits(1),p(t),p(t);const e=m(t);for(let r=0;r<e;r++)p(t)}m(t),t.skipBits(1);const f=m(t),g=m(t),y=16*(f+1),b=16*(g+1);let w=y,v=b;
1const k=t.readBits(1);k||t.skipBits(1),t.skipBits(1);if(t.readBits(1)){const e=m(t),r=m(t),i=m(t),n=m(t);let a,o;if(0===(0===d?s:0))a=1,o=2-k;else{a=3===s?1:2,o=(1===s?2:1)*(2-k)}w-=a*(e+r),v-=o*(i+n)}let T=2,x=2,S=2,C=0,P={num:1,den:1},A=null,E=null;if(t.readBits(1)){if(t.readBits(1)){const e=t.readBits(8);if(255===e)P={num:t.readBits(16),den:t.readBits(16)};else{const t=pt[e];t&&(P=t)}}t.readBits(1)&&t.skipBits(1);if(t.readBits(1)){t.skipBits(3),C=t.readBits(1);t.readBits(1)&&(T=t.readBits(8),x=t.readBits(8),S=t.readBits(8))}t.readBits(1)&&(m(t),m(t));t.readBits(1)&&(t.skipBits(32),t.skipBits(32),t.skipBits(1));const e=t.readBits(1);e&&yt(t);const r=t.readBits(1);r&&yt(t),(e||r)&&t.skipBits(1),t.skipBits(1);t.readBits(1)&&(t.skipBits(1),m(t),m(t),m(t),m(t),A=m(t),E=m(t))}if(null===A){l(null===E);if(44!==r&&86!==r&&100!==r&&110!==r&&122!==r&&244!==r||!(16&n)){const e=f+1,t=(2-k)*(g+1),r=_e.find(e=>e.level>=a)??h(_e),i=Math.min(Math.floor(r.maxDpbMbs/(e*t)),16);A=i,E=i}else A=0,E=0}return l(null!==E),{profileIdc:r,constraintFlags:n,levelIdc:a,frameMbsOnlyFlag:k,chromaFormatIdc:s,bitDepthLumaMinus8:o,bitDepthChromaMinus8:c,codedWidth:y,codedHeight:b,displayWidth:w,displayHeight:v,pixelAspectRatio:P,colourPrimaries:T,matrixCoefficients:S,transferCharacteristics:x,fullRangeFlag:C,numReorderFrames:A,maxDecFrameBuffering:E}}catch(e){return d._error("Error parsing AVC SPS:",e),null}},yt=e=>{const t=m(e);e.skipBits(4),e.skipBits(4);for(let r=0;r<=t;r++)m(e),m(e),e.skipBits(1);e.skipBits(5),e.skipBits(5),e.skipBits(5),e.skipBits(5)},bt=(e,t)=>{if(t.description){const r=3&g(t.description)[21];return st(e,r+1)}return at(e)},wt=e=>e>>1&63,vt=e=>{try{const t=new i(dt(e));t.skipBits(16),t.readBits(4);const r=t.readBits(3),n=t.readBits(1),{general_profile_space:a,general_tier_flag:s,general_profile_idc:o,general_profile_compatibility_flags:c,general_constraint_indicator_flags:d,general_level_idc:l}=Tt(t,r);m(t);const u=m(t);let h=0;3===u&&(h=t.readBits(1));const f=m(t),p=m(t);let g=f,y=p;if(t.readBits(1)){const e=m(t),r=m(t),i=m(t),n=m(t);let a=1,s=1;const o=0===h?u:0;1===o?(a=2,s=2):2===o&&(a=2,s=1),g-=(e+r)*a,y-=(i+n)*s}const b=m(t),w=m(t);m(t);const v=t.readBits(1);let k=0;for(let e=v?0:r;e<=r;e++)m(t),k=m(t),m(t);m(t),m(t),m(t),m(t),m(t),m(t),t.readBits(1)&&t.readBits(1)&&xt(t),t.skipBits(1),t.skipBits(1),t.readBits(1)&&(t.skipBits(4),t.skipBits(4),m(t),m(t),t.skipBits(1));const T=m(t);if(St(t,T),t.readBits(1)){const e=m(t);for(let r=0;r<e;r++)m(t),t.skipBits(1)}t.skipBits(1),t.skipBits(1);let x=2,S=2,C=2,P=0,A=0,E={num:1,den:1};if(t.readBits(1)){const e=Pt(t,r);E=e.pixelAspectRatio,x=e.colourPrimaries,S=e.transferCharacteristics,C=e.matrixCoefficients,P=e.fullRangeFlag,A=e.minSpatialSegmentationIdc}return{displayWidth:g,displayHeight:y,pixelAspectRatio:E,colourPrimaries:x,transferCharacteristics:S,matrixCoefficients:C,fullRangeFlag:P,maxDecFrameBuffering:k+1,spsMaxSubLayersMinus1:r,spsTemporalIdNestingFlag:n,generalProfileSpace:a,generalTierFlag:s,generalProfileIdc:o,generalProfileCompatibilityFlags:c,generalConstraintIndicatorFlags:d,generalLevelIdc:l,chromaFormatIdc:u,bitDepthLumaMinus8:b,bitDepthChromaMinus8:w,minSpatialSegmentationIdc:A}}catch(e){return d._error("Error parsing HEVC SPS:",e),null}},kt=e=>{try{const t=[],r=[],n=[],a=[];for(const i of at(e)){const s=e.subarray(i.offset,i.offset+i.length),o=wt(s[0]);o===nt.VPS_NUT?t.push(s):o===nt.SPS_NUT?r.push(s):o===nt.PPS_NUT?n.push(s):o!==nt.PREFIX_SEI_NUT&&o!==nt.SUFFIX_SEI_NUT||a.push(s)}if(0===r.length||0===n.length)return null;const s=vt(r[0]);if(!s)return null;let o=0;if(n.length>0){const e=n[0],t=new i(dt(e));t.skipBits(16),m(t),m(t),t.skipBits(1),t.skipBits(1),t.skipBits(3),t.skipBits(1),t.skipBits(1),m(t),m(t),p(t),t.skipBits(1),t.skipBits(1),t.readBits(1)&&m(t),p(t),p(t),t.skipBits(1),t.skipBits(1),t.skipBits(1),t.skipBits(1);const r=t.readBits(1),a=t.readBits(1);o=r||a?r&&!a?2:!r&&a?3:0:0}const c=[...t.length?[{arrayCompleteness:1,nalUnitType:nt.VPS_NUT,nalUnits:t}]:[],...r.length?[{arrayCompleteness:1,nalUnitType:nt.SPS_NUT,nalUnits:r}]:[],...n.length?[{arrayCompleteness:1,nalUnitType:nt.PPS_NUT,nalUnits:n}]:[],...a.length?[{arrayCompleteness:1,nalUnitType:wt(a[0][0]),nalUnits:a}]:[]];return{configurationVersion:1,generalProfileSpace:s.generalProfileSpace,generalTierFlag:s.generalTierFlag,generalProfileIdc:s.generalProfileIdc,generalProfileCompatibilityFlags:s.generalProfileCompatibilityFlags,generalConstraintIndicatorFlags:s.generalConstraintIndicatorFlags,generalLevelIdc:s.generalLevelIdc,minSpatialSegmentationIdc:s.minSpatialSegmentationIdc,parallelismType:o,chromaFormatIdc:s.chromaFormatIdc,bitDepthLumaMinus8:s.bitDepthLumaMinus8,bitDepthChromaMinus8:s.bitDepthChromaMinus8,avgFrameRate:0,constantFrameRate:0,numTemporalLayers:s.spsMaxSubLayersMinus1+1,temporalIdNested:s.spsTemporalIdNestingFlag,lengthSizeMinusOne:3,arrays:c}}catch(e){return d._error("Error building HEVC Decoder Configuration Record:",e),null}},Tt=(e,t)=>{const r=e.readBits(2),i=e.readBits(1),n=e.readBits(5);let a=0;for(let t=0;t<32;t++)a=a<<1|e.readBits(1);const s=new Uint8Array(6);for(let t=0;t<6;t++)s[t]=e.readBits(8);const o=e.readBits(8),c=[],d=[];for(let r=0;r<t;r++)c.push(e.readBits(1)),d.push(e.readBits(1));if(t>0)for(let r=t;r<8;r++)e.skipBits(2);for(let r=0;r<t;r++)c[r]&&e.skipBits(88),d[r]&&e.skipBits(8);return{general_profile_space:r,general_tier_flag:i,general_profile_idc:n,general_profile_compatibility_flags:a,general_constraint_indicator_flags:s,general_level_idc:o}},xt=e=>{for(let t=0;t<4;t++)for(let r=0;r<(3===t?2:6);
1r++){if(e.readBits(1)){const r=Math.min(64,1<<4+(t<<1));t>1&&p(e);for(let t=0;t<r;t++)p(e)}else m(e)}},St=(e,t)=>{const r=[];for(let i=0;i<t;i++)r[i]=Ct(e,i,t,r)},Ct=(e,t,r,i)=>{let n=0,a=0,s=0;if(0!==t&&(a=e.readBits(1)),a){if(t===r){s=t-(m(e)+1)}else s=t-1;e.readBits(1),m(e);const a=i[s]??0;for(let t=0;t<=a;t++){e.readBits(1)||e.readBits(1)}n=i[s]}else{const t=m(e),r=m(e);for(let r=0;r<t;r++)m(e),e.readBits(1);for(let t=0;t<r;t++)m(e),e.readBits(1);n=t+r}return n},Pt=(e,t)=>{let r=2,i=2,n=2,a=0,s=0,o={num:1,den:1};if(e.readBits(1)){const t=e.readBits(8);if(255===t)o={num:e.readBits(16),den:e.readBits(16)};else{const e=pt[t];e&&(o=e)}}return e.readBits(1)&&e.readBits(1),e.readBits(1)&&(e.readBits(3),a=e.readBits(1),e.readBits(1)&&(r=e.readBits(8),i=e.readBits(8),n=e.readBits(8))),e.readBits(1)&&(m(e),m(e)),e.readBits(1),e.readBits(1),e.readBits(1),e.readBits(1)&&(m(e),m(e),m(e),m(e)),e.readBits(1)&&(e.readBits(32),e.readBits(32),e.readBits(1)&&m(e),e.readBits(1)&&At(e,!0,t)),e.readBits(1)&&(e.readBits(1),e.readBits(1),e.readBits(1),s=m(e),m(e),m(e),m(e),m(e)),{pixelAspectRatio:o,colourPrimaries:r,transferCharacteristics:i,matrixCoefficients:n,fullRangeFlag:a,minSpatialSegmentationIdc:s}},At=(e,t,r)=>{let i=!1,n=!1,a=!1;t&&(i=1===e.readBits(1),n=1===e.readBits(1),(i||n)&&(a=1===e.readBits(1),a&&(e.readBits(8),e.readBits(5),e.readBits(1),e.readBits(5)),e.readBits(4),e.readBits(4),a&&e.readBits(4),e.readBits(5),e.readBits(5),e.readBits(5)));for(let t=0;t<=r;t++){let t=!0;1===e.readBits(1)||(t=1===e.readBits(1));let r=!1;t?m(e):r=1===e.readBits(1);let s=1;if(!r){s=m(e)+1}i&&Et(e,s,a),n&&Et(e,s,a)}},Et=(e,t,r)=>{for(let i=0;i<t;i++)m(e),m(e),r&&(m(e),m(e)),e.readBits(1)};var It;!function(e){e[e.audAllowed=0]="audAllowed",e[e.beforeFirstVcl=1]="beforeFirstVcl",e[e.afterFirstVcl
1=2]="afterFirstVcl",e[e.eoBitstreamAllowed=3]="eoBitstreamAllowed",e[e.noMoreDataAllowed=4]="noMoreDataAllowed"}(It||(It={}));const $t=(e,t)=>{const r=new Set;let i=It.audAllowed;for(const n of bt(e,t)){if(i===It.noMoreDataAllowed){r.add(n.offset);continue}const t=wt(e[n.offset]);if(i===It.eoBitstreamAllowed&&37!==t){r.add(n.offset);continue}let a=!1;35===t?i>It.audAllowed?a=!0:i=It.beforeFirstVcl:t<=31?i>It.afterFirstVcl?a=!0:i=It.afterFirstVcl:36===t?i!==It.afterFirstVcl?a=!0:i=It.eoBitstreamAllowed:37===t?i<It.afterFirstVcl?a=!0:i=It.noMoreDataAllowed:32===t||33===t||34===t||39===t||t>=41&&t<=44||t>=48&&t<=55?i>It.beforeFirstVcl?a=!0:i=It.beforeFirstVcl:(38===t||40===t||t>=45&&t<=47||t>=56&&t<=63)&&i<It.afterFirstVcl&&(a=!0),a&&r.add(n.offset)}if(0===r.size)return null;const n=[];for(const i of bt(e,t))r.has(i.offset)||n.push(e.subarray(i.offset,i.offset+i.length));return((e,t)=>{if(t.description){const r=3&g(t.description)[21];return ht(e,r+1)}return ut(e)})(n,t)},_t=e=>{const t=new i(e);if(2!==t.readBits(2))return null;const r=t.readBits(1),n=(t.readBits(1)<<1)+r;3===n&&t.skipBits(1);if(1===t.readBits(1))return null;if(0!==t.readBits(1))return null;t.skipBits(2);if(4817730!==t.readBits(24))return null;let a=8;if(n>=2){a=t.readBits(1)?12:10}const s=t.readBits(3);let o=0,c=0;if(7!==s){if(c=t.readBits(1),1===n||3===n){const e=t.readBits(1),r=t.readBits(1);o=e||r?e&&!r?2:1:3,t.skipBits(1)}else o=1}else o=3,c=1;const d=(t.readBits(16)+1)*(t.readBits(16)+1);let l=h(Re).level;for(const e of Re)if(d<=e.maxPictureSize){l=e.level;break}return{profile:n,level:l,bitDepth:a,chromaSubsampling:o,videoFullRangeFlag:c,colourPrimaries:2===s?1:1===s?6:2,transferCharacteristics:2===s?1:1===s?6:2,matrixCoefficients:7===s?0:2===s?1:1===s?6:2}},Nt=function*(e){const t=new i(e),r=()=>{let e=0;for(let r=0;r<8;r++){const i=t.readAlignedByte();if(e|=(127&i)<<7*r,!(128&i))break;if(7===r&&128&i)return null}return e>=2**32-1?null:e};for(;t.getBitsLeft()>=8;){t.skipBits(1);const i=t.readBits(4),n=t.readBits(1),a=t.readBits(1);let s;if(t.skipBits(1),n&&t.skipBits(8),a){const e=r();if(null===e)return;s=e}else s=Math.floor(t.getBitsLeft()/8);l(t.pos%8==0),yield{type:i,data:e.subarray(t.pos/8,t.pos/8+s)},t.skipBits(8*s)}},Rt=e=>{for(const{type:t,data:r}of Nt(e)){if(1!==t)continue;const e=new i(r),n=e.readBits(3),a=(e.readBits(1),e.readBits(1));let s=0,o=0,c=0;if(a)s=e.readBits(5);else{if(e.readBits(1)){e.skipBits(32),e.skipBits(32);if(e.readBits(1))return null}const t=e.readBits(1);t&&(c=e.readBits(5),e.skipBits(32),e.skipBits(5),e.skipBits(5));const r=e.readBits(5);for(let i=0;i<=r;i++){e.skipBits(12);const r=e.readBits(5);if(0===i&&(s=r),r>7){const t=e.readBits(1);0===i&&(o=t)}if(t){if(e.readBits(1)){const t=c+1;e.skipBits(t),e.skipBits(t),e.skipBits(1)}}e.readBits(1)&&e.skipBits(4)}}const d=e.readBits(4),l=e.readBits(4),u=d+1;e.skipBits(u);const h=l+1;e.skipBits(h);let f=0;if(f=a?0:e.readBits(1),f&&(e.skipBits(4),e.skipBits(3)),e.skipBits(1),e.skipBits(1),e.skipBits(1),!a){e.skipBits(1),e.skipBits(1),e.skipBits(1),e.skipBits(1);const t=e.readBits(1);t&&(e.skipBits(1),e.skipBits(1));let r=0;if(r=e.readBits(1)?2:e.readBits(1),r>0){e.readBits(1)||e.skipBits(1)}t&&e.skipBits(3)}e.skipBits(1),e.skipBits(1),e.skipBits(1);const m=e.readBits(1);let p=8;if(2===n&&m){p=e.readBits(1)?12:10}else n<=2&&(p=m?10:8);let g=0;1!==n&&(g=e.readBits(1));let y=1,b=1,w=0;return g||(0===n?(y=1,b=1):1===n?(y=0,b=0):12===p&&(y=e.readBits(1),y&&(b=e.readBits(1))),y&&b&&(w=e.readBits(2))),{profile:n,level:s,tier:o,bitDepth:p,monochrome:g,chromaSubsamplingX:y,chromaSubsamplingY:b,chromaSamplePosition:w}}return null},Ot=e=>{const t=y(e),r=t.getUint8(9),i=t.getUint16(10,!0),n=t.getUint32(12,!0),a=t.getInt16(16,!0),s=t.getUint8(18);let o=null;return s&&(o=e.subarray(19,21+r)),{outputChannelCount:r,preSkip:i,inputSampleRate:n,outputGain:a,channelMappingFamily:s,channelMappingTable:o}},Ft=[480,960,1920,2880,480,960,1920,2880,480,960,1920,2880,480,960,480,960,120,240,480,960,120,240,480,960,120,240,480,960,120,240,480,960],Bt=e=>{if(e.length<7)throw new Error("Setup header is too short.");if(5!==e[0])throw new Error("Wrong packet type in Setup header.");if("vorbis"!==String.fromCharCode(...e.slice(1,7)))throw new Error("Invalid packet signature in Setup header.");const t=e.length,r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e[t-1-i];const n=new i(r);let a=0;for(;n.getBitsLeft()>97;)if(1===n.readBits(1)){a=n.pos;break}if(0===a)throw new Error("Invalid Setup header: framing bit not found.");let s=0,o=!1,c=0;for(;n.getBitsLeft()>=97;){const e=n.pos,t=n.readBits(8),r=n.readBits(16),i=n.readBits(16);if(t>63||0!==r||0!==i){n.pos=e;break}if(n.skipBits(1),s++,s>64)break;n.clone().readBits(6)+1===s&&(o=!0,c=s)}if(!o)throw new Error("Invalid Setup header: mode header not found.");if(c>63)throw new Error(`Unsupported mode count: ${c}.`);const d=c;n.pos=0,n.skipBits(a);const l=Array(d).fill(0);for(let e=d-1;e>=0;e--)n.skipBits(40),l[e]=n.readBits(1);return{modeBlockflags:l}},Dt=(e,t,r)=>{switch(e){case"avc":for(const e of ot(r,t)){const t=r[e.offset],n=ct(t);if(n>=it.NON_IDR_SLICE&&n<=it.SLICE_DPC)return"delta";if(n===it.IDR)return"key";if(n===it.SEI&&(!ae()||oe()>=144)){const t=r.subarray(e.offset,e.offset+e.length),n=dt(t);let a=1;do{let e=0;for(;;){const t=n[a++];if(void 0===t)break;
1if(e+=t,t<255)break}let t=0;for(;;){const e=n[a++];if(void 0===e)break;if(t+=e,e<255)break}if(e===6){const e=new i(n);e.pos=8*a;const t=m(e),r=e.readBits(1);if(0===t&&1===r)return"key"}a+=t}while(a<n.length-1)}}return"delta";case"hevc":for(const e of bt(r,t)){const t=wt(r[e.offset]);if(t<nt.BLA_W_LP)return"delta";if(t<=nt.RSV_IRAP_VCL23)return"key"}return"delta";case"vp8":return 0===(1&r[0])?"key":"delta";case"vp9":{const e=new i(r);if(2!==e.readBits(2))return null;const t=e.readBits(1);3===(e.readBits(1)<<1)+t&&e.skipBits(1);if(e.readBits(1))return null;return 0===e.readBits(1)?"key":"delta"}case"av1":{let e=!1;for(const{type:t,data:n}of Nt(r))if(1===t){const t=new i(n);t.skipBits(4),e=!!t.readBits(1)}else if(3===t||6===t||7===t){if(e)return"key";const t=new i(n);if(t.readBits(1))return null;return 0===t.readBits(2)?"key":"delta"}return null}default:L(e),l(!1)}};var Mt;!function(e){e[e.STREAMINFO=0]="STREAMINFO",e[e.VORBIS_COMMENT=4]="VORBIS_COMMENT",e[e.PICTURE=6]="PICTURE"}(Mt||(Mt={}));const jt=(e,t)=>{const r=y(e);let i=0;const n=r.getUint32(i,!0);i+=4;const a=b.decode(e.subarray(i,i+n));i+=n,n>0&&(t.raw??={},t.raw.vendor??=a);const s=r.getUint32(i,!0);i+=4;for(let n=0;n<s;n++){const n=r.getUint32(i,!0);i+=4;const a=b.decode(e.subarray(i,i+n));i+=n;const s=a.indexOf("=");if(-1===s)continue;const o=a.slice(0,s).toUpperCase(),c=a.slice(s+1);switch(t.raw??={},t.raw[o]??=c,o){case"TITLE":t.title??=c;break;case"DESCRIPTION":t.description??=c;break;case"ARTIST":t.artist??=c;break;case"ALBUM":t.album??=c;break;case"ALBUMARTIST":t.albumArtist??=c;break;case"COMMENT":t.comment??=c;break;case"LYRICS":t.lyrics??=c;break;case"TRACKNUMBER":{const e=c.split("/"),r=Number.parseInt(e[0],10),i=e[1]&&Number.parseInt(e[1],10);Number.isInteger(r)&&r>0&&(t.trackNumber??=r),i&&Number.isInteger(i)&&i>0&&(t.tracksTotal??=i)}break;case"TRACKTOTAL":{const e=Number.parseInt(c,10);Number.isInteger(e)&&e>0&&(t.tracksTotal??=e)}break;case"DISCNUMBER":{const e=c.split("/"),r=Number.parseInt(e[0],10),i=e[1]&&Number.parseInt(e[1],10);Number.isInteger(r)&&r>0&&(t.discNumber??=r),i&&Number.isInteger(i)&&i>0&&(t.discsTotal??=i)}break;case"DISCTOTAL":{const e=Number.parseInt(c,10);Number.isInteger(e)&&e>0&&(t.discsTotal??=e)}break;case"DATE":{const e=new Date(c);Number.isNaN(e.getTime())||(t.date??=e)}break;case"GENRE":t.genre??=c;break;case"METADATA_BLOCK_PICTURE":{const e=he(c),r=y(e),i=r.getUint32(0,!1),n=r.getUint32(4,!1),a=String.fromCharCode(...e.subarray(8,8+n)),s=r.getUint32(8+n,!1),o=b.decode(e.subarray(12+n,12+n+s)),d=r.getUint32(n+s+28),l=e.subarray(n+s+32,n+s+32+d);t.images??=[],t.images.push({data:l,mimeType:a,kind:3===i?"coverFront":4===i?"coverBack":"unknown",name:void 0,description:o||void 0})}}}},Lt=[2,1,2,3,3,4,4,5],Ut=e=>{if(e.length<7)return null;if(11!==e[0]||119!==e[1])return null;const t=new i(e);t.skipBits(16),t.skipBits(16);const r=t.readBits(2);if(3===r)return null;const n=t.readBits(6),a=t.readBits(5);if(a>8)return null;const s=t.readBits(3),o=t.readBits(3);1&o&&1!==o&&t.skipBits(2),4&o&&t.skipBits(2),2===o&&t.skipBits(2);return{fscod:r,bsid:a,bsmod:s,acmod:o,lfeon:t.readBits(1),bitRateCode:Math.floor(n/2)}},zt=[128,138,192,128,140,192,160,174,240,160,176,240,192,208,288,192,210,288,224,242,336,224,244,336,256,278,384,256,280,384,320,348,480,320,350,480,384,416,576,384,418,576,448,486,672,448,488,672,512,556,768,512,558,768,640,696,960,640,698,960,768,834,1152,768,836,1152,896,974,1344,896,976,1344,1024,1114,1536,1024,1116,1536,1280,1392,1920,1280,1394,1920,1536,1670,2304,1536,1672,2304,1792,1950,2688,1792,1952,2688,2048,2228,3072,2048,2230,3072,2304,2506,3456,2304,2508,3456,2560,2786,3840,2560,2788,3840],Wt=(new Uint8Array([5,4,65,67,45,51]),new Uint8Array([5,4,69,65,67,51]),[1,2,3,6]),Vt=e=>{if(e.length<6)return null;if(11!==e[0]||119!==e[1])return null;const t=new i(e);t.skipBits(16);const r=t.readBits(2);if(t.skipBits(3),0!==r&&2!==r)return null;const n=t.readBits(11),a=t.readBits(2);let s,o=0;3===a?(o=t.readBits(2),s=3):s=t.readBits(2);const c=t.readBits(3),d=t.readBits(1),l=t.readBits(5);if(l<11||l>16)return null;const u=Wt[s];let h;h=a<3?tt[a]/1e3:rt[o]/1e3;return{dataRate:Math.round((n+1)*h/(16*u)),substreams:[{fscod:a,fscod2:o,bsid:l,bsmod:0,acmod:c,lfeon:d,numDepSub:0,chanLoc:0}]}},qt=e=>{const t=e.substreams[0];return l(t),t.fscod<3?tt[t.fscod]:null!==t.fscod2&&t.fscod2<3?rt[t.fscod2]:null},Ht=e=>{const t=e.substreams[0];l(t);let r=Lt[t.acmod]+t.lfeon;if(t.numDepSub>0){const e=[2,2,1,1,2,2,2,1,1];for(let i=0;i<9;i++)t.chanLoc&1<<8-i&&(r+=e[i])}return r};class Gt{constructor(e){this.input=e}dispose(){}}
1const Kt=new Uint8Array(0);class Yt{constructor(e,t,r,i,n=-1,a,s){if(this.data=e,this.type=t,this.timestamp=r,this.duration=i,this.sequenceNumber=n,e===Kt&&void 0===a)throw new Error("Internal error: byteLength must be explicitly provided when constructing metadata-only packets.");if(void 0===a&&(a=e.byteLength),!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if("key"!==t&&"delta"!==t)throw new TypeError('type must be either "key" or "delta".');if(!Number.isFinite(r))throw new TypeError("timestamp must be a number.");if(!Number.isFinite(i)||i<0)throw new TypeError("duration must be a non-negative number.");if(!Number.isFinite(n))throw new TypeError("sequenceNumber must be a number.");if(!Number.isInteger(a)||a<0)throw new TypeError("byteLength must be a non-negative integer.");if(void 0!==s&&("object"!=typeof s||!s))throw new TypeError("sideData, when provided, must be an object.");if(void 0!==s?.alpha&&!(s.alpha instanceof Uint8Array))throw new TypeError("sideData.alpha, when provided, must be a Uint8Array.");if(void 0!==s?.alphaByteLength&&(!Number.isInteger(s.alphaByteLength)||s.alphaByteLength<0))throw new TypeError("sideData.alphaByteLength, when provided, must be a non-negative integer.");this.byteLength=a,this.sideData=s??{},this.sideData.alpha&&void 0===this.sideData.alphaByteLength&&(this.sideData.alphaByteLength=this.sideData.alpha.byteLength)}get isMetadataOnly(){return this.data===Kt}get microsecondTimestamp(){return Math.trunc(J*this.timestamp)}get microsecondDuration(){return Math.trunc(J*this.duration)}toEncodedVideoChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if("undefined"==typeof EncodedVideoChunk)throw new Error("Your browser does not support EncodedVideoChunk.");
1return new EncodedVideoChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}alphaToEncodedVideoChunk(e=this.type){if(!this.sideData.alpha)throw new TypeError("This packet does not contain alpha side data.");if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if("undefined"==typeof EncodedVideoChunk)throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.sideData.alpha,type:e,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}toEncodedAudioChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to an audio chunk.");if("undefined"==typeof EncodedAudioChunk)throw new Error("Your browser does not support EncodedAudioChunk.");return new EncodedAudioChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}static fromEncodedChunk(e,t){if(!(e instanceof EncodedVideoChunk||e instanceof EncodedAudioChunk))throw new TypeError("chunk must be an EncodedVideoChunk or EncodedAudioChunk.");const r=new Uint8Array(e.byteLength);return e.copyTo(r),new Yt(r,e.type,e.timestamp/1e6,(e.duration??0)/1e6,void 0,void 0,t)}clone(e){if(void 0!==e&&("object"!=typeof e||null===e))throw new TypeError("options, when provided, must be an object.");if(void 0!==e?.data&&!(e.data instanceof Uint8Array))throw new TypeError("options.data, when provided, must be a Uint8Array.");if(void 0!==e?.type&&"key"!==e.type&&"delta"!==e.type)throw new TypeError('options.type, when provided, must be either "key" or "delta".');if(void 0!==e?.timestamp&&!Number.isFinite(e.timestamp))throw new TypeError("options.timestamp, when provided, must be a number.");if(void 0!==e?.duration&&!Number.isFinite(e.duration))throw new TypeError("options.duration, when provided, must be a number.");if(void 0!==e?.sequenceNumber&&!Number.isFinite(e.sequenceNumber))throw new TypeError("options.sequenceNumber, when provided, must be a number.");if(void 0!==e?.sideData&&("object"!=typeof e.sideData||null===e.sideData))throw new TypeError("options.sideData, when provided, must be an object.");return new Yt(e?.data??this.data,e?.type??this.type,e?.timestamp??this.timestamp,e?.duration??this.duration,e?.sequenceNumber??this.sequenceNumber,this.byteLength,e?.sideData??this.sideData)}}const Xt=e=>{let t=(e.hasVideo?"video/":e.hasAudio?"audio/":"application/")+(e.isQuickTime?"quicktime":"mp4");if(e.codecStrings.length>0){t+=`; codecs="${[...new Set(e.codecStrings)].join(", ")}"`}return t},Qt=e=>{const t=y(e);let r=0;const i=t.getUint8(r);r+=1,r+=3;const n=_(e.subarray(r,r+16));r+=16;let a=null;if(i>0){const i=t.getUint32(r);if(r+=4,i>0){a=[];for(let t=0;t<i;t++)a.push(_(e.subarray(r,r+16))),r+=16}}const s=t.getUint32(r);return r+=4,{systemId:n,keyIds:a,data:e.slice(r,r+s)}},Jt=(e,t)=>e.systemId===t.systemId&&fe(e.data,t.data);class Zt{constructor(e,t){if(this.data=e,this.mimeType=t,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if("string"!=typeof t)throw new TypeError("mimeType must be a string.")}}
1class er{constructor(e,t,r,i){if(this.data=e,this.mimeType=t,this.name=r,this.description=i,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(void 0!==t&&"string"!=typeof t)throw new TypeError("mimeType, when provided, must be a string.");if(void 0!==r&&"string"!=typeof r)throw new TypeError("name, when provided, must be a string.");if(void 0!==i&&"string"!=typeof i)throw new TypeError("description, when provided, must be a string.")}}const tr=e=>{if(!e||"object"!=typeof e)throw new TypeError("tags must be an object.");if(void 0!==e.title&&"string"!=typeof e.title)throw new TypeError("tags.title, when provided, must be a string.");if(void 0!==e.description&&"string"!=typeof e.description)throw new TypeError("tags.description, when provided, must be a string.");if(void 0!==e.artist&&"string"!=typeof e.artist)throw new TypeError("tags.artist, when provided, must be a string.");if(void 0!==e.album&&"string"!=typeof e.album)throw new TypeError("tags.album, when provided, must be a string.");if(void 0!==e.albumArtist&&"string"!=typeof e.albumArtist)throw new TypeError("tags.albumArtist, when provided, must be a string.");if(void 0!==e.trackNumber&&(!Number.isInteger(e.trackNumber)||e.trackNumber<=0))throw new TypeError("tags.trackNumber, when provided, must be a positive integer.");if(void 0!==e.tracksTotal&&(!Number.isInteger(e.tracksTotal)||e.tracksTotal<=0))throw new TypeError("tags.tracksTotal, when provided, must be a positive integer.");if(void 0!==e.discNumber&&(!Number.isInteger(e.discNumber)||e.discNumber<=0))throw new TypeError("tags.discNumber, when provided, must be a positive integer.");if(void 0!==e.discsTotal&&(!Number.isInteger(e.discsTotal)||e.discsTotal<=0))throw new TypeError("tags.discsTotal, when provided, must be a positive integer.");if(void 0!==e.genre&&"string"!=typeof e.genre)throw new TypeError("tags.genre, when provided, must be a string.");if(void 0!==e.date&&(!(e.date instanceof Date)||Number.isNaN(e.date.getTime())))throw new TypeError("tags.date, when provided, must be a valid Date.");if(void 0!==e.lyrics&&"string"!=typeof e.lyrics)throw new TypeError("tags.lyrics, when provided, must be a string.");if(void 0!==e.images){if(!Array.isArray(e.images))throw new TypeError("tags.images, when provided, must be an array.");for(const t of e.images){if(!t||"object"!=typeof t)throw new TypeError("Each image in tags.images must be an object.");if(!(t.data instanceof Uint8Array))throw new TypeError("Each image.data must be a Uint8Array.");if("string"!=typeof t.mimeType)throw new TypeError("Each image.mimeType must be a string.");if(!["coverFront","coverBack","unknown"].includes(t.kind))throw new TypeError("Each image.kind must be 'coverFront', 'coverBack', or 'unknown'.")}}if(void 0!==e.comment&&"string"!=typeof e.comment)throw new TypeError("tags.comment, when provided, must be a string.");if(void 0!==e.raw){if(!e.raw||"object"!=typeof e.raw)throw new TypeError("tags.raw, when provided, must be an object.");for(const t of Object.values(e.raw))if(!(null===t||"string"==typeof t||t instanceof Uint8Array||t instanceof Zt||t instanceof er||Ce(t)))throw new TypeError("Each value in tags.raw must be a string, Uint8Array, RichImageData, AttachedFile, Record<string, string>, or null.")}},rr={default:!0,primary:!0,forced:!1,original:!1,commentary:!1,hearingImpaired:!1,visuallyImpaired:!1};r(76851);me();const ir=1/0;let nr=null;"undefined"!=typeof FinalizationRegistry&&(nr=new FinalizationRegistry(e=>{e()}));class ar extends xe{constructor(){super(),this._disposed=!1,this._refCount=0,this._usedForHls=!1,this._refFinalizationRegistry=null,this._sizePromise=null,this.onread=null,"undefined"!=typeof FinalizationRegistry&&(this._refFinalizationRegistry=new FinalizationRegistry(e=>{e._decrementRefCount()}))}async getSizeOrNull(){if(this._disposed)throw new InputDisposedError;return this._sizePromise??=(async()=>{let e=this._getFileSize();return void 0!==e||(await this._read(0,1,0,ir),e=this._getFileSize(),l(void 0!==e)),e})()}async getSize(){if(this._disposed)throw new InputDisposedError;
1const e=await this.getSizeOrNull();if(null===e)throw new Error("Cannot determine the size of an unsized source.");return e}slice(e,t){if(!Number.isInteger(e)||e<0)throw new TypeError("offset must be a non-negative integer.");if(void 0!==t&&(!Number.isInteger(t)||t<0))throw new TypeError("length, when provided, must be a non-negative integer.");return new mr(this,e,t)}_dispatchRead(e,t){this.onread?.(e,t),this._emit("read",{start:e,end:t})}ref(){return new sr(this)}_incrementRefCount(){this._refCount++}_decrementRefCount(){this._refCount--,0===this._refCount&&(this._dispose(),this._disposed=!0)}}class sr{constructor(e){if(this._freed=!1,e._disposed)throw new Error("Cannot ref a disposed source.");e._incrementRefCount(),e._refFinalizationRegistry?.register(this,e,this),this._source=e}get source(){if(!this._source)throw new Error("Can't get source; ref has already been freed.");return this._source}get freed(){return this._freed}free(){if(this._freed)throw new Error("Illegal operation: double free on SourceRef.");const e=this.source;l(e._refCount>0),e._decrementRefCount(),e._refFinalizationRegistry?.unregister(this),this._freed=!0,this._source=null}[Symbol.dispose](){this.freed||this.free()}}class or extends ar{constructor(e,t){if("string"!=typeof e)throw new TypeError("rootPath must be a string.");if("function"!=typeof t)throw new TypeError("requestHandler must be a function.");super(),this.rootPath=e,this.requestHandler=t}_resolveRequest(e){const t=this.requestHandler(e),r=e=>{if(!(e instanceof ar||e instanceof sr))throw new TypeError("requestHandler must return or resolve to a Source or SourceRef.");const t=e instanceof ar?e.ref():e;return t.source._usedForHls||=this._usedForHls,t};return t instanceof Promise?t.then(r):r(t)}}const cr=(e,t)=>e.path===t.path;class dr extends or{constructor(){super(...arguments),this._root=null,this._rootRequest=null}_read(e,t,r,i){if(!this._root){if(!this._rootRequest){const e=this._resolveRequest({path:this.rootPath,isRoot:!0}),t=e=>{const t=e instanceof ar?e.ref():e;return this._root=t,this._rootRequest=null,t};e instanceof Promise?this._rootRequest=e.then(t):(t(e),l(this._root))}if(this._rootRequest)return this._rootRequest.then(n=>n.source._read(e,t,r,i))}return this._root.source._read(e,t,r,i)}_getFileSize(){if(this._root)return this._root.source._getFileSize()}_dispose(){this._root?this._root.free():this._rootRequest&&this._rootRequest.then(e=>e.free())}}class lr extends ar{constructor(e,t={}){if(!(e instanceof Blob))throw new TypeError("blob must be a Blob.");if(!t||"object"!=typeof t)throw new TypeError("options must be an object.");if(void 0!==t.maxCacheSize&&(!pe(t.maxCacheSize)||t.maxCacheSize<0))throw new TypeError("options.maxCacheSize, when provided, must be a non-negative number.");if(void 0!==t.useStreamReader&&"boolean"!=typeof t.useStreamReader)throw new TypeError("options.useStreamReader, when provided, must be a boolean.");super(),this._readers=new WeakMap,this._blob=e,this._options=t,this._orchestrator=new fr({maxCacheSize:t.maxCacheSize??8388608,maxWorkerCount:4,runWorker:this._runWorker.bind(this),prefetchProfile:hr.fileSystem}),this._orchestrator.fileSize=e.size}_getFileSize(){return this._orchestrator.fileSize}_read(e,t,r,i){return this._orchestrator.read(e,t,r,i)}async _runWorker(e){l(e.strictTarget);let t=this._readers.get(e);if(void 0===t){if("stream"in this._blob&&!te()&&!1!==this._options.useStreamReader){t=this._blob.slice(e.currentPos).stream().getReader()}else t=null;this._readers.set(e,t)}for(;e.currentPos<e.targetPos&&!e.aborted;)if(t){const{done:r,value:i}=await t.read();if(r)throw this._orchestrator.onWorkerFinished(e),new Error("Blob reader stopped unexpectedly before all requested data was read.");if(e.aborted)break;this._dispatchRead(e.currentPos,e.currentPos+i.length),this._orchestrator.supplyWorkerData(e,i)}else{const t=await this._blob.slice(e.currentPos,e.targetPos).arrayBuffer();if(e.aborted)break;this._dispatchRead(e.currentPos,e.currentPos+t.byteLength),this._orchestrator.supplyWorkerData(e,new Uint8Array(t))}this._orchestrator.signalWorkerStoppedRunning(e),e.aborted&&await(t?.cancel())}
1_dispose(){this._orchestrator.dispose()}}new Set;class ur extends ar{constructor(e,t={}){if(!(e instanceof ReadableStream))throw new TypeError("stream must be a ReadableStream.");if(!t||"object"!=typeof t)throw new TypeError("options must be an object.");if(void 0!==t.maxCacheSize&&(!pe(t.maxCacheSize)||t.maxCacheSize<0))throw new TypeError("options.maxCacheSize, when provided, must be a non-negative number.");super(),this._reader=null,this._cache=[],this._pendingSlices=[],this._currentIndex=0,this._targetIndex=0,this._maxRequestedIndex=0,this._endIndex=null,this._pulling=!1,this._stream=e,this._maxCacheSize=t.maxCacheSize??33554432}_getFileSize(){return this._endIndex}_read(e,t){if(null!==this._endIndex&&t>this._endIndex)return null;this._maxRequestedIndex=Math.max(this._maxRequestedIndex,t);const r=O(this._cache,e,e=>e.start),i=-1!==r?this._cache[r]:null;if(i&&i.start<=e&&t<=i.end)return{bytes:i.bytes,view:i.view,offset:i.start};let n=e;const a=new Uint8Array(t-e);if(-1!==r)for(let i=r;i<this._cache.length;i++){const r=this._cache[i];if(r.start>=t)break;const s=Math.max(e,r.start);s>n&&this._throwDueToCacheMiss();const o=Math.min(t,r.end);s<o&&(a.set(r.bytes.subarray(s-r.start,o-r.start),s-e),n=o)}if(n===t)return{bytes:a,view:y(a),offset:e};this._currentIndex>n&&this._throwDueToCacheMiss();const{promise:s,resolve:o,reject:c}=B();return this._pendingSlices.push({start:e,end:t,bytes:a,resolve:o,reject:c}),this._targetIndex=Math.max(this._targetIndex,t),this._pulling||(this._pulling=!0,this._pull().catch(e=>{if(this._pulling=!1,!(this._pendingSlices.length>0))throw e;this._pendingSlices.forEach(t=>t.reject(e)),this._pendingSlices.length=0})),s}_throwDueToCacheMiss(){throw new Error("Read is before the cached region. With ReadableStreamSource, you must access the data more sequentially or increase the size of its cache.")}async _pull(){for(this._reader??=this._stream.getReader();this._currentIndex<this._targetIndex&&!this._disposed;){const{done:e,value:t}=await this._reader.read();if(e){for(const e of this._pendingSlices)e.resolve(null);this._pendingSlices.length=0,this._endIndex=this._currentIndex;break}const r=this._currentIndex,i=this._currentIndex+t.byteLength;this._dispatchRead(r,i);for(let e=0;e<this._pendingSlices.length;e++){const n=this._pendingSlices[e],a=Math.max(r,n.start),s=Math.min(i,n.end);a<s&&(n.bytes.set(t.subarray(a-r,s-r),a-n.start),s===n.end&&(n.resolve({bytes:n.bytes,view:y(n.bytes),offset:n.start}),this._pendingSlices.splice(e,1),e--))}for(this._cache.push({start:r,end:i,bytes:t,view:y(t),age:0});this._cache.length>0;){const e=this._cache[0];if(this._maxRequestedIndex-e.end<=this._maxCacheSize)break;this._cache.shift()}this._currentIndex+=t.byteLength}this._pulling=!1}_dispose(){this._pendingSlices.length=0,this._cache.length=0,this._reader?.cancel()}}const hr={none:(e,t)=>({start:e,end:t}),fileSystem:(e,t)=>{const r=65536;return{start:e=Math.floor((e-r)/r)*r,end:t=Math.ceil((t+r)/r)*r}},network:(e,t,r)=>{const i=65536;e=Math.max(0,Math.floor((e-i)/i)*i);for(const i of r){const r=8388608,n=Math.max((i.startPos+i.targetPos)/2,i.targetPos-r);if(de(e,t,n,i.targetPos)){const e=i.targetPos-i.startPos,n=Math.ceil((e+1)/r)*r,a=2**Math.ceil(Math.log2(e+1)),s=Math.min(a,n);t=Math.max(t,i.startPos+s)}}return{start:e,end:t=Math.max(t,e+524288)}}};class fr{constructor(e){this.options=e,this.fileSize=null,this.nextAge=0,this.workers=[],this.cache=[],this.currentCacheSize=0,this.disposed=!1,this.queuedReads=[]}read(e,t,r,i){l(!this.disposed);const n=this.options.prefetchProfile(e,t,this.workers),a=Math.max(n.start,r),s=Math.min(n.end,this.fileSize??1/0,i);l(a<=e&&t<=s);let o=null;const c=O(this.cache,e,e=>e.start),d=-1!==c?this.cache[c]:null;d&&d.start<=e&&t<=d.end&&(d.age=this.nextAge++,o={bytes:d.bytes,view:d.view,offset:d.start});const u=O(this.cache,a,e=>e.start),h=o?null:new Uint8Array(t-e);let f=0,m=a;const p=[];if(-1!==u){for(let r=u;r<this.cache.length;r++){const i=this.cache[r];if(i.start>=s)break;if(i.end<=a)continue;const n=Math.max(a,i.start),o=Math.min(s,i.end);if(l(n<=o),m<n&&p.push({start:m,end:n}),m=o,h){const r=Math.max(e,i.start),n=Math.min(t,i.end);if(r<n){const t=r-e;h.set(i.bytes.subarray(r-i.start,n-i.start),t),t===f&&(f=n-e)}}i.age=this.nextAge++}m<s&&p.push({start:m,end:s})}else p.push({start:a,end:s});if(h&&f>=h.length&&(o={bytes:h,view:y(h),offset:e}),0===p.length)return l(o),o;const{promise:g,resolve:b,reject:w}=B(),v=[];for(const r of p){const i=Math.max(e,r.start),n=Math.min(t,r.end);i===r.start&&n===r.end?v.push(r):i<n&&v.push({start:i,end:n})}const k=h&&{start:e,bytes:h,holes:v,resolve:b,reject:w};e:for(const e of p){for(const t of this.workers){if(this.checkHoleAgainstWorker(t,e,k?[k]:[])){this.checkQueuedReadsAgainstWorker(t);continue e}}const t=e.end<s||null!==this.fileSize,r=this.createWorker(e.start,e.end,t);if(r)k&&(r.pendingSlices=[k]),this.runWorker(r);else{let r=O(this.queuedReads,e.start,e=>e.hole.start),i=-1!==r?this.queuedReads[r]:null;for(i&&e.start<=i.hole.end?(i.hole.end=Math.max(i.hole.end,e.end),i.strictTarget&&=t,k&&i.pendingSlices.push(k)):(r++,i={hole:{start:e.start,end:e.end},strictTarget:t,pendingSlices:k?[k]:[],age:this.nextAge++},this.queuedReads.splice(r,0,i));r+1<this.queuedReads.length;
1){const e=this.queuedReads[r+1];if(e.hole.start>i.hole.end)break;i.hole.end=Math.max(i.hole.end,e.hole.end),i.pendingSlices.push(...e.pendingSlices),i.strictTarget&&=e.strictTarget,i.age=Math.min(i.age,e.age),this.queuedReads.splice(r+1,1)}}}return o?g.catch(e=>{if(!this.disposed)throw e}):(l(h),o=g.then(t=>t&&{bytes:t,view:y(t),offset:e})),o}checkHoleAgainstWorker(e,t,r){if(de(t.start-2**17,t.start,e.currentPos,e.targetPos)){e.targetPos=Math.max(e.targetPos,t.end);for(let t=0;t<r.length;t++){const i=r[t];e.pendingSlices.includes(i)||e.pendingSlices.push(i)}return e.running||this.runWorker(e),!0}return!1}checkQueuedReadsAgainstWorker(e){let t=!1;for(let r=0;r<this.queuedReads.length;r++){const i=this.queuedReads[r];if(this.checkHoleAgainstWorker(e,i.hole,i.pendingSlices))this.queuedReads.splice(r,1),r--,t=!0;else if(t)break}}createWorker(e,t,r){if(this.workers.length>=this.options.maxWorkerCount){let e=null,t=null;for(let r=0;r<this.workers.length;r++){const i=this.workers[r];i.running||0!==i.pendingSlices.length||e&&!(i.age<e.age)||(t=r,e=i)}if(!e)return null;l(null!==t),l(0===e.pendingSlices.length),this.workers.splice(t,1)}const i={startPos:e,currentPos:e,targetPos:t,strictTarget:r,running:!1,aborted:this.disposed,pendingSlices:[],age:this.nextAge++};return this.workers.push(i),i}runWorker(e){l(!e.running),l(e.currentPos<e.targetPos),e.running=!0,e.age=this.nextAge++,this.options.runWorker(e).catch(t=>{if(e.running=!1,e.pendingSlices.length>0)e.pendingSlices.forEach(e=>e.reject(t)),e.pendingSlices.length=0;else if(!e.aborted&&!this.disposed)throw t}).finally(()=>{if(!(e.running||this.workers.length>=this.options.maxWorkerCount)&&this.queuedReads.length>0){let e=0;for(let t=1;t<this.queuedReads.length;t++){this.queuedReads[t].age<this.queuedReads[e].age&&(e=t)}const t=this.queuedReads[e];this.queuedReads.splice(e,1);const r=this.createWorker(t.hole.start,t.hole.end,t.strictTarget);l(r),r.pendingSlices=t.pendingSlices,this.runWorker(r)}})}consolidateEverythingIntoOneWorker(e){const t=new Set(e.pendingSlices);for(let r=0;r<this.workers.length;r++){const i=this.workers[r];if(i!==e){for(const e of i.pendingSlices)t.add(e);i.aborted=!0,i.pendingSlices.length=0,this.workers.splice(r,1),r--}}for(let e=0;e<this.queuedReads.length;e++){const r=this.queuedReads[e];for(const e of r.pendingSlices)t.add(e)}e.pendingSlices=[...t],this.queuedReads.length=0}supplyWorkerData(e,t){l(!e.aborted);const r=e.currentPos,i=r+t.length;this.insertIntoCache({start:r,end:i,bytes:t,view:y(t),age:this.nextAge++}),e.currentPos+=t.length,e.currentPos>e.targetPos&&(e.targetPos=e.currentPos,this.checkQueuedReadsAgainstWorker(e));for(let n=0;n<e.pendingSlices.length;n++){const a=e.pendingSlices[n],s=Math.max(r,a.start),o=Math.min(i,a.start+a.bytes.length);s<o&&a.bytes.set(t.subarray(s-r,o-r),s-a.start);for(let e=0;e<a.holes.length;e++){const t=a.holes[e];r<=t.start&&i>t.start&&(t.start=i),t.end<=t.start&&(a.holes.splice(e,1),e--)}0===a.holes.length&&(a.resolve(a.bytes),e.pendingSlices.splice(n,1),n--)}for(let t=0;t<this.workers.length;t++){const n=this.workers[t];e===n||n.running||de(r,i,n.currentPos,n.targetPos)&&(this.workers.splice(t,1),t--)}}supplyFileSize(e){l(null===this.fileSize),this.fileSize=e;for(const t of this.workers){t.targetPos=Math.min(t.targetPos,e),t.strictTarget=!0;for(let r=0;r<t.pendingSlices.length;r++){const i=t.pendingSlices[r];for(const n of i.holes)if(n.end>e){i.resolve(null),t.pendingSlices.splice(r,1),r--;break}}}for(let t=0;t<this.queuedReads.length;t++){const r=this.queuedReads[t];if(r.hole.start>=e){for(const e of r.pendingSlices)e.resolve(null);this.queuedReads.splice(t,1),t--}else if(r.hole.end>e){r.hole.end=e,r.strictTarget=!0;for(let t=0;t<r.pendingSlices.length;t++){const i=r.pendingSlices[t];i.start>=e&&(i.resolve(null),r.pendingSlices.splice(t,1),t--)}}}}signalWorkerStoppedRunning(e){e.running=!1,e.pendingSlices.length=0}onWorkerFinished(e){const t=this.workers.indexOf(e);l(-1!==t),e.running=!1,this.workers.splice(t,1),null===this.fileSize&&this.supplyFileSize(e.currentPos);for(const t of e.pendingSlices)t.resolve(null)}insertIntoCache(e){if(0===this.options.maxCacheSize)return;let t=O(this.cache,e.start,e=>e.start)+1;if(t>0){const r=this.cache[t-1];if(r.end>=e.end)return;if(r.end>e.start){const i=new Uint8Array(e.end-r.start);i.set(r.bytes,0),i.set(e.bytes,e.start-r.start),this.currentCacheSize+=e.end-r.end,r.bytes=i,r.view=y(i),r.end=e.end,t
1--,e=r}else this.cache.splice(t,0,e),this.currentCacheSize+=e.bytes.length}else this.cache.splice(t,0,e),this.currentCacheSize+=e.bytes.length;for(let r=t+1;r<this.cache.length;r++){const t=this.cache[r];if(e.end<=t.start)break;if(e.end>=t.end){this.cache.splice(r,1),this.currentCacheSize-=t.bytes.length,r--;continue}const i=new Uint8Array(t.end-e.start);i.set(e.bytes,0),i.set(t.bytes,t.start-e.start),this.currentCacheSize-=e.end-t.start,e.bytes=i,e.view=y(i),e.end=t.end,this.cache.splice(r,1);break}for(;this.currentCacheSize>this.options.maxCacheSize;){let e=0,t=this.cache[0];for(let r=1;r<this.cache.length;r++){const i=this.cache[r];i.age<t.age&&(e=r,t=i)}if(this.currentCacheSize-t.bytes.length<=this.options.maxCacheSize)break;this.cache.splice(e,1),this.currentCacheSize-=t.bytes.length}}dispose(){for(const e of this.workers)e.aborted=!0;this.workers.length=0,this.cache.length=0,this.disposed=!0}}class mr extends ar{constructor(e,t,r){if(super(),this._ref=null,e._disposed)throw new Error("Cannot create a slice of a disposed source.");this._baseSource=e,this._offset=t,this._length=r??null}_getFileSize(){const e=this._baseSource._getFileSize();return void 0===e?null!==this._length?this._length:void 0:null===e?null!==this._length?this._length:null:W(e-this._offset,0,this._length??1/0)}_read(e,t,r,i){if(null!==this._length&&t>this._length)return null;const n=this._baseSource._read(this._offset+e,this._offset+t,this._offset+r,this._offset+i),a=e=>e?(e.offset-=this._offset,e):null;return n instanceof Promise?n.then(a):a(n)}_dispose(){this._ref?.free()}ref(){return this._ref??=this._baseSource.ref(),super.ref()}}class pr{constructor(e){this.source=e}get fileSize(){const e=this.source._getFileSize();if(void 0===e)throw new Error("Reading file size too early; read required first.");return e}get fileSizeNonStrict(){return this.source._getFileSize()??null}requestSlice(e,t){if(this.source._disposed)throw new InputDisposedError;if(e<0)return null;if(null!==this.fileSizeNonStrict&&e+t>this.fileSizeNonStrict)return null;if(0===t){const t=new Uint8Array(0);return new gr(t,y(t),0,e,e)}const r=e+t,i=this.source._read(e,r,0,ir);return i instanceof Promise?i.then(t=>t?new gr(t.bytes,t.view,t.offset,e,r):null):i?new gr(i.bytes,i.view,i.offset,e,r):null}requestSliceRange(e,t,r){if(this.source._disposed)throw new InputDisposedError;if(e<0)return null;if(null!==this.fileSizeNonStrict)return this.requestSlice(e,W(this.fileSizeNonStrict-e,t,r));{const i=this.requestSlice(e,r),n=i=>i||(l(null!==this.fileSizeNonStrict),this.requestSlice(e,W(this.fileSizeNonStrict-e,t,r)));return i instanceof Promise?i.then(n):n(i)}}requestEntireFile(){if(null!==this.fileSizeNonStrict)return this.requestSlice(0,this.fileSizeNonStrict);return(async()=>{const e=[];let t=0;for(;;){if(1===e.length&&null!==this.fileSizeNonStrict)return this.requestSlice(0,this.fileSizeNonStrict);let r=this.requestSliceRange(t,0,1024);if(r instanceof Promise&&(r=await r),!r||0===r.length)break;const i=br(r,r.length);e.push(i),t+=r.length}const r=new Uint8Array(t);let i=0;for(const t of e)r.set(t,i),i+=t.length;return new gr(r,y(r),0,0,t)})()}}class gr{constructor(e,t,r,i,n){this.bytes=e,this.view=t,this.offset=r,this.start=i,this.end=n,this.bufferPos=i-r}static tempFromBytes(e){return new gr(e,y(e),0,0,e.length)}get length(){return this.end-this.start}get filePos(){return this.offset+this.bufferPos}set filePos(e){this.bufferPos=e-this.offset}get remainingLength(){return Math.max(this.end-this.filePos,0)}skip(e){this.bufferPos+=e}slice(e,t=this.end-e){if(e<this.start||e+t>this.end)throw new RangeError("Slicing outside of original slice.");return new gr(this.bytes,this.view,this.offset,e,e+t)}}const yr=(e,t)=>{if(e.filePos<e.start||e.filePos+t>e.end)throw new RangeError(`Tried reading [${e.filePos}, ${e.filePos+t}), but slice is [${e.start}, ${e.end}). This is likely an internal error, please report it alongside the file that caused it.`)},br=(e,t)=>{yr(e,t);const r=e.bytes.subarray(e.bufferPos,e.bufferPos+t);return e.bufferPos+=t,r},wr=e=>(yr(e,1),e.view.getUint8(e.bufferPos++)),vr=(e,t)=>{yr(e,2);const r=e.view.getUint16(e.bufferPos,t);return e.bufferPos+=2,r},kr=e=>{yr(e,2);const t=e.view.getUint16(e.bufferPos,!1);return e.bufferPos+=2,t},Tr=e=>{yr(e,3);const t=U(e.view,e.bufferPos,!1);return e.bufferPos+=3,t},xr=e=>{yr(e,2);const t=e.view.getInt16(e.bufferPos,!1);return e.bufferPos+=2,t},Sr=(e,t)=>
1{yr(e,4);const r=e.view.getUint32(e.bufferPos,t);return e.bufferPos+=4,r},Cr=e=>{yr(e,4);const t=e.view.getUint32(e.bufferPos,!1);return e.bufferPos+=4,t},Pr=e=>{yr(e,4);const t=e.view.getUint32(e.bufferPos,!0);return e.bufferPos+=4,t},Ar=e=>{yr(e,4);const t=e.view.getInt32(e.bufferPos,!1);return e.bufferPos+=4,t},Er=(e,t)=>{let r,i;return t?(r=Sr(e,!0),i=Sr(e,!0)):(i=Sr(e,!1),r=Sr(e,!1)),4294967296*i+r},Ir=e=>4294967296*Cr(e)+Cr(e),$r=e=>4294967296*Ar(e)+Cr(e),_r=e=>{const t=Pr(e),r=(e=>{yr(e,4);const t=e.view.getInt32(e.bufferPos,!0);return e.bufferPos+=4,t})(e);return 4294967296*r+t},Nr=e=>{yr(e,8);const t=e.view.getFloat64(e.bufferPos,!1);return e.bufferPos+=8,t},Rr=(e,t)=>{yr(e,t);let r="";for(let i=0;i<t;i++)r+=String.fromCharCode(e.bytes[e.bufferPos++]);return r},Or=(e,t,r)=>b.decode(br(e,t)).split("\n").map(e=>e.trim()).filter(e=>e.length>0&&!r?.ignore?.(e)),Fr=16,Br=e=>{let t=Cr(e);const r=Rr(e,4);let i=8;1===t&&(t=Ir(e),i=16);const n=t-i;return n<0?null:{name:r,totalSize:t,headerSize:i,contentSize:n}},Dr=e=>Ar(e)/65536,Mr=e=>Ar(e)/1073741824,jr=e=>{let t=0;for(let r=0;r<4;r++){t<<=7;const r=wr(e);if(t|=127&r,!(128&r))break}return t},Lr=e=>{let t=kr(e);return e.skip(2),t=Math.min(t,e.remainingLength),b.decode(br(e,t))},Ur=e=>{const t=Br(e);if(!t||"data"!==t.name)return null;if(e.remainingLength<8)return null;const r=Cr(e);e.skip(4);const i=br(e,t.contentSize-8);switch(r){case 1:return b.decode(i);case 2:return new TextDecoder("utf-16be").decode(i);case 13:return new Zt(i,"image/jpeg");case 14:return new Zt(i,"image/png");case 27:return new Zt(i,"image/bmp");default:return i}},zr=16,Wr=new Uint32Array(256),Vr=new Uint32Array(256),qr=new Uint32Array(256),Hr=new Uint32Array(256),Gr=new Uint32Array(256),Kr=new Uint32Array(256),Yr=new Uint32Array(10);let Xr=!1;class Qr{constructor(){this.roundkey=new Uint32Array(44),this.iv=new Uint32Array(zr/Uint32Array.BYTES_PER_ELEMENT),this.in=new Uint8Array(zr),this.out=new Uint8Array(zr),this.inView=new DataView(this.in.buffer),this.outView=new DataView(this.out.buffer)}init({key:e,iv:t}){l(16===e.byteLength),l(16===t.byteLength),Xr||(()=>{const e=new Uint8Array(256),t=new Uint8Array(256),r=new Uint8Array(256);for(let e=0,i=1;e<256;e++)r[e]=i,t[i]=e,i=i^i<<1^(128&i?283:0);const i=(e,i)=>e&&i?r[(t[e]+t[i])%255]:0;e[0]=99;for(let i=1;i<256;i++){const n=r[255-t[i]];let a=n^n<<1^n<<2^n<<3^n<<4;a=a>>>8^255&a^99,e[i]=a}for(let t=0;t<256;t++){const r=e[t],n=e.indexOf(t);Wr[t]=r<<24|r<<16|r<<8|r,Kr[t]=n<<24|n<<16|n<<8|n;const a=i(n,14)<<24|i(n,9)<<16|i(n,13)<<8|i(n,11);Vr[t]=a,qr[t]=a>>>8|a<<24,Hr[t]=a>>>16|a<<16,Gr[t]=a>>>24|a<<8}let n=1;for(let e=0;e<10;e++)Yr[e]=n<<24,n=n<<1^(128&n?283:0);Xr=!0})();const r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=new DataView(t.buffer,t.byteOffset,t.byteLength);this.roundkey[0]=r.getUint32(0,!1),this.roundkey[1]=r.getUint32(4,!1),this.roundkey[2]=r.getUint32(8,!1),this.roundkey[3]=r.getUint32(12,!1),this.iv[0]=i.getUint32(0,!1),this.iv[1]=i.getUint32(4,!1),this.iv[2]=i.getUint32(8,!1),this.iv[3]=i.getUint32(12,!1);for(let e=4;e<44;e+=4){const t=this.roundkey[e-1];this.roundkey[e]=this.roundkey[e-4]^4278190080&Wr[t>>>16&255]^16711680&Wr[t>>>8&255]^65280&Wr[t>>>0&255]^255&Wr[t>>>24&255]^Yr[e/4-1],this.roundkey[e+1]=this.roundkey[e-3]^this.roundkey[e],this.roundkey[e+2]=this.roundkey[e-2]^this.roundkey[e+1],this.roundkey[e+3]=this.roundkey[e-1]^this.roundkey[e+2]}for(let e=0,t=40;e<t;e+=4,t-=4)for(let r=0;r<4;r++){const i=this.roundkey[e+r];this.roundkey[e+r]=this.roundkey[t+r],this.roundkey[t+r]=i}for(let e=4;e<40;e+=4)for(let t=0;t<4;t++){const r=this.roundkey[e+t];this.roundkey[e+t]=Vr[255&Wr[r>>>24&255]]^qr[255&Wr[r>>>16&255]]^Hr[255&Wr[r>>>8&255]]^Gr[255&Wr[r>>>0&255]]}}decrypt(){let e=this.inView.getUint32(0,!1)^this.roundkey[0],t=this.inView.getUint32(4,!1)^this.roundkey[1],r=this.inView.getUint32(8,!1)^this.roundkey[2],i=this.inView.getUint32(12,!1)^this.roundkey[3];const n=this.inView.getUint32(0,!1),a=this.inView.getUint32(4,!1),s=this.inView.getUint32(8,!1),o=this.inView.getUint32(12,!1);let c,d,l,u;for(let n=1;n<10;n++){const a=4*n;c=Vr[e>>>24]^qr[i>>>16&255]^Hr[r>>>8&255]^Gr[255&t]^this.roundkey[a],d=Vr[t>>>24]^qr[e>>>16&255]^Hr[i>>>8&255]^Gr[255&r]^this.roundkey[a+1],l=Vr[r>>>24]^qr[t>>>16&255]^Hr[e>>>8&255]^Gr[255&i]^this.roundkey[a+2],u=Vr[i>>>24]^qr[r>>>16&255]^Hr[t>>>8&255]^Gr[255&e]^this.roundkey[a+3],e=c,t=d,r=l,i=u}const h=4278190080&Kr[e>>>24&255]^16711680&Kr[i>>>16&255]^65280&Kr[r>>>8&255]^255&Kr[t>>>0&255]^this.roundkey[40],f=4278190080&Kr[t>>>24&255]^16711680&Kr[e>>>16&255]^65280&Kr[i>>>8&255]^255&Kr[r>>>0&255]^this.roundkey[41],m=4278190080&Kr[r>>>24&255]^16711680&Kr[t>>>16&255]^65280&Kr[e>>>8&255]^255&Kr[i>>>0&255]^this.roundkey[42],p=4278190080&Kr[i>>>24&255]^16711680&Kr[r>>>16&255]^65280&Kr[t>>>8&255]^255&Kr[e>>>0&255]^this.roundkey[43];this.outView.setUint32(0,h^this.iv[0],!1),this.outView.setUint32(4,f^this.iv[1],!1),this.outView.setUint32(8,m^this.iv[2],!1),this.outView.setUint32(12,p^this.iv[3],!1),this.iv[0]=n,this.iv[1]=a,this.iv[2]=s,this.iv[3]=o}}class Jr extends Gt{constructor(e){super(e),this.moovSlice=null,this.currentTrack=null,this.tracks=[],this.metadataPromise=null,this.movieTimescale=-1,this.movieDurationInTimescale=-1,this.isQuickTime=!1,this.metadataTags={},this.currentMetadataKeys=null,this.isFragmented=!1,this.fragmentTrackDefaults=[],this.pss
1hBoxes=[],this.currentFragment=null,this.lastReadFragment=null,this.decryptionKeyCache=new Map,this.reader=e._reader}async getTrackBackings(){return await this.readMetadata(),this.tracks.map(e=>e.trackBacking)}async getMimeType(){await this.readMetadata();const e=await this.getTrackBackings(),t=await Promise.all(e.map(e=>e.getDecoderConfig().then(e=>e?.codec??null)));return Xt({isQuickTime:this.isQuickTime,hasVideo:this.tracks.some(e=>"video"===e.info?.type),hasAudio:this.tracks.some(e=>"audio"===e.info?.type),codecStrings:t.filter(Boolean)})}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}readMetadata(){return this.metadataPromise??=(async()=>{let e=0,t=!1;for(;;){let r=this.reader.requestSliceRange(e,8,Fr);if(r instanceof Promise&&(r=await r),!r)break;const i=e,n=Br(r);if(!n)break;if("ftyp"===n.name||"styp"===n.name){const e=Rr(r,4);this.isQuickTime="qt "===e}else{if("moov"===n.name){let e=this.reader.requestSlice(r.filePos,n.contentSize);if(e instanceof Promise&&(e=await e),!e)break;this.moovSlice=e,this.readContiguousBoxes(this.moovSlice);for(const e of this.tracks){const t=e.editListPreviousSegmentDurations/this.movieTimescale;e.editListOffset-=Math.round(t*e.timescale)}t=this.isFragmented&&null!==this.reader.fileSize&&this.reader.fileSize>i+n.totalSize;break}if("moof"===n.name){if(!this.input._initInput)throw new Error('"moof" box encountered with no "moov" box present; this file is likely a Segment as described in ISO/IEC 14496-12 Section 8.16. A separate init file that contains a "moov" box is required to read this file, please provide it using InputOptions.initInput.');const e=await this.input._initInput._getDemuxer();if(e.constructor!==Jr)throw new Error("Init input must match the input's format.");await e.readMetadata(),this.movieTimescale=e.movieTimescale,this.movieDurationInTimescale=e.movieDurationInTimescale,this.metadataTags=e.metadataTags,this.isFragmented=!0,this.fragmentTrackDefaults=e.fragmentTrackDefaults,this.psshBoxes=e.psshBoxes;for(const t of e.tracks){const e={id:t.id,demuxer:this,trackBacking:null,disposition:t.disposition,timescale:t.timescale,durationInMediaTimescale:t.durationInMediaTimescale,durationInMovieTimescale:t.durationInMovieTimescale,rotation:t.rotation,internalCodecId:t.internalCodecId,name:t.name,languageCode:t.languageCode,sampleTableByteOffset:null,sampleTable:null,fragmentLookupTable:[],currentFragmentState:null,fragmentPositionCache:[],editListPreviousSegmentDurations:t.editListPreviousSegmentDurations,editListOffset:t.editListOffset,encryptionInfo:t.encryptionInfo,encryptionAuxInfo:null,frmaCodecString:null,info:t.info};if(t.trackBacking)if(l(e.info),"video"===e.info.type&&-1!==e.info.width){const t=e;e.trackBacking=new ei(t),this.tracks.push(e)}else if("audio"===e.info.type&&-1!==e.info.numberOfChannels){const t=e;e.trackBacking=new ti(t),this.tracks.push(e)}}t=!1;break}}e=i+n.totalSize}if(t){l(null!==this.reader.fileSize);let e=this.reader.requestSlice(this.reader.fileSize-4,4);e instanceof Promise&&(e=await e),l(e);const t=Cr(e),r=this.reader.fileSize-t;if(r>=0&&r<=this.reader.fileSize-Fr){let e=this.reader.requestSliceRange(r,8,Fr);if(e instanceof Promise&&(e=await e),e){const t=Br(e);if(t&&"mfra"===t.name){let r=this.reader.requestSlice(e.filePos,t.contentSize);r instanceof Promise&&(r=await r),r&&this.readContiguousBoxes(r)}}}}})()}getSampleTableForTrack(e){if(e.sampleTable)return e.sampleTable;const t={sampleTimingEntries:[],sampleCompositionTimeOffsets:[],sampleSizes:[],keySampleIndices:null,chunkOffsets:[],sampleToChunk:[],presentationTimestamps:null,presentationTimestampIndexMap:null};if(e.sampleTable=t,null===e.sampleTableByteOffset)return t;l(this.moovSlice);const r=this.moovSlice.slice(e.sampleTableByteOffset);this.currentTrack=e,this.traverseBox(r),this.currentTrack=null;if("audio"===e.info?.type&&e.info.codec&&Ae.includes(e.info.codec)&&0===t.sampleCompositionTimeOffsets.length){l("audio"===e.info?.type);const r=Ve(e.info.codec),i=[],n=[];for(let a=0;a<t.sampleToChunk.length;a++){const s=t.sampleToChunk[a],o=t.sampleToChunk[a+1],c=(o?o.startChunkIndex:t.chunkOffsets.length)-s.startChunkIndex;for(let a=0;a<c;a++){const o=s.startSampleIndex+a*s.samplesPerChunk,c=o+s.samplesPerChunk,d=O(t.sampleTimingEntries,o,e=>e.startIndex),l=t.sampleTimingEntries[d],u=O(t.sampleTimingEntries,c,e=>e.startIndex),f=t.sampleTimingEntries[u],m=l.startDecodeTimestamp+(o-l.startIndex)*l.delta,p=f.startDecodeTimestamp+(c-f.startIndex)*f.delta-m,g=h(i);g&&g.delta===p?g.count++:i.push({startIndex:s.startChunkIndex+a,startDecodeTimestamp:m,count:1,delta:p});const y=s.samplesPerChunk*r.sampleSize*e.info.numberOfChannels;n.push(y)}s.startSampleIndex=s.startChunkIndex,s.samplesPerChunk=1}t.sampleTimingEntries=i,t.sampleSizes=n}
1if(t.sampleCompositionTimeOffsets.length>0){t.presentationTimestamps=[];for(const e of t.sampleTimingEntries)for(let r=0;r<e.count;r++)t.presentationTimestamps.push({presentationTimestamp:e.startDecodeTimestamp+r*e.delta,sampleIndex:e.startIndex+r});for(const e of t.sampleCompositionTimeOffsets)for(let r=0;r<e.count;r++){const i=e.startIndex+r,n=t.presentationTimestamps[i];n&&(n.presentationTimestamp+=e.offset)}t.presentationTimestamps.sort((e,t)=>e.presentationTimestamp-t.presentationTimestamp),t.presentationTimestampIndexMap=Array(t.presentationTimestamps.length).fill(-1);for(let e=0;e<t.presentationTimestamps.length;e++)t.presentationTimestampIndexMap[t.presentationTimestamps[e].sampleIndex]=e}return t}async readFragment(e){if(this.lastReadFragment?.moofOffset===e)return this.lastReadFragment;let t=this.reader.requestSliceRange(e,8,Fr);t instanceof Promise&&(t=await t),l(t);const r=Br(t);l("moof"===r?.name);let i=this.reader.requestSlice(e,r.totalSize);i instanceof Promise&&(i=await i),l(i),this.traverseBox(i);const n=this.lastReadFragment;l(n&&n.moofOffset===e);for(const[,e]of n.trackData){const t=e.track,{fragmentPositionCache:r}=t;if(!e.startTimestampIsFinal){const i=t.fragmentLookupTable.find(e=>e.moofOffset===n.moofOffset);if(i)si(e,i.timestamp);else{const t=O(r,n.moofOffset-1,e=>e.moofOffset);if(-1!==t){const i=r[t];si(e,i.endTimestamp)}}e.startTimestampIsFinal=!0}const i=O(r,e.startTimestamp,e=>e.startTimestamp);if(-1!==i&&r[i].moofOffset===n.moofOffset||r.splice(i+1,0,{moofOffset:n.moofOffset,startTimestamp:e.startTimestamp,endTimestamp:e.endTimestamp}),e.encryptionAuxInfo&&t.encryptionInfo){const r=await li(this.reader,t.encryptionInfo,e.encryptionAuxInfo);for(let t=0;t<Math.min(e.samples.length,r.length);t++){const i=r[t];e.samples[t].encryption=i}}}return n}readContiguousBoxes(e){const t=e.filePos;for(;e.filePos-t<=e.length-8;){if(!this.traverseBox(e))break}}*iterateContiguousBoxes(e){const t=e.filePos;for(;e.filePos-t<=e.length-8;){const t=e.filePos,r=Br(e);if(!r)break;yield{boxInfo:r,slice:e},e.filePos=t+r.totalSize}}traverseBox(e){const t=e.filePos,r=Br(e);if(!r)return!1;const n=e.filePos,a=t+r.totalSize;switch(r.name){case"mdia":case"minf":case"dinf":case"mfra":case"edts":case"sinf":case"schi":case"wave":this.readContiguousBoxes(e.slice(n,r.contentSize));break;case"mvhd":{const t=wr(e);e.skip(3),1===t?(e.skip(16),this.movieTimescale=Cr(e),this.movieDurationInTimescale=Ir(e)):(e.skip(8),this.movieTimescale=Cr(e),this.movieDurationInTimescale=Cr(e))}break;case"trak":{const t={id:-1,demuxer:this,trackBacking:null,disposition:{...rr,primary:!1},info:null,timescale:-1,durationInMovieTimescale:-1,durationInMediaTimescale:-1,rotation:0,internalCodecId:null,name:null,languageCode:V,sampleTableByteOffset:-1,sampleTable:null,fragmentLookupTable:[],currentFragmentState:null,fragmentPositionCache:[],editListPreviousSegmentDurations:0,editListOffset:0,encryptionInfo:null,encryptionAuxInfo:null,frmaCodecString:null};if(this.currentTrack=t,this.readContiguousBoxes(e.slice(n,r.contentSize)),-1!==t.id&&-1!==t.timescale&&null!==t.info)if("video"===t.info.type&&-1!==t.info.width){const e=t;t.trackBacking=new ei(e),this.tracks.push(t)}else if("audio"===t.info.type&&-1!==t.info.numberOfChannels){const e=t;t.trackBacking=new ti(e),this.tracks.push(t)}this.currentTrack=null}break;case"tkhd":{const t=this.currentTrack;if(!t)break;const r=wr(e),i=!!(1&Tr(e));if(t.disposition.default=i,0===r)e.skip(8),t.id=Cr(e),e.skip(4),t.durationInMovieTimescale=Cr(e);else{if(1!==r)throw new Error(`Incorrect track header version ${r}.`);e.skip(16),t.id=Cr(e),e.skip(4),t.durationInMovieTimescale=Ir(e)}e.skip(16);const n=[Dr(e),Dr(e),Mr(e),Dr(e),Dr(e),Mr(e),Dr(e),Dr(e),Mr(e)],a=u(H(oi(n),90));l(0===a||90===a||180===a||270===a),t.rotation=a}break;case"elst":{const t=this.currentTrack;if(!t)break;const r=wr(e);e.skip(3);let i=!1,n=0;const a=Cr(e);for(let s=0;s<a;s++){const a=1===r?Ir(e):Cr(e),s=1===r?$r(e):Ar(e),o=Dr(e);if(0!==a){if(i){d._warn("Unsupported edit list: multiple edits are not currently supported. Only using first edit.");break}if(-1!==s){if(1!==o){d._warn("Unsupported edit list entry: media rate must be 1.");break}t.editListPreviousSegmentDurations=n,t.editListOffset=s,i=!0}else n+=a}}}break;case"mdhd":{const t=this.currentTrack;if(!t)break;const r=wr(e);e.skip(3),0===r?(e.skip(8),t.timescale=Cr(e),t.durationInMediaTimescale=Cr(e)):1===r&&(e.skip(16),t.timescale=Cr(e),t.durationInMediaTimescale=Ir(e));let i=kr(e);
1if(i>0){t.languageCode="";for(let e=0;e<3;e++)t.languageCode=String.fromCharCode(96+(31&i))+t.languageCode,i>>=5;Q(t.languageCode)||(t.languageCode=V)}}break;case"hdlr":{const t=this.currentTrack;if(!t)break;e.skip(8);const r=Rr(e,4);"vide"===r?t.info={type:"video",width:-1,height:-1,squarePixelWidth:-1,squarePixelHeight:-1,codec:null,codecDescription:null,colorSpace:null,avcType:null,avcCodecInfo:null,hevcCodecInfo:null,vp9CodecInfo:null,av1CodecInfo:null}:"soun"===r&&(t.info={type:"audio",numberOfChannels:-1,sampleRate:-1,codec:null,codecDescription:null,aacCodecInfo:null,pcmLittleEndian:!1,pcmSampleSize:null})}break;case"stbl":{const i=this.currentTrack;if(!i)break;i.sampleTableByteOffset=t,this.readContiguousBoxes(e.slice(n,r.contentSize))}break;case"stsd":{const t=this.currentTrack;if(!t)break;if(null===t.info||t.sampleTable)break;const r=wr(e);e.skip(3);const i=Cr(e);for(let n=0;n<i;n++){const i=e.filePos,n=Br(e);if(!n)break;t.internalCodecId=n.name;const a=n.name.toLowerCase();if("video"===t.info.type){e.skip(24),t.info.width=kr(e),t.info.height=kr(e),t.info.squarePixelWidth=t.info.width,t.info.squarePixelHeight=t.info.height,e.skip(50),t.frmaCodecString=null,this.readContiguousBoxes(e.slice(e.filePos,i+n.totalSize-e.filePos));const r="encv"===a?t.frmaCodecString:a;t.frmaCodecString=null,"avc1"===r||"avc3"===r?(t.info.codec="avc",t.info.avcType="avc1"===r?1:3):"hvc1"===r||"hev1"===r?t.info.codec="hevc":"vp08"===r?t.info.codec="vp8":"vp09"===r?t.info.codec="vp9":"av01"===r?t.info.codec="av1":null===r?d._warn("Unknown encrypted video codec due to missing frma box."):d._warn(`Unsupported video codec (sample entry type '${n.name}').`)}else{e.skip(8);const s=kr(e);e.skip(6);let o=kr(e),c=kr(e);e.skip(4);let l=Cr(e)/65536,u=null;0===r&&s>0&&(1===s?(e.skip(4),c=8*Cr(e),e.skip(8)):2===s&&(e.skip(4),l=Nr(e),o=Cr(e),e.skip(4),c=Cr(e),u=Cr(e),e.skip(8))),t.info.numberOfChannels=o,t.info.sampleRate=l,t.frmaCodecString=null,this.readContiguousBoxes(e.slice(e.filePos,i+n.totalSize-e.filePos));const h="enca"===a?t.frmaCodecString:a;if(t.frmaCodecString=null,"mp4a"===h);else if("opus"===h)t.info.codec="opus",t.info.sampleRate=48e3;else if("flac"===h)t.info.codec="flac";else if("ulaw"===h)t.info.codec="ulaw";else if("alaw"===h)t.info.codec="alaw";else if("ac-3"===h)t.info.codec="ac3";else if("ec-3"===h)t.info.codec="eac3";else if("twos"===h)8===c?t.info.codec="pcm-s8":16===c?t.info.codec=t.info.pcmLittleEndian?"pcm-s16":"pcm-s16be":(d._warn(`Unsupported sample size ${c} for codec 'twos'.`),t.info.codec=null);else if("sowt"===h)8===c?t.info.codec="pcm-s8":16===c?t.info.codec="pcm-s16":(d._warn(`Unsupported sample size ${c} for codec 'sowt'.`),t.info.codec=null);else if("raw "===h)t.info.codec="pcm-u8";else if("in24"===h)t.info.codec=t.info.pcmLittleEndian?"pcm-s24":"pcm-s24be";else if("in32"===h)t.info.codec=t.info.pcmLittleEndian?"pcm-s32":"pcm-s32be";else if("fl32"===h)t.info.codec=t.info.pcmLittleEndian?"pcm-f32":"pcm-f32be";else if("fl64"===h)t.info.codec=t.info.pcmLittleEndian?"pcm-f64":"pcm-f64be";else if("ipcm"===h){const e=t.info.pcmSampleSize;t.info.pcmLittleEndian?16===e?t.info.codec="pcm-s16":24===e?t.info.codec="pcm-s24":32===e?t.info.codec="pcm-s32":(d._warn(`Invalid ipcm sample size ${e}.`),t.info.codec=null):16===e?t.info.codec="pcm-s16be":24===e?t.info.codec="pcm-s24be":32===e?t.info.codec="pcm-s32be":(d._warn(`Invalid ipcm sample size ${e}.`),t.info.codec=null)}else if("fpcm"===h){const e=t.info.pcmSampleSize;t.info.pcmLittleEndian?32===e?t.info.codec="pcm-f32":64===e?t.info.codec="pcm-f64":(d._warn(`Invalid fpcm sample size ${e}.`),t.info.codec=null):32===e?t.info.codec="pcm-f32be":64===e?t.info.codec="pcm-f64be":(d._warn(`Invalid fpcm sample size ${e}.`),t.info.codec=null)}else if("lpcm"===h&&null!==u){const e=c+7>>3,r=Boolean(1&u),i=Boolean(2&u),n=4&u?-1:0;c>0&&c<=64&&(r?32===c&&(t.info.codec=i?"pcm-f32be":"pcm-f32"):n&1<<e-1?1===e?t.info.codec="pcm-s8":2===e?t.info.codec=i?"pcm-s16be":"pcm-s16":3===e?t.info.codec=i?"pcm-s24be":"pcm-s24":4===e&&(t.info.codec=i?"pcm-s32be":"pcm-s32"):1===e&&(t.info.codec="pcm-u8")),null===t.info.codec&&d._warn("Unsupported PCM format.")}else null===h?d._warn("Unknown encrypted audio codec due to missing frma box."):d._warn(`Unsupported audio codec (sample entry type '${n.name}').`)}e.filePos=i+n.totalSize}}break;case"frma":{const t=this.currentTrack;if(!t)break;const r=Rr(e,4).toLowerCase();t.frmaCodecString=r}break;case"schm":{const t=this.currentTrack;if(!t)break;e.skip(4);const r=Rr(e,4);
1"cenc"===r||"cens"===r||"cbcs"===r?t.encryptionInfo={scheme:r,defaultKid:null,defaultIsProtected:null,defaultPerSampleIvSize:null,defaultConstantIv:null,defaultCryptByteBlock:null,defaultSkipByteBlock:null}:d._warn(`Unsupported encryption scheme '${r}'.`)}break;case"tenc":{const t=this.currentTrack;if(!t||!t.encryptionInfo)break;const r=wr(e);e.skip(3),e.skip(1);const i=wr(e);if(r>0?(t.encryptionInfo.defaultCryptByteBlock=i>>4,t.encryptionInfo.defaultSkipByteBlock=15&i):(t.encryptionInfo.defaultCryptByteBlock=0,t.encryptionInfo.defaultSkipByteBlock=0),t.encryptionInfo.defaultIsProtected=0!==wr(e),t.encryptionInfo.defaultPerSampleIvSize=wr(e),t.encryptionInfo.defaultKid=_(br(e,16)),t.encryptionInfo.defaultIsProtected&&0===t.encryptionInfo.defaultPerSampleIvSize){const r=wr(e),i=new Uint8Array(16);i.set(br(e,r),0),t.encryptionInfo.defaultConstantIv=i}}break;case"avcC":{const t=this.currentTrack;if(!t)break;l(t.info),t.info.codecDescription=br(e,r.contentSize)}break;case"hvcC":{const t=this.currentTrack;if(!t)break;l(t.info),t.info.codecDescription=br(e,r.contentSize)}break;case"vpcC":{const t=this.currentTrack;if(!t)break;l("video"===t.info?.type),e.skip(4);const r=wr(e),i=wr(e),n=wr(e),a=n>>4,s=n>>1&7,o=1&n,c=wr(e),d=wr(e),u=wr(e);t.info.vp9CodecInfo={profile:r,level:i,bitDepth:a,chromaSubsampling:s,videoFullRangeFlag:o,colourPrimaries:c,transferCharacteristics:d,matrixCoefficients:u}}break;case"av1C":{const t=this.currentTrack;if(!t)break;l("video"===t.info?.type),e.skip(1);const r=wr(e),i=r>>5,n=31&r,a=wr(e),s=a>>7,o=a>>6&1,c=a>>4&1,d=a>>3&1,u=a>>2&1,h=3&a,f=2===i&&o?a>>5&1?12:10:o?10:8;t.info.av1CodecInfo={profile:i,level:n,tier:s,bitDepth:f,monochrome:c,chromaSubsamplingX:d,chromaSubsamplingY:u,chromaSamplePosition:h}}break;case"colr":{const t=this.currentTrack;if(!t)break;l("video"===t.info?.type);const r=Rr(e,4);if("nclx"!==r&&"nclc"!==r)break;const i=kr(e),n=kr(e),a=kr(e);let s;"nclx"===r&&(s=Boolean(128&wr(e))),t.info.colorSpace={primaries:T[i],transfer:S[n],matrix:P[a],fullRange:s}}break;case"pasp":{const t=this.currentTrack;if(!t)break;l("video"===t.info?.type);const r=Cr(e),i=Cr(e);r>0&&i>0&&(r>i?t.info.squarePixelWidth=Math.round(t.info.width*r/i):t.info.squarePixelHeight=Math.round(t.info.height*i/r))}break;case"esds":{const t=this.currentTrack;if(!t)break;l("audio"===t.info?.type),e.skip(4);l(3===wr(e)),jr(e),e.skip(2);const r=wr(e),i=!!(64&r),n=!!(32&r);if(!!(128&r)&&e.skip(2),i){const t=wr(e);e.skip(t)}n&&e.skip(2);l(4===wr(e));const a=jr(e),o=e.filePos,c=wr(e);if(64===c||103===c?(t.info.codec="aac",t.info.aacCodecInfo={isMpeg2:103===c,objectType:null}):105===c||107===c?t.info.codec="mp3":221===c?t.info.codec="vorbis":d._warn(`Unsupported audio codec (objectTypeIndication ${c}) - discarding track.`),e.skip(12),a>e.filePos-o){l(5===wr(e));const r=jr(e);if(t.info.codecDescription=br(e,r),"aac"===t.info.codec){const e=s(t.info.codecDescription);null!==e.numberOfChannels&&(t.info.numberOfChannels=e.numberOfChannels),null!==e.sampleRate&&(t.info.sampleRate=e.sampleRate)}}}break;case"enda":{const t=this.currentTrack;if(!t)break;l("audio"===t.info?.type),t.info.pcmLittleEndian=!!(255&kr(e))}break;case"pcmC":{const t=this.currentTrack;if(!t)break;l("audio"===t.info?.type),e.skip(4);const r=wr(e);t.info.pcmLittleEndian=Boolean(1&r),t.info.pcmSampleSize=wr(e)}break;case"dOps":{const t=this.currentTrack;if(!t)break;l("audio"===t.info?.type),e.skip(1);const r=wr(e),i=kr(e),n=Cr(e),a=xr(e),s=wr(e);let o;o=0!==s?br(e,2+r):new Uint8Array(0);const c=new Uint8Array(19+o.byteLength),d=new DataView(c.buffer);d.setUint32(0,1332770163,!1),d.setUint32(4,1214603620,!1),d.setUint8(8,1),d.setUint8(9,r),d.setUint16(10,i,!0),d.setUint32(12,n,!0),d.setInt16(16,a,!0),d.setUint8(18,s),c.set(o,19),t.info.codecDescription=c,t.info.numberOfChannels=r}break;case"dfLa":{const t=this.currentTrack;if(!t)break;l("audio"===t.info?.type),e.skip(4);const r=127,i=128,n=e.filePos;for(;e.filePos<a;){const n=wr(e),a=Tr(e);if((n&r)===Mt.STREAMINFO){e.skip(10);const r=Cr(e),i=r>>>12,n=1+(r>>9&7);t.info.sampleRate=i,t.info.numberOfChannels=n,e.skip(20)}else e.skip(a);if(n&i)break}const s=e.filePos;e.filePos=n;const o=br(e,s-n),c=new Uint8Array(4+o.byteLength);new DataView(c.buffer).setUint32(0,1716281667,!1),c.set(o,4),t.info.codecDescription=c}break;case"dac3":{const t=this.currentTrack;if(!t)break;l("audio"===t.info?.type);const r=br(e,3),n=new i(r),a=n.readBits(2);n.skipBits(8);const s=n.readBits(3),o=n.readBits(1);a<3&&(t.info.sampleRate=tt[a]),t.info.numberOfChannels=Lt[s]+o}break;case"dec3":{const t=this.currentTrack;if(!t)break;l("audio"===t.info?.type);const n=(e=>{if(e.length<2)return null;const t=new i(e),r=t.readBits(13),n=t.readBits(3),a=[];for(let r=0;r<=n&&!(Math.ceil(t.pos/8)+3>e.length);r++){const e=t.readBits(2),r=t.readBits(5);t.skipBits(1),t.skipBits(1);const i=t.readBits(3),n=t.readBits(3),s=t.readBits(1);t.skipBits(3);const o=t.readBits(4);let c=0;o>
10?c=t.readBits(9):t.skipBits(1),a.push({fscod:e,fscod2:null,bsid:r,bsmod:i,acmod:n,lfeon:s,numDepSub:o,chanLoc:c})}return 0===a.length?null:{dataRate:r,substreams:a}})(br(e,r.contentSize));if(!n){d._warn("Invalid dec3 box contents, ignoring.");break}const a=qt(n);null!==a&&(t.info.sampleRate=a),t.info.numberOfChannels=Ht(n)}break;case"stts":{const t=this.currentTrack;if(!t)break;if(!t.sampleTable)break;e.skip(4);const r=Cr(e);let i=0,n=0;for(let a=0;a<r;a++){const r=Cr(e),a=Cr(e);t.sampleTable.sampleTimingEntries.push({startIndex:i,startDecodeTimestamp:n,count:r,delta:a}),i+=r,n+=r*a}}break;case"ctts":{const t=this.currentTrack;if(!t)break;if(!t.sampleTable)break;e.skip(4);const r=Cr(e);let i=0;for(let n=0;n<r;n++){const r=Cr(e),n=Ar(e);t.sampleTable.sampleCompositionTimeOffsets.push({startIndex:i,count:r,offset:n}),i+=r}}break;case"stsz":{const t=this.currentTrack;if(!t)break;if(!t.sampleTable)break;e.skip(4);const r=Cr(e),i=Cr(e);if(0===r)for(let r=0;r<i;r++){const r=Cr(e);t.sampleTable.sampleSizes.push(r)}else t.sampleTable.sampleSizes.push(r)}break;case"stz2":{const t=this.currentTrack;if(!t)break;if(!t.sampleTable)break;e.skip(4),e.skip(3);const r=wr(e),n=Cr(e),a=br(e,Math.ceil(n*r/8)),s=new i(a);for(let e=0;e<n;e++){const e=s.readBits(r);t.sampleTable.sampleSizes.push(e)}}break;case"stss":{const t=this.currentTrack;if(!t)break;if(!t.sampleTable)break;e.skip(4),t.sampleTable.keySampleIndices=[];const r=Cr(e);for(let i=0;i<r;i++){const r=Cr(e)-1;t.sampleTable.keySampleIndices.push(r)}0!==t.sampleTable.keySampleIndices[0]&&t.sampleTable.keySampleIndices.unshift(0)}break;case"stsc":{const t=this.currentTrack;if(!t)break;if(!t.sampleTable)break;e.skip(4);const r=Cr(e);for(let i=0;i<r;i++){const r=Cr(e)-1,i=Cr(e),n=Cr(e);t.sampleTable.sampleToChunk.push({startSampleIndex:-1,startChunkIndex:r,samplesPerChunk:i,sampleDescriptionIndex:n})}let i=0;for(let e=0;e<t.sampleTable.sampleToChunk.length;e++)if(t.sampleTable.sampleToChunk[e].startSampleIndex=i,e<t.sampleTable.sampleToChunk.length-1){i+=(t.sampleTable.sampleToChunk[e+1].startChunkIndex-t.sampleTable.sampleToChunk[e].startChunkIndex)*t.sampleTable.sampleToChunk[e].samplesPerChunk}}break;case"stco":{const t=this.currentTrack;if(!t)break;if(!t.sampleTable)break;e.skip(4);const r=Cr(e);for(let i=0;i<r;i++){const r=Cr(e);t.sampleTable.chunkOffsets.push(r)}}break;case"co64":{const t=this.currentTrack;if(!t)break;if(!t.sampleTable)break;e.skip(4);const r=Cr(e);for(let i=0;i<r;i++){const r=Ir(e);t.sampleTable.chunkOffsets.push(r)}}break;case"mvex":this.isFragmented=!0,this.readContiguousBoxes(e.slice(n,r.contentSize));break;case"mehd":{const t=wr(e);e.skip(3);const r=1===t?Ir(e):Cr(e);this.movieDurationInTimescale=r}break;case"trex":{e.skip(4);const t=Cr(e),r=Cr(e),i=Cr(e),n=Cr(e),a=Cr(e);this.fragmentTrackDefaults.push({trackId:t,defaultSampleDescriptionIndex:r,defaultSampleDuration:i,defaultSampleSize:n,defaultSampleFlags:a})}break;case"tfra":{const t=wr(e);e.skip(3);const r=Cr(e),i=this.tracks.find(e=>e.id===r);if(!i)break;const n=Cr(e),a=(12&n)>>2,s=3&n,o=[wr,kr,Tr,Cr],c=o[(48&n)>>4],d=o[a],l=o[s],u=Cr(e);for(let r=0;r<u;r++){const r=1===t?Ir(e):Cr(e),n=1===t?Ir(e):Cr(e);c(e),d(e),l(e),i.fragmentLookupTable.push({timestamp:r,moofOffset:n})}i.fragmentLookupTable.sort((e,t)=>e.timestamp-t.timestamp);for(let e=0;e<i.fragmentLookupTable.length-1;e++){const t=i.fragmentLookupTable[e],r=i.fragmentLookupTable[e+1];t.timestamp===r.timestamp&&(i.fragmentLookupTable.splice(e+1,1),e--)}}break;case"moof":this.currentFragment={moofOffset:t,moofSize:r.totalSize,implicitBaseDataOffset:t,trackData:new Map,psshBoxes:[]},this.readContiguousBoxes(e.slice(n,r.contentSize)),this.lastReadFragment=this.currentFragment,this.currentFragment=null;break;case"traf":if(l(this.currentFragment),this.readContiguousBoxes(e.slice(n,r.contentSize)),this.currentTrack){const e=this.currentFragment.trackData.get(this.currentTrack.id);e:if(e){if(0===e.samples.length){this.currentFragment.trackData.delete(this.currentTrack.id);break e}e.presentationTimestamps=e.samples.map((e,t)=>({presentationTimestamp:e.presentationTimestamp,sampleIndex:t})).sort((e,t)=>
1e.presentationTimestamp-t.presentationTimestamp);for(let t=0;t<e.presentationTimestamps.length;t++){const r=e.presentationTimestamps[t],i=e.samples[r.sampleIndex];if(null===e.firstKeyFrameTimestamp&&i.isKeyFrame&&(e.firstKeyFrameTimestamp=i.presentationTimestamp),t<e.presentationTimestamps.length-1){const n=e.presentationTimestamps[t+1].presentationTimestamp-r.presentationTimestamp;i.duration=n}}const t=e.samples[e.presentationTimestamps[0].sampleIndex],r=e.samples[h(e.presentationTimestamps).sampleIndex];e.startTimestamp=t.presentationTimestamp,e.endTimestamp=r.presentationTimestamp+r.duration;const{currentFragmentState:i}=this.currentTrack;l(i),null!==i.startTimestamp&&(si(e,i.startTimestamp),e.startTimestampIsFinal=!0),i.encryptionAuxInfo&&!e.samples[0].encryption&&(e.encryptionAuxInfo=i.encryptionAuxInfo)}this.currentTrack.currentFragmentState=null,this.currentTrack=null}break;case"pssh":{if(this.input._formatOptions.isobmff?._suppressPsshParsing)break;const t=Qt(br(e,r.contentSize));this.currentFragment?this.currentFragment.psshBoxes.push(t):this.currentTrack||this.psshBoxes.push(t)}break;case"tfhd":{l(this.currentFragment),e.skip(1);const t=Tr(e),r=Boolean(1&t),i=Boolean(2&t),n=Boolean(8&t),a=Boolean(16&t),s=Boolean(32&t),o=Boolean(65536&t),c=Boolean(131072&t),d=Cr(e),u=this.tracks.find(e=>e.id===d);if(!u)break;const h=this.fragmentTrackDefaults.find(e=>e.trackId===d);this.currentTrack=u,u.currentFragmentState={baseDataOffset:this.currentFragment.implicitBaseDataOffset,sampleDescriptionIndex:h?.defaultSampleDescriptionIndex??null,defaultSampleDuration:h?.defaultSampleDuration??null,defaultSampleSize:h?.defaultSampleSize??null,defaultSampleFlags:h?.defaultSampleFlags??null,startTimestamp:null,encryptionAuxInfo:null},r?u.currentFragmentState.baseDataOffset=Ir(e):c&&(u.currentFragmentState.baseDataOffset=this.currentFragment.moofOffset),i&&(u.currentFragmentState.sampleDescriptionIndex=Cr(e)),n&&(u.currentFragmentState.defaultSampleDuration=Cr(e)),a&&(u.currentFragmentState.defaultSampleSize=Cr(e)),s&&(u.currentFragmentState.defaultSampleFlags=Cr(e)),o&&(u.currentFragmentState.defaultSampleDuration=0)}break;case"tfdt":{const t=this.currentTrack;if(!t)break;l(t.currentFragmentState);const r=wr(e);e.skip(3);const i=0===r?Cr(e):Ir(e);t.currentFragmentState.startTimestamp=i}break;case"trun":{const t=this.currentTrack;if(!t)break;l(this.currentFragment),l(t.currentFragmentState);const r=wr(e),i=Tr(e),n=Boolean(1&i),a=Boolean(4&i),s=Boolean(256&i),o=Boolean(512&i),c=Boolean(1024&i),d=Boolean(2048&i),u=Cr(e);let h=null;n&&(h=Ar(e));let f,m=null;a&&(m=Cr(e)),this.currentFragment.trackData.has(t.id)?(f=this.currentFragment.trackData.get(t.id),null!==h&&(f.currentOffset=t.currentFragmentState.baseDataOffset+h)):(f={track:t,currentTimestamp:0,currentOffset:t.currentFragmentState.baseDataOffset+(h??0),startTimestamp:0,endTimestamp:0,firstKeyFrameTimestamp:null,samples:[],presentationTimestamps:[],startTimestampIsFinal:!1,encryptionAuxInfo:null},this.currentFragment.trackData.set(t.id,f));for(let i=0;i<u;i++){let n,a,u;s?n=Cr(e):(l(null!==t.currentFragmentState.defaultSampleDuration),n=t.currentFragmentState.defaultSampleDuration),o?a=Cr(e):(l(null!==t.currentFragmentState.defaultSampleSize),a=t.currentFragmentState.defaultSampleSize),c?u=Cr(e):(l(null!==t.currentFragmentState.defaultSampleFlags),u=t.currentFragmentState.defaultSampleFlags),0===i&&null!==m&&(u=m);let h=0;d&&(h=0===r?Cr(e):Ar(e));const p=!(65536&u);f.samples.push({presentationTimestamp:f.currentTimestamp+h,duration:n,byteOffset:f.currentOffset,byteSize:a,isKeyFrame:p,encryption:null}),f.currentOffset+=a,f.currentTimestamp+=n}this.currentFragment.implicitBaseDataOffset=f.currentOffset}break;case"saiz":{const t=this.currentTrack;if(!t||!t.encryptionInfo)break;e.skip(1);if(1&Tr(e)){const r=Rr(e,4),i=Cr(e);if(r!==t.encryptionInfo.scheme||0!==i)break}const r=wr(e),i=Cr(e);let n=null;0===r&&i>0&&(n=br(e,i));const a=di(t);a.defaultSampleInfoSize=r,a.sampleSizes=n,a.sampleCount=i}break;case"saio":{const t=this.currentTrack;if(!t||!t.encryptionInfo)break;const r=wr(e);if(1&Tr(e)){const r=Rr(e,4),i=Cr(e);
1if(r!==t.encryptionInfo.scheme||0!==i)break}const i=Cr(e);if(0===i)break;i>1&&d._warn("Multiple saio entries are not supported; using the first offset only.");let n=0===r?Cr(e):Number(Ir(e));this.currentFragment&&(n+=this.currentFragment.moofOffset);di(t).offset=n}break;case"senc":{const t=this.currentTrack;if(!t||!t.encryptionInfo)break;l(this.currentFragment);const r=this.currentFragment.trackData.get(t.id);if(!r)break;e.skip(1);const i=Tr(e),n=Boolean(2&i),a=Cr(e),s=t.encryptionInfo.defaultPerSampleIvSize;l(null!==s);for(let i=0;i<Math.min(a,r.samples.length);i++){const a=new Uint8Array(16);s>0?a.set(br(e,s),0):a.set(t.encryptionInfo.defaultConstantIv,0);let o=null;if(n){const t=kr(e);o=[];for(let r=0;r<t;r++){const t=kr(e),r=Cr(e);o.push({clearLen:t,protectedLen:r})}}r.samples[i].encryption={iv:a,subsamples:o}}}break;case"udta":{const t=this.iterateContiguousBoxes(e.slice(n,r.contentSize));for(const{boxInfo:e,slice:r}of t){if("meta"!==e.name&&!this.currentTrack){const t=r.filePos;this.metadataTags.raw??={},"©"===e.name[0]?this.metadataTags.raw[e.name]??=Lr(r):this.metadataTags.raw[e.name]??=br(r,e.contentSize),r.filePos=t}switch(e.name){case"meta":r.skip(-e.headerSize),this.traverseBox(r);break;case"©nam":case"name":this.currentTrack?this.currentTrack.name=b.decode(br(r,e.contentSize)):this.metadataTags.title??=Lr(r);break;case"©des":this.currentTrack||(this.metadataTags.description??=Lr(r));break;case"©ART":this.currentTrack||(this.metadataTags.artist??=Lr(r));break;case"©alb":this.currentTrack||(this.metadataTags.album??=Lr(r));break;case"albr":this.currentTrack||(this.metadataTags.albumArtist??=Lr(r));break;case"©gen":this.currentTrack||(this.metadataTags.genre??=Lr(r));break;case"©day":if(!this.currentTrack){const e=new Date(Lr(r));Number.isNaN(e.getTime())||(this.metadataTags.date??=e)}break;case"©cmt":this.currentTrack||(this.metadataTags.comment??=Lr(r));break;case"©lyr":this.currentTrack||(this.metadataTags.lyrics??=Lr(r))}}}break;case"meta":{if(this.currentTrack)break;const t=0!==Cr(e);this.currentMetadataKeys=new Map,t?this.readContiguousBoxes(e.slice(n,r.contentSize)):this.readContiguousBoxes(e.slice(n+4,r.contentSize-4)),this.currentMetadataKeys=null}break;case"keys":{if(!this.currentMetadataKeys)break;e.skip(4);const t=Cr(e);for(let r=0;r<t;r++){const t=Cr(e);e.skip(4);const i=b.decode(br(e,t-8));this.currentMetadataKeys.set(r+1,i)}}break;case"ilst":{if(!this.currentMetadataKeys)break;const t=this.iterateContiguousBoxes(e.slice(n,r.contentSize));for(const{boxInfo:e,slice:r}of t){let t=e.name;const i=(t.charCodeAt(0)<<24)+(t.charCodeAt(1)<<16)+(t.charCodeAt(2)<<8)+t.charCodeAt(3);this.currentMetadataKeys.has(i)&&(t=this.currentMetadataKeys.get(i));const n=Ur(r);switch(this.metadataTags.raw??={},this.metadataTags.raw[t]??=n,t){case"©nam":case"titl":case"com.apple.quicktime.title":case"title":"string"==typeof n&&(this.metadataTags.title??=n);break;case"©des":case"desc":case"dscp":case"com.apple.quicktime.description":case"description":"string"==typeof n&&(this.metadataTags.description??=n);break;case"©ART":case"com.apple.quicktime.artist":case"artist":"string"==typeof n&&(this.metadataTags.artist??=n);break;case"©alb":case"albm":case"com.apple.quicktime.album":case"album":"string"==typeof n&&(this.metadataTags.album??=n);break;case"aART":case"album_artist":"string"==typeof n&&(this.metadataTags.albumArtist??=n);break;case"©cmt":case"com.apple.quicktime.comment":case"comment":"string"==typeof n&&(this.metadataTags.comment??=n);break;case"©gen":case"gnre":case"com.apple.quicktime.genre":case"genre":"string"==typeof n&&(this.metadataTags.genre??=n);break;case"©lyr":case"lyrics":"string"==typeof n&&(this.metadataTags.lyrics??=n);break;case"©day":case"rldt":case"com.apple.quicktime.creationdate":case"date":if("string"==typeof n){const e=new Date(n);Number.isNaN(e.getTime())||(this.metadataTags.date??=e)}break;case"covr":case"com.apple.quicktime.artwork":n instanceof Zt?(this.metadataTags.images??=[],this.metadataTags.images.push({data:n.data,kind:"coverFront",mimeType:n.mimeType})):n instanceof Uint8Array&&(this.metadataTags.images??=[],this.metadataTags.images.push({data:n,kind:"coverFront",mimeType:"image/*"}));break;case"track":if("string"==typeof n){const e=n.split("/"),t=Number.parseInt(e[0],10),r=e[1]&&Number.parseInt(e[1],10);Number.isInteger(t)&&t>0&&(this.metadataTags.trackNumber??=t),r&&Number.isInteger(r)&&r>0&&(this.metadataTags.tracksTotal??=r)}break;case"trkn":if(n instanceof Uint8Array&&n.length>=6){const e=y(n),t=e.getUint16(2,!1),r=e.getUint16(4,!1);t>0&&(this.metadataTags.trackNumber??=t),r>0&&(this.metadataTags.tracksTotal??=r)}break;case"disc":case"disk":if(n instanceof Uint8Array&&n.length>=6){const e=y(n),t=e.getUint16(2,!1),r=e.getUint16(4,!1);t>0&&(this.metadataTags.discNumber??=t),r>0&&(this.metadataTags.discsTotal??=r)}}}}}return e.filePos=a,!0}}class Zr{constructor(e){this.internalTrack=e,this.packetToSampleIndex=new WeakMap,this.packetToFragmentLocation=new WeakMap}getId(){return this.internalTrack.id}getNumber(){const e=this.internalTrack.demuxer,t=this.internalTrack.trackBacking.getType();let r=0;for(const i of e.tracks)if(i.trackBacking.getType()===t&&r++,i===this.internalTrack)break;return r}getCodec(){throw new Error("Not implemented on base class.")}getInternalCodecId(){return this.internalTrack.internalCodecId}getName(){return this.internalTrack.name}getLanguageCode(){return this.internalTrack.languageCode}getTimeResolution(){return this.internalTrack.timescale}isRelativeToUnixEpoch(){return!1}getUnixTimeForTimestamp(){return null}getDisposition(){return this.internalTrack.disposition}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){const e=this.internalTrack;if(e.durationInMediaTimescale<=0)return null;l(e.trackBacking);const t=await e.trackBacking.getFirstPacket({metadataOnly:!0});return(t?.timestamp??0)+e.durationInMediaTimescale/e.timescale}
1async getLiveRefreshInterval(){return null}async getFirstPacket(e){const t=await this.fetchPacketForSampleIndex(0,e);return t||!this.internalTrack.demuxer.isFragmented?t:this.performFragmentedLookup(null,e=>e.trackData.get(this.internalTrack.id)?{sampleIndex:0,correctSampleFound:!0}:{sampleIndex:-1,correctSampleFound:!1},-1/0,1/0,e)}mapTimestampIntoTimescale(e){return q(e*this.internalTrack.timescale)+this.internalTrack.editListOffset}async getPacket(e,t){const r=this.mapTimestampIntoTimescale(e),i=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),n=ri(i,r),a=await this.fetchPacketForSampleIndex(n,t);return ci(i)&&this.internalTrack.demuxer.isFragmented?this.performFragmentedLookup(null,e=>{const t=e.trackData.get(this.internalTrack.id);if(!t)return{sampleIndex:-1,correctSampleFound:!1};const i=O(t.presentationTimestamps,r,e=>e.presentationTimestamp);return{sampleIndex:-1!==i?t.presentationTimestamps[i].sampleIndex:-1,correctSampleFound:-1!==i&&r<t.endTimestamp}},r,r,t):a}async getNextPacket(e,t){const r=this.packetToSampleIndex.get(e);if(void 0!==r)return this.fetchPacketForSampleIndex(r+1,t);const i=this.packetToFragmentLocation.get(e);if(void 0===i)throw new Error("Packet was not created from this track.");return this.performFragmentedLookup(i.fragment,e=>{if(e===i.fragment){const t=e.trackData.get(this.internalTrack.id);if(i.sampleIndex+1<t.samples.length)return{sampleIndex:i.sampleIndex+1,correctSampleFound:!0}}else{if(e.trackData.get(this.internalTrack.id))return{sampleIndex:0,correctSampleFound:!0}}return{sampleIndex:-1,correctSampleFound:!1}},-1/0,1/0,t)}async getKeyPacket(e,t){const r=this.mapTimestampIntoTimescale(e),i=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),n=ii(i,r),a=await this.fetchPacketForSampleIndex(n,t);return ci(i)&&this.internalTrack.demuxer.isFragmented?this.performFragmentedLookup(null,e=>{const t=e.trackData.get(this.internalTrack.id);if(!t)return{sampleIndex:-1,correctSampleFound:!1};const i=j(t.presentationTimestamps,e=>t.samples[e.sampleIndex].isKeyFrame&&e.presentationTimestamp<=r);return{sampleIndex:-1!==i?t.presentationTimestamps[i].sampleIndex:-1,correctSampleFound:-1!==i&&r<t.endTimestamp}},r,r,t):a}async getNextKeyPacket(e,t){const r=this.packetToSampleIndex.get(e);if(void 0!==r){const e=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),i=ai(e,r);return this.fetchPacketForSampleIndex(i,t)}const i=this.packetToFragmentLocation.get(e);if(void 0===i)throw new Error("Packet was not created from this track.");return this.performFragmentedLookup(i.fragment,e=>{if(e===i.fragment){const t=e.trackData.get(this.internalTrack.id).samples.findIndex((e,t)=>e.isKeyFrame&&t>i.sampleIndex);if(-1!==t)return{sampleIndex:t,correctSampleFound:!0}}else{const t=e.trackData.get(this.internalTrack.id);if(t&&null!==t.firstKeyFrameTimestamp){const e=t.samples.findIndex(e=>e.isKeyFrame);return l(-1!==e),{sampleIndex:e,correctSampleFound:!0}}}return{sampleIndex:-1,correctSampleFound:!1}},-1/0,1/0,t)}async fetchPacketForSampleIndex(e,t){if(-1===e)return null;const r=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),i=ni(r,e);if(!i)return null;let n;if(t.metadataOnly)n=Kt;else{let t=this.internalTrack.demuxer.reader.requestSlice(i.sampleOffset,i.sampleSize);if(t instanceof Promise&&(t=await t),!t)return null;if(n=br(t,i.sampleSize),this.internalTrack.encryptionAuxInfo){l(this.internalTrack.encryptionInfo);const t=await li(this.internalTrack.demuxer.reader,this.internalTrack.encryptionInfo,this.internalTrack.encryptionAuxInfo);e<t.length&&(n=await ui(this.internalTrack,t[e],n,null))}}const a=(i.presentationTimestamp-this.internalTrack.editListOffset)/this.internalTrack.timescale,s=i.duration/this.internalTrack.timescale,o=new Yt(n,i.isKeyFrame?"key":"delta",a,s,e,i.sampleSize);return this.packetToSampleIndex.set(o,e),o}async fetchPacketInFragment(e,t,r){if(-1===t)return null;const i=e.trackData.get(this.internalTrack.id).samples[t];let n;if(l(i),r.metadataOnly)n=Kt;else{let t=this.internalTrack.demuxer.reader.requestSlice(i.byteOffset,i.byteSize);if(t instanceof Promise&&(t=await t),!t)return null;n=br(t,i.byteSize),i.encryption&&(n=await ui(this.internalTrack,i.encryption,n,e))}const a=(i.presentationTimestamp-this.internalTrack.editListOffset)/this.internalTrack.timescale,s=i.duration/this.internalTrack.timescale,o=new Yt(n,i.isKeyFrame?"key":"delta",a,s,e.moofOffset+t,i.byteSize);return this.packetToFragmentLocation.set(o,{fragment:e,sampleIndex:t}),o}async performFragmentedLookup(e,t,r,i,n){const a=this.internalTrack.demuxer;let s=null,o=null,c=-1;if(e){const{sampleIndex:r,correctSampleFound:i}=t(e);if(i)return this.fetchPacketInFragment(e,r,n);-1!==r&&(o=e,c=r)}const d=O(this.internalTrack.fragmentLookupTable,r,e=>e.timestamp),u=-1!==d?this.internalTrack.fragmentLookupTable[d]:null,h=O(this.internalTrack.fragmentPositionCache,r,e=>e.startTimestamp),f=-1!==h?this.internalTrack.fragmentPositionCache[h]:null,m=Math.max(u?.moofOffset??0,f?.moofOffset??0)||null;let p;for(e?null===m||e.moofOffset>=m?(p=e.moofOffset+e.moofSize,s=e):p=m:p=m??0;;){if(s){const e=s.trackData.get(this.internalTrack.id);if(e&&e.startTimestamp>i)break}let e=a.reader.requestSliceRange(p,8,Fr);if(e instanceof Promise&&(e=await e),!e)break;const r=p,d=Br(e);if(!d)break;if("moof"===d.name){s=await a.readFragment(r);const{sampleIndex:e,correctSampleFound:i}=t(s);if(i)return this.fetchPacketInFragment(s,e,n);-1!==e&&(o=s,c=e)}p=r+d.totalSize}
1if(u&&(!o||o.moofOffset<u.moofOffset)){const e=this.internalTrack.fragmentLookupTable[d-1];l(!e||e.timestamp<u.timestamp);const r=e?.timestamp??-1/0;return this.performFragmentedLookup(null,t,r,i,n)}return o?this.fetchPacketInFragment(o,c,n):null}}class ei extends Zr{constructor(e){super(e),this.decoderConfigPromise=null,this.internalTrack=e}getType(){return"video"}getCodec(){return this.internalTrack.info.codec}getCodedWidth(){return this.internalTrack.info.width}getCodedHeight(){return this.internalTrack.info.height}getSquarePixelWidth(){return this.internalTrack.info.squarePixelWidth}getSquarePixelHeight(){return this.internalTrack.info.squarePixelHeight}getRotation(){return this.internalTrack.rotation}async getColorSpace(){return{primaries:this.internalTrack.info.colorSpace?.primaries,transfer:this.internalTrack.info.colorSpace?.transfer,matrix:this.internalTrack.info.colorSpace?.matrix,fullRange:this.internalTrack.info.colorSpace?.fullRange}}async canBeTransparent(){return!1}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfigPromise??=(async()=>{if("vp9"!==this.internalTrack.info.codec||this.internalTrack.info.vp9CodecInfo){if("av1"===this.internalTrack.info.codec&&!this.internalTrack.info.av1CodecInfo){const e=await this.getFirstPacket({});this.internalTrack.info.av1CodecInfo=e&&Rt(e.data)}}else{const e=await this.getFirstPacket({});this.internalTrack.info.vp9CodecInfo=e&&_t(e.data)}const e={codec:Le(this.internalTrack.info),codedWidth:this.internalTrack.info.width,codedHeight:this.internalTrack.info.height,description:this.internalTrack.info.codecDescription??void 0,colorSpace:this.internalTrack.info.colorSpace??void 0};return this.internalTrack.info.width===this.internalTrack.info.squarePixelWidth&&this.internalTrack.info.height===this.internalTrack.info.squarePixelHeight||(e.displayAspectWidth=this.internalTrack.info.squarePixelWidth,e.displayAspectHeight=this.internalTrack.info.squarePixelHeight),e})():null}}class ti extends Zr{constructor(e){super(e),this.decoderConfig=null,this.internalTrack=e}getType(){return"audio"}getCodec(){return this.internalTrack.info.codec}getNumberOfChannels(){return this.internalTrack.info.numberOfChannels}getSampleRate(){return this.internalTrack.info.sampleRate}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfig??={codec:ze(this.internalTrack.info),numberOfChannels:this.internalTrack.info.numberOfChannels,sampleRate:this.internalTrack.info.sampleRate,description:this.internalTrack.info.codecDescription??void 0}:null}}const ri=(e,t)=>{if(e.presentationTimestamps){const r=O(e.presentationTimestamps,t,e=>e.presentationTimestamp);return-1===r?-1:e.presentationTimestamps[r].sampleIndex}{const r=O(e.sampleTimingEntries,t,e=>e.startDecodeTimestamp);if(-1===r)return-1;const i=e.sampleTimingEntries[r];return i.startIndex+Math.min(Math.floor((t-i.startDecodeTimestamp)/i.delta),i.count-1)}},ii=(e,t)=>{if(!e.keySampleIndices)return ri(e,t);if(e.presentationTimestamps){const r=O(e.presentationTimestamps,t,e=>e.presentationTimestamp);if(-1===r)return-1;for(let t=r;t>=0;t--){const r=e.presentationTimestamps[t].sampleIndex;if(-1!==R(e.keySampleIndices,r,e=>e))return r}return-1}{const r=ri(e,t),i=O(e.keySampleIndices,r,e=>e);return e.keySampleIndices[i]??-1}},ni=(e,t)=>{const r=O(e.sampleTimingEntries,t,e=>e.startIndex),i=e.sampleTimingEntries[r];if(!i||i.startIndex+i.count<=t)return null;let n=i.startDecodeTimestamp+(t-i.startIndex)*i.delta;const a=O(e.sampleCompositionTimeOffsets,t,e=>e.startIndex),s=e.sampleCompositionTimeOffsets[a];s&&t-s.startIndex<s.count&&(n+=s.offset);const o=e.sampleSizes[Math.min(t,e.sampleSizes.length-1)],c=O(e.sampleToChunk,t,e=>e.startSampleIndex),d=e.sampleToChunk[c];l(d);const u=d.startChunkIndex+Math.floor((t-d.startSampleIndex)/d.samplesPerChunk),h=e.chunkOffsets[u],f=d.startSampleIndex+(u-d.startChunkIndex)*d.samplesPerChunk;let m=0,p=h;if(1===e.sampleSizes.length)p+=o*(t-f),m+=o*d.samplesPerChunk;else for(let r=f;r<f+d.samplesPerChunk;r++){const i=e.sampleSizes[r];r<t&&(p+=i),m+=i}let g=i.delta;if(e.presentationTimestamps){const r=e.presentationTimestampIndexMap[t];if(l(void 0!==r),r<e.presentationTimestamps.length-1){g=e.presentationTimestamps[r+1].presentationTimestamp-n}}return{presentationTimestamp:n,duration:g,sampleOffset:p,sampleSize:o,chunkOffset:h,chunkSize:m,isKeyFrame:!e.keySampleIndices||-1!==R(e.keySampleIndices,t,e=>e)}},ai=(e,t)=>
1{if(!e.keySampleIndices)return t+1;const r=O(e.keySampleIndices,t,e=>e);return e.keySampleIndices[r+1]??-1},si=(e,t)=>{e.startTimestamp+=t,e.endTimestamp+=t;for(const r of e.samples)r.presentationTimestamp+=t;for(const r of e.presentationTimestamps)r.presentationTimestamp+=t},oi=e=>{const[t,r]=e,i=Math.atan2(r,t);return Number.isFinite(i)?i*(180/Math.PI):0},ci=e=>0===e.sampleSizes.length,di=e=>e.currentFragmentState?e.currentFragmentState.encryptionAuxInfo??={defaultSampleInfoSize:0,sampleSizes:null,sampleCount:0,offset:null,resolved:null}:e.encryptionAuxInfo??={defaultSampleInfoSize:0,sampleSizes:null,sampleCount:0,offset:null,resolved:null},li=async(e,t,r)=>{if(r.resolved)return r.resolved;if(null===r.offset||0===r.sampleCount)throw new Error("Incomplete saiz/saio info; cannot resolve encryption data.");let i=0;if(r.defaultSampleInfoSize>0)i=r.defaultSampleInfoSize*r.sampleCount;else{l(r.sampleSizes);for(let e=0;e<r.sampleCount;e++)i+=r.sampleSizes[e]}let n=e.requestSlice(r.offset,i);if(n instanceof Promise&&(n=await n),!n)throw new Error("Failed to read auxiliary encryption info.");const a=t.defaultPerSampleIvSize;l(null!==a);const s=[];for(let e=0;e<r.sampleCount;e++){const i=r.defaultSampleInfoSize>0?r.defaultSampleInfoSize:r.sampleSizes[e],o=new Uint8Array(16);a>0?o.set(br(n,a),0):o.set(t.defaultConstantIv,0);let c=null;if(i>a){const e=kr(n);c=[];for(let t=0;t<e;t++){const e=kr(n),t=Cr(n);c.push({clearLen:e,protectedLen:t})}}s.push({iv:o,subsamples:c})}return r.resolved=s,s},ui=async(e,t,r,i)=>{l(e.encryptionInfo);const n=e.encryptionInfo;l(null!==n.defaultKid);const a=n.defaultKid;let s;const o=e.demuxer.decryptionKeyCache.get(a);if(o)s=await o;else{if(!e.demuxer.input._formatOptions.isobmff?.resolveKeyId)throw new Error("Encrypted media samples encountered. To decrypt them, please provide a callback for InputOptions.formatOptions.isobmff.resolveKeyId.");const t=(async()=>{let t=e.demuxer.psshBoxes;if(i){t=[...t,...i.psshBoxes].filter(e=>null===e.keyIds||e.keyIds.includes(a));for(let e=0;e<t.length-1;e++)for(let r=e+1;r<t.length;r++)Jt(t[e],t[r])&&(t.splice(r,1),r--)}const r=await e.demuxer.input._formatOptions.isobmff.resolveKeyId({keyId:a,psshBoxes:t});if(!("string"==typeof r&&32===r.length&&$.test(r)||r instanceof Uint8Array&&16===r.byteLength))throw new TypeError("resolveKeyId must return a 32-character hex string or a 16-byte Uint8Array containing the decryption key.");return r instanceof Uint8Array?r:(e=>{l(e.length%2==0);const t=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=parseInt(e.slice(r,r+2),16);return t})(r)})();e.demuxer.decryptionKeyCache.set(a,t),s=await t}return"cenc"===n.scheme||"cens"===n.scheme?hi(s,n,t,r):fi(s,n,t,r)},hi=async(e,t,r,i)=>{const n=new Uint8Array(16);n.set(r.iv,0);const a=await crypto.subtle.importKey("raw",e,{name:"AES-CTR"},!1,["decrypt"]),s=async e=>{const t=await crypto.subtle.decrypt({name:"AES-CTR",counter:n,length:64},a,e);return new Uint8Array(t)};if(!r.subsamples)return s(i);l(null!==t.defaultCryptByteBlock&&null!==t.defaultSkipByteBlock);const o=mi(r.subsamples,t.defaultCryptByteBlock,t.defaultSkipByteBlock);let c=0;for(const e of o)for(const t of e.perSubsample)c+=t.length;const d=new Uint8Array(c);let u=0;for(const e of o)for(const t of e.perSubsample)d.set(i.subarray(t.offset,t.offset+t.length),u),u+=t.length;const h=await s(d),f=new Uint8Array(i);let m=0;for(const e of o)for(const t of e.perSubsample)f.set(h.subarray(m,m+t.length),t.offset),m+=t.length;return f},fi=(e,t,r,i)=>{const n=new Qr;n.init({key:e,iv:r.iv});const a=t.defaultCryptByteBlock,s=t.defaultSkipByteBlock;if(l(null!==a&&null!==s),!r.subsamples){const e=new Uint8Array(i),t=Math.floor(i.length/16);for(let r=0;r<t;r++){const t=16*r;n.in.set(i.subarray(t,t+16)),n.decrypt(),e.set(n.out,t)}return e}if(0===a&&0===s)throw new Error("cbcs with subsamples requires pattern encryption.");const o=new Uint8Array(i),c=mi(r.subsamples,a,s),d=new DataView(r.iv.buffer,r.iv.byteOffset,16);for(const e of c){n.iv[0]=d.getUint32(0,!1),n.iv[1]=d.getUint32(4,!1),n.iv[2]=d.getUint32(8,!1),n.iv[3]=d.getUint32(12,!1);for(const t of e.perSubsample){const e=t.length/16;for(let r=0;r<e;r++){const e=t.offset+16*r;n.in.set(i.subarray(e,e+16)),n.decrypt(),o.set(n.out,e)}}}return o},mi=(e,t,r)=>{const i=[],n=0!==t||0!==r;let a=0;for(const s of e){a+=s.clearLen;const e=[];
1if(n){let i=s.protectedLen,n=a;for(;i>0&&!(i<16*t);){const a=16*t;e.push({offset:n,length:a}),n+=a,i-=a;const s=Math.min(16*r,i);n+=s,i-=s}a+=s.protectedLen}else s.protectedLen>0&&e.push({offset:a,length:s.protectedLen}),a+=s.protectedLen;i.push({perSubsample:e})}return i};class pi{constructor(e){this.value=e}}class gi{constructor(e){this.value=e}}class yi{constructor(e){this.value=e}}class bi{constructor(e){this.value=e}}var wi;!function(e){e[e.EBML=440786851]="EBML",e[e.EBMLVersion=17030]="EBMLVersion",e[e.EBMLReadVersion=17143]="EBMLReadVersion",e[e.EBMLMaxIDLength=17138]="EBMLMaxIDLength",e[e.EBMLMaxSizeLength=17139]="EBMLMaxSizeLength",e[e.DocType=17026]="DocType",e[e.DocTypeVersion=17031]="DocTypeVersion",e[e.DocTypeReadVersion=17029]="DocTypeReadVersion",e[e.Void=236]="Void",e[e.Segment=408125543]="Segment",e[e.SeekHead=290298740]="SeekHead",e[e.Seek=19899]="Seek",e[e.SeekID=21419]="SeekID",e[e.SeekPosition=21420]="SeekPosition",e[e.Duration=17545]="Duration",e[e.Info=357149030]="Info",e[e.TimestampScale=2807729]="TimestampScale",e[e.MuxingApp=19840]="MuxingApp",e[e.WritingApp=22337]="WritingApp",e[e.Tracks=374648427]="Tracks",e[e.TrackEntry=174]="TrackEntry",e[e.TrackNumber=215]="TrackNumber",e[e.TrackUID=29637]="TrackUID",e[e.TrackType=131]="TrackType",e[e.FlagEnabled=185]="FlagEnabled",e[e.FlagDefault=136]="FlagDefault",e[e.FlagForced=21930]="FlagForced",e[e.FlagOriginal=21934]="FlagOriginal",e[e.FlagHearingImpaired=21931]="FlagHearingImpaired",e[e.FlagVisualImpaired=21932]="FlagVisualImpaired",e[e.FlagCommentary=21935]="FlagCommentary",e[e.FlagLacing=156]="FlagLacing",e[e.Name=21358]="Name",e[e.Language=2274716]="Language",e[e.LanguageBCP47=2274717]="LanguageBCP47",e[e.CodecID=134]="CodecID",e[e.CodecPrivate=25506]="CodecPrivate",e[e.CodecDelay=22186]="CodecDelay",e[e.SeekPreRoll=22203]="SeekPreRoll",e[e.DefaultDuration=2352003]="DefaultDuration",e[e.Video=224]="Video",e[e.PixelWidth=176]="PixelWidth",e[e.PixelHeight=186]="PixelHeight",e[e.DisplayWidth=21680]="DisplayWidth",e[e.DisplayHeight=21690]="DisplayHeight",e[e.DisplayUnit=21682]="DisplayUnit",e[e.AlphaMode=21440]="AlphaMode",e[e.Audio=225]="Audio",e[e.SamplingFrequency=181]="SamplingFrequency",e[e.Channels=159]="Channels",e[e.BitDepth=25188]="BitDepth",e[e.SimpleBlock=163]="SimpleBlock",e[e.BlockGroup=160]="BlockGroup",e[e.Block=161]="Block",e[e.BlockAdditions=30113]="BlockAdditions",e[e.BlockMore=166]="BlockMore",e[e.BlockAdditional=165]="BlockAdditional",e[e.BlockAddID=238]="BlockAddID",e[e.BlockDuration=155]="BlockDuration",e[e.ReferenceBlock=251]="ReferenceBlock",e[e.Cluster=524531317]="Cluster",e[e.Timestamp=231]="Timestamp",e[e.Cues=475249515]="Cues",e[e.CuePoint=187]="CuePoint",e[e.CueTime=179]="CueTime",e[e.CueTrackPositions=183]="CueTrackPositions",e[e.CueTrack=247]="CueTrack",e[e.CueClusterPosition=241]="CueClusterPosition",e[e.Colour=21936]="Colour",e[e.MatrixCoefficients=21937]="MatrixCoefficients",e[e.TransferCharacteristics=21946]="TransferCharacteristics",e[e.Primaries=21947]="Primaries",e[e.Range=21945]="Range",e[e.Projection=30320]="Projection",e[e.ProjectionType=30321]="ProjectionType",e[e.ProjectionPoseRoll=30325]="ProjectionPoseRoll",e[e.Attachments=423732329]="Attachments",e[e.AttachedFile=24999]="AttachedFile",e[e.FileDescription=18046]="FileDescription",e[e.FileName=18030]="FileName",e[e.FileMediaType=18016]="FileMediaType",e[e.FileData=18012]="FileData",e[e.FileUID=18094]="FileUID",e[e.Chapters=272869232]="Chapters",e[e.Tags=307544935]="Tags",e[e.Tag=29555]="Tag",e[e.Targets=25536]="Targets",e[e.TargetTypeValue=26826]="TargetTypeValue",e[e.TargetType=25546]="TargetType",e[e.TagTrackUID=25541]="TagTrackUID",e[e.TagEditionUID=25545]="TagEditionUID",e[e.TagChapterUID=25540]="TagChapterUID",e[e.TagAttachmentUID=25542]="TagAttachmentUID",e[e.SimpleTag=26568]="SimpleTag",e[e.TagName=17827]="TagName",e[e.TagLanguage=17530]="TagLanguage",e[e.TagString=17543]="TagString",e[e.TagBinary=17541]="TagBinary",e[e.ContentEncodings=28032]="ContentEncodings",e[e.ContentEncoding=25152]="ContentEncoding",e[e.ContentEncodingOrder=20529]="ContentEncodingOrder",e[e.ContentEncodingScope=20530]="ContentEncodingScope",e[e.ContentCompression=20532]="ContentCompression",e[e.ContentCompAlgo=16980]="ContentCompAlgo",e[e.ContentCompSettings=16981]="ContentCompSettings",e[e.ContentEncryption=20533]="ContentEncryption"}(wi||(wi={}));const vi=[wi.EBML,wi.Segment],ki=[wi.SeekHead,wi.Info,wi.Cluster,wi.Tracks,wi.Cues,wi.Attachments,wi.Chapters,wi.Tags],Ti=[...vi,...ki],xi=e=>e<256?1:e<65536?2:e<1<<24?3:e<2**32?4:e<2**40?5:6,Si=e=>e<256n?1:e<65536n?2:e<1n<<24n?3:e<1n<<32n?4:e<1n<<40n?5:e<1n<<48n?6:e<1n<<56n?7:8,Ci=e=>e>=-64&&e<64?1:e>=-8192&&e<8192?2:e>=-1048576&&e<1<<20?3:e>=-(1<<27)&&e<1<<27?4:e>=-(2**34)&&e<2**34?5:6;class Pi{constructor(e){this.writer=e,this.helper=new Uint8Array(8),this.helperView=new DataView(this.helper.buffer),this.offsets=new WeakMap,this.dataOffsets=new WeakMap}writeByte(e){this.helperView.setUint8(0,e),this.writer.write(this.helper.subarray(0,1))}writeFloat32(e){this.helperView.setFloat32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}writeFloat64(e){this.helperView.setFloat64(0,e,!1),this.writer.write(this.helper)}writeUnsignedInt(e,t=xi(e)){let r=0;switch(t){case 6:this.helperView.setUint8(r++,e/2**40|0);case 5:this.helperView.setUint8(r++,e/2**32|0);case 4:this.helperView.setUint8(r++,e>>24);case 3:this.helperView.setUint8(r++,e>>16);case 2:this.helperView.setUint8(r++,e>>8);case 1:this.helperView.setUint8(r++,e);break;default:throw new Error("Bad unsigned int size "+t)}this.writer.write(this.helper.subarray(0,r))}writeUnsignedBigInt(e,t=Si(e)){let r=0;for(let i=t-1;i>=0;i--)this.helperView.setUint8(r++,Number(e>>BigInt(8*i)&0xffn));this.writer.write(this.helper.subarray(0,r))}writeSignedInt(e,t=Ci(e)){e<0&&(e+=2**(8*t)),this.writeUnsignedInt(e,t)}
1writeVarInt(e,t=(e=>{if(e<127)return 1;if(e<16383)return 2;if(e<2097151)return 3;if(e<268435455)return 4;if(e<2**35-1)return 5;if(e<2**42-1)return 6;throw new Error("EBML varint size not supported "+e)})(e)){let r=0;switch(t){case 1:this.helperView.setUint8(r++,128|e);break;case 2:this.helperView.setUint8(r++,64|e>>8),this.helperView.setUint8(r++,e);break;case 3:this.helperView.setUint8(r++,32|e>>16),this.helperView.setUint8(r++,e>>8),this.helperView.setUint8(r++,e);break;case 4:this.helperView.setUint8(r++,16|e>>24),this.helperView.setUint8(r++,e>>16),this.helperView.setUint8(r++,e>>8),this.helperView.setUint8(r++,e);break;case 5:this.helperView.setUint8(r++,8|e/2**32&7),this.helperView.setUint8(r++,e>>24),this.helperView.setUint8(r++,e>>16),this.helperView.setUint8(r++,e>>8),this.helperView.setUint8(r++,e);break;case 6:this.helperView.setUint8(r++,4|e/2**40&3),this.helperView.setUint8(r++,e/2**32|0),this.helperView.setUint8(r++,e>>24),this.helperView.setUint8(r++,e>>16),this.helperView.setUint8(r++,e>>8),this.helperView.setUint8(r++,e);break;default:throw new Error("Bad EBML varint size "+t)}this.writer.write(this.helper.subarray(0,r))}writeAsciiString(e){this.writer.write(new Uint8Array(e.split("").map(e=>e.charCodeAt(0))))}writeEBML(e){if(null!==e)if(e instanceof Uint8Array)this.writer.write(e);else if(Array.isArray(e))for(const t of e)this.writeEBML(t);else if(this.offsets.set(e,this.writer.getPos()),this.writeUnsignedInt(e.id),Array.isArray(e.data)){const t=this.writer.getPos(),r=-1===e.size?1:e.size??4;-1===e.size?this.writeByte(255):this.writer.seek(this.writer.getPos()+r);const i=this.writer.getPos();if(this.dataOffsets.set(e,i),this.writeEBML(e.data),-1!==e.size){const e=this.writer.getPos()-i,n=this.writer.getPos();this.writer.seek(t),this.writeVarInt(e,r),this.writer.seek(n)}}else if("number"==typeof e.data){const t=e.size??xi(e.data);this.writeVarInt(t),this.writeUnsignedInt(e.data,t)}else if("bigint"==typeof e.data){const t=e.size??Si(e.data);this.writeVarInt(t),this.writeUnsignedBigInt(e.data,t)}else if("string"==typeof e.data)this.writeVarInt(e.data.length),this.writeAsciiString(e.data);else if(e.data instanceof Uint8Array)this.writeVarInt(e.data.byteLength,e.size),this.writer.write(e.data);else if(e.data instanceof pi)this.writeVarInt(4),this.writeFloat32(e.data.value);else if(e.data instanceof gi)this.writeVarInt(8),this.writeFloat64(e.data.value);else if(e.data instanceof yi){const t=e.size??Ci(e.data.value);this.writeVarInt(t),this.writeSignedInt(e.data.value,t)}else if(e.data instanceof bi){const t=w.encode(e.data.value);this.writeVarInt(t.length),this.writer.write(t)}else L(e.data)}}const Ai=16,Ei=e=>{if(e.remainingLength<1)return null;const t=wr(e);if(e.skip(-1),0===t)return null;let r=1,i=128;for(;0===(t&i);)r++,i>>=1;return e.remainingLength<r?null:r},Ii=e=>{if(e.remainingLength<1)return null;const t=wr(e);if(0===t)return null;let r=1,i=128;for(;0===(t&i);)r++,i>>=1;if(e.remainingLength<r-1)return null;let n=t&i-1;for(let t=1;t<r;t++)n*=256,n+=wr(e);return n},$i=(e,t)=>{if(t<1||t>8)throw new Error("Bad unsigned int size "+t);let r=0;for(let i=0;i<t;i++)r*=256,r+=wr(e);return r},_i=e=>{const t=Ei(e);if(null===t)return null;if(e.remainingLength<t)return null;return $i(e,t)},Ni=e=>{if(e.remainingLength<1)return null;if(255===wr(e))return;e.skip(-1);const t=Ii(e);return null===t?null:72057594037927940!==t?t:void 0},Ri=e=>{l(e.remainingLength>=2);const t=_i(e);if(null===t)return null;const r=Ni(e);return null===r?null:{id:t,size:r}},Oi=(e,t)=>{const r=br(e,t);let i=0;for(;i<t&&0!==r[i];)i+=1;return String.fromCharCode(...r.subarray(0,i))},Fi=(e,t)=>{const r=br(e,t);let i=0;for(;i<t&&0!==r[i];)i+=1;return b.decode(r.subarray(0,i))},Bi=(e,t)=>{if(0===t)return 0;if(4!==t&&8!==t)throw new Error("Bad float size "+t);return 4===t?(e=>{yr(e,4);const t=e.view.getFloat32(e.bufferPos,!1);return e.bufferPos+=4,t})(e):Nr(e)},Di=async(e,t,r,i)=>{const n=new Set(r);let a=t;for(;null===i||a<i;){let t=e.requestSliceRange(a,2,Ai);if(t instanceof Promise&&(t=await t),!t)break;const r=Ri(t);if(!r)break;if(n.has(r.id))return{pos:a,found:!0};Li(r.size),a=t.filePos+r.size}return{pos:null!==i&&i>a?i:a,found:!1}},Mi=async(e,t,r,i)=>{const n=new Set(r);let a=t;for(;a<i;){let t=e.requestSliceRange(a,0,Math.min(65536,i-a));if(t instanceof Promise&&(t=await t),!t)break;
1if(t.length<8)break;for(let e=0;e<t.length-8;e++){t.filePos=a;const e=_i(t);if(null!==e&&n.has(e))return a;a++}}return null},ji={avc:"V_MPEG4/ISO/AVC",hevc:"V_MPEGH/ISO/HEVC",vp8:"V_VP8",vp9:"V_VP9",av1:"V_AV1",aac:"A_AAC",mp3:"A_MPEG/L3",opus:"A_OPUS",vorbis:"A_VORBIS",flac:"A_FLAC",ac3:"A_AC3",eac3:"A_EAC3","pcm-u8":"A_PCM/INT/LIT","pcm-s16":"A_PCM/INT/LIT","pcm-s16be":"A_PCM/INT/BIG","pcm-s24":"A_PCM/INT/LIT","pcm-s24be":"A_PCM/INT/BIG","pcm-s32":"A_PCM/INT/LIT","pcm-s32be":"A_PCM/INT/BIG","pcm-f32":"A_PCM/FLOAT/IEEE","pcm-f64":"A_PCM/FLOAT/IEEE",webvtt:"S_TEXT/WEBVTT"};function Li(e){if(void 0===e)throw new Error("Undefined element size is used in a place where it is not supported.")}const Ui=e=>{let t=(e.hasVideo?"video/":e.hasAudio?"audio/":"application/")+(e.isWebM?"webm":"x-matroska");if(e.codecStrings.length>0){t+=`; codecs="${[...new Set(e.codecStrings.filter(Boolean))].join(", ")}"`}return t};var zi,Wi,Vi;!function(e){e[e.None=0]="None",e[e.Xiph=1]="Xiph",e[e.FixedSize=2]="FixedSize",e[e.Ebml=3]="Ebml"}(zi||(zi={})),function(e){e[e.Block=1]="Block",e[e.Private=2]="Private",e[e.Next=4]="Next"}(Wi||(Wi={})),function(e){e[e.Zlib=0]="Zlib",e[e.Bzlib=1]="Bzlib",e[e.lzo1x=2]="lzo1x",e[e.HeaderStripping=3]="HeaderStripping"}(Vi||(Vi={}));const qi=[{id:wi.SeekHead,flag:"seekHeadSeen"},{id:wi.Info,flag:"infoSeen"},{id:wi.Tracks,flag:"tracksSeen"},{id:wi.Cues,flag:"cuesSeen"}],Hi=10485760;class Gi extends Gt{constructor(e){super(e),this.readMetadataPromise=null,this.segments=[],this.currentSegment=null,this.currentTrack=null,this.currentCluster=null,this.currentBlock=null,this.currentBlockAdditional=null,this.currentCueTime=null,this.currentDecodingInstruction=null,this.currentTagTargetIsMovie=!0,this.currentSimpleTagName=null,this.currentAttachedFile=null,this.isWebM=!1,this.reader=e._reader}async getTrackBackings(){return await this.readMetadata(),this.segments.flatMap(e=>e.tracks.map(e=>e.trackBacking))}async getMimeType(){await this.readMetadata();const e=await this.getTrackBackings(),t=await Promise.all(e.map(e=>e.getDecoderConfig().then(e=>e?.codec??null)));return Ui({isWebM:this.isWebM,hasVideo:this.segments.some(e=>e.tracks.some(e=>"video"===e.info?.type)),hasAudio:this.segments.some(e=>e.tracks.some(e=>"audio"===e.info?.type)),codecStrings:t.filter(Boolean)})}async getMetadataTags(){await this.readMetadata();for(const e of this.segments)e.metadataTagsCollected||(null!==this.reader.fileSize&&await this.loadSegmentMetadata(e),e.metadataTagsCollected=!0);let e={};for(const t of this.segments)e={...e,...t.metadataTags};return e}readMetadata(){return this.readMetadataPromise??=(async()=>{let e=0;for(;;){let t=this.reader.requestSliceRange(e,2,Ai);if(t instanceof Promise&&(t=await t),!t)break;const r=Ri(t);if(!r)break;const i=r.id;let n=r.size;const a=t.filePos;if(i===wi.EBML){Li(n);let e=this.reader.requestSlice(a,n);if(e instanceof Promise&&(e=await e),!e)break;this.readContiguousElements(e)}else if(i===wi.Segment){if(await this.readSegment(a,n),void 0===n)break;if(null===this.reader.fileSize)break}else if(i===wi.Cluster){if(null===this.reader.fileSize)break;if(void 0===n){n=(await Di(this.reader,a,Ti,this.reader.fileSize)).pos-a}const e=h(this.segments);e&&(e.elementEndPos=a+n)}Li(n),e=a+n}})()}async readSegment(e,t){this.currentSegment={seekHeadSeen:!1,infoSeen:!1,tracksSeen:!1,cuesSeen:!1,tagsSeen:!1,attachmentsSeen:!1,timestampScale:-1,timestampFactor:-1,duration:-1,seekEntries:[],tracks:[],cuePoints:[],dataStartPos:e,elementEndPos:void 0===t?null:e+t,clusterSeekStartPos:e,lastReadCluster:null,metadataTags:{},metadataTagsCollected:!1},this.segments.push(this.currentSegment);let r=e;for(;null===this.currentSegment.elementEndPos||r<this.currentSegment.elementEndPos;){let e=this.reader.requestSliceRange(r,2,Ai);if(e instanceof Promise&&(e=await e),!e)break;const t=r,i=Ri(e);if(!i||!ki.includes(i.id)&&i.id!==wi.Void){const e=await Mi(this.reader,t,ki,Math.min(this.currentSegment.elementEndPos??1/0,t+Hi));if(e){r=e;continue}break}const{id:n,size:a}=i,s=e.filePos,o=qi.findIndex(e=>e.id===n);if(-1!==o){const e=qi[o].flag;this.currentSegment[e]=!0,Li(a);let t=this.reader.requestSlice(s,a);t instanceof Promise&&(t=await t),t&&this.readContiguousElements(t)}else if(n===wi.Tags||n===wi.Attachments){n===wi.Tags?this.currentSegment.tagsSeen=!0:this.currentSegment.attachmentsSeen=!0,Li(a);let e=this.reader.requestSlice(s,a);e instanceof Promise&&(e=await e),e&&this.readContiguousElements(e)}else if(n===wi.Cluster){this.currentSegment.clusterSeekStartPos=t;break}if(void 0===a)break;r=s+a}if(this.currentSegment.seekEntries.sort((e,t)=>
1e.segmentPosition-t.segmentPosition),null!==this.reader.fileSize)for(const t of this.currentSegment.seekEntries){const r=qi.find(e=>e.id===t.id);if(!r)continue;if(this.currentSegment[r.flag])continue;let i=this.reader.requestSliceRange(e+t.segmentPosition,2,Ai);if(i instanceof Promise&&(i=await i),!i)continue;const n=Ri(i);if(!n)continue;const{id:a,size:s}=n;if(a!==r.id)continue;Li(s),this.currentSegment[r.flag]=!0;let o=this.reader.requestSlice(i.filePos,s);o instanceof Promise&&(o=await o),o&&this.readContiguousElements(o)}-1===this.currentSegment.timestampScale&&(this.currentSegment.timestampScale=1e6,this.currentSegment.timestampFactor=1e3);for(const e of this.currentSegment.tracks)null!==e.defaultDurationNs&&(e.defaultDuration=this.currentSegment.timestampFactor*e.defaultDurationNs/1e9);const i=new Map(this.currentSegment.tracks.map(e=>[e.id,e]));for(const e of this.currentSegment.cuePoints){const t=i.get(e.trackId);t&&t.cuePoints.push(e)}for(const e of this.currentSegment.tracks){e.cuePoints.sort((e,t)=>e.time-t.time);for(let t=0;t<e.cuePoints.length-1;t++){const r=e.cuePoints[t],i=e.cuePoints[t+1];r.time===i.time&&(e.cuePoints.splice(t+1,1),t--)}}let n=null,a=-1/0;for(const e of this.currentSegment.tracks)e.cuePoints.length>a&&(a=e.cuePoints.length,n=e);for(const e of this.currentSegment.tracks)0===e.cuePoints.length&&(e.cuePoints=n.cuePoints);this.currentSegment=null}async readCluster(e,t){if(t.lastReadCluster?.elementStartPos===e)return t.lastReadCluster;let r=this.reader.requestSliceRange(e,2,Ai);r instanceof Promise&&(r=await r),l(r);const i=e,n=Ri(r);l(n);l(n.id===wi.Cluster);let a=n.size;const s=r.filePos;if(void 0===a){a=(await Di(this.reader,s,Ti,t.elementEndPos)).pos-s}let o=this.reader.requestSlice(s,a);o instanceof Promise&&(o=await o);const c={segment:t,elementStartPos:i,elementEndPos:s+a,dataStartPos:s,timestamp:-1,trackData:new Map};if(this.currentCluster=c,o){const e=this.readContiguousElements(o,Ti);c.elementEndPos=e}for(const[,e]of c.trackData){const t=e.track;l(e.blocks.length>0);let r=!1;for(let t=0;t<e.blocks.length;t++){const i=e.blocks[t];i.timestamp+=c.timestamp,r||=i.lacing!==zi.None}e.presentationTimestamps=e.blocks.map((e,t)=>({timestamp:e.timestamp,blockIndex:t})).sort((e,t)=>e.timestamp-t.timestamp);for(let r=0;r<e.presentationTimestamps.length;r++){const i=e.presentationTimestamps[r],n=e.blocks[i.blockIndex];if(null===e.firstKeyFrameTimestamp&&n.isKeyFrame&&(e.firstKeyFrameTimestamp=n.timestamp),r<e.presentationTimestamps.length-1){const t=e.presentationTimestamps[r+1];n.duration=t.timestamp-n.timestamp}else 0===n.duration&&null!=t.defaultDuration&&n.lacing===zi.None&&(n.duration=t.defaultDuration)}r&&(this.expandLacedBlocks(e.blocks,t),e.presentationTimestamps=e.blocks.map((e,t)=>({timestamp:e.timestamp,blockIndex:t})).sort((e,t)=>e.timestamp-t.timestamp));const n=e.blocks[e.presentationTimestamps[0].blockIndex],a=e.blocks[h(e.presentationTimestamps).blockIndex];e.startTimestamp=n.timestamp,e.endTimestamp=a.timestamp+a.duration;const s=O(t.clusterPositionCache,e.startTimestamp,e=>e.startTimestamp);-1!==s&&t.clusterPositionCache[s].elementStartPos===i||t.clusterPositionCache.splice(s+1,0,{elementStartPos:c.elementStartPos,startTimestamp:e.startTimestamp})}return t.lastReadCluster=c,c}getTrackDataInCluster(e,t){let r=e.trackData.get(t);if(!r){const i=e.segment.tracks.find(e=>e.id===t);if(!i)return null;r={track:i,startTimestamp:0,endTimestamp:0,firstKeyFrameTimestamp:null,blocks:[],presentationTimestamps:[]},e.trackData.set(t,r)}return r}expandLacedBlocks(e,t){for(let r=0;r<e.length;r++){const i=e[r];if(i.lacing===zi.None)continue;i.decoded||(i.data=this.decodeBlockData(t,i.data),i.decoded=!0);const n=gr.tempFromBytes(i.data),a=[],s=wr(n)+1;switch(i.lacing){case zi.Xiph:{let e=0;for(let t=0;t<s-1;t++){let t=0;for(;n.bufferPos<n.length;){const r=wr(n);if(t+=r,r<255){a.push(t),e+=t;break}}}a.push(n.length-(n.bufferPos+e))}break;case zi.FixedSize:{const e=n.length-1,t=Math.floor(e/s);for(let e=0;e<s;e++)a.push(t)}break;case zi.Ebml:{const e=Ii(n);l(null!==e);let t=e;a.push(t);let r=t;for(let e=1;e<s-1;e++){const e=n.bufferPos,i=Ii(n);l(null!==i);t+=i-((1<<7*(n.bufferPos-e)-1)-1),a.push(t),r+=t}a.push(n.length-(n.bufferPos+r))}break;default:l(!1)}l(a.length===s),e.splice(r,1);const o=i.duration||s*(t.defaultDuration??0);for(let t=0;t<s;t++){const c=a[t],d=br(n,c),l=i.timestamp+o*t/s,u=o/s;e.splice(r+t,0,{timestamp:l,duration:u,isKeyFrame:i.isKeyFrame,data:d,lacing:zi.None,decoded:!0,mainAdditional:i.mainAdditional})}r+=s,r--}}async loadSegmentMetadata(e){for(const t of e.seekEntries){if(t.id!==wi.Tags||e.tagsSeen){if(t.id!==wi.Attachments||e.attachmentsSeen)continue}else;let r=this.reader.requestSliceRange(e.dataStartPos+t.segmentPosition,2,Ai);if(r instanceof Promise&&(r=await r),!r)continue;const i=Ri(r);if(!i||i.id!==t.id)continue;const{size:n}=i;Li(n),l(!this.currentSegment),this.currentSegment=e;let a=this.reader.requestSlice(r.filePos,n);a instanceof Promise&&(a=await a),a&&this.readContiguousElements(a),this.currentSegment=null,t.id===wi.Tags?e.tagsSeen=!0:t.id===wi.Attachments&&(e.attachmentsSeen=!0)}}readContiguousElements(e,t){for(;e.remainingLength>=2;){const r=e.filePos;if(!this.traverseElement(e,t))return r}return e.filePos}traverseElement(e,t){const r=Ri(e);if(!r)return!1;if(t&&t.includes(r.id))return!1;const{id:i,size:n}=r,a=e.filePos;switch(Li(n),i){case wi.DocType:this.isWebM="webm"===Oi(e,n);break;case wi.Seek:{if(!this.currentSegment)break;const t={id:-1,segmentPosition:-1};this.currentSegment.seekEntries.push(t),this.readContiguousElements(e.slice(a,n)),-1!==t.id&&-1!==t.segmentPosition||this.currentSegment.seekEntries.pop()}break;case wi.SeekID:{const t=this.currentSegment?.seekEntries[this.currentSegment.seekEntries.length-1];if(!t)break;
1t.id=$i(e,n)}break;case wi.SeekPosition:{const t=this.currentSegment?.seekEntries[this.currentSegment.seekEntries.length-1];if(!t)break;t.segmentPosition=$i(e,n)}break;case wi.TimestampScale:if(!this.currentSegment)break;this.currentSegment.timestampScale=$i(e,n),this.currentSegment.timestampFactor=1e9/this.currentSegment.timestampScale;break;case wi.Duration:if(!this.currentSegment)break;this.currentSegment.duration=Bi(e,n);break;case wi.TrackEntry:if(!this.currentSegment)break;if(this.currentTrack={id:-1,segment:this.currentSegment,demuxer:this,clusterPositionCache:[],cuePoints:[],disposition:{...rr,primary:!1},trackBacking:null,codecId:null,codecPrivate:null,defaultDuration:null,defaultDurationNs:null,name:null,languageCode:"eng",hasLanguageBcp47:!1,decodingInstructions:[],info:null},this.readContiguousElements(e.slice(a,n)),!this.currentTrack)break;if(this.currentTrack.decodingInstructions.some(e=>"decompress"!==e.data?.type||e.scope!==Wi.Block||e.data.algorithm!==Vi.HeaderStripping)&&(d._warn(`Track #${this.currentTrack.id} has an unsupported content encoding; dropping.`),this.currentTrack=null),this.currentTrack&&-1!==this.currentTrack.id&&this.currentTrack.codecId&&this.currentTrack.info){const e=this.currentTrack.codecId.indexOf("/"),t=-1===e?this.currentTrack.codecId:this.currentTrack.codecId.slice(0,e);if("video"===this.currentTrack.info.type&&-1!==this.currentTrack.info.width&&-1!==this.currentTrack.info.height){if(this.currentTrack.info.squarePixelWidth=this.currentTrack.info.width,this.currentTrack.info.squarePixelHeight=this.currentTrack.info.height,null!==this.currentTrack.info.displayWidth&&null!==this.currentTrack.info.displayHeight){const e=this.currentTrack.info.displayWidth*this.currentTrack.info.height,t=this.currentTrack.info.displayHeight*this.currentTrack.info.width;e>0&&t>0&&(e>t?this.currentTrack.info.squarePixelWidth=Math.round(this.currentTrack.info.width*e/t):this.currentTrack.info.squarePixelHeight=Math.round(this.currentTrack.info.height*t/e))}this.currentTrack.codecId===ji.avc?(this.currentTrack.info.codec="avc",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):this.currentTrack.codecId===ji.hevc?(this.currentTrack.info.codec="hevc",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):t===ji.vp8?this.currentTrack.info.codec="vp8":t===ji.vp9?this.currentTrack.info.codec="vp9":t===ji.av1&&(this.currentTrack.info.codec="av1");const e=this.currentTrack;this.currentTrack.trackBacking=new Yi(e),this.currentSegment.tracks.push(this.currentTrack)}else if("audio"===this.currentTrack.info.type){t===ji.aac?(this.currentTrack.info.codec="aac",this.currentTrack.info.aacCodecInfo={isMpeg2:this.currentTrack.codecId.includes("MPEG2"),objectType:null},this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):this.currentTrack.codecId===ji.mp3?this.currentTrack.info.codec="mp3":t===ji.opus?(this.currentTrack.info.codec="opus",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate,this.currentTrack.info.sampleRate=48e3):t===ji.vorbis?(this.currentTrack.info.codec="vorbis",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):t===ji.flac?(this.currentTrack.info.codec="flac",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):t===ji.ac3?(this.currentTrack.info.codec="ac3",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):t===ji.eac3?(this.currentTrack.info.codec="eac3",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):"A_PCM/INT/LIT"===this.currentTrack.codecId?8===this.currentTrack.info.bitDepth?this.currentTrack.info.codec="pcm-u8":16===this.currentTrack.info.bitDepth?this.currentTrack.info.codec="pcm-s16":24===this.currentTrack.info.bitDepth?this.currentTrack.info.codec="pcm-s24":32===this.currentTrack.info.bitDepth&&(this.currentTrack.info.codec="pcm-s32"):"A_PCM/INT/BIG"===this.currentTrack.codecId?8===this.currentTrack.info.bitDepth?this.currentTrack.info.codec="pcm-u8":16===this.currentTrack.info.bitDepth?this.currentTrack.info.codec="pcm-s16be":24===this.currentTrack.info.bitDepth?this.currentTrack.info.codec="pcm-s24be":32===this.currentTrack.info.bitDepth&&(this.currentTrack.info.codec="pcm-s32be"):"A_PCM/FLOAT/IEEE"===this.currentTrack.codecId&&(32===this.currentTrack.info.bitDepth?this.currentTrack.info.codec="pcm-f32":64===this.currentTrack.info.bitDepth&&(this.currentTrack.info.codec="pcm-f64"));const e=this.currentTrack;this.currentTrack.trackBacking=new Xi(e),this.currentSegment.tracks.push(this.currentTrack)}}this.currentTrack=null;break;case wi.TrackNumber:if(!this.currentTrack)break;
1this.currentTrack.id=$i(e,n);break;case wi.TrackType:{if(!this.currentTrack)break;const t=$i(e,n);1===t?this.currentTrack.info={type:"video",width:-1,height:-1,displayWidth:null,displayHeight:null,displayUnit:null,squarePixelWidth:-1,squarePixelHeight:-1,rotation:0,codec:null,codecDescription:null,colorSpace:null,alphaMode:!1}:2===t&&(this.currentTrack.info={type:"audio",numberOfChannels:1,sampleRate:8e3,bitDepth:-1,codec:null,codecDescription:null,aacCodecInfo:null})}break;case wi.FlagEnabled:if(!this.currentTrack)break;$i(e,n)||(this.currentTrack=null);break;case wi.FlagDefault:if(!this.currentTrack)break;this.currentTrack.disposition.default=!!$i(e,n);break;case wi.FlagForced:if(!this.currentTrack)break;this.currentTrack.disposition.forced=!!$i(e,n);break;case wi.FlagOriginal:if(!this.currentTrack)break;this.currentTrack.disposition.original=!!$i(e,n);break;case wi.FlagHearingImpaired:if(!this.currentTrack)break;this.currentTrack.disposition.hearingImpaired=!!$i(e,n);break;case wi.FlagVisualImpaired:if(!this.currentTrack)break;this.currentTrack.disposition.visuallyImpaired=!!$i(e,n);break;case wi.FlagCommentary:if(!this.currentTrack)break;this.currentTrack.disposition.commentary=!!$i(e,n);break;case wi.CodecID:if(!this.currentTrack)break;this.currentTrack.codecId=Oi(e,n);break;case wi.CodecPrivate:if(!this.currentTrack)break;this.currentTrack.codecPrivate=br(e,n);break;case wi.DefaultDuration:if(!this.currentTrack)break;this.currentTrack.defaultDurationNs=$i(e,n);break;case wi.Name:if(!this.currentTrack)break;this.currentTrack.name=Fi(e,n);break;case wi.Language:if(!this.currentTrack)break;if(this.currentTrack.hasLanguageBcp47)break;this.currentTrack.languageCode=Oi(e,n),Q(this.currentTrack.languageCode)||(this.currentTrack.languageCode=V);break;case wi.LanguageBCP47:{if(!this.currentTrack)break;const t=Oi(e,n).split("-")[0];this.currentTrack.languageCode=t||V,this.currentTrack.hasLanguageBcp47=!0}break;case wi.Video:if("video"!==this.currentTrack?.info?.type)break;this.readContiguousElements(e.slice(a,n));break;case wi.PixelWidth:if("video"!==this.currentTrack?.info?.type)break;this.currentTrack.info.width=$i(e,n);break;case wi.PixelHeight:if("video"!==this.currentTrack?.info?.type)break;this.currentTrack.info.height=$i(e,n);break;case wi.DisplayWidth:if("video"!==this.currentTrack?.info?.type)break;this.currentTrack.info.displayWidth=$i(e,n);break;case wi.DisplayHeight:if("video"!==this.currentTrack?.info?.type)break;this.currentTrack.info.displayHeight=$i(e,n);break;case wi.DisplayUnit:if("video"!==this.currentTrack?.info?.type)break;this.currentTrack.info.displayUnit=$i(e,n);break;case wi.AlphaMode:if("video"!==this.currentTrack?.info?.type)break;this.currentTrack.info.alphaMode=1===$i(e,n);break;case wi.Colour:if("video"!==this.currentTrack?.info?.type)break;this.currentTrack.info.colorSpace={},this.readContiguousElements(e.slice(a,n));break;case wi.MatrixCoefficients:{if("video"!==this.currentTrack?.info?.type||!this.currentTrack.info.colorSpace)break;const t=$i(e,n),r=P[t]??null;this.currentTrack.info.colorSpace.matrix=r}break;case wi.Range:if("video"!==this.currentTrack?.info?.type||!this.currentTrack.info.colorSpace)break;this.currentTrack.info.colorSpace.fullRange=2===$i(e,n);break;case wi.TransferCharacteristics:{if("video"!==this.currentTrack?.info?.type||!this.currentTrack.info.colorSpace)break;const t=$i(e,n),r=S[t]??null;this.currentTrack.info.colorSpace.transfer=r}break;case wi.Primaries:{if("video"!==this.currentTrack?.info?.type||!this.currentTrack.info.colorSpace)break;const t=$i(e,n),r=T[t]??null;this.currentTrack.info.colorSpace.primaries=r}break;case wi.Projection:if("video"!==this.currentTrack?.info?.type)break;this.readContiguousElements(e.slice(a,n));break;case wi.ProjectionPoseRoll:{if("video"!==this.currentTrack?.info?.type)break;const t=-Bi(e,n);try{this.currentTrack.info.rotation=u(t)}catch{}}break;case wi.Audio:if("audio"!==this.currentTrack?.info?.type)break;this.readContiguousElements(e.slice(a,n));break;case wi.SamplingFrequency:if("audio"!==this.currentTrack?.info?.type)break;this.currentTrack.info.sampleRate=Bi(e,n);break;case wi.Channels:if("audio"!==this.currentTrack?.info?.type)break;
1this.currentTrack.info.numberOfChannels=$i(e,n);break;case wi.BitDepth:if("audio"!==this.currentTrack?.info?.type)break;this.currentTrack.info.bitDepth=$i(e,n);break;case wi.CuePoint:if(!this.currentSegment)break;this.readContiguousElements(e.slice(a,n)),this.currentCueTime=null;break;case wi.CueTime:this.currentCueTime=$i(e,n);break;case wi.CueTrackPositions:{if(null===this.currentCueTime)break;l(this.currentSegment);const t={time:this.currentCueTime,trackId:-1,clusterPosition:-1};this.currentSegment.cuePoints.push(t),this.readContiguousElements(e.slice(a,n)),-1!==t.trackId&&-1!==t.clusterPosition||this.currentSegment.cuePoints.pop()}break;case wi.CueTrack:{const t=this.currentSegment?.cuePoints[this.currentSegment.cuePoints.length-1];if(!t)break;t.trackId=$i(e,n)}break;case wi.CueClusterPosition:{const t=this.currentSegment?.cuePoints[this.currentSegment.cuePoints.length-1];if(!t)break;l(this.currentSegment),t.clusterPosition=this.currentSegment.dataStartPos+$i(e,n)}break;case wi.Timestamp:if(!this.currentCluster)break;this.currentCluster.timestamp=$i(e,n);break;case wi.SimpleBlock:{if(!this.currentCluster)break;const t=Ii(e);if(null===t)break;const r=this.getTrackDataInCluster(this.currentCluster,t);if(!r)break;const i=xr(e),s=wr(e),o=s>>1&3;let c=!!(128&s);"audio"===r.track.info?.type&&r.track.info.codec&&(c=!0);const d=br(e,n-(e.filePos-a)),l=r.track.decodingInstructions.length>0;r.blocks.push({timestamp:i,duration:0,isKeyFrame:c,data:d,lacing:o,decoded:!l,mainAdditional:null})}break;case wi.BlockGroup:if(!this.currentCluster)break;this.readContiguousElements(e.slice(a,n)),this.currentBlock=null;break;case wi.Block:{if(!this.currentCluster)break;const t=Ii(e);if(null===t)break;const r=this.getTrackDataInCluster(this.currentCluster,t);if(!r)break;const i=xr(e),s=wr(e)>>1&3,o=br(e,n-(e.filePos-a)),c=r.track.decodingInstructions.length>0;this.currentBlock={timestamp:i,duration:0,isKeyFrame:!0,data:o,lacing:s,decoded:!c,mainAdditional:null},r.blocks.push(this.currentBlock)}break;case wi.BlockAdditions:this.readContiguousElements(e.slice(a,n));break;case wi.BlockMore:if(!this.currentBlock)break;this.currentBlockAdditional={addId:1,data:null},this.readContiguousElements(e.slice(a,n)),this.currentBlockAdditional.data&&1===this.currentBlockAdditional.addId&&(this.currentBlock.mainAdditional=this.currentBlockAdditional.data),this.currentBlockAdditional=null;break;case wi.BlockAdditional:if(!this.currentBlockAdditional)break;this.currentBlockAdditional.data=br(e,n);break;case wi.BlockAddID:if(!this.currentBlockAdditional)break;this.currentBlockAdditional.addId=$i(e,n);break;case wi.BlockDuration:if(!this.currentBlock)break;this.currentBlock.duration=$i(e,n);break;case wi.ReferenceBlock:if(!this.currentBlock)break;this.currentBlock.isKeyFrame=!1;break;case wi.Tag:this.currentTagTargetIsMovie=!0,this.readContiguousElements(e.slice(a,n));break;case wi.Targets:this.readContiguousElements(e.slice(a,n));break;case wi.TargetTypeValue:50!==$i(e,n)&&(this.currentTagTargetIsMovie=!1);break;case wi.TagTrackUID:case wi.TagEditionUID:case wi.TagChapterUID:case wi.TagAttachmentUID:this.currentTagTargetIsMovie=!1;break;case wi.SimpleTag:if(!this.currentTagTargetIsMovie)break;this.currentSimpleTagName=null,this.readContiguousElements(e.slice(a,n));break;case wi.TagName:this.currentSimpleTagName=Fi(e,n);break;case wi.TagString:{if(!this.currentSimpleTagName)break;const t=Fi(e,n);this.processTagValue(this.currentSimpleTagName,t)}break;case wi.TagBinary:{if(!this.currentSimpleTagName)break;const t=br(e,n);this.processTagValue(this.currentSimpleTagName,t)}break;case wi.AttachedFile:{if(!this.currentSegment)break;this.currentAttachedFile={fileUid:null,fileName:null,fileMediaType:null,fileData:null,fileDescription:null},this.readContiguousElements(e.slice(a,n));const t=this.currentSegment.metadataTags;if(this.currentAttachedFile.fileUid&&this.currentAttachedFile.fileData&&(t.raw??={},t.raw[this.currentAttachedFile.fileUid.toString()]=new er(this.currentAttachedFile.fileData,this.currentAttachedFile.fileMediaType??void 0,this.currentAttachedFile.fileName??void 0,this.currentAttachedFile.fileDescription??void 0)),this.currentAttachedFile.fileMediaType?.startsWith("image/")&&this.currentAttachedFile.fileData){const e=this.currentAttachedFile.fileName;let r="unknown";if(e){const t=e.toLowerCase();t.startsWith("cover.")?r="coverFront":t.startsWith("back.")&&(r="coverBack")}t.images??=[],t.images.push({data:this.currentAttachedFile.fileData,mimeType:this.currentAttachedFile.fileMediaType,kind:r,name:this.currentAttachedFile.fileName??void 0,description:this.currentAttachedFile.fileDescription??void 0})}this.currentAttachedFile=null}break;case wi.FileUID:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileUid=((e,t)=>{if(t<1)throw new Error("Bad unsigned int size "+t);let r=0n;for(let i=0;i<t;i++)r<<=8n,r+=BigInt(wr(e));return r})(e,n);break;case wi.FileName:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileName=Fi(e,n);break;case wi.FileMediaType:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileMediaType=Oi(e,n);break;case wi.FileData:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileData=br(e,n);break;case wi.FileDescription:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileDescription=Fi(e,n);break;case wi.ContentEncodings:if(!this.currentTrack)break;this.readContiguousElements(e.slice(a,n)),this.currentTrack.decodingInstructions.sort((e,t)=>
1t.order-e.order);break;case wi.ContentEncoding:this.currentDecodingInstruction={order:0,scope:Wi.Block,data:null},this.readContiguousElements(e.slice(a,n)),this.currentDecodingInstruction.data&&this.currentTrack.decodingInstructions.push(this.currentDecodingInstruction),this.currentDecodingInstruction=null;break;case wi.ContentEncodingOrder:if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.order=$i(e,n);break;case wi.ContentEncodingScope:if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.scope=$i(e,n);break;case wi.ContentCompression:if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.data={type:"decompress",algorithm:Vi.Zlib,settings:null},this.readContiguousElements(e.slice(a,n));break;case wi.ContentCompAlgo:if("decompress"!==this.currentDecodingInstruction?.data?.type)break;this.currentDecodingInstruction.data.algorithm=$i(e,n);break;case wi.ContentCompSettings:if("decompress"!==this.currentDecodingInstruction?.data?.type)break;this.currentDecodingInstruction.data.settings=br(e,n);break;case wi.ContentEncryption:if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.data={type:"decrypt"}}return e.filePos=a+n,!0}decodeBlockData(e,t){l(e.decodingInstructions.length>0);let r=t;for(const t of e.decodingInstructions)if(l(t.data),"decompress"===t.data.type)if(t.data.algorithm===Vi.HeaderStripping)if(t.data.settings&&t.data.settings.length>0){const e=t.data.settings,i=new Uint8Array(e.length+r.length);i.set(e,0),i.set(r,e.length),r=i}return r}processTagValue(e,t){if(!this.currentSegment?.metadataTags)return;const r=this.currentSegment.metadataTags;if(r.raw??={},r.raw[e]??=t,"string"==typeof t)switch(e.toLowerCase()){case"title":r.title??=t;break;case"description":r.description??=t;break;case"artist":r.artist??=t;break;case"album":r.album??=t;break;case"album_artist":r.albumArtist??=t;break;case"genre":r.genre??=t;break;case"comment":r.comment??=t;break;case"lyrics":r.lyrics??=t;break;case"date":{const e=new Date(t);Number.isNaN(e.getTime())||(r.date??=e)}break;case"track_number":case"part_number":{const e=t.split("/"),i=Number.parseInt(e[0],10),n=e[1]&&Number.parseInt(e[1],10);Number.isInteger(i)&&i>0&&(r.trackNumber??=i),n&&Number.isInteger(n)&&n>0&&(r.tracksTotal??=n)}break;case"disc_number":case"disc":{const e=t.split("/"),i=Number.parseInt(e[0],10),n=e[1]&&Number.parseInt(e[1],10);Number.isInteger(i)&&i>0&&(r.discNumber??=i),n&&Number.isInteger(n)&&n>0&&(r.discsTotal??=n)}}}}class Ki{constructor(e){this.internalTrack=e,this.packetToClusterLocation=new WeakMap}getId(){return this.internalTrack.id}getNumber(){const e=this.internalTrack.demuxer,t=this.internalTrack.trackBacking.getType();let r=0;for(const i of e.segments)for(const e of i.tracks)if(e.trackBacking.getType()===t&&r++,e===this.internalTrack)break;return r}getCodec(){throw new Error("Not implemented on base class.")}getInternalCodecId(){return this.internalTrack.codecId}getName(){return this.internalTrack.name}getLanguageCode(){return this.internalTrack.languageCode}getTimeResolution(){return this.internalTrack.segment.timestampFactor}isRelativeToUnixEpoch(){return!1}getUnixTimeForTimestamp(){return null}getDisposition(){return this.internalTrack.disposition}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){const e=this.internalTrack.segment;if(e.duration<=0)return null;let t=e.duration/e.timestampFactor;const r=await this.getFirstPacket({metadataOnly:!0});return t+=r?.timestamp??0,t}
1async getLiveRefreshInterval(){return null}async getFirstPacket(e){return this.performClusterLookup(null,e=>e.trackData.get(this.internalTrack.id)?{blockIndex:0,correctBlockFound:!0}:{blockIndex:-1,correctBlockFound:!1},-1/0,1/0,e)}intoTimescale(e){return q(e*this.internalTrack.segment.timestampFactor)}async getPacket(e,t){const r=this.intoTimescale(e);return this.performClusterLookup(null,e=>{const t=e.trackData.get(this.internalTrack.id);if(!t)return{blockIndex:-1,correctBlockFound:!1};const i=O(t.presentationTimestamps,r,e=>e.timestamp);return{blockIndex:-1!==i?t.presentationTimestamps[i].blockIndex:-1,correctBlockFound:-1!==i&&r<t.endTimestamp}},r,r,t)}async getNextPacket(e,t){const r=this.packetToClusterLocation.get(e);if(void 0===r)throw new Error("Packet was not created from this track.");return this.performClusterLookup(r.cluster,e=>{if(e===r.cluster){const t=e.trackData.get(this.internalTrack.id);if(r.blockIndex+1<t.blocks.length)return{blockIndex:r.blockIndex+1,correctBlockFound:!0}}else{if(e.trackData.get(this.internalTrack.id))return{blockIndex:0,correctBlockFound:!0}}return{blockIndex:-1,correctBlockFound:!1}},-1/0,1/0,t)}async getKeyPacket(e,t){const r=this.intoTimescale(e);return this.performClusterLookup(null,e=>{const t=e.trackData.get(this.internalTrack.id);if(!t)return{blockIndex:-1,correctBlockFound:!1};const i=j(t.presentationTimestamps,e=>t.blocks[e.blockIndex].isKeyFrame&&e.timestamp<=r);return{blockIndex:-1!==i?t.presentationTimestamps[i].blockIndex:-1,correctBlockFound:-1!==i&&r<t.endTimestamp}},r,r,t)}async getNextKeyPacket(e,t){const r=this.packetToClusterLocation.get(e);if(void 0===r)throw new Error("Packet was not created from this track.");return this.performClusterLookup(r.cluster,e=>{if(e===r.cluster){const t=e.trackData.get(this.internalTrack.id).blocks.findIndex((e,t)=>e.isKeyFrame&&t>r.blockIndex);if(-1!==t)return{blockIndex:t,correctBlockFound:!0}}else{const t=e.trackData.get(this.internalTrack.id);if(t&&null!==t.firstKeyFrameTimestamp){const e=t.blocks.findIndex(e=>e.isKeyFrame);return l(-1!==e),{blockIndex:e,correctBlockFound:!0}}}return{blockIndex:-1,correctBlockFound:!1}},-1/0,1/0,t)}async fetchPacketInCluster(e,t,r){if(-1===t)return null;const i=e.trackData.get(this.internalTrack.id).blocks[t];l(i),i.decoded||(i.data=this.internalTrack.demuxer.decodeBlockData(this.internalTrack,i.data),i.decoded=!0);const n=r.metadataOnly?Kt:i.data,a=i.timestamp/this.internalTrack.segment.timestampFactor,s=i.duration/this.internalTrack.segment.timestampFactor,o={};i.mainAdditional&&"video"===this.internalTrack.info?.type&&this.internalTrack.info.alphaMode&&(o.alpha=r.metadataOnly?Kt:i.mainAdditional,o.alphaByteLength=i.mainAdditional.byteLength);const c=new Yt(n,i.isKeyFrame?"key":"delta",a,s,e.dataStartPos+t,i.data.byteLength,o);return this.packetToClusterLocation.set(c,{cluster:e,blockIndex:t}),c}async performClusterLookup(e,t,r,i,n){const{demuxer:a,segment:s}=this.internalTrack;let o=null,c=null,d=-1;if(e){const{blockIndex:r,correctBlockFound:i}=t(e);if(i)return this.fetchPacketInCluster(e,r,n);-1!==r&&(c=e,d=r)}const u=O(this.internalTrack.cuePoints,r,e=>e.time),h=-1!==u?this.internalTrack.cuePoints[u]:null,f=O(this.internalTrack.clusterPositionCache,r,e=>e.startTimestamp),m=-1!==f?this.internalTrack.clusterPositionCache[f]:null,p=Math.max(h?.clusterPosition??0,m?.elementStartPos??0)||null;let g;for(e?null===p||e.elementStartPos>=p?(g=e.elementEndPos,o=e):g=p:g=p??s.clusterSeekStartPos;null===s.elementEndPos||g<=s.elementEndPos-2;){if(o){const e=o.trackData.get(this.internalTrack.id);if(e&&e.startTimestamp>i)break}let e=a.reader.requestSliceRange(g,2,Ai);if(e instanceof Promise&&(e=await e),!e)break;const r=g,u=Ri(e);if(!u||!ki.includes(u.id)&&u.id!==wi.Void){const e=await Mi(a.reader,r,ki,Math.min(s.elementEndPos??1/0,r+Hi));if(e){g=e;continue}break}const h=u.id;let f=u.size;const m=e.filePos;if(h===wi.Cluster){o=await a.readCluster(r,s),f=o.elementEndPos-m;const{blockIndex:e,correctBlockFound:i}=t(o);if(i)return this.fetchPacketInCluster(o,e,n);-1!==e&&(c=o,d=e)}if(void 0===f){l(h!==wi.Cluster);f=(await Di(a.reader,m,Ti,s.elementEndPos)).pos-m}const p=m+f;if(null===s.elementEndPos){let e=a.reader.requestSliceRange(p,2,Ai);if(e instanceof Promise&&(e=await e),!e)break;if(_i(e)===wi.Segment){s.elementEndPos=p;break}}g=p}if(h&&(!c||c.elementStartPos<h.clusterPosition)){const e=this.internalTrack.cuePoints[u-1];l(!e||e.time<h.time);const r=e?.time??-1/0;return this.performClusterLookup(null,t,r,i,n)}return c?this.fetchPacketInCluster(c,d,n):null}}class Yi extends Ki{constructor(e){super(e),this.decoderConfigPromise=null,this.internalTrack=e}getType(){return"video"}getCodec(){return this.internalTrack.info.codec}getCodedWidth(){return this.internalTrack.info.width}getCodedHeight(){return this.internalTrack.info.height}getSquarePixelWidth(){return this.internalTrack.info.squarePixelWidth}getSquarePixelHeight(){return this.internalTrack.info.squarePixelHeight}getRotation(){return this.internalTrack.info.rotation}async getColorSpace(){return{primaries:this.internalTrack.info.colorSpace?.primaries,transfer:this.internalTrack.info.colorSpace?.transfer,matrix:this.internalTrack.info.colorSpace?.matrix,fullRange:this.internalTrack.info.colorSpace?.fullRange}}
1async canBeTransparent(){return this.internalTrack.info.alphaMode}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfigPromise??=(async()=>{let e=null;("vp9"===this.internalTrack.info.codec||"av1"===this.internalTrack.info.codec||"avc"===this.internalTrack.info.codec&&!this.internalTrack.info.codecDescription||"hevc"===this.internalTrack.info.codec&&!this.internalTrack.info.codecDescription)&&(e=await this.getFirstPacket({}));const t={codec:Le({width:this.internalTrack.info.width,height:this.internalTrack.info.height,codec:this.internalTrack.info.codec,codecDescription:this.internalTrack.info.codecDescription,colorSpace:this.internalTrack.info.colorSpace,avcType:1,avcCodecInfo:"avc"===this.internalTrack.info.codec&&e?ft(e.data):null,hevcCodecInfo:"hevc"===this.internalTrack.info.codec&&e?kt(e.data):null,vp9CodecInfo:"vp9"===this.internalTrack.info.codec&&e?_t(e.data):null,av1CodecInfo:"av1"===this.internalTrack.info.codec&&e?Rt(e.data):null}),codedWidth:this.internalTrack.info.width,codedHeight:this.internalTrack.info.height,description:this.internalTrack.info.codecDescription??void 0,colorSpace:this.internalTrack.info.colorSpace??void 0};return this.internalTrack.info.width===this.internalTrack.info.squarePixelWidth&&this.internalTrack.info.height===this.internalTrack.info.squarePixelHeight||(t.displayAspectWidth=this.internalTrack.info.squarePixelWidth,t.displayAspectHeight=this.internalTrack.info.squarePixelHeight),t})():null}}class Xi extends Ki{constructor(e){super(e),this.decoderConfig=null,this.internalTrack=e}getType(){return"audio"}getCodec(){return this.internalTrack.info.codec}getNumberOfChannels(){return this.internalTrack.info.numberOfChannels}getSampleRate(){return this.internalTrack.info.sampleRate}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfig??={codec:ze({codec:this.internalTrack.info.codec,codecDescription:this.internalTrack.info.codecDescription,aacCodecInfo:this.internalTrack.info.aacCodecInfo}),numberOfChannels:this.internalTrack.info.numberOfChannels,sampleRate:this.internalTrack.info.sampleRate,description:this.internalTrack.info.codecDescription??void 0}:null}}const Qi=[44100,48e3,32e3],Ji=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1,-1,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1,-1,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1,-1,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1,-1,32,48,56,64,80,96,112,128,144,160,176,192,224,256,-1],Zi=1483304551,en=1231971951,tn=(e,t,r,i,n)=>0===t?0:1===t?Math.floor(144*r/(i<<e))+n:2===t?Math.floor(144*r/i)+n:4*(Math.floor(12*r/i)+n),rn=(e,t)=>3===e?3===t?21:36:3===t?13:21,nn=(e,t)=>{const r=e>>>24,i=e>>>16&255,n=e>>>8&255,a=255&e;if(255!==r&&255!==i&&255!==n&&255!==a)return{header:null,bytesAdvanced:4};if(255!==r)return{header:null,bytesAdvanced:1};if(224&~i)return{header:null,bytesAdvanced:1};let s=0,o=0;16&i?s=8&i?0:1:(s=1,o=1);const c=i>>3&3,d=i>>1&3,l=(n>>2&3)%3,u=a>>6&3,h=a>>4&3,f=a>>3&1,m=a>>2&1,p=3&a,g=Ji[16*s*4+16*d+(n>>4&15)];if(-1===g)return{header:null,bytesAdvanced:1};const y=1e3*g,b=Qi[l]>>s+o,w=tn(s,d,y,b,n>>1&1);if(null!==t&&t<w)return{header:null,bytesAdvanced:1};let v;return v=3===c?3===d?384:1152:3===d?384:2===d?1152:576,{header:{totalSize:w,mpegVersionId:c,lowSamplingFrequency:s,layer:d,bitrate:y,frequencyIndex:l,sampleRate:b,channel:u,modeExtension:h,copyright:f,original:m,emphasis:p,audioSamplesInFrame:v},bytesAdvanced:1}},an=e=>{let t=2130706432,r=0;for(;0!==t;)r>>=1,r|=e&t,t>>=8;return r};var sn;!function(e){e[e.FrameCount=1]="FrameCount",e[e.FileSize=2]="FileSize",e[e.Toc=4]="Toc"}(sn||(sn={}));const on=e=>3===e?1:2;var cn,dn;!function(e){e[e.Unsynchronisation=128]="Unsynchronisation",e[e.ExtendedHeader=64]="ExtendedHeader",e[e.ExperimentalIndicator=32]="ExperimentalIndicator",e[e.Footer=16]="Footer"}(cn||(cn={})),function(e){e[e.ISO_8859_1=0]="ISO_8859_1",e[e.UTF_16_WITH_BOM=1]="UTF_16_WITH_BOM",e[e.UTF_16_BE_NO_BOM=2]="UTF_16_BE_NO_BOM",e[e.UTF_8=3]="UTF_8"}(dn||(dn={}));const ln=128,un=10,hn=["Blues","Classic rock","Country","Dance","Disco","Funk","Grunge","Hip-hop","Jazz","Metal","New age","Oldies","Other","Pop","Rhythm and blues","Rap","Reggae","Rock","Techno","Industrial","Alternative","Ska","Death metal","Pranks","Soundtrack","Euro-techno","Ambient","Trip-hop","Vocal","Jazz & funk","Fusion","Trance","Classical","Instrumental","Acid","House","Game","S
1ound clip","Gospel","Noise","Alternative rock","Bass","Soul","Punk","Space","Meditative","Instrumental pop","Instrumental rock","Ethnic","Gothic","Darkwave","Techno-industrial","Electronic","Pop-folk","Eurodance","Dream","Southern rock","Comedy","Cult","Gangsta","Top 40","Christian rap","Pop/funk","Jungle music","Native US","Cabaret","New wave","Psychedelic","Rave","Showtunes","Trailer","Lo-fi","Tribal","Acid punk","Acid jazz","Polka","Retro","Musical","Rock 'n' roll","Hard rock","Folk","Folk rock","National folk","Swing","Fast fusion","Bebop","Latin","Revival","Celtic","Bluegrass","Avantgarde","Gothic rock","Progressive rock","Psychedelic rock","Symphonic rock","Slow rock","Big band","Chorus","Easy listening","Acoustic","Humour","Speech","Chanson","Opera","Chamber music","Sonata","Symphony","Booty bass","Primus","Porn groove","Satire","Slow jam","Club","Tango","Samba","Folklore","Ballad","Power ballad","Rhythmic Soul","Freestyle","Duet","Punk rock","Drum solo","A cappella","Euro-house","Dance hall","Goa music","Drum & bass","Club-house","Hardcore techno","Terror","Indie","Britpop","Negerpunk","Polsk punk","Beat","Christian gangsta rap","Heavy metal","Black metal","Crossover","Contemporary Christian","Christian rock","Merengue","Salsa","Thrash metal","Anime","Jpop","Synthpop","Christmas","Art rock","Baroque","Bhangra","Big beat","Breakbeat","Chillout","Downtempo","Dub","EBM","Eclectic","Electro","Electroclash","Emo","Experimental","Garage","Global","IDM","Illbient","Industro-Goth","Jam Band","Krautrock","Leftfield","Lounge","Math rock","New romantic","Nu-breakz","Post-punk","Post-rock","Psytrance","Shoegaze","Space rock","Trop rock","World music","Neoclassical","Audiobook","Audio theatre","Neue Deutsche Welle","Podcast","Indie rock","G-Funk","Dubstep","Garage rock","Psybient"],fn=(e,t)=>{const r=br(e,t),i=ce(r.indexOf(0),r.length),n=r.subarray(0,i);let a="";for(let e=0;e<n.length;e++)a+=String.fromCharCode(n[e]);return a.trimEnd()},mn=e=>{const t=e.filePos,r=Rr(e,3),i=wr(e),n=wr(e),a=wr(e),s=Cr(e);if("ID3"!==r||255===i||255===n||2155905152&s)return e.filePos=t,null;let o=an(s);return a&cn.Footer&&(o+=un),{majorVersion:i,revision:n,flags:a,size:o}},pn=(e,t,r)=>{if(![2,3,4].includes(t.majorVersion))return void d._warn(`Unsupported ID3v2 major version: ${t.majorVersion}`);const i=t.flags&cn.Footer?t.size-un:t.size,n=br(e,i),a=new gn(t,n);if(t.flags&cn.Unsynchronisation&&3===t.majorVersion&&a.ununsynchronizeAll(),t.flags&cn.ExtendedHeader){const e=a.readU32();3===t.majorVersion?a.pos+=e:a.pos+=e-4}for(;a.pos<=a.bytes.length-a.frameHeaderSize();){const e=a.readId3V2Frame();if(!e)break;const i=a.pos,n=a.pos+e.size;let s=!1,o=!1,c=!1;if(3===t.majorVersion?(s=!!(64&e.flags),o=!!(128&e.flags)):4===t.majorVersion&&(s=!!(4&e.flags),o=!!(8&e.flags),c=!!(2&e.flags)||!!(t.flags&cn.Unsynchronisation)),s)d._warn(`Skipping encrypted ID3v2 frame ${e.id}`),a.pos=n;else if(o)d._warn(`Skipping compressed ID3v2 frame ${e.id}`),a.pos=n;else{if(c&&a.ununsynchronizeRegion(a.pos,n),r.raw??={},"TXXX"===e.id){const e=r.raw.TXXX??={},t=a.readId3V2TextEncoding(),i=a.readId3V2Text(t,n),s=a.readId3V2Text(t,n);e[i]??=s}else"T"===e.id[0]?r.raw[e.id]??=a.readId3V2EncodingAndText(n):r.raw[e.id]??=a.readBytes(e.size);switch(a.pos=i,e.id){case"TIT2":case"TT2":r.title??=a.readId3V2EncodingAndText(n);break;case"TIT3":case"TT3":r.description??=a.readId3V2EncodingAndText(n);break;case"TPE1":case"TP1":r.artist??=a.readId3V2EncodingAndText(n);break;case"TALB":case"TAL":r.album??=a.readId3V2EncodingAndText(n);break;case"TPE2":case"TP2":r.albumArtist??=a.readId3V2EncodingAndText(n);break;case"TRCK":case"TRK":{const e=a.readId3V2EncodingAndText(n).split("/"),t=Number.parseInt(e[0],10),i=e[1]&&Number.parseInt(e[1],10);Number.isInteger(t)&&t>0&&(r.trackNumber??=t),i&&Number.isInteger(i)&&i>0&&(r.tracksTotal??=i)}break;case"TPOS":case"TPA":{const e=a.readId3V2EncodingAndText(n).split("/"),t=Number.parseInt(e[0],10),i=e[1]&&Number.parseInt(e[1],10);Number.isInteger(t)&&t>0&&(r.discNumber??=t),i&&Number.isInteger(i)&&i>0&&(r.discsTotal??=i)}break;case"TCON":case"TCO":{const e=a.readId3V2EncodingAndText(n);let t=/^\((\d+)\)/.exec(e);if(t){const e=Number.parseInt(t[1]);if(void 0!==hn[e]){r.genre??=hn[e];break}}if(t=/^\d+$/.exec(e),t){const e=Number.parseInt(t[0]);if(void 0!==hn[e]){r.genre??=hn[e];break}}r.genre??=e}break;case"TDRC":case"TDAT":{const e=a.readId3V2EncodingAndText(n),t=new Date(e);Number.isNaN(t.getTime())||(r.date??=t)}break;case"TYER":case"TYE":{const e=a.readId3V2EncodingAndText(n),t=Number.parseInt(e,10);Number.isInteger(t)&&(r.date??=new Date(String(t)))}break;case"USLT":case"ULT":{const e=a.readU8();a.pos+=3,a.readId3V2Text(e,n),r.lyrics??=a.readId3V2Text(e,n)}break;case"COMM":case"COM":{const e=a.readU8();a.pos+=3,a.readId3V2Text(e,n),r.comment??=a.readId3V2Text(e,n)}break;case"APIC":case"PIC":{const e=a.readId3V2TextEncoding();let i;if(2===t.majorVersion){const e=a.readAscii(3);i="PNG"===e?"image/png":"JPG"===e?"image/jpeg":"image/*"}else i=a.readId3V2Text(e,n);const s=a.readU8(),o=a.readId3V2Text(e,n).trimEnd(),c=n-a.pos;if(c>=0){const e=a.readBytes(c);r.images||(r.images=[]),r.images.push({data:e,mimeType:i,kind:3===s?"coverFront":4===s?"coverBack":"unknown",de
1scription:o})}}break;default:a.pos+=e.size}a.pos=n}}};class gn{constructor(e,t){this.header=e,this.bytes=t,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}frameHeaderSize(){return 2===this.header.majorVersion?6:10}ununsynchronizeAll(){const e=[];for(let t=0;t<this.bytes.length;t++){const r=this.bytes[t];if(e.push(r),255===r&&t!==this.bytes.length-1){0===this.bytes[t]&&t++}}this.bytes=new Uint8Array(e),this.view=new DataView(this.bytes.buffer)}ununsynchronizeRegion(e,t){const r=[];for(let i=e;i<t;i++){const e=this.bytes[i];if(r.push(e),255===e&&i!==t-1){0===this.bytes[i+1]&&i++}}const i=this.bytes.subarray(0,e),n=this.bytes.subarray(t);this.bytes=new Uint8Array(i.length+r.length+n.length),this.bytes.set(i,0),this.bytes.set(r,i.length),this.bytes.set(n,i.length+r.length),this.view=new DataView(this.bytes.buffer)}readBytes(e){const t=this.bytes.subarray(this.pos,this.pos+e);return this.pos+=e,t}readU8(){const e=this.view.getUint8(this.pos);return this.pos+=1,e}readU16(){const e=this.view.getUint16(this.pos,!1);return this.pos+=2,e}readU24(){const e=this.view.getUint16(this.pos,!1),t=this.view.getUint8(this.pos+2);return this.pos+=3,256*e+t}readU32(){const e=this.view.getUint32(this.pos,!1);return this.pos+=4,e}readAscii(e){let t="";for(let r=0;r<e;r++)t+=String.fromCharCode(this.view.getUint8(this.pos+r));return this.pos+=e,t}readId3V2Frame(){if(2===this.header.majorVersion){const e=this.readAscii(3);if("\0\0\0"===e)return null;return{id:e,size:this.readU24(),flags:0}}{const e=this.readAscii(4);if("\0\0\0\0"===e)return null;const t=this.readU32();let r=4===this.header.majorVersion?an(t):t;const i=this.readU16(),n=this.pos,a=e=>{const t=this.pos+e;if(t>this.bytes.length)return!1;if(t<=this.bytes.length-this.frameHeaderSize()){this.pos+=e;const t=this.readAscii(4);if("\0\0\0\0"!==t&&!/[0-9A-Z]{4}/.test(t))return!1}return!0};if(!a(r)){const e=4===this.header.majorVersion?t:an(t);a(e)&&(r=e)}return this.pos=n,{id:e,size:r,flags:i}}}readId3V2TextEncoding(){const e=this.readU8();if(e>3)throw new Error(`Unsupported text encoding: ${e}`);return e}readId3V2Text(e,t){const r=this.pos,i=this.readBytes(t-this.pos);switch(e){case dn.ISO_8859_1:{let e="";for(let t=0;t<i.length;t++){const n=i[t];if(0===n){this.pos=r+t+1;break}e+=String.fromCharCode(n)}return e}case dn.UTF_16_WITH_BOM:if(255===i[0]&&254===i[1]){const e=new TextDecoder("utf-16le"),t=ce(i.findIndex((e,t)=>0===e&&0===i[t+1]&&t%2==0),i.length);return this.pos=r+Math.min(t+2,i.length),e.decode(i.subarray(2,t))}if(254===i[0]&&255===i[1]){const e=new TextDecoder("utf-16be"),t=ce(i.findIndex((e,t)=>0===e&&0===i[t+1]&&t%2==0),i.length);return this.pos=r+Math.min(t+2,i.length),e.decode(i.subarray(2,t))}{const e=ce(i.findIndex(e=>0===e),i.length);return this.pos=r+Math.min(e+1,i.length),b.decode(i.subarray(0,e))}case dn.UTF_16_BE_NO_BOM:{const e=new TextDecoder("utf-16be"),t=ce(i.findIndex((e,t)=>0===e&&0===i[t+1]&&t%2==0),i.length);return this.pos=r+Math.min(t+2,i.length),e.decode(i.subarray(0,t))}case dn.UTF_8:{const e=ce(i.findIndex(e=>0===e),i.length);return this.pos=r+Math.min(e+1,i.length),b.decode(i.subarray(0,e))}}}readId3V2EncodingAndText(e){if(this.pos>=e)return"";const t=this.readId3V2TextEncoding();return this.readId3V2Text(t,e)}}const yn=async(e,t,r,i=null)=>{let n=t;for(;null===r||n<r;){const t=null!==r?Math.min(65536,r-n):65536;let a=e.requestSliceRange(n,4,t);if(a instanceof Promise&&(a=await a),!a||a.length<4)break;for(;a.remainingLength>=4;){const t=a.filePos,r=Cr(a),s=null!==e.fileSize?e.fileSize-n:null,o=nn(r,s);if(o.header&&(!i||o.header.sampleRate===i.sampleRate&&o.header.mpegVersionId===i.mpegVersionId&&o.header.layer===i.layer&&on(o.header.channel)===on(i.channel)))return{header:o.header,startPos:n};a.filePos=t+o.bytesAdvanced,n=a.filePos}}return null};class bn extends Gt{constructor(e){super(e),this.metadataPromise=null,this.firstFrameHeader=null,this.firstFrameHeaderPos=null,this.loadedSamples=[],this.metadataTags=null,this.xingData=null,this.trackBackings=[],this.readingMutex=new I,this.lastSampleLoaded=!1,this.lastLoadedPos=0,this.nextTimestampInSamples=0,this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{for(;!this.firstFrameHeader&&!this.lastSampleLoaded;)await this.advanceReader();if(!this.firstFrameHeader)throw new Error("No valid MP3 frame found.");this.trackBackings=[new wn(this)]})()}
1async advanceReader(){if(0===this.lastLoadedPos)for(;;){let e=this.reader.requestSlice(this.lastLoadedPos,un);if(e instanceof Promise&&(e=await e),!e)return void(this.lastSampleLoaded=!0);const t=mn(e);if(!t)break;this.lastLoadedPos=e.filePos+t.size}const e=await yn(this.reader,this.lastLoadedPos,this.reader.fileSize,this.firstFrameHeader);if(!e)return void(this.lastSampleLoaded=!0);const t=e.header;this.lastLoadedPos=e.startPos+t.totalSize-1;const r=rn(t.mpegVersionId,t.channel);let i=this.reader.requestSlice(e.startPos+r,4);if(i instanceof Promise&&(i=await i),i){const t=Cr(i);if(t===Zi||t===en){if(!this.xingData){let t=this.reader.requestSlice(e.startPos+r+4,12);if(t instanceof Promise&&(t=await t),t){const e=br(t,12),r=y(e),i=r.getUint32(0,!1);this.xingData={frameCount:i&sn.FrameCount?r.getUint32(4,!1):null,fileSize:i&sn.FileSize?r.getUint32(8,!1):null}}}return}}this.firstFrameHeader||(this.firstFrameHeader=t,this.firstFrameHeaderPos=e.startPos);const n=t.audioSamplesInFrame/this.firstFrameHeader.sampleRate,a={timestamp:this.nextTimestampInSamples/this.firstFrameHeader.sampleRate,duration:n,dataStart:e.startPos,dataSize:t.totalSize};this.loadedSamples.push(a),this.nextTimestampInSamples+=t.audioSamplesInFrame}async getMimeType(){return"audio/mpeg"}async getTrackBackings(){return await this.readMetadata(),this.trackBackings}async getMetadataTags(){const e=await this.readingMutex.acquire();try{if(await this.readMetadata(),this.metadataTags)return this.metadataTags;this.metadataTags={};let e=0,t=!1;for(;;){let r=this.reader.requestSlice(e,un);if(r instanceof Promise&&(r=await r),!r)break;const i=mn(r);if(!i)break;t=!0;let n=this.reader.requestSlice(r.filePos,i.size);if(n instanceof Promise&&(n=await n),!n)break;pn(n,i,this.metadataTags),e=r.filePos+i.size}if(!t&&null!==this.reader.fileSize&&this.reader.fileSize>=ln){let e=this.reader.requestSlice(this.reader.fileSize-ln,ln);e instanceof Promise&&(e=await e),l(e);"TAG"===Rr(e,3)&&((e,t)=>{const r=e.filePos;t.raw??={},t.raw.TAG??=br(e,125),e.filePos=r;const i=fn(e,30);i&&(t.title??=i);const n=fn(e,30);n&&(t.artist??=n);const a=fn(e,30);a&&(t.album??=a);const s=fn(e,4),o=Number.parseInt(s,10);Number.isInteger(o)&&o>0&&(t.date??=new Date(String(o)));const c=br(e,30);let d;if(0===c[28]&&0!==c[29]){const r=c[29];r>0&&(t.trackNumber??=r),e.skip(-30),d=fn(e,28),e.skip(2)}else e.skip(-30),d=fn(e,30);d&&(t.comment??=d);const l=wr(e);l<hn.length&&(t.genre??=hn[l])})(e,this.metadataTags)}return this.metadataTags}finally{e()}}}class wn{constructor(e){this.demuxer=e}getType(){return"audio"}getId(){return 1}getNumber(){return 1}getTimeResolution(){return l(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.sampleRate/this.demuxer.firstFrameHeader.audioSamplesInFrame}isRelativeToUnixEpoch(){return!1}getUnixTimeForTimestamp(){return null}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){const e=this.demuxer;if(l(null!==e.firstFrameHeader),l(null!==e.firstFrameHeaderPos),e.xingData){if(null!==e.xingData.frameCount)return e.xingData.frameCount*e.firstFrameHeader.audioSamplesInFrame/e.firstFrameHeader.sampleRate}else if(null!==e.reader.fileSize){const a=(t=e.firstFrameHeader.lowSamplingFrequency,r=e.firstFrameHeader.layer,i=e.firstFrameHeader.bitrate,n=e.firstFrameHeader.sampleRate,0===r?0:1===r?144*i/(n<<t):2===r?144*i/n:12*i/n*4),s=(e.reader.fileSize-e.firstFrameHeaderPos)/a;return Math.round(s)*e.firstFrameHeader.audioSamplesInFrame/e.firstFrameHeader.sampleRate}var t,r,i,n;return null}
1async getLiveRefreshInterval(){return null}getName(){return null}getLanguageCode(){return V}getCodec(){return"mp3"}getInternalCodecId(){return null}getNumberOfChannels(){return l(this.demuxer.firstFrameHeader),on(this.demuxer.firstFrameHeader.channel)}getSampleRate(){return l(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.sampleRate}getDisposition(){return{...rr}}async getDecoderConfig(){return l(this.demuxer.firstFrameHeader),{codec:"mp3",numberOfChannels:on(this.demuxer.firstFrameHeader.channel),sampleRate:this.demuxer.firstFrameHeader.sampleRate}}async getPacketAtIndex(e,t){if(-1===e)return null;const r=this.demuxer.loadedSamples[e];if(!r)return null;let i;if(t.metadataOnly)i=Kt;else{let e=this.demuxer.reader.requestSlice(r.dataStart,r.dataSize);if(e instanceof Promise&&(e=await e),!e)return null;i=br(e,r.dataSize)}return new Yt(i,"key",r.timestamp,r.duration,e,r.dataSize)}getFirstPacket(e){return this.getPacketAtIndex(0,e)}async getNextPacket(e,t){const r=await this.demuxer.readingMutex.acquire();try{const r=R(this.demuxer.loadedSamples,e.timestamp,e=>e.timestamp);if(-1===r)throw new Error("Packet was not created from this track.");const i=r+1;for(;i>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(i,t)}finally{r()}}async getPacket(e,t){const r=await this.demuxer.readingMutex.acquire();try{for(;;){const r=O(this.demuxer.loadedSamples,e,e=>e.timestamp);if(-1===r&&this.demuxer.loadedSamples.length>0)return null;if(this.demuxer.lastSampleLoaded)return this.getPacketAtIndex(r,t);if(r>=0&&r+1<this.demuxer.loadedSamples.length)return this.getPacketAtIndex(r,t);await this.demuxer.advanceReader()}}finally{r()}}getKeyPacket(e,t){return this.getPacket(e,t)}getNextKeyPacket(e,t){return this.getNextPacket(e,t)}}const vn=1399285583,kn=new Uint32Array(256);for(let e=0;e<256;e++){let t=e<<24;for(let e=0;e<8;e++)t=2147483648&t?t<<1^79764919:t<<1;kn[e]=t>>>0&4294967295}const Tn=e=>{const t=y(e),r=t.getUint32(22,!0);t.setUint32(22,0,!0);let i=0;for(let t=0;t<e.length;t++){const r=e[t];i=(i<<8^kn[i>>>24^r])>>>0}return t.setUint32(22,r,!0),i},xn=(e,t,r)=>{let i=0,n=null;if(e.length>0)if("vorbis"===t.codec){l(t.vorbisInfo);const a=(1<<(e=>{let t=0;for(;e;)t++,e>>=1;return t})(t.vorbisInfo.modeBlockflags.length-1))-1<<1,s=(e[0]&a)>>1;if(s>=t.vorbisInfo.modeBlockflags.length)throw new Error("Invalid mode number.");let o=r;const c=t.vorbisInfo.modeBlockflags[s];if(n=t.vorbisInfo.blocksizes[c],1===c){const r=1+(1|a),i=e[0]&r?1:0;o=t.vorbisInfo.blocksizes[i]}i=null!==o?o+n>>2:0}else if("opus"===t.codec){i=(e=>{const t=e[0]>>3;return{durationInSamples:Ft[t]}})(e).durationInSamples}return{durationInSamples:i,vorbisBlockSize:n}},Sn=e=>{let t="audio/ogg";if(e.codecStrings){t+=`; codecs="${[...new Set(e.codecStrings)].join(", ")}"`}return t},Cn=27,Pn=282,An=e=>{const t=e.filePos;if(Pr(e)!==vn)return null;e.skip(1);const r=wr(e),i=_r(e),n=Pr(e),a=Pr(e),s=Pr(e),o=wr(e),c=new Uint8Array(o);for(let t=0;t<o;t++)c[t]=wr(e);const d=27+o,l=c.reduce((e,t)=>e+t,0);return{headerStartPos:t,totalSize:d+l,dataStartPos:t+d,dataSize:l,headerType:r,granulePosition:i,serialNumber:n,sequenceNumber:a,checksum:s,lacingValues:c}},En=(e,t)=>{for(;e.filePos<t-3;){const t=Pr(e),r=79;if((255&t)===r||(t>>>8&255)===r||(t>>>16&255)===r||(t>>>24&255)===r){if(e.skip(-4),t===vn)return!0;e.skip(1)}}return!1};class In extends Gt{constructor(e){super(e),this.metadataPromise=null,this.bitstreams=[],this.trackBackings=[],this.metadataTags={},this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{let e=0;for(;;){let t=this.reader.requestSliceRange(e,Cn,Pn);if(t instanceof Promise&&(t=await t),!t)break;const r=An(t);if(!r)break;if(!!!(2&r.headerType))break;this.bitstreams.push({serialNumber:r.serialNumber,bosPage:r,description:null,numberOfChannels:-1,sampleRate:-1,codecInfo:{codec:null,vorbisInfo:null,opusInfo:null},lastMetadataPacket:null}),e=r.headerStartPos+r.totalSize}for(const e of this.bitstreams){const t=await this.readPacket(e.bosPage,0);t&&(t.data.byteLength>=7&&1===t.data[0]&&118===t.data[1]&&111===t.data[2]&&114===t.data[3]&&98===t.data[4]&&105===t.data[5]&&115===t.data[6]?await this.readVorbisMetadata(t,e):t.data.byteLength>=8&&79===t.data[0]&&112===t.data[1]&&117===t.data[2]&&115===t.data[3]&&72===t.data[4]&&101===t.data[5]&&97===t.data[6]&&100===t.data[7]&&await this.readOpusMetadata(t,e),null!==e.codecInfo.codec&&this.trackBackings.push(new $n(e,this)))}})()}async readVorbisMetadata(e,t){let r=await this.findNextPacketStart(e);if(!r)return;const i=await this.readPacket(r.startPage,r.startSegmentIndex);if(!i)return;if(r=await this.findNextPacketStart(i),!r)return;const n=await this.readPacket(r.startPage,r.startSegmentIndex);if(!n)return;if(3!==i.data[0]||5!==n.data[0])return;const a=[],s=e=>{for(;a.push(Math.min(255,e)),!(e<255);)e-=255};s(e.data.length),s(i.data.length);const o=new Uint8Array(1+a.length+e.data.length+i.data.length+n.data.length);o[0]=2,o.set(a,1),o.set(e.data,1+a.length),o.set(i.data,1+a.length+e.data.length),o.set(n.data,1+a.length+e.data.length+i.data.length),t.codecInfo.codec="vorbis",t.description=o,t.lastMetadataPacket=n;const c=y(e.data);t.numberOfChannels=c.getUint8(11),t.sampleRate=c.getUint32(12,!0);const d=c.getUint8(28);t.codecInfo.vorbisInfo={blocksizes:[1<<(15&d),1<<(d>>4)],modeBlockflags:Bt(n.data).modeBlockflags},jt(i.data.subarray(7),this.metadataTags)}async readOpusMetadata(e,t){const r=await this.findNextPacketStart(e);if(!r)return;const i=await this.readPacket(r.startPage,r.startSegmentIndex);if(!i)return;t.codecInfo.codec="opus",t.description=e.data,t.lastMetadataPacket=i;const n=Ot(e.data);t.numberOfChannels=n.outputChannelCount,t.sampleRate=48e3,t.codecInfo.opusInfo={preSkip:n.preSkip},jt(i.data.subarray(8),this.metadataTags)}async readPacket(e,t){l(t<e.lacingValues.length);let r=0;for(let i=0;i<t;i++)r+=e.lacingValues[i];let i=e,n=r,a=t;const s=[];e:for(;;){let t=this.reader.requestSlice(i.dataStartPos,i.dataSize);t instanceof Promise&&(t=await t),l(t);const o=br(t,i.dataSize);for(;;){if(a===i.lacingValues.length){s.push(o.subarray(r,n));break}const e=i.lacingValues[a];if(n+=e,e<255){s.push(o.subarray(r,n));break e}a++}let c=i.headerStartPos+i.totalSize;
1for(;;){let t=this.reader.requestSliceRange(c,Cn,Pn);if(t instanceof Promise&&(t=await t),!t)return null;const r=An(t);if(!r)return null;if(i=r,i.serialNumber===e.serialNumber)break;c=i.headerStartPos+i.totalSize}r=0,n=0,a=0}const o=s.reduce((e,t)=>e+t.length,0);if(0===o)return null;const c=new Uint8Array(o);let d=0;for(let e=0;e<s.length;e++){const t=s[e];c.set(t,d),d+=t.length}return{data:c,endPage:i,endSegmentIndex:a}}async findNextPacketStart(e){if(e.endSegmentIndex<e.endPage.lacingValues.length-1)return{startPage:e.endPage,startSegmentIndex:e.endSegmentIndex+1};if(!!(4&e.endPage.headerType))return null;let t=e.endPage.headerStartPos+e.endPage.totalSize;for(;;){let r=this.reader.requestSliceRange(t,Cn,Pn);if(r instanceof Promise&&(r=await r),!r)return null;const i=An(r);if(!i)return null;if(i.serialNumber===e.endPage.serialNumber)return{startPage:i,startSegmentIndex:0};t=i.headerStartPos+i.totalSize}}async getMimeType(){await this.readMetadata();const e=await Promise.all(this.trackBackings.map(e=>e.getDecoderConfig().then(e=>e?.codec??null)));return Sn({codecStrings:e.filter(Boolean)})}async getTrackBackings(){return await this.readMetadata(),this.trackBackings}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}}class $n{constructor(e,t){this.bitstream=e,this.demuxer=t,this.encodedPacketToMetadata=new WeakMap,this.sequentialScanCache=[],this.sequentialScanMutex=new I,this.internalSampleRate="opus"===e.codecInfo.codec?48e3:e.sampleRate}getType(){return"audio"}getId(){return this.bitstream.serialNumber}getNumber(){const e=this.demuxer.trackBackings.findIndex(e=>e.bitstream===this.bitstream);return l(-1!==e),e+1}getNumberOfChannels(){return this.bitstream.numberOfChannels}getSampleRate(){return this.bitstream.sampleRate}getTimeResolution(){return this.bitstream.sampleRate}isRelativeToUnixEpoch(){return!1}getUnixTimeForTimestamp(){return null}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){return null}
1async getLiveRefreshInterval(){return null}getCodec(){return this.bitstream.codecInfo.codec}getInternalCodecId(){return null}async getDecoderConfig(){return l(this.bitstream.codecInfo.codec),{codec:this.bitstream.codecInfo.codec,numberOfChannels:this.bitstream.numberOfChannels,sampleRate:this.bitstream.sampleRate,description:this.bitstream.description??void 0}}getName(){return null}getLanguageCode(){return V}getDisposition(){return{...rr,primary:!1}}granulePositionToTimestampInSamples(e){return"opus"===this.bitstream.codecInfo.codec?(l(this.bitstream.codecInfo.opusInfo),e-this.bitstream.codecInfo.opusInfo.preSkip):e}createEncodedPacketFromOggPacket(e,t,r){if(!e)return null;const{durationInSamples:i,vorbisBlockSize:n}=xn(e.data,this.bitstream.codecInfo,t.vorbisLastBlocksize),a=new Yt(r.metadataOnly?Kt:e.data,"key",Math.max(0,t.timestampInSamples)/this.internalSampleRate,i/this.internalSampleRate,e.endPage.headerStartPos+e.endSegmentIndex,e.data.byteLength);return this.encodedPacketToMetadata.set(a,{packet:e,timestampInSamples:t.timestampInSamples,durationInSamples:i,vorbisLastBlockSize:t.vorbisLastBlocksize,vorbisBlockSize:n}),a}async getFirstPacket(e){l(this.bitstream.lastMetadataPacket);const t=await this.demuxer.findNextPacketStart(this.bitstream.lastMetadataPacket);if(!t)return null;let r=0;"opus"===this.bitstream.codecInfo.codec&&(l(this.bitstream.codecInfo.opusInfo),r-=this.bitstream.codecInfo.opusInfo.preSkip);const i=await this.demuxer.readPacket(t.startPage,t.startSegmentIndex);return this.createEncodedPacketFromOggPacket(i,{timestampInSamples:r,vorbisLastBlocksize:null},e)}async getNextPacket(e,t){const r=this.encodedPacketToMetadata.get(e);if(!r)throw new Error("Packet was not created from this track.");const i=await this.demuxer.findNextPacketStart(r.packet);if(!i)return null;const n=r.timestampInSamples+r.durationInSamples,a=await this.demuxer.readPacket(i.startPage,i.startSegmentIndex);return this.createEncodedPacketFromOggPacket(a,{timestampInSamples:n,vorbisLastBlocksize:r.vorbisBlockSize},t)}async getPacket(e,t){if(null===this.demuxer.reader.fileSize)return this.getPacketSequential(e,t);const r=q(e*this.internalSampleRate);if(0===r)return this.getFirstPacket(t);if(r<0)return null;l(this.bitstream.lastMetadataPacket);const i=await this.demuxer.findNextPacketStart(this.bitstream.lastMetadataPacket);if(!i)return null;let n=i.startPage,a=this.demuxer.reader.fileSize;const s=[n];e:for(;n.headerStartPos+n.totalSize<a;){const e=n.headerStartPos,t=Math.floor((e+a)/2);let i=t;for(;;){const e=Math.min(i+65307,a-Cn);let o=this.demuxer.reader.requestSlice(i,e-i);o instanceof Promise&&(o=await o),l(o);if(!En(o,e)){a=t+Cn;continue e}let c=this.demuxer.reader.requestSliceRange(o.filePos,Cn,Pn);c instanceof Promise&&(c=await c),l(c);const d=An(c);l(d);let u=!1;if(d.serialNumber===this.bitstream.serialNumber)u=!0;else{let e=this.demuxer.reader.requestSlice(d.headerStartPos,d.totalSize);e instanceof Promise&&(e=await e),l(e);const t=br(e,d.totalSize);u=Tn(t)===d.checksum}if(!u){i=d.headerStartPos+4;continue}if(u&&d.serialNumber!==this.bitstream.serialNumber){i=d.headerStartPos+d.totalSize;continue}if(!(-1===d.granulePosition)){this.granulePositionToTimestampInSamples(d.granulePosition)>r?a=d.headerStartPos:(n=d,s.push(d));continue e}i=d.headerStartPos+d.totalSize}}let o=i.startPage;for(const e of s){if(e.granulePosition===n.granulePosition)break;(!o||e.headerStartPos>o.headerStartPos)&&(o=e)}let c=o;const d=[c];for(;c.serialNumber!==this.bitstream.serialNumber||c.granulePosition!==n.granulePosition;){const e=c.headerStartPos+c.totalSize;let t=this.demuxer.reader.requestSliceRange(e,Cn,Pn);t instanceof Promise&&(t=await t),l(t);const r=An(t);l(r),c=r,c.serialNumber===this.bitstream.serialNumber&&d.push(c)}l(-1!==c.granulePosition);let u,h,f=null,m=c,p=0;if(c.headerStartPos===i.startPage.headerStartPos)u=this.granulePositionToTimestampInSamples(0),h=!0,f=0;else{u=0,h=!1;for(let e=c.lacingValues.length-1;e>=0;e--){if(c.lacingValues[e]<255){f=e+1;break}}if(null===f)throw new Error("Invalid page with granule position: no packets end on this page.");p=f-1;const e={data:Kt,endPage:m,endSegmentIndex:p};if(await this.demuxer.findNextPacketStart(e)){const e=Nn(d,c,f);l(e);const t=_n(d,e.page,e.segmentIndex);t&&(c=t.page,f=t.segmentIndex)}else for(;;){const e=Nn(d,c,f);if(!e)break;const t=_n(d,e.page,e.segmentIndex);if(!t)break;
1if(c=t.page,f=t.segmentIndex,e.page.headerStartPos!==m.headerStartPos){m=e.page,p=e.segmentIndex;break}}}let g=null,y=null;for(;null!==c;){l(null!==f);const e=await this.demuxer.readPacket(c,f);if(!e)break;if(!(c.headerStartPos===i.startPage.headerStartPos&&f<i.startSegmentIndex)){let i=this.createEncodedPacketFromOggPacket(e,{timestampInSamples:u,vorbisLastBlocksize:y?.vorbisBlockSize??null},t);l(i);let n=this.encodedPacketToMetadata.get(i);if(l(n),h||e.endPage.headerStartPos!==m.headerStartPos||e.endSegmentIndex!==p?u+=n.durationInSamples:(u=this.granulePositionToTimestampInSamples(c.granulePosition),h=!0,i=this.createEncodedPacketFromOggPacket(e,{timestampInSamples:u-n.durationInSamples,vorbisLastBlocksize:y?.vorbisBlockSize??null},t),l(i),n=this.encodedPacketToMetadata.get(i),l(n)),g=i,y=n,h&&(Math.max(u,0)>r||Math.max(n.timestampInSamples,0)===r))break}const n=await this.demuxer.findNextPacketStart(e);if(!n)break;c=n.startPage,f=n.startSegmentIndex}return g}async getPacketSequential(e,t){const r=await this.sequentialScanMutex.acquire();try{const r=q(e*this.internalSampleRate);e=r/this.internalSampleRate;const i=O(this.sequentialScanCache,r,e=>e.timestampInSamples);let n;if(-1!==i){const e=this.sequentialScanCache[i];n=this.createEncodedPacketFromOggPacket(e.packet,{timestampInSamples:e.timestampInSamples,vorbisLastBlocksize:e.vorbisLastBlockSize},t)}else n=await this.getFirstPacket(t);let a=0;for(;n&&n.timestamp<e;){const r=await this.getNextPacket(n,t);if(!r||r.timestamp>e)break;if(n=r,a++,100===a){a=0;const e=this.encodedPacketToMetadata.get(n);l(e),this.sequentialScanCache.length>0&&l(h(this.sequentialScanCache).timestampInSamples<=e.timestampInSamples),this.sequentialScanCache.push(e)}}return n}finally{r()}}getKeyPacket(e,t){return this.getPacket(e,t)}getNextKeyPacket(e,t){return this.getNextPacket(e,t)}}const _n=(e,t,r)=>{let i=t,n=r;e:for(;;){for(n--;n>=0;n--){if(i.lacingValues[n]<255){n++;break e}}l(-1===n);if(!(1&i.headerType)){n=0;break}const t=M(e,e=>e.headerStartPos<i.headerStartPos);if(!t)return null;i=t,n=i.lacingValues.length}if(l(-1!==n),n===i.lacingValues.length){const t=e[e.indexOf(i)+1];l(t),i=t,n=0}return{page:i,segmentIndex:n}},Nn=(e,t,r)=>{if(r>0)return{page:t,segmentIndex:r-1};const i=M(e,e=>e.headerStartPos<t.headerStartPos);return i?{page:i,segmentIndex:i.lacingValues.length-1}:null};var Rn;!function(e){e[e.PCM=1]="PCM",e[e.IEEE_FLOAT=3]="IEEE_FLOAT",e[e.ALAW=6]="ALAW",e[e.MULAW=7]="MULAW",e[e.EXTENSIBLE=65534]="EXTENSIBLE"}(Rn||(Rn={}));class On extends Gt{constructor(e){super(e),this.metadataPromise=null,this.dataStart=-1,this.dataSize=-1,this.audioInfo=null,this.trackBackings=[],this.lastKnownPacketIndex=0,this.metadataTags={},this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{let e=this.reader.requestSlice(0,12);e instanceof Promise&&(e=await e),l(e);const t=Rr(e,4),r="RIFX"!==t,i="RF64"===t,n=Sr(e,r);let a=i?this.reader.fileSize:Math.min(n+8,this.reader.fileSize??1/0);if("WAVE"!==Rr(e,4))throw new Error("Invalid WAVE file - wrong format");let s=0,o=null,c=e.filePos;for(;null===a||c<a;){let e=this.reader.requestSlice(c,8);if(e instanceof Promise&&(e=await e),!e)break;const t=Rr(e,4),n=Sr(e,r),d=e.filePos;if(i&&0===s&&"ds64"!==t)throw new Error('Invalid RF64 file: First chunk must be "ds64".');if("fmt "===t)await this.parseFmtChunk(d,n,r);else if("data"===t){if(o??=n,this.dataStart=e.filePos,this.dataSize=Math.min(o,(a??1/0)-this.dataStart),null===this.reader.fileSize)break}else if("ds64"===t){let e=this.reader.requestSlice(d,n);if(e instanceof Promise&&(e=await e),!e)break;const t=Er(e,r);o=Er(e,r),a=Math.min(t+8,this.reader.fileSize??1/0)}else"LIST"===t?await this.parseListChunk(d,n,r):"ID3 "!==t&&"id3 "!==t||await this.parseId3Chunk(d,n);c=d+n+(1&n),s++}if(!this.audioInfo)throw new Error('Invalid WAVE file - missing "fmt " chunk');if(-1===this.dataStart)throw new Error('Invalid WAVE file - missing "data" chunk');const d=this.audioInfo.blockSizeInBytes;this.dataSize=Math.floor(this.dataSize/d)*d,this.trackBackings.push(new Bn(this))})()}async parseFmtChunk(e,t,r){let i=this.reader.requestSlice(e,t);if(i instanceof Promise&&(i=await i),!i)return;let n=vr(i,r);const a=vr(i,r),s=Sr(i,r);i.skip(4);const o=vr(i,r);let c;if(c=14===t?8:vr(i,r),t>=18&&357!==n){const e=vr(i,r),a=t-18;if(Math.min(a,e)>=22&&n===Rn.EXTENSIBLE){i.skip(6);const e=br(i,16);n=e[0]|e[1]<<8}}n!==Rn.MULAW&&n!==Rn.ALAW||(c=8),this.audioInfo={format:n,numberOfChannels:a,sampleRate:s,sampleSizeInBytes:Math.ceil(c/8),blockSizeInBytes:o}}async parseListChunk(e,t,r){let i=this.reader.requestSlice(e,t);if(i instanceof Promise&&(i=await i),!i)return;const n=Rr(i,4);if("INFO"!==n&&"INF0"!==n)return;let a=i.filePos;for(;a<=e+t-8;){i.filePos=a;const e=Rr(i,4),t=Sr(i,r),n=br(i,t);let s=0;for(let e=0;e<n.length&&0!==n[e];e++)s++;const o=String.fromCharCode(...n.subarray(0,s));switch(this.metadataTags.raw??={},this.metadataTags.raw[e]=o,e){case"INAM":case"TITL":this.metadataTags.title??=o;break;case"TIT3":this.metadataTags.description??=o;break;case"IART":this.metadataTags.artist??=o;break;case"IPRD":this.metadataTags.album??=o;break;case"IPRT":case"ITRK":case"TRCK":{const e=o.split("/"),t=Number.parseInt(e[0],10),r=e[1]&&Number.parseInt(e[1],10);Number.isInteger(t)&&t>0&&(this.metadataTags.trackNumber??=t),r&&Number.isInteger(r)&&r>0&&(this.metadataTags.tracksTotal??=r)}break;case"ICRD":case"IDIT":{const e=new Date(o);Number.isNaN(e.getTime())||(this.metadataTags.date??=e)}break;case"YEAR":{const e=Number.parseInt(o,10);Number.isInteger(e)&&e>
10&&(this.metadataTags.date??=new Date(e,0,1))}break;case"IGNR":case"GENR":this.metadataTags.genre??=o;break;case"ICMT":case"CMNT":case"COMM":this.metadataTags.comment??=o}a+=8+t+(1&t)}}async parseId3Chunk(e,t){let r=this.reader.requestSlice(e,t);if(r instanceof Promise&&(r=await r),!r)return;const i=mn(r);if(i){const n=t-un;if(i.size=Math.min(i.size,n),i.size>0){const t=r.slice(e+un,i.size);pn(t,i,this.metadataTags)}}}getCodec(){if(l(this.audioInfo),this.audioInfo.format===Rn.MULAW)return"ulaw";if(this.audioInfo.format===Rn.ALAW)return"alaw";if(this.audioInfo.format===Rn.PCM){if(1===this.audioInfo.sampleSizeInBytes)return"pcm-u8";if(2===this.audioInfo.sampleSizeInBytes)return"pcm-s16";if(3===this.audioInfo.sampleSizeInBytes)return"pcm-s24";if(4===this.audioInfo.sampleSizeInBytes)return"pcm-s32"}return this.audioInfo.format===Rn.IEEE_FLOAT&&4===this.audioInfo.sampleSizeInBytes?"pcm-f32":null}async getMimeType(){return"audio/wav"}async getTrackBackings(){return await this.readMetadata(),this.trackBackings}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}}const Fn=2048;class Bn{constructor(e){this.demuxer=e}getType(){return"audio"}getId(){return 1}getNumber(){return 1}getCodec(){return this.demuxer.getCodec()}getInternalCodecId(){return l(this.demuxer.audioInfo),this.demuxer.audioInfo.format}async getDecoderConfig(){const e=this.demuxer.getCodec();return e?(l(this.demuxer.audioInfo),{codec:e,numberOfChannels:this.demuxer.audioInfo.numberOfChannels,sampleRate:this.demuxer.audioInfo.sampleRate}):null}getNumberOfChannels(){return l(this.demuxer.audioInfo),this.demuxer.audioInfo.numberOfChannels}getSampleRate(){return l(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}getTimeResolution(){return l(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}isRelativeToUnixEpoch(){return!1}getUnixTimeForTimestamp(){return null}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){return l(-1!==this.demuxer.dataSize),this.demuxer.dataSize/this.demuxer.audioInfo.blockSizeInBytes/this.demuxer.audioInfo.sampleRate}
1async getLiveRefreshInterval(){return null}getName(){return null}getLanguageCode(){return V}getDisposition(){return{...rr}}async getPacketAtIndex(e,t){l(e>=0),l(this.demuxer.audioInfo);const r=e*Fn*this.demuxer.audioInfo.blockSizeInBytes;if(r>=this.demuxer.dataSize)return null;const i=Math.min(Fn*this.demuxer.audioInfo.blockSizeInBytes,this.demuxer.dataSize-r);if(null===this.demuxer.reader.fileSize){let e=this.demuxer.reader.requestSlice(this.demuxer.dataStart+r,i);if(e instanceof Promise&&(e=await e),!e)return null}let n;if(t.metadataOnly)n=Kt;else{let e=this.demuxer.reader.requestSlice(this.demuxer.dataStart+r,i);e instanceof Promise&&(e=await e),l(e),n=br(e,i)}const a=e*Fn/this.demuxer.audioInfo.sampleRate,s=i/this.demuxer.audioInfo.blockSizeInBytes/this.demuxer.audioInfo.sampleRate;return this.demuxer.lastKnownPacketIndex=Math.max(e,this.demuxer.lastKnownPacketIndex),new Yt(n,"key",a,s,e,i)}getFirstPacket(e){return this.getPacketAtIndex(0,e)}async getPacket(e,t){l(this.demuxer.audioInfo);const r=Math.floor(Math.min(e*this.demuxer.audioInfo.sampleRate/Fn,(this.demuxer.dataSize-1)/(Fn*this.demuxer.audioInfo.blockSizeInBytes)));if(r<0)return null;const i=await this.getPacketAtIndex(r,t);if(i)return i;if(0===r)return null;l(null===this.demuxer.reader.fileSize);let n=await this.getPacketAtIndex(this.demuxer.lastKnownPacketIndex,t);for(;n;){const e=await this.getNextPacket(n,t);if(!e)break;n=e}return n}getNextPacket(e,t){l(this.demuxer.audioInfo);const r=Math.round(e.timestamp*this.demuxer.audioInfo.sampleRate/Fn);return this.getPacketAtIndex(r+1,t)}getKeyPacket(e,t){return this.getPacket(e,t)}getNextKeyPacket(e,t){return this.getNextPacket(e,t)}}const Dn=e=>{const t=e.filePos,r=br(e,9),n=new i(r);if(4095!==n.readBits(12))return null;n.skipBits(1);if(0!==n.readBits(2))return null;const a=n.readBits(1),s=n.readBits(2)+1,o=n.readBits(4);if(15===o)return null;n.skipBits(1);const c=n.readBits(3);if(0===c)throw new Error("ADTS frames with channel configuration 0 are not supported.");n.skipBits(1),n.skipBits(1),n.skipBits(1),n.skipBits(1);const d=n.readBits(13);n.skipBits(11);const l=n.readBits(2)+1;if(1!==l)throw new Error("ADTS frames with more than one AAC frame are not supported.");let u=null;return 1===a?e.filePos-=2:u=n.readBits(16),{objectType:s,samplingFrequencyIndex:o,channelConfiguration:c,frameLength:d,numberOfAacFrames:l,crcCheck:u,startPos:t}},Mn=1024;class jn extends Gt{constructor(e){super(e),this.metadataPromise=null,this.firstFrameHeader=null,this.loadedSamples=[],this.metadataTags=null,this.trackBackings=[],this.readingMutex=new I,this.lastSampleLoaded=!1,this.lastLoadedPos=0,this.nextTimestampInSamples=0,this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{for(;!this.firstFrameHeader&&!this.lastSampleLoaded;)await this.advanceReader();l(this.firstFrameHeader),this.trackBackings=[new Ln(this)]})()}async advanceReader(){if(0===this.lastLoadedPos)for(;;){let e=this.reader.requestSlice(this.lastLoadedPos,un);if(e instanceof Promise&&(e=await e),!e)return void(this.lastSampleLoaded=!0);const t=mn(e);if(!t)break;this.lastLoadedPos=e.filePos+t.size}let e=this.reader.requestSliceRange(this.lastLoadedPos,7,9);if(e instanceof Promise&&(e=await e),!e)return void(this.lastSampleLoaded=!0);const t=Dn(e);if(!t)return void(this.lastSampleLoaded=!0);if(null!==this.reader.fileSize&&t.startPos+t.frameLength>this.reader.fileSize)return void(this.lastSampleLoaded=!0);this.firstFrameHeader||(this.firstFrameHeader=t);const r=n[t.samplingFrequencyIndex];l(void 0!==r);const i=Mn/r,a={timestamp:this.nextTimestampInSamples/r,duration:i,dataStart:t.startPos,dataSize:t.frameLength};this.loadedSamples.push(a),this.nextTimestampInSamples+=Mn,this.lastLoadedPos=t.startPos+t.frameLength}async getMimeType(){return"audio/aac"}async getTrackBackings(){return await this.readMetadata(),this.trackBackings}async getMetadataTags(){const e=await this.readingMutex.acquire();try{if(await this.readMetadata(),this.metadataTags)return this.metadataTags;this.metadataTags={};let e=0;for(;;){let t=this.reader.requestSlice(e,un);if(t instanceof Promise&&(t=await t),!t)break;const r=mn(t);if(!r)break;let i=this.reader.requestSlice(t.filePos,r.size);
1if(i instanceof Promise&&(i=await i),!i)break;pn(i,r,this.metadataTags),e=t.filePos+r.size}return this.metadataTags}finally{e()}}}class Ln{constructor(e){this.demuxer=e}getType(){return"audio"}getId(){return 1}getNumber(){return 1}getTimeResolution(){return this.getSampleRate()/Mn}isRelativeToUnixEpoch(){return!1}getUnixTimeForTimestamp(){return null}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){return null}async getLiveRefreshInterval(){return null}getName(){return null}getLanguageCode(){return V}getCodec(){return"aac"}getInternalCodecId(){return l(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.objectType}getNumberOfChannels(){l(this.demuxer.firstFrameHeader);const e=a[this.demuxer.firstFrameHeader.channelConfiguration];return l(void 0!==e),e}getSampleRate(){l(this.demuxer.firstFrameHeader);const e=n[this.demuxer.firstFrameHeader.samplingFrequencyIndex];return l(void 0!==e),e}getDisposition(){return{...rr}}async getDecoderConfig(){return l(this.demuxer.firstFrameHeader),{codec:`mp4a.40.${this.demuxer.firstFrameHeader.objectType}`,numberOfChannels:this.getNumberOfChannels(),sampleRate:this.getSampleRate()}}async getPacketAtIndex(e,t){if(-1===e)return null;const r=this.demuxer.loadedSamples[e];if(!r)return null;let i;if(t.metadataOnly)i=Kt;else{let e=this.demuxer.reader.requestSlice(r.dataStart,r.dataSize);if(e instanceof Promise&&(e=await e),!e)return null;i=br(e,r.dataSize)}return new Yt(i,"key",r.timestamp,r.duration,e,r.dataSize)}getFirstPacket(e){return this.getPacketAtIndex(0,e)}async getNextPacket(e,t){const r=await this.demuxer.readingMutex.acquire();try{const r=R(this.demuxer.loadedSamples,e.timestamp,e=>e.timestamp);if(-1===r)throw new Error("Packet was not created from this track.");const i=r+1;for(;i>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(i,t)}finally{r()}}async getPacket(e,t){const r=await this.demuxer.readingMutex.acquire();try{for(;;){const r=O(this.demuxer.loadedSamples,e,e=>e.timestamp);if(-1===r&&this.demuxer.loadedSamples.length>0)return null;if(this.demuxer.lastSampleLoaded)return this.getPacketAtIndex(r,t);if(r>=0&&r+1<this.demuxer.loadedSamples.length)return this.getPacketAtIndex(r,t);await this.demuxer.advanceReader()}}finally{r()}}getKeyPacket(e,t){return this.getPacket(e,t)}getNextKeyPacket(e,t){return this.getNextPacket(e,t)}}const Un=e=>0===e?null:1===e?192:e>=2&&e<=5?144*2**e:6===e?"uncommon-u8":7===e?"uncommon-u16":e>=8&&e<=15?2**e:null,zn=e=>{let t=0;const r=new i(br(e,1));for(;1===r.readBits(1);)t++;if(0===t)return r.readBits(7);const n=[],a=t-1,s=new i(br(e,a)),o=8-t-1;for(let e=0;e<o;e++)n.unshift(r.readBits(1));for(let e=0;e<a;e++)for(let e=0;e<8;e++){const t=s.readBits(1);e<2||n.unshift(t)}return n.reduce((e,t,r)=>e|t<<r,0)},Wn=(e,t)=>"uncommon-u16"===t?kr(e)+1:"uncommon-u8"===t?wr(e)+1:"number"==typeof t?t:(L(t),void l(!1));class Vn extends Gt{constructor(e){super(e),this.loadedSamples=[],this.metadataPromise=null,this.trackBacking=null,this.metadataTags={},this.audioInfo=null,this.lastLoadedPos=null,this.blockingBit=null,this.readingMutex=new I,this.lastSampleLoaded=!1,this.reader=e._reader}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}async getTrackBackings(){return await this.readMetadata(),l(this.trackBacking),[this.trackBacking]}async getMimeType(){return"audio/flac"}async readMetadata(){return this.metadataPromise??=(async()=>{let e=0;for(;;){let t=this.reader.requestSlice(e,un);if(t instanceof Promise&&(t=await t),!t)return void(this.lastSampleLoaded=!0);const r=mn(t);if(!r)break;let i=this.reader.requestSlice(t.filePos,r.size);i instanceof Promise&&(i=await i),l(i),pn(i,r,this.metadataTags),e=t.filePos+r.size}for(e+=4;null===this.reader.fileSize||e<this.reader.fileSize;){let t=this.reader.requestSlice(e,4);if(t instanceof Promise&&(t=await t),e+=4,null===t)throw new Error(`Metadata block at position ${e} is too small! Corrupted file.`);l(t);const r=wr(t),n=Tr(t),a=!!(128&r);switch(127&r){case Mt.STREAMINFO:{let t=this.reader.requestSlice(e,n);if(t instanceof Promise&&(t=await t),l(t),null===t)throw new Error(`StreamInfo block at position ${e} is too small! Corrupted file.`);const r=br(t,34),a=new i(r),s=a.readBits(16),o=a.readBits(16),c=a.readBits(24),d=a.readBits(24),u=a.readBits(20),h=a.readBits(3)+1;a.readBits(5);const f=a.readBits(36);a.skipBits(128);const m=new Uint8Array(42);m.set(new Uint8Array([102,76,97,67]),0),m.set(new Uint8Array([128,0,0,34]),4),m.set(r,8),this.audioInfo={numberOfChannels:h,sampleRate:u,totalSamples:f,minimumBlockSize:s,maximumBlockSize:o,minimumFrameSize:c,maximumFrameSize:d,description:m},this.trackBacking=new qn(this);break}case Mt.VORBIS_COMMENT:{let t=this.reader.requestSlice(e,n);t instanceof Promise&&(t=await t),l(t),jt(br(t,n),this.metadataTags);break}case Mt.PICTURE:{let t=this.reader.requestSlice(e,n);t instanceof Promise&&(t=await t),l(t);
1const r=Cr(t),i=Cr(t),a=b.decode(br(t,i)),s=Cr(t),o=b.decode(br(t,s));t.skip(16);const c=Cr(t),d=br(t,c);this.metadataTags.images??=[],this.metadataTags.images.push({data:d,mimeType:a,kind:3===r?"coverFront":4===r?"coverBack":"unknown",description:o});break}}if(e+=n,a){this.lastLoadedPos=e;break}}if(!this.audioInfo)throw new Error("Missing STREAMINFO metadata block! Corrupted FLAC file.")})()}async readNextFlacFrame({startPos:e,isFirstPacket:t}){l(this.audioInfo);const r=this.audioInfo.maximumBlockSize*this.audioInfo.numberOfChannels*4+16+2,i=this.audioInfo.minimumFrameSize||10,n=(this.audioInfo.maximumFrameSize||r)+16,a=await this.reader.requestSliceRange(e,16,n);if(!a)return null;const s=this.readFlacFrameHeader({slice:a,isFirstPacket:t});if(!s)return null;for(a.filePos=e+i;;){if(a.filePos>a.end-6)return{num:s.num,blockSize:s.blockSize,sampleRate:s.sampleRate,size:a.end-e,isLastFrame:!0};if(255===wr(a)){const t=a.filePos;if(wr(a)!==(1===this.blockingBit?249:248)){a.filePos=t;continue}a.skip(-2);const r=a.filePos-e,i=this.readFlacFrameHeader({slice:a,isFirstPacket:!1});if(!i){a.filePos=t;continue}if(0===this.blockingBit){if(i.num-s.num!==1){a.filePos=t;continue}}else if(i.num-s.num!==s.blockSize){a.filePos=t;continue}return{num:s.num,blockSize:s.blockSize,sampleRate:s.sampleRate,size:r,isLastFrame:!1}}}}readFlacFrameHeader({slice:e,isFirstPacket:t}){const r=e.filePos,n=br(e,4),a=new i(n);if(32764!==a.readBits(15))return null;if(null===this.blockingBit){l(t);const e=a.readBits(1);this.blockingBit=e}else if(1===this.blockingBit){l(!t);if(1!==a.readBits(1))return null}else{if(0!==this.blockingBit)throw new Error("Invalid blocking bit");l(!t);if(0!==a.readBits(1))return null}const s=Un(a.readBits(4));if(!s)return null;l(this.audioInfo);const o=((e,t)=>{switch(e){case 0:return t;case 1:return 88200;case 2:return 176400;case 3:return 192e3;case 4:return 8e3;case 5:return 16e3;case 6:return 22050;case 7:return 24e3;case 8:return 32e3;case 9:return 44100;case 10:return 48e3;case 11:return 96e3;case 12:return"uncommon-u8";case 13:return"uncommon-u16";case 14:return"uncommon-u16-10";default:return null}})(a.readBits(4),this.audioInfo.sampleRate);if(!o)return null;a.readBits(4),a.readBits(3);if(0!==a.readBits(1))return null;const c=zn(e),d=Wn(e,s),u=((e,t)=>"uncommon-u16"===t?kr(e):"uncommon-u16-10"===t?10*kr(e):"uncommon-u8"===t?wr(e):"number"==typeof t?t:null)(e,o);if(null===u)return null;if(u!==this.audioInfo.sampleRate)return null;const h=e.filePos-r,f=wr(e);e.skip(-h),e.skip(-1);const m=(e=>{let t=0;for(const r of e){t^=r;for(let e=0;e<8;e++)128&t?t=t<<1^7:t<<=1,t&=255}return t})(br(e,h));return f!==m?null:{num:c,blockSize:d,sampleRate:u}}async advanceReader(){await this.readMetadata(),l(null!==this.lastLoadedPos),l(this.audioInfo);const e=this.lastLoadedPos,t=await this.readNextFlacFrame({startPos:e,isFirstPacket:0===this.loadedSamples.length});if(!t)return void(this.lastSampleLoaded=!0);const r=this.loadedSamples[this.loadedSamples.length-1],i={blockOffset:r?r.blockOffset+r.blockSize:0,blockSize:t.blockSize,byteOffset:e,byteSize:t.size};this.lastLoadedPos=this.lastLoadedPos+t.size,this.loadedSamples.push(i),t.isLastFrame&&(this.lastSampleLoaded=!0)}}class qn{constructor(e){this.demuxer=e}getType(){return"audio"}getId(){return 1}getNumber(){return 1}getCodec(){return"flac"}getInternalCodecId(){return null}getNumberOfChannels(){return l(this.demuxer.audioInfo),this.demuxer.audioInfo.numberOfChannels}getSampleRate(){return l(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}getName(){return null}getLanguageCode(){return V}getTimeResolution(){return l(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}isRelativeToUnixEpoch(){return!1}getUnixTimeForTimestamp(){return null}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){return l(this.demuxer.audioInfo),0===this.demuxer.audioInfo.totalSamples?null:this.demuxer.audioInfo.totalSamples/this.demuxer.audioInfo.sampleRate}
1async getLiveRefreshInterval(){return null}getDisposition(){return{...rr}}async getDecoderConfig(){return l(this.demuxer.audioInfo),{codec:"flac",numberOfChannels:this.demuxer.audioInfo.numberOfChannels,sampleRate:this.demuxer.audioInfo.sampleRate,description:this.demuxer.audioInfo.description}}async getPacket(e,t){if(l(this.demuxer.audioInfo),e<0)return null;const r=await this.demuxer.readingMutex.acquire();try{for(;;){const r=O(this.demuxer.loadedSamples,e,e=>e.blockOffset/this.demuxer.audioInfo.sampleRate);if(-1===r){await this.demuxer.advanceReader();continue}const i=this.demuxer.loadedSamples[r],n=i.blockOffset/this.demuxer.audioInfo.sampleRate;if(!(n+i.blockSize/this.demuxer.audioInfo.sampleRate<=e))return this.getPacketAtIndex(r,t);if(this.demuxer.lastSampleLoaded)return this.getPacketAtIndex(this.demuxer.loadedSamples.length-1,t);await this.demuxer.advanceReader()}}finally{r()}}async getNextPacket(e,t){const r=await this.demuxer.readingMutex.acquire();try{const r=e.sequenceNumber+1;if(this.demuxer.lastSampleLoaded&&r>=this.demuxer.loadedSamples.length)return null;for(;r>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(r,t)}finally{r()}}getKeyPacket(e,t){return this.getPacket(e,t)}getNextKeyPacket(e,t){return this.getNextPacket(e,t)}async getPacketAtIndex(e,t){const r=this.demuxer.loadedSamples[e];if(!r)return null;let i;if(t.metadataOnly)i=Kt;else{let e=this.demuxer.reader.requestSlice(r.byteOffset,r.byteSize);if(e instanceof Promise&&(e=await e),!e)return null;i=br(e,r.byteSize)}l(this.demuxer.audioInfo);const n=r.blockOffset/this.demuxer.audioInfo.sampleRate,a=r.blockSize/this.demuxer.audioInfo.sampleRate;return new Yt(i,"key",n,a,e,r.byteSize)}async getFirstPacket(e){for(;0===this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(0,e)}}const Hn=e=>{let t="video/MP2T";const r=[...new Set(e.filter(Boolean))];return r.length>0&&(t+=`; codecs="${r.join(", ")}"`),t},Gn="PES packet is missing PTS where it was expected. PES packets without PTS are not currently supported. If you think this file should be supported, please report it.",Kn=new Set;class Yn extends Gt{constructor(e){super(e),this.metadataPromise=null,this.elementaryStreams=[],this.trackBackingEntries=[],this.packetOffset=0,this.packetStride=-1,this.sectionEndPositions=[],this.seekChunkSize=5242880,this.minReferencePointByteDistance=-1,this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{let e=this.reader.requestSlice(0,205);e instanceof Promise&&(e=await e),l(e);const t=br(e,205);if(71===t[0]&&71===t[188])this.packetOffset=0,this.packetStride=188;else if(71===t[0]&&71===t[204])this.packetOffset=0,this.packetStride=204;else{if(71!==t[4]||71!==t[196])throw new Error("Unreachable.");this.packetOffset=4,this.packetStride=192}this.minReferencePointByteDistance=256*this.packetStride;let r=this.packetOffset,s=null,o=!1,c=!1;for(;;){const e=await this.readPacketHeader(r);if(!e)break;if(0===e.payloadUnitStartIndicator){r+=this.packetStride;continue}if(c&&!this.elementaryStreams.some(t=>t.pid===e.pid)){r+=this.packetStride;continue}const t=await this.readSection(r,!0,!c);if(!t)break;const u=3,h=32;let f=!1;if(!c&&0!==t.pid){if(!(0===t.payload[0]&&0===t.payload[1]&&1===t.payload[2])){const e=new i(t.payload),r=e.readAlignedByte();e.skipBits(8*r);f=2===e.readBits(8)}}if(0!==t.pid||o)if(t.pid!==s&&!f||c){const e=this.elementaryStreams.find(e=>e.pid===t.pid);e:if(e&&!e.initialized){const r=Qn(t,!0);if(!r)throw new Error(`Couldn't read first PES packet for Elementary Stream with PID ${e.pid}`);if(e.firstSection=t,e.canBeTrustedWithKeyPackets=1===t.randomAccessIndicator,this.input._initInput){const r=(await this.input._initInput._getDemuxer()).elementaryStreams.find(r=>r.pid===t.pid&&r.info.codec===e.info.codec);if(r){e.info=r.info,e.initialized=!0;break e}}const i=new ra(e,r);if("video"===e.info.type){for(;;){if(i.suppliedPacket=null,await i.markNextPacket(),"avc"===e.info.codec){if
1(!i.suppliedPacket)throw new Error("Invalid AVC video stream; could not extract AVCDecoderConfigurationRecord from any packet.");if(e.info.avcCodecInfo=ft(i.suppliedPacket.data),!e.info.avcCodecInfo)continue;const t=e.info.avcCodecInfo.sequenceParameterSets[0];l(t);const r=gt(t);e.info.width=r.displayWidth,e.info.height=r.displayHeight;const n=r.pixelAspectRatio.num,a=r.pixelAspectRatio.den;n>0&&a>0&&(n>a?(e.info.squarePixelWidth=Math.round(e.info.width*n/a),e.info.squarePixelHeight=e.info.height):(e.info.squarePixelWidth=e.info.width,e.info.squarePixelHeight=Math.round(e.info.height*a/n))),e.info.colorSpace={primaries:T[r.colourPrimaries],transfer:S[r.transferCharacteristics],matrix:P[r.matrixCoefficients],fullRange:!!r.fullRangeFlag},e.info.reorderSize=r.maxDecFrameBuffering;break}if("hevc"===e.info.codec){if(!i.suppliedPacket)throw new Error("Invalid HEVC video stream; could not extract HVCDecoderConfigurationRecord from first packet.");if(e.info.hevcCodecInfo=kt(i.suppliedPacket.data),!e.info.hevcCodecInfo)continue;const t=e.info.hevcCodecInfo.arrays.find(e=>e.nalUnitType===nt.SPS_NUT).nalUnits[0];l(t);const r=vt(t);e.info.width=r.displayWidth,e.info.height=r.displayHeight,r.pixelAspectRatio.num>r.pixelAspectRatio.den?(e.info.squarePixelWidth=Math.round(e.info.width*r.pixelAspectRatio.num/r.pixelAspectRatio.den),e.info.squarePixelHeight=e.info.height):(e.info.squarePixelWidth=e.info.width,e.info.squarePixelHeight=Math.round(e.info.height*r.pixelAspectRatio.den/r.pixelAspectRatio.num)),e.info.colorSpace={primaries:T[r.colourPrimaries],transfer:S[r.transferCharacteristics],matrix:P[r.matrixCoefficients],fullRange:!!r.fullRangeFlag},e.info.reorderSize=r.maxDecFrameBuffering;break}throw new Error("Unhandled.")}e.info.decoderConfig={codec:Le({width:e.info.width,height:e.info.height,codec:e.info.codec,codecDescription:null,colorSpace:e.info.colorSpace,avcType:1,avcCodecInfo:e.info.avcCodecInfo,hevcCodecInfo:e.info.hevcCodecInfo,vp9CodecInfo:null,av1CodecInfo:null}),codedWidth:e.info.width,codedHeight:e.info.height,colorSpace:e.info.colorSpace},e.info.width===e.info.squarePixelWidth&&e.info.height===e.info.squarePixelHeight||(e.info.decoderConfig.displayAspectWidth=e.info.squarePixelWidth,e.info.decoderConfig.displayAspectHeight=e.info.squarePixelHeight),e.initialized=!0}else{if(await i.markNextPacket(),!i.suppliedPacket)throw new Error(`Couldn't parse first media packet for Elementary Stream with PID ${e.pid}`);if("aac"===e.info.codec){const t=gr.tempFromBytes(i.suppliedPacket.data),r=Dn(t);if(!r)throw new Error("Invalid AAC audio stream; could not read ADTS frame header from first packet.");e.info.aacCodecInfo={isMpeg2:!1,objectType:r.objectType},e.info.numberOfChannels=a[r.channelConfiguration],e.info.sampleRate=n[r.samplingFrequencyIndex]}else if("mp3"===e.info.codec){const t=Cr(gr.tempFromBytes(i.suppliedPacket.data)),r=nn(t,i.suppliedPacket.data.byteLength);if(!r.header)throw new Error("Invalid MP3 audio stream; could not read frame header from first packet.");e.info.numberOfChannels=on(r.header.channel),e.info.sampleRate=r.header.sampleRate}else if("ac3"===e.info.codec){const t=Ut(i.suppliedPacket.data);if(!t)throw new Error("Invalid AC-3 audio stream; could not read sync frame from first packet.");if(3===t.fscod)throw new Error("Invalid AC-3 audio stream; reserved sample rate code found in first packet.");e.info.numberOfChannels=Lt[t.acmod]+t.lfeon,e.info.sampleRate=tt[t.fscod]}else{if("eac3"!==e.info.codec)throw new Error("Unhandled.");{const t=Vt(i.suppliedPacket.data);if(!t)throw new Error("Invalid E-AC-3 audio stream; could not read sync frame from first packet.");const r=qt(t);if(null===r)throw new Error("Invalid E-AC-3 audio stream; reserved sample rate code found in first packet.");e.info.numberOfChannels=Ht(t),e.info.sampleRate=r}}e.info.decoderConfig={codec:ze({codec:e.info.codec,codecDescription:null,aacCodecInfo:e.info.aacCodecInfo}),numberOfChannels:e.info.numberOfChannels,sampleRate:e.info.sampleRate},e.initialized=!0}}}else{const e=new i(t.payload),r=e.readAlignedByte();e.skipBits(8*r),e.skipBits(12);const n=e.readBits(12);e.skipBits(43);e.readBits(13);e.skipBits(6);const a=e.readBits(10);for(e.skipBits(8*a);8*(n+u)-e.pos>h;){const t=e.readBits(8);e.skipBits(3);const r=e.readBits(13);e.skipBits(6);const i=e.readBits(10),n=e.pos+8*i;let a=!1,s=!1;for(;e.pos<n;){const t=e.readBits(8),r=e.readBits(8);106===t?a=!0:122!==t&&204!==t||(s=!0),e.skipBits(8*r)}let o=null;switch(t){case 27:case 36:o={type:"video",codec:27===t?"avc":"hevc",decoderConfig:null,avcCodecInfo:null,hevcCodecInfo:null,colorSpace:{primaries:null,transfer:null,matrix:null,fullRange:null},width:-1,height:-1,squarePixelWidth:-1,squarePixelHeight:-1,reorderSize:-1};break;case 3:case 4:case 15:case 129:case 135:{let e;if(3===t||4===t)e="mp3";else if(15===t)e="aac";else if(129===t)e="ac3";else{if(135!==t)throw new Error("Unreachable.");e="eac3"}o={type:"audio",codec:e,decoderConfig:null,aacCodecInfo:null,numberOfChannels:-1,sampleRate:-1}}break;case 6:s?o={type:"audio",codec:"eac3",decoderConfig:null,aacCodecInfo:null,numberOfChannels:-1,sampleRate:-1}:a&&(o={type:"audio",codec:"ac3",decoderConfig:null,aacCodecInfo:null,numberOfChannels:-1,sampleRate:-1});break;default:Kn.has(t)||(d._warn(`Note: MPEG-TS streams with stream_type 0x${t.toString(16)} are not currently supported.`),Kn.add(t))}o&&this.elementaryStreams.push({demuxer:this,pid:r,streamType:t,initialized:!1,firstSection:null,canBeTrustedWithKeyPackets:!1,info:o,referencePesPackets:[]})}c=!0}else{const e=new i(t.payload),r=e.readAlignedByte();e.skipBits(8*r),e.skipBits(14);const n=e.readBits(10);for(e.skipBits(40);8*(n+u)-e.pos>h;){const t=e.readBits(16);e.skipBits(3);const r=e.readBits(13);if(0!==t){if(null!==s)throw new Error("Only files with a single program are supported.");s=r}}if(null===s)throw new Error("Program Association Table must link to a Program Map Table.");o=!0}if(c&&this.elementaryStreams.every(e=>e.initialized))break;r+=this.packetStride}if(!c){if(!o)throw new Error("No Program Association Table found in the file.");throw new Error("No Program Map Table found in the file.")}for(const e of this.elementaryStreams)"video"===e.info.type?this.trackBackingEntries.push(new Zn(e)):this.trackBackingEntries.push(new ea(e))})()}async getTrackBackings(){return await this.readMetadata(),this.trackBackingEntries}async getMetadataTags(){return{}}async getMimeType(){await this.readMetadata();const e=await Promise.all(this.trackBackingEntries.map(e=>e.getDecoderConfig().then(e=>e?.codec??null)));return Hn(e)}async readSection(e,t,r=!1){let i=e,n=e;const a=[];let s,o=0,c=null,d=!0,l=0;for(;;){const e=await this.readPacket(n);if(n+=this.packetStride,!e)break;if(c){if(e.pid!==c.pid){if(r)break;continue}if(1===e.payloadUnitStartIndicator)break}else{if(0===e.payloadUnitStartIndicator)break;c=e}const s=!!(2&e.adaptationFieldControl),u=!!(1&e.adaptationFieldControl);let h=0;if(s&&(h=1+e.body[0],e===c&&h>1&&(l=e.body[1]>>6&1)),u&&(0===h?(a.push(e.body),o+=e.body.byteLength):(a.push(e.body.subarray(h)),o+=e.body.byteLength-h)),i=n,!t&&o>=64){d=!1;break}if(-1!==R(this.sectionEndPositions,i,e=>e)){d=!1;break}}if(d){const e=O(this.sectionEndPositions,i,e=>e);this.sectionEndPositions.splice(e+1,0,i)}if(!c)return null;if(1===a.length)s=a[0];else{const e=a.reduce((e,t)=>
1e+t.length,0);s=new Uint8Array(e);let t=0;for(const e of a)s.set(e,t),t+=e.length}return{startPos:e,endPos:t?i:null,pid:c.pid,payload:s,randomAccessIndicator:l}}async readPacketHeader(e){let t=this.reader.requestSlice(e,4);if(t instanceof Promise&&(t=await t),!t)return null;if(71!==wr(t))throw new Error("Invalid TS packet sync byte. Likely an internal bug, please report this file.");const r=kr(t),i=r>>14&1,n=8191&r,a=wr(t);return{payloadUnitStartIndicator:i,pid:n,adaptationFieldControl:a>>4&3}}async readPacket(e){let t=this.reader.requestSlice(e,188);if(t instanceof Promise&&(t=await t),!t)return null;const r=br(t,188);if(71!==r[0])throw new Error("Invalid TS packet sync byte. Likely an internal bug, please report this file.");const i=(r[1]<<8)+r[2],n=i>>14&1,a=8191&i,s=r[3];return{payloadUnitStartIndicator:n,pid:a,adaptationFieldControl:s>>4&3,body:r.subarray(4)}}}const Xn=(e,t)=>{if(e.payload.byteLength<3)return null;const r=new i(e.payload);if(1!==r.readBits(24))return null;const n=r.readBits(8);if(r.skipBits(16),188===n||190===n||191===n||240===n||241===n||255===n||242===n||248===n)return null;r.skipBits(8);const a=r.readBits(2);r.skipBits(14);let s=null;if(2===a||3===a)s=0,r.skipBits(4),s+=r.readBits(3)*(1<<30),r.skipBits(1),s+=32768*r.readBits(15),r.skipBits(1),s+=r.readBits(15);else if(t)throw new Error(Gn);return{sectionStartPos:e.startPos,sectionEndPos:e.endPos,pts:s,randomAccessIndicator:e.randomAccessIndicator}},Qn=(e,t)=>{l(null!==e.endPos);const r=Xn(e,t);if(!r)return null;const n=new i(e.payload);n.skipBits(32);const a=n.readBits(16);n.skipBits(16);const s=n.readBits(8),o=n.pos+8*s;n.pos=o;const c=o/8;l(Number.isInteger(c));const d=e.payload.subarray(c,a>0?6+a:e.payload.byteLength);return{...r,data:d}};class Jn{constructor(e){this.elementaryStream=e,this.packetBuffers=new WeakMap,this.packetSectionStarts=new WeakMap}getId(){return this.elementaryStream.pid}getNumber(){const e=this.elementaryStream.demuxer,t=this.elementaryStream.info.type;let r=0;for(const i of e.trackBackingEntries)if(i.getType()===t&&r++,l(i instanceof Jn),i.elementaryStream===this.elementaryStream)break;return r}getCodec(){throw new Error("Not implemented on base class.")}getInternalCodecId(){return this.elementaryStream.streamType}getName(){return null}getLanguageCode(){return V}getDisposition(){return{...rr,primary:!1}}getTimeResolution(){return 9e4}isRelativeToUnixEpoch(){return!1}getUnixTimeForTimestamp(){return null}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){return null}
1async getLiveRefreshInterval(){return null}createEncodedPacket(e,t,r){let i;return i=this.allPacketsAreKeyPackets()||1===e.randomAccessIndicator?"key":"delta",new Yt(r.metadataOnly?Kt:e.data,i,e.pts/9e4,Math.max(t/9e4,0),e.sequenceNumber,e.data.byteLength)}async getFirstPacket(e){const t=this.elementaryStream.firstSection;l(t);const r=Qn(t,!0);l(r);const i=new ra(this.elementaryStream,r),n=new ia(this,i),a=await n.readNext();if(!a)return null;const s=this.createEncodedPacket(a.packet,a.duration,e);return this.packetBuffers.set(s,n),this.packetSectionStarts.set(s,a.packet.sectionStartPos),s}async getNextPacket(e,t){let r=this.packetBuffers.get(e);if(r){const i=await r.readNext();if(!i)return null;this.packetBuffers.delete(e);const n=this.createEncodedPacket(i.packet,i.duration,t);return this.packetBuffers.set(n,r),this.packetSectionStarts.set(n,i.packet.sectionStartPos),n}const i=this.packetSectionStarts.get(e);if(void 0===i)throw new Error("Packet was not created from this track.");const n=this.elementaryStream.demuxer,a=await n.readSection(i,!0);l(a);const s=Qn(a,!0);l(s);const o=new ra(this.elementaryStream,s);r=new ia(this,o);const c=e.sequenceNumber;for(;;){const e=await r.readNext();if(!e)return null;if(e.packet.sequenceNumber>c){const i=this.createEncodedPacket(e.packet,e.duration,t);return this.packetBuffers.set(i,r),this.packetSectionStarts.set(i,e.packet.sectionStartPos),i}}}async getNextKeyPacket(e,t){let r=e;for(;;){if(r=await this.getNextPacket(r,t),!r)return null;if("key"===r.type)return r}}getPacket(e,t){return this.doPacketLookup(e,!1,t)}getKeyPacket(e,t){return this.doPacketLookup(e,!0,t)}async doPacketLookup(e,t,r){const i=q(9e4*e),n=this.elementaryStream.demuxer,{reader:a,seekChunkSize:s}=n,o=this.elementaryStream.pid,c=async(e,t,r)=>{let i=e;for(;i<t;){const e=await n.readPacketHeader(i);if(!e)return null;if(e.pid===o&&1===e.payloadUnitStartIndicator){const e=await n.readSection(i,r);if(!e)return null;const t=Xn(e,!1);if(t&&null!==t.pts)return{pesPacketHeader:t,section:e}}i+=n.packetStride}return null},d=this.elementaryStream.firstSection;l(d);const u=Xn(d,!0);if(l(u),i<u.pts)return null;let f;const m=this.elementaryStream.referencePesPackets,p=O(m,i,e=>e.pts),g=-1!==p?m[p]:null;if(g&&i-g.pts<45e3)f=g.sectionStartPos;else{let e=0;if(null!==a.fileSize){const t=Math.ceil(a.fileSize/s);if(t>1){let r=0,a=t-1;for(e=r;r<=a;){const t=Math.floor((r+a)/2),o=K(t*s,n.packetStride)+u.sectionStartPos,d=o+s,l=await c(o,d,!1);l?l.pesPacketHeader.pts<=i?(e=t,r=t+1):a=t-1:a=t-1}}}f=K(e*s,n.packetStride)+u.sectionStartPos}const y=await c(f,a.fileSize??1/0,!1);let b=y?.pesPacketHeader??null;b||(b=u);const w=this.getReorderSize(),v=async(e,t)=>{const a=await n.readSection(e,!0);l(a);const s=Qn(a,!0);l(s);const o=new ra(this.elementaryStream,s),c=new ia(this,o);for(;;){if((h(c.presentationOrderPackets)?.pts??-1/0)>=i)break;if(!await c.readNextPacket())break}const d=j(c.presentationOrderPackets,t);if(-1===d)return null;const u=c.presentationOrderPackets[d],f=0===d?0:u.pts-c.presentationOrderPackets[d-1].pts;for(;c.decodeOrderPackets[0]!==u;)c.decodeOrderPackets.shift();c.lastDuration=f;const m=await c.readNext();l(m);const p=this.createEncodedPacket(m.packet,m.duration,r);return this.packetBuffers.set(p,c),this.packetSectionStarts.set(p,m.packet.sectionStartPos),p};if(!t||this.allPacketsAreKeyPackets()){e:for(;;){let e=b.sectionStartPos+n.packetStride;for(;;){const t=await n.readPacketHeader(e);if(!t)break e;if(t.pid===o&&1===t.payloadUnitStartIndicator){const t=await n.readSection(e,!1);if(t){const e=Xn(t,!1);if(e&&null!==e.pts){if(e.pts>i)break e;b=e,ta(this.elementaryStream,b);break}}}e+=n.packetStride}}e:for(let e=0;e<w+1;e++){let e=b.sectionStartPos-n.packetStride;for(;e>=n.packetOffset;){const t=await n.readPacketHeader(e);if(!t)break e;if(t.pid===o&&1===t.payloadUnitStartIndicator){const t=await n.readSection(e,!1);if(t){const e=Xn(t,!1);if(e&&null!==e.pts){b=e;break}}}e-=n.packetStride}}return v(b.sectionStartPos,e=>e.pts<=i)}{let e=f,t=null;const r=!this.elementaryStream.canBeTrustedWithKeyPackets;for(;;){let h=null;const f=e<=u.sectionStartPos;let m,p=null;if(f)m=u,p=d;else{const t=await c(e,a.fileSize??1/0,r);m=t?.pesPacketHeader??null,p=t?.section??null}let g=!1,y=0;e:for(;m&&!(null!==t&&m.sectionStartPos>=t);){if(m.pts<=i){let e;if(this.elementaryStream.canBeTrustedWithKeyPackets)e=1===m.randomAccessIndicator;else{l(p);const t=Qn(p,!0);l(t);const r=new ra(this.elementaryStream,t);await r.markNextPacket(),e=1===r.suppliedPacket?.randomAccessIndicator}e&&(h=m)}if(m.pts>i&&(g=!0),g&&(y++,y>w))break;let e=m.sectionStartPos+n.packetStride;for(;;){const t=await n.readPacketHeader(e);if(!t)break e;if(t.pid===o&&1===t.payloadUnitStartIndicator){const t=await n.readSection(e,r);if(t){const e=Xn(t,!1);if(e&&null!==e.pts){m=e,p=t,ta(this.elementaryStream,m);break}}}e+=n.packetStride}}if(h){let e=h;if(0===y)e:for(let t=0;t<w;t++){let t=e.sectionStartPos-n.packetStride;for(;t>=n.packetOffset;){const i=await n.readPacketHeader(t);if(!i)break e;if(i.pid===o&&1===i.payloadUnitStartIndicator){const i=await n.readSection(t,r);if(i){const t=Xn(i,!1);if(t&&null!==t.pts){e=t;break}}}t-=n.packetStride}}const t=await v(e.sectionStartPos,e=>e.pts<=i&&1===e.randomAccessIndicator);return l(t),t}if(f)return null;t=e,e=Math.max(K(e-u.sectionStartPos-s,n.packetStride)+u.sectionStartPos,u.sectionStartPos)}}}}class Zn extends Jn{getType(){return"video"}getCodec(){return this.elementaryStream.info.codec}getCodedWidth(){return this.elementaryStream.info.width}getCodedHeight(){return this.elementaryStream.info.height}getSquarePixelWidth(){return this.elementaryStream.info.squarePixelWidth}getSquarePixelHeight(){return this.elementaryStream.info.squarePixelHeight}getRotation(){return 0}async getColorSpace(){return this.elementaryStream.info.colorSpace}
1async canBeTransparent(){return!1}async getDecoderConfig(){return l(this.elementaryStream.info.decoderConfig),this.elementaryStream.info.decoderConfig}allPacketsAreKeyPackets(){return!1}getReorderSize(){return this.elementaryStream.info.reorderSize}}class ea extends Jn{getType(){return"audio"}getCodec(){return this.elementaryStream.info.codec}getNumberOfChannels(){return this.elementaryStream.info.numberOfChannels}getSampleRate(){return this.elementaryStream.info.sampleRate}async getDecoderConfig(){return l(this.elementaryStream.info.decoderConfig),this.elementaryStream.info.decoderConfig}allPacketsAreKeyPackets(){return!0}getReorderSize(){return 0}}const ta=(e,t)=>{const r=e.referencePesPackets,i=O(r,t.sectionStartPos,e=>e.sectionStartPos);if(i>=0){const n=r[i];if(t.pts<=n.pts)return!1;const a=e.demuxer.minReferencePointByteDistance;if(t.sectionStartPos-n.sectionStartPos<a)return!1;if(i<r.length-1){const e=r[i+1];if(e.pts<t.pts)return!1;if(e.sectionStartPos-t.sectionStartPos<a)return!1}}return r.splice(i+1,0,t),!0};class ra{constructor(e,t){this.currentPos=0,this.pesPackets=[],this.currentPesPacketIndex=0,this.currentPesPacketPos=0,this.endPos=0,this.lastSuppliedPesPacket=null,this.nextPts=null,this.suppliedPacket=null,this.elementaryStream=e,this.pid=e.pid,this.demuxer=e.demuxer,this.startingPesPacket=t}ensureBuffered(e){const t=this.endPos-this.currentPos;return t>=e?e:this.bufferData(e-t).then(()=>Math.min(this.endPos-this.currentPos,e))}getCurrentPesPacket(){const e=this.pesPackets[this.currentPesPacketIndex];return l(e),e}async bufferData(e){const t=this.endPos+e;for(;this.endPos<t;){let e;if(0===this.pesPackets.length)e=this.startingPesPacket;else{let t=h(this.pesPackets).sectionEndPos;for(l(null!==t);;){const r=await this.demuxer.readPacketHeader(t);if(!r)return;if(r.pid===this.pid){const r=await this.demuxer.readSection(t,!0);if(!r)return;const i=Qn(r,!1);if(i){e=i;break}}t+=this.demuxer.packetStride}}this.pesPackets.push(e),this.endPos+=e.data.byteLength}}readBytes(e){const t=this.getCurrentPesPacket(),r=this.currentPos-this.currentPesPacketPos,i=r+e;if(this.currentPos+=e,i<=t.data.byteLength)return t.data.subarray(r,i);const n=new Uint8Array(e);n.set(t.data.subarray(r));let a=t.data.byteLength-r;for(;;){this.advanceCurrentPacket();const t=this.getCurrentPesPacket(),r=e-a;if(r<=t.data.byteLength){n.set(t.data.subarray(0,r),a);break}n.set(t.data,a),a+=t.data.byteLength}return n}readU8(){let e=this.getCurrentPesPacket();const t=this.currentPos-this.currentPesPacketPos;return this.currentPos++,t<e.data.byteLength?e.data[t]:(this.advanceCurrentPacket(),e=this.getCurrentPesPacket(),e.data[0])}seekTo(e){if(e!==this.currentPos){if(e<this.currentPos)for(;e<this.currentPesPacketPos;){this.currentPesPacketIndex--;const e=this.getCurrentPesPacket();this.currentPesPacketPos-=e.data.byteLength}else for(;;){const t=this.getCurrentPesPacket();if(e<this.currentPesPacketPos+t.data.byteLength)break;this.currentPesPacketPos+=t.data.byteLength,this.currentPesPacketIndex++}this.currentPos=e}}skip(e){this.seekTo(this.currentPos+e)}advanceCurrentPacket(){this.currentPesPacketPos+=this.getCurrentPesPacket().data.byteLength,this.currentPesPacketIndex++}async markNextPacket(){l(!this.suppliedPacket);const e=this.elementaryStream;if("video"===e.info.type){const t=e.info.codec,r=1024;if("avc"!==t&&"hevc"!==t)throw new Error("Unhandled.");const n="avc"===t?1:2;let a=null,s=!1,o=0;for(;;){let e=this.ensureBuffered(r);if(e instanceof Promise&&(e=await e),0===e)break;const c=this.currentPos,d=this.readBytes(e),l=d.byteLength;let u=0;for(;u<l;){const e=d.indexOf(0,u);if(-1===e||e>=l)break;u=e;const r=c+u;if(u+3>=l){this.seekTo(r);break}const h=d[u+1],f=d[u+2],p=d[u+3];let g=0;if(0===h&&0===f&&1===p?g=4:0===h&&1===f&&(g=3),0===g){u++;continue}const y=r;a??=y;const b=u+g,w=b+n,v=6;if(w+("avc"===t?v:1)>l){this.seekTo(r);break}const k=d[b];let T,x,S;if("avc"===t)T=ct(k),x=T===it.NON_IDR_SLICE||T===it.SLICE_DPA||T===it.IDR,S=T===it.SEI||T===it.SPS||T===it.PPS||T===it.AUD;else{T=wt(k);if(((1&k)<<5|d[b+1]>>3)>0){u+=g;continue}x=T<=nt.RASL_R||T>=nt.BLA_W_LP&&T<=21,S=T>=nt.VPS_NUT&&T<=37||T===nt.PREFIX_SEI_NUT||T>=41&&T<=44||T>=48&&T<=55}let C=!1;if(x){let e;if("avc"===t){const t=d.subarray(w,w+v),r=m(new i(t));e=!s||r<=o,o=r}else e=d[w]>>7==1;e&&(s?C=!0:s=!0)}else S&&s&&(C=!0);if(C){const e=y-a;return this.seekTo(a),this.supplyPacket(e,0)}u+=g}if(e<r)break}if(null!==a&&this.endPos>a){const e=this.endPos-a;return this.seekTo(a),this.supplyPacket(e,0)}}else{const t=e.info.codec,r=128;for(;;){let i=this.ensureBuffered(r);i instanceof Promise&&(i=await i);const n=this.currentPos;for(;this.currentPos-n<i;){const r=this.readU8();if("aac"===t){if(255!==r)continue;this.skip(-1);const t=this.currentPos;let i=this.ensureBuffered(9);if(i instanceof Promise&&(i=await i),i<9)return;const n=this.readBytes(9),a=Dn(gr.tempFromBytes(n));if(a){this.seekTo(t);let r=this.ensureBuffered(a.frameLength);return r instanceof Promise&&(r=await r),this.supplyPacket(r,Math.round(9216e4/e.info.sampleRate))}this.seekTo(t+1)}else{if("mp3"!==t){if("ac3"===t){if(11!==r)continue;this.skip(-1);const t=this.currentPos;let i=this.ensureBuffered(5);if(i instanceof Promise&&(i=await i),i<5)return;const n=this.readBytes(5);if(11!==n[0]||119!==n[1]){this.seekTo(t+1);continue}const a=n[4]>>6,s=63&n[4];if(3===a||s>37){this.seekTo(t+1);continue}const o=zt[3*s+a];l(void 0!==o),this.seekTo(t),i=this.ensureBuffered(o),i instanceof Promise&&(i=await i);const c=Math.round(13824e4/e.info.sampleRate);return this.supplyPacket(i,c)}if("eac3"===t){if(11!==r)continue;this.skip(-1);const t=this.currentPos;let i=this.ensureBuffered(5);if(i instanceof Promise&&(i=await i),i<5)return;const n=this.readBytes(5);if(11!==n[0]||119!==n[1]){this.seekTo(t+1);continue}const a=2*(((7&n[2])<<8|n[3])+1),s=3===n[4]>>6?3:n[4]>>4&3,o=Wt[s];this.seekTo(t),i=this.ensureBuffered(a),i instanceof Promise&&(i=await i);const c=256*o,d=Math.round(9e4*c/e.info.sampleRate);return this.supplyPacket(i,d)}throw new Error("Unhandled.")}{if(255!==r)continue;this.skip(-1);const t=this.currentPos;let i=this.ensureBuffered(4);if(i instanceof Promise&&(i=await i),i<4)return;const n=this.readBytes(4),a=y(n).getUint32(0),s=nn(a,null);if(s.header){this.seekTo(t);let r=this.ensureBuffered(s.header.totalSize);r instanceof Promise&&(r=await r);const i=9e4*s.header.audioSamplesInFrame/e.info.sampleRate;return this.supplyPacket(r,Math.round(i))}this.seekTo(t+1)}}}if(i<r)break}}}supplyPacket(e,t){const r=this.getCurrentPesPacket();let i;if(this.lastSuppliedPesPacket===r)l(null!==this.nextPts),i=this.nextPts;else{if(null===r.pts)throw new Error(Gn);i=r.pts,ta(this.elementaryStream,r)}this.lastSuppliedPesPacket=r,this.nextPts=i+t;const n=r.sectionStartPos,a=n+(this.currentPos-this.currentPesPacketPos),s=this.readBytes(e);let o=r.randomAccessIndicator;if(0===o&&!this.elementaryStream.canBeTrustedWithKeyPackets)if("audio"===this.elementaryStream.info.type)o=1;else if(this.elementaryStream.info.decoderConfig){const e="key"===Dt(this.elementaryStream.info.codec,this.elementaryStream.info.decoderConfig,s);o=Number(e)}this.suppliedPacket={pts:i,data:s,sequenceNumber:a,sectionStartPos:n,randomAccessIndicator:o},this.pesPackets.splice(0,this.currentPesPacketIndex),this.currentPesPacketIndex=0}}class ia{constructor(e,t){this.decodeOrderPackets=[],this.reorderBuffer=[],this.presentationOrderPackets=[],this.reachedEnd=!1,this.lastDuration=0,this.backing=e,this.context=t,this.reorderSize=e.getReorderSize(),l(this.reorderSize>=0)}
1async readNext(){if(0===this.decodeOrderPackets.length){if(!await this.readNextPacket())return null}await this.ensureCurrentPacketHasNext();const e=this.decodeOrderPackets[0],t=this.presentationOrderPackets.indexOf(e);let r;if(l(-1!==t),t===this.presentationOrderPackets.length-1)r=this.lastDuration;else{r=this.presentationOrderPackets[t+1].pts-e.pts,this.lastDuration=r}for(this.decodeOrderPackets.shift();this.presentationOrderPackets.length>0;){const e=this.presentationOrderPackets[0];if(this.decodeOrderPackets.includes(e))break;this.presentationOrderPackets.shift()}return{packet:e,duration:r}}async readNextPacket(){if(this.reachedEnd)return!1;let e;return this.context.suppliedPacket||await this.context.markNextPacket(),e=this.context.suppliedPacket,this.context.suppliedPacket=null,e?(this.decodeOrderPackets.push(e),this.processPacketThroughReorderBuffer(e),!0):(this.reachedEnd=!0,this.flushReorderBuffer(),!1)}async ensureCurrentPacketHasNext(){const e=this.decodeOrderPackets[0];for(l(e);;){const t=this.presentationOrderPackets.indexOf(e);if(-1!==t&&t<=this.presentationOrderPackets.length-2)break;if(!await this.readNextPacket())break}}processPacketThroughReorderBuffer(e){if(this.reorderBuffer.push(e),this.reorderBuffer.length>this.reorderSize){let e=0;for(let t=1;t<this.reorderBuffer.length;t++)this.reorderBuffer[t].pts<this.reorderBuffer[e].pts&&(e=t);const t=this.reorderBuffer[e];this.presentationOrderPackets.push(t),this.reorderBuffer.splice(e,1)}}flushReorderBuffer(){this.reorderBuffer.sort((e,t)=>e.pts-t.pts),this.presentationOrderPackets.push(...this.reorderBuffer),this.reorderBuffer.length=0}}const na="application/vnd.apple.mpegurl",aa="#EXT-X-STREAM-INF:",sa="#EXT-X-I-FRAME-STREAM-INF:",oa="#EXT-X-MEDIA:",ca="#EXTINF:",da="#EXT-X-MAP:",la="#EXT-X-KEY:",ua="#EXT-X-MEDIA-SEQUENCE:",ha="#EXT-X-BYTERANGE:",fa="#EXT-X-PROGRAM-DATE-TIME:",ma="#EXT-X-TARGETDURATION:",pa="#EXT-X-PLAYLIST-TYPE:",ga=e=>0===e.length||e.startsWith("#")&&!e.startsWith("#EXT");class ya{constructor(e){this._attributes={};let t="",r="",i=!1,n=!1;for(let a=0;a<e.length;a++){const s=e[a];'"'===s?n=!n:"="!==s||i||n?","!==s||n?i?r+=s:t+=s:(t&&(this._attributes[t.trim().toLowerCase()]=r),t="",r="",i=!1):i=!0}t&&(this._attributes[t.trim().toLowerCase()]=r)}get(e){return this._attributes[e.toLowerCase()]??null}getAsNumber(e){const t=this.get(e);if(null===t)return null;const r=Number(t);return Number.isFinite(r)?r:null}merge(e){Object.assign(this._attributes,e._attributes)}}class ba{constructor(e,t,r){this.nextInputCacheAge=0,this.inputCache=[],this.trackBackingsPromise=null,this.firstSegment=null,this.firstSegmentFirstTimestamps=new WeakMap,this.firstTimestampCache=new WeakMap,this.input=e,this.path=t,this.trackDeclarations=r}
1async getDurationFromMetadata(e){const t=await this.getSegmentAt(1/0,{skipLiveWait:e.skipLiveWait});return t?t.timestamp+t.duration:null}async getUnixTimeForTimestamp(e){let t=await this.getSegmentAt(e,{});if(t??=await this.getFirstSegment({}),!t||null===t.unixEpochTimestamp)return null;const r=e-t.timestamp;return t.unixEpochTimestamp+r}async getTrackBackings(){return this.trackBackingsPromise??=(async()=>{const e=[];if(this.trackDeclarations){for(const t of this.trackDeclarations)if("video"===t.type){const r=ye(e,e=>"video"===e.getType())+1;e.push(new va(this,t,r))}else if("audio"===t.type){const r=ye(e,e=>"audio"===e.getType())+1;e.push(new ka(this,t,r))}}else{if(this.firstSegment=await this.getFirstSegment({}),!this.firstSegment)return[];const t=this.getInputForSegment(this.firstSegment),r=await t.getTracks();for(const t of r)if("video"===t.type){const t=ye(e,e=>"video"===e.getType())+1;e.push(new va(this,{id:e.length+1,type:"video"},t))}else if("audio"===t.type){const t=ye(e,e=>"audio"===e.getType())+1;e.push(new ka(this,{id:e.length+1,type:"audio"},t))}}return e})()}async getFirstTimestampForInput(e){const t=this.firstTimestampCache.get(e);if(void 0!==t)return t;const r=await e.getFirstTimestamp();return this.firstTimestampCache.set(e,r),r}async getMediaOffset(e,t){const r=e.firstSegment??e;let i;if(this.firstSegmentFirstTimestamps.has(r))i=this.firstSegmentFirstTimestamps.get(r);else{const e=this.getInputForSegment(r);i=await this.getFirstTimestampForInput(e),this.firstSegmentFirstTimestamps.set(r,i)}if(r===e)return r.timestamp-i;const n=await this.getFirstTimestampForInput(t),a=e.timestamp-r.timestamp,s=n-i-a;return Math.abs(s)<=Math.min(.25,a)?r.timestamp-i:e.timestamp-n}dispose(){for(const e of this.inputCache)e.input.dispose();this.inputCache.length=0}}class wa{constructor(e,t,r){this.packetInfos=new WeakMap,this.hydrationPromise=null,this.firstInputTrack=null,this.segmentedInput=e,this.decl=t,this.number=r}hydrate(){return this.hydrationPromise??=(async()=>{if(this.segmentedInput.firstSegment??=await this.segmentedInput.getFirstSegment({}),!this.segmentedInput.firstSegment)throw new Error("Missing first segment, can't retrieve track.");const e=this.segmentedInput.getInputForSegment(this.segmentedInput.firstSegment),t=(await e.getTracks()).find(e=>e.type===this.decl.type&&e.number===this.number);if(!t)throw new Error("No matching track found in underlying media data.");this.firstInputTrack=t})()}getId(){return this.decl.id}getType(){return this.decl.type}getNumber(){return this.number}delegate(e){return this.firstInputTrack?e():this.hydrate().then(e)}async getDecoderConfig(){return this.delegate(()=>this.firstInputTrack._backing.getDecoderConfig())}getHasOnlyKeyPackets(){return this.delegate(()=>this.firstInputTrack._backing.getHasOnlyKeyPackets?.()??null)}getPairingMask(){return 1n}getCodec(){return this.delegate(()=>this.firstInputTrack._backing.getCodec())}getInternalCodecId(){return this.delegate(()=>this.firstInputTrack._backing.getInternalCodecId())}getDisposition(){return this.delegate(()=>this.firstInputTrack._backing.getDisposition())}getLanguageCode(){return this.delegate(()=>this.firstInputTrack._backing.getLanguageCode())}getName(){return this.delegate(()=>this.firstInputTrack._backing.getName())}getTimeResolution(){return this.delegate(()=>this.firstInputTrack._backing.getTimeResolution())}async isRelativeToUnixEpoch(){return await this.hydrate(),l(this.segmentedInput.firstSegment),this.segmentedInput.firstSegment.unixEpochTimestamp===this.segmentedInput.firstSegment.timestamp}getUnixTimeForTimestamp(e){return this.segmentedInput.getUnixTimeForTimestamp(e)}getBitrate(){return this.delegate(()=>this.firstInputTrack._backing.getBitrate())}getAverageBitrate(){return this.delegate(()=>this.firstInputTrack._backing.getAverageBitrate())}getDurationFromMetadata(e){return this.segmentedInput.getDurationFromMetadata(e)}
1getLiveRefreshInterval(){return this.segmentedInput.getLiveRefreshInterval()}async createAdjustedPacket(e,t,r){l(e.sequenceNumber>=0),l(this.segmentedInput.firstSegment);const i=await this.segmentedInput.getMediaOffset(t,r.input),n=t.timestamp-this.segmentedInput.firstSegment.timestamp,a=e.clone({timestamp:G(e.timestamp+i,await r.getTimeResolution()),sequenceNumber:Math.floor(1e8*n)+e.sequenceNumber});return this.packetInfos.set(a,{segment:t,track:r,sourcePacket:e}),a}async getFirstPacket(e){await this.hydrate(),l(this.segmentedInput.firstSegment),l(this.firstInputTrack);const t=await this.firstInputTrack._backing.getFirstPacket(e);return t?this.createAdjustedPacket(t,this.segmentedInput.firstSegment,this.firstInputTrack):null}getNextPacket(e,t){return this._getNextInternal(e,t,!1)}getNextKeyPacket(e,t){return this._getNextInternal(e,t,!0)}async _getNextInternal(e,t,r){const i=this.packetInfos.get(e);if(!i)throw new Error("Packet was not created from this track.");const n=r?await i.track._backing.getNextKeyPacket(i.sourcePacket,t):await i.track._backing.getNextPacket(i.sourcePacket,t);if(n)return this.createAdjustedPacket(n,i.segment,i.track);let a=i.segment;for(;;){const e=await this.segmentedInput.getNextSegment(a,{skipLiveWait:t.skipLiveWait});if(!e)return null;const r=this.segmentedInput.getInputForSegment(e),n=(await r.getTracks()).find(e=>e.type===i.track.type&&e.number===i.track.number);if(!n){a=e;continue}const s=await n._backing.getFirstPacket(t);return s?this.createAdjustedPacket(s,e,n):null}}getPacket(e,t){return this._getPacketInternal(e,t,!1)}getKeyPacket(e,t){return this._getPacketInternal(e,t,!0)}async _getPacketInternal(e,t,r){let i=await this.segmentedInput.getSegmentAt(e,{skipLiveWait:t.skipLiveWait});if(!i)return null;for(await this.hydrate();i;){const n=this.segmentedInput.getInputForSegment(i),a=(await n.getTracks()).find(e=>e.type===this.firstInputTrack.type&&e.number===this.firstInputTrack.number);if(!a){i=await this.segmentedInput.getPreviousSegment(i,{skipLiveWait:t.skipLiveWait});continue}const s=e-await this.segmentedInput.getMediaOffset(i,n),o=r?await a._backing.getKeyPacket(s,t):await a._backing.getPacket(s,t);if(o)return this.createAdjustedPacket(o,i,a);i=await this.segmentedInput.getPreviousSegment(i,{skipLiveWait:t.skipLiveWait})}return null}}class va extends wa{getType(){return"video"}getCodec(){return this.delegate(()=>this.firstInputTrack._backing.getCodec())}getCodedWidth(){return this.delegate(()=>this.firstInputTrack._backing.getCodedWidth())}getCodedHeight(){return this.delegate(()=>this.firstInputTrack._backing.getCodedHeight())}getSquarePixelWidth(){return this.delegate(()=>this.firstInputTrack._backing.getSquarePixelWidth())}getSquarePixelHeight(){return this.delegate(()=>this.firstInputTrack._backing.getSquarePixelHeight())}getRotation(){return this.delegate(()=>this.firstInputTrack._backing.getRotation())}async getColorSpace(){return this.delegate(()=>this.firstInputTrack._backing.getColorSpace())}
1async canBeTransparent(){return this.delegate(()=>this.firstInputTrack._backing.canBeTransparent())}async getDecoderConfig(){return this.delegate(()=>this.firstInputTrack._backing.getDecoderConfig())}}class ka extends wa{getType(){return"audio"}getCodec(){return this.delegate(()=>this.firstInputTrack._backing.getCodec())}getNumberOfChannels(){return this.delegate(()=>this.firstInputTrack._backing.getNumberOfChannels())}getSampleRate(){return this.delegate(()=>this.firstInputTrack._backing.getSampleRate())}async getDecoderConfig(){return this.delegate(()=>this.firstInputTrack._backing.getDecoderConfig())}}var Ta=function(e,t,r){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var i,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=t[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=t[Symbol.dispose],r&&(n=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");n&&(i=function(){try{n.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:i,async:r})}else r&&e.stack.push({async:!0});return t},xa=function(e){return function(t){function r(r){t.error=t.hasError?new e(r,t.error,"An error was suppressed during disposal."):r,t.hasError=!0}var i,n=0;return function e(){for(;i=t.stack.pop();)try{if(!i.async&&1===n)return n=0,t.stack.push(i),Promise.resolve().then(e);if(i.dispose){var a=i.dispose.call(i.value);if(i.async)return n|=2,Promise.resolve(a).then(e,function(t){return r(t),e()})}else n|=1}catch(e){r(e)}if(1===n)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}()}}("function"==typeof SuppressedError?SuppressedError:function(e,t,r){var i=new Error(r);return i.name="SuppressedError",i.error=e,i.suppressed=t,i});const Sa=/^0[xX][0-9a-fA-F]+$/,Ca=/^data:.*;base64,/i;
1class Pa extends ba{constructor(e,t,r,i){super(e.input,t,r),this.segments=[],this.nextLines=null,this.currentUpdateSegmentsPromise=null,this.streamHasEnded=!1,this.lastSegmentUpdateTime=-1/0,this.refreshInterval=5,this.rootPath=t,this.demuxer=e,this.nextLines=i}runUpdateSegments(){return this.currentUpdateSegmentsPromise??=(async()=>{try{const e=this.getRemainingWaitTimeMs();e>0&&await ke(e),this.lastSegmentUpdateTime=performance.now(),await this.updateSegments()}finally{this.currentUpdateSegmentsPromise=null}})()}getRemainingWaitTimeMs(){const e=performance.now()-this.lastSegmentUpdateTime,t=Math.max(0,1e3*this.refreshInterval-e);return t<=50?0:t}async updateSegments(){let e=this.nextLines;if(this.nextLines=null,!e){const t={stack:[],error:void 0,hasError:!1};try{const r=Ta(t,await this.demuxer.input._getSourceUncached({path:this.rootPath,isRoot:!1}),!1),i=new pr(r.source),n=await i.requestEntireFile();l(n),e=Or(n,n.length,{ignore:ga}),r.source instanceof or&&(this.rootPath=r.source.rootPath)}catch(e){t.error=e,t.hasError=!0}finally{xa(t)}}const t=!1!==this.input._formatOptions.hls?.offsetTimestampsByDateTime;let r=!1,i=0,n=null,a=null,s=null,o=0,c=null,d=null,u=null,f=null,m=null,p=null,g=!1,b=h(this.segments)??null;const w=e=>{const t=e.indexOf("@"),r=Number(-1===t?e:e.slice(0,t));if(!Number.isInteger(r)||r<0)throw new Error(`Invalid #EXT-X-BYTERANGE length '${e}'.`);let i=null;if(-1!==t&&(i=Number(e.slice(t+1)),!Number.isInteger(i)||i<0))throw new Error(`Invalid #EXT-X-BYTERANGE offset '${e}'.`);return{length:r,offset:i}},v=e=>{o=e,b&&(l(null!==b.sequenceNumber),b.sequenceNumber<e&&(i=b.timestamp+b.duration,c=b.firstSegment,d=b.initSegment,m=b.lastProgramDateTimeSeconds,n=null!==b.unixEpochTimestamp?b.unixEpochTimestamp+b.duration:null,b=null))};for(let l=0;l<e.length;l++){const k=e[l];if(r){if(!k.startsWith("#")){if(!b){if(null===a)throw new Error("Invalid M3U8 file; a segment must be preceded by an #EXTINF tag.");let e=s;if(e&&"AES-128"===e.method&&!e.iv){const t=new Uint8Array(zr),r=y(t);r.setUint32(8,Math.floor(o/2**32)),r.setUint32(12,o),e={...e,iv:t}}const t=ge(this.rootPath,k),r={timestamp:i,unixEpochTimestamp:n,firstSegment:c,sequenceNumber:o,location:{path:t,offset:f?.offset??0,length:f?.length??null},duration:a,encryption:e,initSegment:d,lastProgramDateTimeSeconds:m};c??=r,i+=a,null!==n&&(n+=a),this.segments.push(r)}a=null,null===f?u=null:f=null,v(o+1)}if(k.startsWith(ca)){if(b){g=!0;continue}g||(null===m&&o>0&&null!==p&&(i=o*p),g=!0);const e=k.slice(8),t=e.indexOf(","),r=-1===t?e:e.slice(0,t),n=Number(r);if(!Number.isFinite(n)||n<0)throw new Error(`Invalid #EXTINF tag duration '${r}'.`);a=n}else if(k.startsWith(da)){const e=new ya(k.slice(11)),t=e.get("uri");if(!t)throw new Error("Invalid #EXT-X-MAP tag; missing URI attribute.");const r=e.get("byterange");let o=null;if(null!==r&&(o=w(r)),o&&null===o.offset)throw new Error("Invalid #EXT-X-MAP tag; BYTERANGE attribute must have a specified offset.");if(!b){const e={path:ge(this.rootPath,t),offset:o?.offset??0,length:o?.length??null};if("AES-128"===s?.method&&!s.iv)throw new Error("IV attribute must be set on #EXT-X-KEY tag preceding the #EXT-X-MAP tag.");d={timestamp:i,unixEpochTimestamp:n,firstSegment:null,sequenceNumber:null,location:e,duration:0,encryption:s,initSegment:null,lastProgramDateTimeSeconds:m}}a=null,null===f?u=null:f=null}else if(k.startsWith(la)){const e=new ya(k.slice(11)),t=e.get("method");if("NONE"===t)s=null;else if("AES-128"===t){const t=e.get("uri");if(!t)throw new Error("Invalid #EXT-X-KEY: AES-128 requires a URI attribute.");let r=null;const i=e.get("iv");if(i){if(!Sa.test(i))throw new Error(`Unsupported IV format '${i}'.`);let e=i.slice(2);e=e.padStart(32,"0"),r=new Uint8Array(zr);for(let t=0;t<zr;t++){const i=-32+t;r[t]=parseInt(e.slice(i,i+2),16)}}const n=e.get("keyformat")??"identity";if("identity"!==n)throw new Error("For AES-128 encryption, only the 'identity' KEYFORMAT is currently supported. If you think other formats should be supported, please raise an issue.");s={method:"AES-128",keyUri:ge(this.rootPath,t),iv:r,keyFormat:n}}else{if("SAMPLE-AES"!==t&&"SAMPLE-AES-CTR"!==t)throw new Error(`Unsupported encryption method '${t}'. If you think this method should be supported, please raise an issue.`);{const r=e.get("uri");if(!r)throw new Error(`Invalid #EXT-X-KEY: ${t} requires a URI attribute.`);if("identity"===(e.get("keyformat")??"identity"))throw new Error("For SAMPLE-AES and SAMPLE-AES-CTR encryption, the 'identity' KEYFORMAT is not supported. If you think this format should be supported, please raise an issue.");let i=null;if(Ca.test(r)){const e=r.indexOf(","),t=he(r.slice(e+1));if(t.length>=8&&112===t[4]&&115===t[5]&&115===t[6]&&104===t[7]){const e=y(t).getUint32(0);i=Qt(t.subarray(8,Math.min(e,t.length)))}}s={method:t,psshBox:i}}}}else if(k.startsWith(ua)){const e=k.slice(22),t=Number(e);if(!Number.isInteger(t)||t<0)throw new Error(`Invalid EXT-X-MEDIA-SEQUENCE value '${e}'.`);v(t)}else if(k.startsWith(ha)){const e=w(k.slice(17));if(null===e.offset){if(null===u)throw new Error("Invalid M3U8 file; #EXT-X-BYTERANGE without offset requires a previous byte range.");e.offset=u}f=e,u=e.offset+e.length}else if(k.startsWith(fa)){if(b)continue;const e=k.slice(25),r=Date.parse(e);if(!Number.isFinite(r))continue;const a=r/1e3;if(m===a)continue;if(null===m&&this.segments.length>0){const e=h(this.segments),r=a-(e.timestamp+e.duration);for(const e of this.segments)e.unixEpochTimestamp=e.timestamp+r,t&&(e.timestamp=e.unixEpochTimestamp)}m=a,n=a,t&&(i=a)}else if("#EXT-X-DISCONTINUITY"===k)c=null;else if(k.startsWith(ma)){const e=k.slice(22),t=Number(e);if(!Number.isFinite(t)||t<0)throw new Error(`Invalid EXT-X-TARGETDURATION value '${e}'.`);this.refreshInterval=t,p=t}else{if("#EXT-X-ENDLIST"===k){this.streamHasEnded=!0;break}if(k.startsWith(pa)){"vod"===k.slice(21).toLowerCase()&&(this.streamHasEnded=!0)}}}else{if("#EXTM3U"!==k)throw new Error("Invalid M3U8 file; expected first line to be #EXTM3U.");r=!0}}if(!r)throw new Error("Invalid M3U8 file; no #EXTM3U header.")}async getFirstSegment(){return 0===this.segments.length&&await this.runUpdateSegments(),this.segments[0]??null}async getSegmentAt(e,t){0===this.segments.length&&await this.runUpdateSegments();let r=!!t.skipLiveWait&&this.getRemainingWaitTimeMs()>0;for(;;){const i=O(this.segments,e,e=>e.timestamp);if(-1===i)return null;if(i<this.segments.length-1||this.streamHasEnded||r)return this.segments[i];const n=this.segments[i];if(e<n.timestamp+n.duration)return n;await this.runUpdateSegments(),t.skipLiveWait&&(r=!0)}}async getNextSegment(e,t){const r=this.segments.indexOf(e);l(-1!==r);const i=r+1;let n=!!t.skipLiveWait&&this.getRemainingWaitTimeMs()>0;for(;;){if(i<this.segments.length)return this.segments[i];if(this.streamHasEnded||n)return null;await this.runUpdateSegments(),t.skipLiveWait&&(n=!0)}}async getPreviousSegment(e){const t=this.segments.indexOf(e);return l(-1!==t),this.segments[t-1]??null}getInputForSegment(e){const t=e,r=this.inputCache.find(e=>e.segment===t);if(r)return r.age=this.nextInputCacheAge++,r.input;let i=null;(t.initSegment||t.firstSegment)&&(i=this.getInputForSegment(t.initSegment??t.firstSegment));const n={...this.input._formatOptions,isobmff:{...this.input._formatOptions.isobmff,resolveKeyId:this.input._formatOptions.isobmff?.resolveKeyId&&
1(e=>{if(!t.encryption||"SAMPLE-AES"!==t.encryption.method&&"SAMPLE-AES-CTR"!==t.encryption.method||!t.encryption.psshBox)return this.input._formatOptions.isobmff.resolveKeyId(e);let r=e.psshBoxes;const{psshBox:i}=t.encryption;return null!==i.keyIds&&!i.keyIds.includes(e.keyId)||r.some(e=>Jt(e,i))||(r=[...r,i]),this.input._formatOptions.isobmff.resolveKeyId({...e,psshBoxes:r})})}},a=new ho({source:new dr(t.location.path,async e=>{l(e.isRoot);const r={...e,isRoot:!1};let i;const n=t.location.offset>0||null!==t.location.length;if(t.encryption&&"SAMPLE-AES"!==t.encryption.method&&"SAMPLE-AES-CTR"!==t.encryption.method)if("AES-128"===t.encryption.method){const e=t.encryption;l(e.iv);let a=await this.input._getSourceCached(r);if(n){const e=a.source.slice(t.location.offset,t.location.length??void 0).ref();a.free(),a=e}const s=((e,t,r)=>{let i=!1,n=0;const a=new Qr;return new ReadableStream({pull:async s=>{i||(a.init(await t()),i=!0);let o=e.requestSliceRange(n,0,65552);if(o instanceof Promise&&(o=await o),!o||0===o.length)throw new Error("Invalid ciphertext.");const c=o.length;if(c%16!=0)throw new Error("Invalid ciphertext.");const d=65552===c?c-16:c,l=br(o,d),u=new Uint8Array(d);for(let e=0;e<d;e+=16)a.in.set(l.subarray(e,e+16)),a.decrypt(),u.set(a.out,e);if(d<c)s.enqueue(u),n+=d;else{const e=u[d-1];if(0===e||e>16)throw new Error("Invalid PKCS#7 padding. Incorrect key or corrupted data.");const t=u.subarray(0,d-e);s.enqueue(t),s.close(),r()}},cancel:()=>{r()}})})(new pr(a.source),async()=>{const t={stack:[],error:void 0,hasError:!1};try{const r=Ta(t,await this.input._getSourceCached({path:e.keyUri,isRoot:!1},uo),!1),i=new pr(r.source),n=await i.requestSlice(0,zr);if(!n)throw new Error("Invalid AES-128 key; expected at least 16 bytes of data.");return{key:br(n,zr),iv:e.iv}}catch(e){t.error=e,t.hasError=!0}finally{xa(t)}},()=>{a.free()});i=new ur(s).ref()}else l(!1);else if(i=await this.input._getSourceCached(r),n){const e=i.source.slice(t.location.offset,t.location.length??void 0).ref();i.free(),i=e}return i}),formats:this.input._formats.filter(e=>!(e instanceof Ha)),initInput:i??void 0,formatOptions:n});a._onFormatDetermined=e=>{if(("SAMPLE-AES"===t.encryption?.method||"SAMPLE-AES-CTR"===t.encryption?.method)&&!e._isIsobmff)throw new Error("The SAMPLE-AES and SAMPLE-AES-CTR encryption methods are currently only supported for ISOBMFF files.")},this.inputCache.push({segment:t,input:a,age:this.nextInputCacheAge++});if(this.inputCache.length>4){const e=be(this.inputCache,e=>e.age);l(-1!==e),this.inputCache.splice(e,1)}return a}
1async getLiveRefreshInterval(){return 0===this.getRemainingWaitTimeMs()&&await this.runUpdateSegments(),this.streamHasEnded?null:this.refreshInterval}}class Aa extends Gt{constructor(e){super(e),this.metadataPromise=null,this.trackBackings=null,this.internalTracks=null,this.segmentedInputs=[],this.hasMasterPlaylist=!0}readMetadata(){return this.metadataPromise??=(async()=>{l(this.input._rootSource instanceof or);const e=await this.input._reader.requestEntireFile();l(e);const t=Or(e,e.length,{ignore:ga}),{rootPath:r}=this.input._rootSource,i=[],n=[];for(let e=1;e<t.length;e++){const a=t[e];if(a.startsWith(aa)){const n=e,s=t[++e];if(void 0===s)throw new Error("Incorrect M3U8 file; a line must follow the #EXT-X-STREAM-INF tag.");const o=ge(r,s),c=new ya(a.slice(18));if(null===c.getAsNumber("bandwidth"))throw new Error("Invalid M3U8 file; #EXT-X-STREAM-INF tag requires a BANDWIDTH attribute with a valid numerical value.");i.push({fullPath:o,attributes:c,lineNumber:n,hasOnlyKeyPackets:!1})}else if(a.startsWith(sa)){const t=new ya(a.slice(26)),n=t.get("uri");if(null===n)throw new Error("Invalid M3U8 file; #EXT-X-I-FRAME-STREAM-INF tag requires a URI attribute.");if(null===t.getAsNumber("bandwidth"))throw new Error("Invalid M3U8 file; #EXT-X-I-FRAME-STREAM-INF tag requires a BANDWIDTH attribute with a valid numerical value.");const s=ge(r,n);i.push({fullPath:s,attributes:t,lineNumber:e,hasOnlyKeyPackets:!0})}else if(a.startsWith(oa)){const t=new ya(a.slice(13));if(null===t.get("type"))throw new Error("Invalid M3U8 file; #EXT-X-MEDIA tag requires a TYPE attribute.");if(null===t.get("group-id"))throw new Error("Invalid M3U8 file; #EXT-X-MEDIA tag requires a GROUP-ID attribute.");let i=null;const s=t.get("uri");null!==s&&(i=ge(r,s)),n.push({fullPath:i,attributes:t,lineNumber:e})}else if("#EXT-X-I-FRAMES-ONLY"===a);else if(a.startsWith(ca)){const e=new Pa(this,r,null,t);return this.segmentedInputs=[e],this.hasMasterPlaylist=!1,void(this.trackBackings=await e.getTrackBackings())}}const a=[...new Set(n.filter(e=>"video"===e.attributes.get("type").toLowerCase()).map(e=>e.attributes.get("group-id")))],s=[...new Set(n.filter(e=>"audio"===e.attributes.get("type").toLowerCase()).map(e=>e.attributes.get("group-id")))],o=await Promise.all(i.map(async(e,t)=>{const i=[],o=e.attributes.get("codecs");let c;if(o)c=o.split(",").map(e=>e.trim());else{const t=this.getSegmentedInputForPath(e.fullPath),r=await t.getTrackBackings(),i=await Promise.all(r.map(async e=>({track:e,codec:await e.getCodec()})));c=await Promise.all(i.filter(e=>null!==e.codec).map(e=>e.track.getDecoderConfig().then(e=>e.codec)))}const d=e.attributes.get("video"),u=e.attributes.get("audio"),h=c.some(e=>Pe.includes(qe(e))),f=c.some(e=>Ie.includes(qe(e)));if(null!==d&&!h){if(!a.includes(d))throw new Error(`Invalid M3U8 file; variant stream references video group "${d}" which is not defined in any #EXT-X-MEDIA tags.`);const e=n.find(e=>{const t=e.attributes.get("group-id"),r=e.attributes.get("type");return t===d&&"video"===r.toLowerCase()});e:if(e){const t=e.attributes.get("uri");if(null===t)break e;const i=ge(r,t),n=this.getSegmentedInputForPath(i),a=(await n.getTrackBackings()).find(e=>"video"===e.getType());if(!a||null===await a.getCodec())break e;const s=await a.getDecoderConfig().then(e=>e?.codec??null);l(null!==s),c.push(s)}}if(null!==u&&!f){if(!s.includes(u))throw new Error(`Invalid M3U8 file; variant stream references audio group "${u}" which is not defined in any #EXT-X-MEDIA tags.`);const e=n.find(e=>{const t=e.attributes.get("group-id"),r=e.attributes.get("type");return t===u&&"audio"===r.toLowerCase()});e:if(e){const t=e.attributes.get("uri");if(null===t)break e;const i=ge(r,t),n=this.getSegmentedInputForPath(i),a=(await n.getTrackBackings()).find(e=>"audio"===e.getType());if(!a||null===await a.getCodec())break e;const s=await a.getDecoderConfig().then(e=>e?.codec??null);l(null!==s),c.push(s)}}c=[...new Set(c)];let m=null,p=null;const g=e.attributes.getAsNumber("bandwidth");l(null!==g);const y=e.attributes.getAsNumber("average-bandwidth"),b=e.attributes.get("name");for(const r of c){const o=qe(r);if(null!==o)if(Pe.includes(o)){if(null!==m)throw new Error("Unsupported M3U8 file; multiple video codecs found in the CODECS attribute of a variant stream.");m=r;const s=e.attributes.get("video");if(null===s){const r=e.attributes.get("resolution");let n=null,a=null;if(r){const e=r.match(/^(\d+)x(\d+)$/);e&&(n=Number(e[1]),a=Number(e[2]))}i.push({id:-1,demuxer:this,backingTrack:null,default:!0,autoselect:!0,languageCode:V,lineNumber:e.lineNumber,fullPath:e.fullPath,fullCodecString:m,pairingMask:1n<<BigInt(t),peakBitrate:g,averageBitrate:y,name:b,hasOnlyKeyPackets:e.hasOnlyKeyPackets,info:{type:"video",width:n,height:a}})}else{if(!a.includes(s))throw new Error(`Invalid M3U8 file; variant stream references video group "${s}" which is not defined in any #EXT-X-MEDIA tags.`);for(const r of n){const n=r.attributes.get("group-id"),a=r.attributes.get("type");if(n!==s||"video"!==a.toLowerCase())continue;const o=r.attributes.get("resolution")??e.attributes.get("resolution");let c=null,d=null;if(o){const e=o.match(/^(\d+)x(\d+)$/);e&&(c=Number(e[1]),d=Number(e[2]))}i.push({id:-1,demuxer:this,backingTrack:null,default:_a(r.attributes),autoselect:_a(r.attributes)||Na(r.attributes),languageCode:Ra(r.attributes.get("language")),lineNumber:r.lineNumber,fullPath:r.fullPath??e.fullPath,fullCodecString:m,pairingMask:1n<<BigInt(t),peakBitrate:null,averageBitrate:null,name:r.attributes.get("name"),hasOnlyKeyPackets:e.hasOnlyKeyPackets,info:{type:"video",width:c,height:d}})}}}else if(Ie.includes(o)){if(null!==p)throw new Error("Unsupported M3U8 file; multiple audio codecs found in the CODECS attribute of a variant stream.");p=r;const a=e.attributes.get("audio");if(null===a){const r=e.attributes.get("channels"),n=null!==r?Number(r.split("/")[0]):null;i.push({id:-1,demuxer:this,backingTrack:null,default:!0,autoselect:!0,languageCode:V,lineNumber:e.lineNumber,fullPath:e.fullPath,fullCodecString:p,pairingMask:1n<<BigInt(t),peakBitrate:g,averageBitrate:y,name:b,hasOnlyKeyPackets:e.hasOnlyKeyPackets,info:{type:"audio",numberOfChannels:null!==n&&Number.isInteger(n)&&n>0?n:null}})}else{if(!s.includes(a))throw new Error(`Invalid M3U8 file; variant stream references audio group "${a}" which is not defined in any #EXT-X-MEDIA tags.`);for(const r of n){const n=r.attributes.get("group-id"),s=r.attributes.get("type");if(n!==a||"audio"!==s.toLowerCase())continue;const o=r.attributes.get("channels")??e.attributes.get("channels"),c=null!==o?Number(o.split("/")[0]):null;i.push({id:-1,demuxer:this,backingTrack:null,default:_a(r.attributes),autoselect:_a(r.attributes)||Na(r.attributes),languageCode:Ra(r.attributes.get("language")),lineNumber:r.lineNumber,fullPath:r.fullPath??e.fullPath,fullCodecString:p,pairingMask:1n<<BigInt(t),peakBitrate:null,averageBitrate:null,name:r.attributes.get("name"),hasOnlyKeyPackets:e.hasOnlyKeyPackets,info:{type:"audio",numberOfChannels:null!==c&&Number.isInteger(c)&&c>0?c:null}})}}}}return i})),c=[],d=e=>{const t=c.find(t=>t.fullPath===e.fullPath&&t.info.type===e.info.type);t?(t.pairingMask|=e.pairingMask,t.default||=e.default,t.autoselect||=e.autoselect,t.lineNumber=Math.min(t.lineNumber,e.lineNumber),null!==e.peakBitrate&&(t.peakBitrate=Math.max(t.peakBitrate??-1/0,e.peakBitrate)),null!==e.averageBitrate&&(t.averageBitrate=Math.max(t.averageBitrate??-1/0,e.averageBitrate)),t.languageCode===V&&(t.languageCode=e.languageCode)):(e.id=c.length+1,c.push(e))};for(const e of o)for(const t of e)d(t);c.sort((e,t)=>
1e.lineNumber-t.lineNumber),this.trackBackings=[];for(const e of c)"video"===e.info.type?this.trackBackings.push(new Ia(e)):this.trackBackings.push(new $a(e));this.internalTracks=c})()}async getTrackBackings(){return await this.readMetadata(),l(this.trackBackings),this.trackBackings}getSegmentedInputForPath(e){let t=this.segmentedInputs.find(t=>t.path===e);if(t)return t;let r=null;if(this.internalTracks){r=this.internalTracks.filter(t=>t.fullPath===e).map(e=>({id:e.id,type:e.info.type}))}return t=new Pa(this,e,r,null),this.segmentedInputs.push(t),t}async getMetadataTags(){return{}}async getMimeType(){return na}dispose(){if(this.segmentedInputs){for(const e of this.segmentedInputs)e.dispose();this.segmentedInputs.length=0}}}class Ea{constructor(e){this.internalTrack=e,this.hydrationPromise=null}hydrate(){return this.hydrationPromise??=(async()=>{const e=this.internalTrack.demuxer.getSegmentedInputForPath(this.internalTrack.fullPath);let t=null;const r=(await e.getTrackBackings()).filter(e=>e.getType()===this.getType());if(1===r.length)t=r[0];else if(this instanceof Ia){for(const e of r)if(await e.getCodec()===this.getCodec()){t=e;break}}else{l(this instanceof $a);for(const e of r)if(await e.getCodec()===this.getCodec()){t=e;break}}if(!t)throw new Error("Could not find matching track in underlying media data.");this.internalTrack.backingTrack=t})()}delegate(e){return this.internalTrack.backingTrack?e():this.hydrate().then(e)}getCodec(){throw new Error("Not implemented on base class.")}getDisposition(){return{...rr,default:this.internalTrack.autoselect,primary:this.internalTrack.default}}getId(){return this.internalTrack.id}getPairingMask(){return this.internalTrack.pairingMask}getInternalCodecId(){return null}getLanguageCode(){return this.internalTrack.languageCode}getName(){return this.internalTrack.name}getNumber(){l(this.internalTrack.demuxer.internalTracks);const e=this.internalTrack.info.type;let t=0;for(const r of this.internalTrack.demuxer.internalTracks)if(r.info.type===e&&t++,r===this.internalTrack)break;return t}getTimeResolution(){return this.delegate(()=>this.internalTrack.backingTrack.getTimeResolution())}isRelativeToUnixEpoch(){return this.delegate(()=>this.internalTrack.backingTrack.isRelativeToUnixEpoch())}getUnixTimeForTimestamp(e){return this.delegate(()=>this.internalTrack.backingTrack.getUnixTimeForTimestamp(e))}getBitrate(){return this.internalTrack.peakBitrate}getAverageBitrate(){return this.internalTrack.averageBitrate}async getDurationFromMetadata(e){return await this.hydrate(),this.internalTrack.backingTrack.getDurationFromMetadata(e)}
1async getLiveRefreshInterval(){return await this.hydrate(),this.internalTrack.backingTrack.getLiveRefreshInterval()}getHasOnlyKeyPackets(){return this.internalTrack.hasOnlyKeyPackets||null}async getFirstPacket(e){return await this.hydrate(),this.internalTrack.backingTrack.getFirstPacket(e)}async getPacket(e,t){return await this.hydrate(),this.internalTrack.backingTrack.getPacket(e,t)}async getKeyPacket(e,t){return await this.hydrate(),this.internalTrack.backingTrack.getKeyPacket(e,t)}async getNextPacket(e,t){return await this.hydrate(),this.internalTrack.backingTrack.getNextPacket(e,t)}async getNextKeyPacket(e,t){return await this.hydrate(),this.internalTrack.backingTrack.getNextKeyPacket(e,t)}}class Ia extends Ea{constructor(e){super(e)}get backingVideoTrack(){return this.internalTrack.backingTrack}getType(){return"video"}getCodec(){return qe(this.internalTrack.fullCodecString)}getCodedWidth(){return this.delegate(()=>this.backingVideoTrack.getCodedWidth())}getCodedHeight(){return this.delegate(()=>this.backingVideoTrack.getCodedHeight())}getSquarePixelWidth(){return this.delegate(()=>this.backingVideoTrack.getSquarePixelWidth())}getSquarePixelHeight(){return this.delegate(()=>this.backingVideoTrack.getSquarePixelHeight())}getMetadataDisplayWidth(){return this.backingVideoTrack?null:this.internalTrack.info.width}getMetadataDisplayHeight(){return this.backingVideoTrack?null:this.internalTrack.info.height}getRotation(){return this.delegate(()=>this.backingVideoTrack.getRotation())}async getColorSpace(){return await this.hydrate(),this.backingVideoTrack.getColorSpace()}
1async canBeTransparent(){return await this.hydrate(),this.backingVideoTrack.canBeTransparent()}getMetadataCodecParameterString(){return this.backingVideoTrack?null:this.internalTrack.fullCodecString}async getDecoderConfig(){return await this.hydrate(),this.backingVideoTrack.getDecoderConfig()}}class $a extends Ea{constructor(e){super(e)}get backingAudioTrack(){return this.internalTrack.backingTrack}getType(){return"audio"}getCodec(){return qe(this.internalTrack.fullCodecString)}getNumberOfChannels(){return null!==this.internalTrack.info.numberOfChannels?this.internalTrack.info.numberOfChannels:this.delegate(()=>this.backingAudioTrack.getNumberOfChannels())}getSampleRate(){return this.delegate(()=>this.backingAudioTrack.getSampleRate())}getMetadataCodecParameterString(){return this.backingAudioTrack?null:this.internalTrack.fullCodecString}async getDecoderConfig(){return await this.hydrate(),this.backingAudioTrack.getDecoderConfig()}}const _a=e=>{const t=e.get("default");if(null===t)return!1;const r=t.toUpperCase();if("YES"===r)return!0;if("NO"===r)return!1;throw new Error(`Invalid M3U8 file; #EXT-X-MEDIA DEFAULT attribute must be YES or NO, got "${t}".`)},Na=e=>{const t=e.get("autoselect");if(null===t)return!1;const r=t.toUpperCase();if("YES"===r)return!0;if("NO"===r)return!1;throw new Error(`Invalid M3U8 file; #EXT-X-MEDIA AUTOSELECT attribute must be YES or NO, got "${t}".`)},Ra=e=>{if(null===e)return V;const t=e.split("-")[0];return t||V};class Oa{constructor(){this._isIsobmff=!1}}class Fa extends Oa{constructor(){super(...arguments),this._isIsobmff=!0}async _getMajorBrand(e){let t=e._reader.requestSlice(0,12);if(t instanceof Promise&&(t=await t),!t)return null;t.skip(4);const r=Rr(t,4);return"ftyp"!==r&&"styp"!==r?null:Rr(t,4)}_createDemuxer(e){return new Jr(e)}}class Ba extends Fa{async _canReadInput(e){const t=await this._getMajorBrand(e);if(null!==t)return"qt "!==t;let r=e._reader.requestSlice(4,4);if(r instanceof Promise&&(r=await r),!r)return!1;const i=Rr(r,4);return"moof"===i||"sidx"===i}get name(){return"MP4"}get mimeType(){return"video/mp4"}}class Da extends Fa{async _canReadInput(e){return"qt "===await this._getMajorBrand(e)}get name(){return"QuickTime File Format"}get mimeType(){return"video/quicktime"}}class Ma extends Oa{async isSupportedEBMLOfDocType(e,t){let r=e._reader.requestSlice(0,Ai);if(r instanceof Promise&&(r=await r),!r)return!1;const i=Ei(r);if(null===i)return!1;if(i<1||i>8)return!1;if($i(r,i)!==wi.EBML)return!1;const n=Ni(r);if("number"!=typeof n)return!1;let a=e._reader.requestSlice(r.filePos,n);if(a instanceof Promise&&(a=await a),!a)return!1;const s=r.filePos;for(;a.filePos<=s+n-2;){const e=Ri(a);if(!e)break;const{id:r,size:i}=e,n=a.filePos;if(void 0===i)return!1;switch(r){case wi.EBMLVersion:if(1!==$i(a,i))return!1;break;case wi.EBMLReadVersion:if(1!==$i(a,i))return!1;break;case wi.DocType:if(Oi(a,i)!==t)return!1;break;case wi.DocTypeVersion:if($i(a,i)>4)return!1}a.filePos=n+i}return!0}_canReadInput(e){return this.isSupportedEBMLOfDocType(e,"matroska")}_createDemuxer(e){return new Gi(e)}get name(){return"Matroska"}get mimeType(){return"video/x-matroska"}}class ja extends Ma{_canReadInput(e){return this.isSupportedEBMLOfDocType(e,"webm")}get name(){return"WebM"}get mimeType(){return"video/webm"}}class La extends Oa{async _canReadInput(e){let t=0;for(;;){let r=e._reader.requestSlice(t,un);if(r instanceof Promise&&(r=await r),!r)break;const i=mn(r);if(!i)break;t=r.filePos+i.size}const r=await yn(e._reader,t,t+4096);if(!r)return!1;const i=r.header,n=rn(i.mpegVersionId,i.channel);let a=e._reader.requestSlice(r.startPos+n,4);if(a instanceof Promise&&(a=await a),!a)return!1;const s=Cr(a);if(s===Zi||s===en)return!0;t=r.startPos+r.header.totalSize;const o=await yn(e._reader,t,t+4);if(!o)return!1;const c=o.header;return i.channel===c.channel&&i.sampleRate===c.sampleRate}_createDemuxer(e){return new bn(e)}get name(){return"MP3"}get mimeType(){return"audio/mpeg"}}class Ua extends Oa{async _canReadInput(e){let t=e._reader.requestSlice(0,12);if(t instanceof Promise&&(t=await t),!t)return!1;const r=Rr(t,4);if("RIFF"!==r&&"RIFX"!==r&&"RF64"!==r)return!1;t.skip(4);return"WAVE"===Rr(t,4)}_createDemuxer(e){return new On(e)}get name(){return"WAVE"}get mimeType(){return"audio/wav"}}
1class za extends Oa{async _canReadInput(e){let t=e._reader.requestSlice(0,4);return t instanceof Promise&&(t=await t),!!t&&"OggS"===Rr(t,4)}_createDemuxer(e){return new In(e)}get name(){return"Ogg"}get mimeType(){return"application/ogg"}}class Wa extends Oa{async _canReadInput(e){let t=0;for(;;){let r=e._reader.requestSlice(t,un);if(r instanceof Promise&&(r=await r),!r)break;const i=mn(r);if(!i)break;t=r.filePos+i.size}let r=e._reader.requestSlice(t,4);return r instanceof Promise&&(r=await r),!!r&&"fLaC"===Rr(r,4)}get name(){return"FLAC"}get mimeType(){return"audio/flac"}_createDemuxer(e){return new Vn(e)}}class Va extends Oa{async _canReadInput(e){let t=0;for(;;){let r=e._reader.requestSlice(t,un);if(r instanceof Promise&&(r=await r),!r)break;const i=mn(r);if(!i)break;t=r.filePos+i.size}let r=e._reader.requestSliceRange(t,7,9);if(r instanceof Promise&&(r=await r),!r)return!1;const i=Dn(r);if(!i)return!1;if(t+=i.frameLength,r=e._reader.requestSliceRange(t,7,9),r instanceof Promise&&(r=await r),!r)return!1;const n=Dn(r);return!!n&&(i.objectType===n.objectType&&i.samplingFrequencyIndex===n.samplingFrequencyIndex&&i.channelConfiguration===n.channelConfiguration)}_createDemuxer(e){return new jn(e)}get name(){return"ADTS"}get mimeType(){return"audio/aac"}}class qa extends Oa{async _canReadInput(e){let t=e._reader.requestSlice(0,205);if(t instanceof Promise&&(t=await t),!t)return!1;const r=br(t,205);return 71===r[0]&&71===r[188]||(71===r[0]&&71===r[204]||71===r[4]&&71===r[196])}_createDemuxer(e){return new Yn(e)}get name(){return"MPEG Transport Stream"}get mimeType(){return"video/MP2T"}}class Ha extends Oa{async _canReadInput(e){let t=e._reader.requestSlice(0,7);if(t instanceof Promise&&(t=await t),!t)return!1;if(!("#EXTM3U"===Rr(t,7)))return!1;if(!(e._rootSource instanceof or))throw new TypeError("HLS inputs require `InputOptions.source` to be a PathedSource or a ref to one.");return e._rootSource._usedForHls=!0,!0}_createDemuxer(e){return new Aa(e)}get name(){return"HTTP Live Streaming (HLS)"}get mimeType(){return na}}const Ga=new Ba,Ka=new Da,Ya=new Ma,Xa=new ja,Qa=new La,Ja=new Ua,Za=new za,es=new Va,ts=new Wa,rs=new qa,is=new Ha,ns=[is,Ga,Ka,Ya,Xa,Ja,Za,ts,Qa,es,rs];const as=[],ss=[],os=[],cs=[];var ds=function(e,t,r){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var i,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=t[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=t[Symbol.dispose],r&&(n=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");n&&(i=function(){try{n.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:i,async:r})}else r&&e.stack.push({async:!0});return t},ls=function(e){return function(t){function r(r){t.error=t.hasError?new e(r,t.error,"An error was suppressed during disposal."):r,t.hasError=!0}var i,n=0;return function e(){for(;i=t.stack.pop();)try{if(!i.async&&1===n)return n=0,t.stack.push(i),Promise.resolve().then(e);if(i.dispose){var a=i.dispose.call(i.value);if(i.async)return n|=2,Promise.resolve(a).then(e,function(t){return r(t),e()})}else n|=1}catch(e){r(e)}if(1===n)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}()}}("function"==typeof SuppressedError?SuppressedError:function(e,t,r){var i=new Error(r);return i.name="SuppressedError",i.error=e,i.suppressed=t,i});me();let us=-1/0,hs=-1/0,fs=null;"undefined"!=typeof FinalizationRegistry&&(fs=new FinalizationRegistry(e=>{const t=performance.now();"video"===e.type?(t-us>=1e3&&(d._error("A VideoSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your VideoSamples as soon as you're done using them."),us=t),"undefined"!=typeof VideoFrame&&e.data instanceof VideoFrame&&e.data.close()):(t-hs>=1e3&&(d._error("An AudioSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your AudioSamples as soon as you're done using them."),hs=t),"undefined"!=typeof AudioData&&e.data instanceof AudioData&&e.data.close())}));class ms{constructor(){this._referenceCount=0,this._lastAllocationBuffer=null}}const ps=["I420","I420P10","I420P12","I420A","I420AP10","I420AP12","I422","I422P10","I422P12","I422A","I422AP10","I422AP12","I444","I444P10","I444P12","I444A","I444AP10","I444AP12","NV12","RGBA","RGBX","BGRA","BGRX"],gs=new Set(ps);
1class ys{get codedWidth(){return this.visibleRect.width}get codedHeight(){return this.visibleRect.height}get displayWidth(){return this.rotation%180==0?this.squarePixelWidth:this.squarePixelHeight}get displayHeight(){return this.rotation%180==0?this.squarePixelHeight:this.squarePixelWidth}get microsecondTimestamp(){return Math.trunc(J*this.timestamp)}get microsecondDuration(){return Math.trunc(J*this.duration)}get hasAlpha(){return this.format&&this.format.includes("A")}constructor(e,t){if(this._closed=!1,e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer||ArrayBuffer.isView(e)){if(!t||"object"!=typeof t)throw new TypeError("init must be an object.");if(void 0===t.format||!gs.has(t.format))throw new TypeError("init.format must be one of: "+ps.join(", "));if(!Number.isInteger(t.codedWidth)||t.codedWidth<=0)throw new TypeError("init.codedWidth must be a positive integer.");if(!Number.isInteger(t.codedHeight)||t.codedHeight<=0)throw new TypeError("init.codedHeight must be a positive integer.");if(void 0!==t.rotation&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(void 0!==t.duration&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");if(void 0!==t.layout){if(!Array.isArray(t.layout))throw new TypeError("init.layout, when provided, must be an array.");for(const e of t.layout){if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("Each entry in init.layout must be an object.");if(!Number.isInteger(e.offset)||e.offset<0)throw new TypeError("plane.offset must be a non-negative integer.");if(!Number.isInteger(e.stride)||e.stride<0)throw new TypeError("plane.stride must be a non-negative integer.")}}if(void 0!==t.visibleRect&&ve(t.visibleRect,"init.visibleRect"),void 0!==t.displayWidth&&(!Number.isInteger(t.displayWidth)||t.displayWidth<=0))throw new TypeError("init.displayWidth, when provided, must be a positive integer.");if(void 0!==t.displayHeight&&(!Number.isInteger(t.displayHeight)||t.displayHeight<=0))throw new TypeError("init.displayHeight, when provided, must be a positive integer.");if(void 0!==t.displayWidth!=(void 0!==t.displayHeight))throw new TypeError("init.displayWidth and init.displayHeight must be either both provided or both omitted.");this._data=t._doNotCopy?g(e):g(e).slice(),this._layout=t.layout??As(t.format,t.codedWidth,t.codedHeight),this.format=t.format,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0;let r=t.colorSpace??null;null===r&&(r="RGBA"===this.format||"RGBX"===this.format||"BGRA"===this.format||"BGRX"===this.format?{primaries:"bt709",transfer:"iec61966-2-1",matrix:"rgb",fullRange:!0}:{primaries:"bt709",transfer:"bt709",matrix:"bt709",fullRange:!1}),this.colorSpace=new Ts(r),this.visibleRect={left:t.visibleRect?.left??0,top:t.visibleRect?.top??0,width:t.visibleRect?.width??t.codedWidth,height:t.visibleRect?.height??t.codedHeight},void 0!==t.displayWidth?(this.squarePixelWidth=this.rotation%180==0?t.displayWidth:t.displayHeight,this.squarePixelHeight=this.rotation%180==0?t.displayHeight:t.displayWidth):(this.squarePixelWidth=this.visibleRect.width,this.squarePixelHeight=this.visibleRect.height)}else if("undefined"!=typeof VideoFrame&&e instanceof VideoFrame){if(void 0!==t?.rotation&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(void 0!==t?.timestamp&&!Number.isFinite(t?.timestamp))throw new TypeError("init.timestamp, when provided, must be a number.");if(void 0!==t?.duration&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");void 0!==t?.visibleRect&&ve(t.visibleRect,"init.visibleRect"),this._data=e,this._layout=null,this.format=e.format,this.visibleRect={left:e.visibleRect?.x??0,top:e.visibleRect?.y??0,width:e.visibleRect?.width??e.codedWidth,height:e.visibleRect?.height??e.codedHeight},this.rotation=t?.rotation??0,this.squarePixelWidth=e.displayWidth,this.squarePixelHeight=e.displayHeight,this.timestamp=t?.timestamp??e.timestamp/1e6,this.duration=t?.duration??(e.duration??0)/1e6,this.colorSpace
1=new Ts(e.colorSpace)}else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof SVGImageElement&&e instanceof SVGImageElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas){if(!t||"object"!=typeof t)throw new TypeError("init must be an object.");if(void 0!==t.rotation&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(void 0!==t.duration&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");if("undefined"!=typeof VideoFrame)return new ys(new VideoFrame(e,{timestamp:Math.trunc(t.timestamp*J),duration:Math.trunc((t.duration??0)*J)||void 0}),t);let r=0,i=0;if("naturalWidth"in e?(r=e.naturalWidth,i=e.naturalHeight):"videoWidth"in e?(r=e.videoWidth,i=e.videoHeight):"width"in e&&(r=Number(e.width),i=Number(e.height)),!r||!i)throw new TypeError("Could not determine dimensions.");const n=new OffscreenCanvas(r,i),a=n.getContext("2d",{alpha:ie(),willReadFrequently:!0});if(!a)throw new Error("OffscreenCanvas must have support for the '2d' context in order to create a VideoSample from this data.");a.drawImage(e,0,0),this._data=n,this._layout=null,this.format="RGBX",this.visibleRect={left:0,top:0,width:r,height:i},this.squarePixelWidth=r,this.squarePixelHeight=i,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=new Ts({matrix:"rgb",primaries:"bt709",transfer:"iec61966-2-1",fullRange:!0})}else{if(!(e instanceof ms))throw new TypeError("Invalid data type: Must be a BufferSource, CanvasImageSource, or VideoSampleResource.");if(!t||"object"!=typeof t)throw new TypeError("init must be an object.");if(void 0!==t.rotation&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(void 0!==t.duration&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");if(this._data=e,e._referenceCount++,this.format=e.getFormat(),null!==this.format&&!ps.includes(this.format))throw new TypeError("getFormat() must return a VideoSamplePixelFormat or null.");if(this.visibleRect={left:0,top:0,width:e.getCodedWidth(),height:e.getCodedHeight()},!Number.isInteger(this.visibleRect.width)||this.visibleRect.width<=0)throw new TypeError("getCodedWidth() must return a positive integer.");if(!Number.isInteger(this.visibleRect.height)||this.visibleRect.height<=0)throw new TypeError("getCodedHeight() must return a positive integer.");if(this.squarePixelWidth=e.getSquarePixelWidth(),!Number.isInteger(this.squarePixelWidth)||this.squarePixelWidth<=0)throw new TypeError("getSquarePixelWidth() must return a positive integer.");if(this.squarePixelHeight=e.getSquarePixelHeight(),!Number.isInteger(this.squarePixelHeight)||this.squarePixelHeight<=0)throw new TypeError("getSquarePixelHeight() must return a positive integer.");this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=e.getColorSpace()}this.encodeOptions=t?.encodeOptions??{},this.pixelAspectRatio=we({num:this.squarePixelWidth*this.codedHeight,den:this.squarePixelHeight*this.codedWidth}),fs?.register(this,{type:"video",data:this._data},this)}clone(){if(this._closed)throw new Error("VideoSample is closed.");return l(null!==this._data),this._data instanceof ms?new ys(this._data,{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation,encodeOptions:this.encodeOptions}):xs(this._data)?new ys(this._data.clone(),{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation,encodeOptions:this.encodeOptions}):this._data instanceof Uint8Array?(l(this._layout),new ys(this._data,{format:this.format,layout:this._layout,codedWidth:this.codedWidth,coded
1Height:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation,visibleRect:this.visibleRect,displayWidth:this.displayWidth,displayHeight:this.displayHeight,encodeOptions:this.encodeOptions,_doNotCopy:!0})):new ys(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation,visibleRect:this.visibleRect,displayWidth:this.displayWidth,displayHeight:this.displayHeight,encodeOptions:this.encodeOptions})}close(){this._closed||(fs?.unregister(this),this._data instanceof ms?(this._data._referenceCount--,0===this._data._referenceCount&&this._data.close()):xs(this._data)?this._data.close():this._data=null,this._closed=!0)}allocationSize(e={}){if(Ps(e),this._closed)throw new Error("VideoSample is closed.");if(null==(e.format??this.format))throw new Error("Cannot get allocation size when format is null.");if(xs(this._data))return this._data.allocationSize(e);return ParseVideoFrameCopyToOptions(this,e).allocationSize}async copyTo(e,t={}){if(!E(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(Ps(t),this._closed)throw new Error("VideoSample is closed.");if(null==(t.format??this.format))throw new Error("Cannot copy video sample data when format is null.");if(l(null!==this._data),xs(this._data))return this._data.copyTo(e,t);if(t.format&&!["RGBA","RGBX","BGRA","BGRX"].includes(this.format)&&["RGBA","RGBX","BGRA","BGRX"].includes(t.format)){if(!(this._data instanceof ms)){if("undefined"==typeof VideoFrame)throw new Error("For this sample, converting from a non-RGB to an RGB format requires VideoFrame to be defined.");const r=this.toVideoFrame(),i=await r.copyTo(e,t);return r.close(),i}{const r={stack:[],error:void 0,hasError:!1};try{const i=ds(r,await this._data.toRgbSample({timestamp:this.timestamp,duration:this.duration,rotation:this.rotation},t.colorSpace??"srgb"),!1);if(!(i instanceof ys))throw new TypeError("toRgbSample() must return a VideoSample.");if(!["RGBA","RGBX","BGRA","BGRX"].includes(i.format))throw new Error(`Sample returned by toRgbSample was expected to have an RGB format, got '${i.format}' instead.`);return await i.copyTo(e,t)}catch(e){r.error=e,r.hasError=!0}finally{ls(r)}}}const r=ParseVideoFrameCopyToOptions(this,t);l(this.format);const i=g(e);if(i.byteLength<r.allocationSize)throw new TypeError(`Destination buffer too small. Required: ${r.allocationSize}, Available: ${i.byteLength}`);const n=Es(this.format);let a;if(this._data instanceof ms){let e=this._data.getDataPlanes();if(e instanceof Promise&&(e=await e),!Array.isArray(e)||e.some(e=>!(e.data instanceof Uint8Array)||!Number.isInteger(e.stride)||e.stride<0))throw new TypeError('getDataPlanes() must return an array of objects with a Uint8Array "data" property and a non-negative integer "stride" property.');a=e}else if(this._data instanceof Uint8Array)l(this._layout),l(this._layout.length===n.length),a=this._layout.map((e,t)=>{const r=Math.ceil(this.codedHeight/n[t].heightDivisor);return{data:this._data.subarray(e.offset,e.offset+e.stride*r),stride:e.stride}});else{const e=this._data.getContext("2d");l(e);const t=e.getImageData(0,0,this.codedWidth,this.codedHeight);a=[{data:g(t.data),stride:4*this.codedWidth}]}const s=[],o=n.length;for(let e=0;e<o;e++){const t=r.computedLayouts[e],n=a[e].stride,o=a[e].data;let c=t.sourceTop*n;c+=t.sourceLeftBytes;let d=t.destinationOffset;const l=t.sourceWidthBytes,u={offset:d,stride:t.destinationStride};for(let e=0;e<t.sourceHeight;e++){if(c+l>o.byteLength)throw new Error("Source buffer OOB read.");if(d+l>i.byteLength)throw new Error("Destination buffer OOB write.");const e=o.subarray(c,c+l);i.set(e,d),c+=n,d+=t.destinationStride}s.push(u)}if(void 0!==t.format){const e=this.format.startsWith("RGB")!==t.format.startsWith("RGB"),n=this.format.includes("X")&&t.format.includes("A");if(e||n)for(let t=0;t<r.allocationSize;t+=4){if(e){const e=i[t],r=i[t+2];i[t]=r,i[t+2]=e}n&&(i[t+3]=255)}}return s}toVideoFrame(){if(this._closed)throw new Error("VideoSample is closed.");if(l(null!==this._data),this._data instanceof ms){if(null===this.format)throw new Error("Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if format is null.");const e=this._data.getDataPlanes();if(e instanceof Promise)throw new Error("Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if getDataPlanes() returns a promise.");const t=e.reduce((e,t)=>
1e+t.data.byteLength,0),r=new Uint8Array(t);let i=0;const n=[];for(const t of e)r.set(t.data,i),n.push(i),i+=t.data.byteLength;return new VideoFrame(r,{format:this.format,layout:e.map((e,t)=>({offset:n[t],stride:e.stride})),codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration,colorSpace:this.colorSpace,displayWidth:this.squarePixelWidth,displayHeight:this.squarePixelHeight})}return xs(this._data)?new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0}):this._data instanceof Uint8Array?new VideoFrame(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0,colorSpace:this.colorSpace,displayWidth:this.squarePixelWidth,displayHeight:this.squarePixelHeight}):new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0})}draw(e,t,r,i,n,a,s,o,c){let d=0,l=0,u=this.displayWidth,h=this.displayHeight,f=0,m=0,p=this.displayWidth,g=this.displayHeight;if(void 0!==a?(d=t,l=r,u=i,h=n,f=a,m=s,void 0!==o?(p=o,g=c):(p=u,g=h)):(f=t,m=r,void 0!==i&&(p=i,g=n)),!("undefined"!=typeof CanvasRenderingContext2D&&e instanceof CanvasRenderingContext2D||"undefined"!=typeof OffscreenCanvasRenderingContext2D&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!Number.isFinite(d))throw new TypeError("sx must be a number.");if(!Number.isFinite(l))throw new TypeError("sy must be a number.");if(!Number.isFinite(u)||u<0)throw new TypeError("sWidth must be a non-negative number.");if(!Number.isFinite(h)||h<0)throw new TypeError("sHeight must be a non-negative number.");if(!Number.isFinite(f))throw new TypeError("dx must be a number.");if(!Number.isFinite(m))throw new TypeError("dy must be a number.");if(!Number.isFinite(p)||p<0)throw new TypeError("dWidth must be a non-negative number.");if(!Number.isFinite(g)||g<0)throw new TypeError("dHeight must be a non-negative number.");if(this._closed)throw new Error("VideoSample is closed.");({sx:d,sy:l,sWidth:u,sHeight:h}=this._rotateSourceRegion(d,l,u,h,this.rotation));const y=this.toCanvasImageSource();e.save();const b=f+p/2,w=m+g/2;
1e.translate(b,w),e.rotate(this.rotation*Math.PI/180);const v=this.rotation%180==0?1:p/g;e.scale(1/v,v),e.drawImage(y,d,l,u,h,-p/2,-g/2,p,g),e.restore()}drawWithFit(e,t){if(!("undefined"!=typeof CanvasRenderingContext2D&&e instanceof CanvasRenderingContext2D||"undefined"!=typeof OffscreenCanvasRenderingContext2D&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!t||"object"!=typeof t)throw new TypeError("options must be an object.");if(!["fill","contain","cover"].includes(t.fit))throw new TypeError("options.fit must be 'fill', 'contain', or 'cover'.");if(void 0!==t.rotation&&![0,90,180,270].includes(t.rotation))throw new TypeError("options.rotation, when provided, must be 0, 90, 180, or 270.");void 0!==t.crop&&Cs(t.crop,"options.");const r=e.canvas.width,i=e.canvas.height,n=t.rotation??this.rotation,[a,s]=n%180==0?[this.squarePixelWidth,this.squarePixelHeight]:[this.squarePixelHeight,this.squarePixelWidth];let o,c,d,l,u=t.crop;u&&(u=Ss(u,a,s));const{sx:h,sy:f,sWidth:m,sHeight:p}=this._rotateSourceRegion(t.crop?.left??0,t.crop?.top??0,t.crop?.width??a,t.crop?.height??s,n);if("fill"===t.fit)o=0,c=0,d=r,l=i;else{const[e,n]=t.crop?[t.crop.width,t.crop.height]:[a,s],u="contain"===t.fit?Math.min(r/e,i/n):Math.max(r/e,i/n);d=e*u,l=n*u,o=(r-d)/2,c=(i-l)/2}e.save();const g=n%180==0?1:d/l;e.translate(r/2,i/2),e.rotate(n*Math.PI/180),e.scale(1/g,g),e.translate(-r/2,-i/2),e.drawImage(this.toCanvasImageSource(),h,f,m,p,o,c,d,l),e.restore()}_rotateSourceRegion(e,t,r,i,n){return 90===n?[e,t,r,i]=[t,this.squarePixelHeight-e-r,i,r]:180===n?[e,t]=[this.squarePixelWidth-e-r,this.squarePixelHeight-t-i]:270===n&&([e,t,r,i]=[this.squarePixelWidth-t-i,e,i,r]),{sx:e,sy:t,sWidth:r,sHeight:i}}toCanvasImageSource(){if(this._closed)throw new Error("VideoSample is closed.");if(l(null!==this._data),this._data instanceof ms||this._data instanceof Uint8Array){const e=this.toVideoFrame();return queueMicrotask(()=>e.close()),e}return this._data}async transform(e){if(!e||"object"!=typeof e)throw new TypeError("options must be an object.");if(void 0!==e.width&&(!Number.isInteger(e.width)||e.width<=0))throw new TypeError("options.width, when provided, must be a positive integer.");if(void 0!==e.height&&(!Number.isInteger(e.height)||e.height<=0))throw new TypeError("options.height, when provided, must be a positive integer.");if(void 0!==e.roundDimensionsTo&&(!Number.isInteger(e.roundDimensionsTo)||e.roundDimensionsTo<=0))throw new TypeError("options.roundDimensionsTo, when provided, must be a positive integer.");if(void 0!==e.fit&&!["fill","contain","cover"].includes(e.fit))throw new TypeError('options.fit, when provided, must be one of "fill", "contain", or "cover".');if(void 0!==e.width&&void 0!==e.height&&void 0===e.fit)throw new TypeError("When both options.width and options.height are provided, options.fit must also be provided.");if(void 0!==e.rotate&&![0,90,180,270].includes(e.rotate))throw new TypeError("options.rotate, when provided, must be 0, 90, 180 or 270.");if(void 0!==e.crop&&Cs(e.crop,"options."),void 0!==e.alpha&&!["keep","discard"].includes(e.alpha))throw new TypeError("options.alpha, when provided, must be 'keep' or 'discard'.");const t=u(this.rotation+(e.rotate??0)),[r,i]=t%180==0?[this.squarePixelWidth,this.squarePixelHeight]:[this.squarePixelHeight,this.squarePixelWidth];let n=e.crop;n&&(n=Ss(n,r,i));const a=n?n.width:r,s=n?n.height:i,o=a/s;let c,d;void 0!==e.width&&void 0===e.height?(c=e.width,d=c/o):void 0===e.width&&void 0!==e.height?(d=e.height,c=d*o):void 0!==e.width&&void 0!==e.height?(c=e.width,d=e.height):(c=a,d=s),c=H(c,e.roundDimensionsTo??1),d=H(d,e.roundDimensionsTo??1);const l={width:c,height:d,fit:e.fit??"fill",rotation:t,crop:n??{left:0,top:0,width:r,height:i},alpha:e.alpha??"keep"};for(const e of bs){let t=e(this,l);if(t instanceof Promise&&(t=await t),null!==t)return t}let h=null,f=!1;for(const e of vs)if(e.canvas.width===l.width&&e.canvas.height===l.height){h=e.canvas,e.age=ks++;break}if(null===h){if("undefined"!=typeof OffscreenCanvas)h=new OffscreenCanvas(l.width,l.height);else{if("undefined"==typeof window||"undefined"==typeof document)throw new Error("Cannot transform VideoSamples in this environment. Either run in an environment with OffscreenCanvas or HTMLCanvasElement, or supply a custom VideoSample transformer using registerVideoSampleTransformer().");h=document.createElement("canvas"),h.width=l.width,h.height=l.height}f=!0,vs.length>=ws&&vs.splice(be(vs,e=>e.age),1),vs.push({canvas:h,age:ks++})}const m=h.getContext("2d",{alpha:!0});if(!m)throw new Error("The '2d' canvas context is required to transform VideoSamples. Register a custom transformer using registerVideoSampleTransformer to work around this limitation.");return"discard"===l.alpha?(m.fillStyle="black",m.fillRect(0,0,l.width,l.height)):f||m.clearRect(0,0,l.width,l.height),this.drawWithFit(m,{fit:l.fit,rotation:l.rotation,crop:l.crop}),new ys(h,{timestamp:this.timestamp,duration:this.duration,rotation:0})}setRotation(e){if(![0,90,180,270].includes(e))throw new TypeError("newRotation must be 0, 90, 180, or 270.");this.rotation=e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}setDuration(e){if(!Number.isFinite(e)||e<0)throw new TypeError("newDuration must be a non-negative number.");this.duration=e}setEncodeOptions(e){if(!e||"object"!=typeof e)throw new TypeError("newEncodeOptions must be an object.");this.encodeOptions=e}[Symbol.dispose](){this.close()}}const bs=[],ws=3,vs=[];let ks=0;class Ts{constructor(e){if(void 0!==e){if(!e||"object"!=typeof e)throw new TypeError("init.colorSpace, when provided, must be an object.");const t=Object.keys(k);if(null!=e.primaries&&!t.includes(e.primaries))throw new TypeError(`init.colorSpace.primaries, when provided, must be one of ${t.join(", ")}.`);const r=Object.keys(x);if(null!=e.transfer&&!r.includes(e.transfer))throw new TypeError(`init.colorSpace.transfer, when provided, must be one of ${r.join(", ")}.`);const i=Object.keys(C);if(null!=e.matrix&&!i.includes(e.matrix))throw new TypeError(`init.colorSpace.matrix, when provided, must be one of ${i.join(", ")}.`);
1if(null!=e.fullRange&&"boolean"!=typeof e.fullRange)throw new TypeError("init.colorSpace.fullRange, when provided, must be a boolean.")}this.primaries=e?.primaries??null,this.transfer=e?.transfer??null,this.matrix=e?.matrix??null,this.fullRange=e?.fullRange??null}toJSON(){return{primaries:this.primaries,transfer:this.transfer,matrix:this.matrix,fullRange:this.fullRange}}}const xs=e=>"undefined"!=typeof VideoFrame&&e instanceof VideoFrame,Ss=(e,t,r)=>{const i=Math.min(e.left,t),n=Math.min(e.top,r),a=Math.min(e.width,t-i),s=Math.min(e.height,r-n);return l(a>=0),l(s>=0),{left:i,top:n,width:a,height:s}},Cs=(e,t)=>{if(!e||"object"!=typeof e)throw new TypeError(t+"crop, when provided, must be an object.");if(!Number.isInteger(e.left)||e.left<0)throw new TypeError(t+"crop.left must be a non-negative integer.");if(!Number.isInteger(e.top)||e.top<0)throw new TypeError(t+"crop.top must be a non-negative integer.");if(!Number.isInteger(e.width)||e.width<0)throw new TypeError(t+"crop.width must be a non-negative integer.");if(!Number.isInteger(e.height)||e.height<0)throw new TypeError(t+"crop.height must be a non-negative integer.")},Ps=e=>{if(!e||"object"!=typeof e)throw new TypeError("options must be an object.");if(void 0!==e.colorSpace&&!["display-p3","srgb"].includes(e.colorSpace))throw new TypeError("options.colorSpace, when provided, must be 'dis
1play-p3' or 'srgb'.");if(void 0!==e.format&&"string"!=typeof e.format)throw new TypeError("options.format, when provided, must be a string.");if(void 0!==e.layout){if(!Array.isArray(e.layout))throw new TypeError("options.layout, when provided, must be an array.");for(const t of e.layout){if(!t||"object"!=typeof t)throw new TypeError("Each entry in options.layout must be an object.");if(!Number.isInteger(t.offset)||t.offset<0)throw new TypeError("plane.offset must be a non-negative integer.");if(!Number.isInteger(t.stride)||t.stride<0)throw new TypeError("plane.stride must be a non-negative integer.")}}if(void 0!==e.rect){if(!e.rect||"object"!=typeof e.rect)throw new TypeError("options.rect, when provided, must be an object.");if(void 0!==e.rect.x&&(!Number.isInteger(e.rect.x)||e.rect.x<0))throw new TypeError("options.rect.x, when provided, must be a non-negative integer.");if(void 0!==e.rect.y&&(!Number.isInteger(e.rect.y)||e.rect.y<0))throw new TypeError("options.rect.y, when provided, must be a non-negative integer.");if(void 0!==e.rect.width&&(!Number.isInteger(e.rect.width)||e.rect.width<0))throw new TypeError("options.rect.width, when provided, must be a non-negative integer.");if(void 0!==e.rect.height&&(!Number.isInteger(e.rect.height)||e.rect.height<0))throw new TypeError("options.rect.height, when provided, must be a non-negative integer.")}},As=(e,t,r)=>{const i=Es(e),n=[];let a=0;for(const e of i){const i=Math.ceil(t/e.widthDivisor),s=Math.ceil(r/e.heightDivisor),o=i*e.sampleBytes,c=o*s;n.push({offset:a,stride:o}),a+=c}return n},Es=e=>{const t=(e,t,r,i,n)=>{const a=[{sampleBytes:e,widthDivisor:1,heightDivisor:1},{sampleBytes:t,widthDivisor:r,heightDivisor:i},{sampleBytes:t,widthDivisor:r,heightDivisor:i}];return n&&a.push({sampleBytes:e,widthDivisor:1,heightDivisor:1}),a};switch(e){case"I420":return t(1,1,2,2,!1);case"I420P10":case"I420P12":return t(2,2,2,2,!1);case"I420A":return t(1,1,2,2,!0);case"I420AP10":case"I420AP12":return t(2,2,2,2,!0);case"I422":return t(1,1,2,1,!1);case"I422P10":case"I422P12":return t(2,2,2,1,!1);case"I422A":return t(1,1,2,1,!0);case"I422AP10":case"I422AP12":return t(2,2,2,1,!0);case"I444":return t(1,1,1,1,!1);case"I444P10":case"I444P12":return t(2,2,1,1,!1);case"I444A":return t(1,1,1,1,!0);case"I444AP10":case"I444AP12":return t(2,2,1,1,!0);case"NV12":return[{sampleBytes:1,widthDivisor:1,heightDivisor:1},{sampleBytes:2,widthDivisor:2,heightDivisor:2}];case"RGBA":case"RGBX":case"BGRA":case"BGRX":return[{sampleBytes:4,widthDivisor:1,heightDivisor:1}];default:L(e),l(!1)}},ParseVideoFrameCopyToOptions=(e,t)=>{const r={left:0,top:0,width:e.codedWidth,height:e.codedHeight},i=t.rect,n=ParseVisibleRect(r,i,e.codedWidth,e.codedHeight,e.format),a=t.layout;let s;if(t.format&&t.format!==e.format){if(!["RGBA","RGBX","BGRA","BGRX"].includes(t.format))throw new Error("NotSupportedError: Invalid destination format.");s=t.format}else s=e.format;return ComputeLayoutAndAllocationSize(n,s,a)},ParseVisibleRect=(e,t,r,i,n)=>{const a={...e};if(void 0!==t){if(0===t.width||0===t.height)throw new TypeError("visibleRect dimensions cannot be zero.");if((t.x||0)+(t.width||0)>r)throw new TypeError("visibleRect exceeds codedWidth.");if((t.y||0)+(t.height||0)>i)throw new TypeError("visibleRect exceeds codedHeight.");a.x=t.x||0,a.y=t.y||0,a.width=t.width||0,a.height=t.height||0}if(!VerifyRectOffsetAlignment(n,a))throw new TypeError("visibleRect alignment is invalid for the format.");return a},VerifyRectOffsetAlignment=(e,t)=>{if(null===e)return!0;const r=Es(e);for(let e=0;e<r.length;e++){const i=r[e],n=i.widthDivisor,a=i.heightDivisor;if((t.x||0)%n!==0)return!1;if((t.y||0)%a!==0)return!1}return!0},ComputeLayoutAndAllocationSize=(e,t,r)=>{const i=Es(t),n=i.length;if(void 0!==r&&r.length!==n)throw new TypeError(`Layout must have ${n} planes.`);let a=0;const s=[],o=[];for(let t=0;t<n;t++){const n=i[t],c=n.sampleBytes,d=n.widthDivisor,l=n.heightDivisor,u={destinationOffset:0,destinationStride:0,sourceTop:0,sourceHeight:0,sourceLeftBytes:0,sourceWidthBytes:0};if(u.sourceTop=Math.ceil(Math.trunc(e.y||0)/l),u.sourceHeight=Math.ceil(Math.trunc(e.he
1ight||0)/l),u.sourceLeftBytes=Math.floor(Math.trunc(e.x||0)/d)*c,u.sourceWidthBytes=Math.floor(Math.trunc(e.width||0)/d)*c,void 0!==r){const e=r[t];if(e.stride<u.sourceWidthBytes)throw new TypeError(`Stride for plane ${t} is too small.`);u.destinationOffset=e.offset,u.destinationStride=e.stride}else u.destinationOffset=a,u.destinationStride=u.sourceWidthBytes;const h=u.destinationStride*u.sourceHeight+u.destinationOffset;if(h>4294967295)throw new TypeError("Allocation size exceeds limit.");o.push(h),a=Math.max(a,h);for(let e=0;e<t;e++){const r=s[e];if(!(o[t]<=r.destinationOffset||o[e]<=u.destinationOffset))throw new TypeError("Planes overlap.")}s.push(u)}return{allocationSize:a,computedLayouts:s}},Is=new Set(["f32","f32-planar","s16","s16-planar","s32","s32-planar","u8","u8-planar"]);class $s{constructor(){this._referenceCount=0}}class _s{get microsecondTimestamp(){return Math.trunc(J*this.timestamp)}get microsecondDuration(){return Math.trunc(J*this.duration)}constructor(e){if(this._closed=!1,Bs(e)){if(null===e.format)throw new TypeError("AudioData with null format is not supported.");this._data=e,this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=e.numberOfFrames,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp/1e6,this.duration=e.numberOfFrames/e.sampleRate}else if(e instanceof $s){if(this._data=e,e._referenceCount++,this.format=e.getFormat(),!Is.has(this.format))throw new TypeError("getFormat() must return an AudioSampleFormat.");if(this.sampleRate=e.getSampleRate(),!Number.isInteger(this.sampleRate)||this.sampleRate<=0)throw new TypeError("getSampleRate() must return a positive integer.");if(this.numberOfFrames=e.getNumberOfFrames(),!Number.isInteger(this.numberOfFrames)||this.numberOfFrames<0)throw new TypeError("getNumberOfFrames() must return a non-negative integer.");if(this.numberOfChannels=e.getNumberOfChannels(),!Number.isInteger(this.numberOfChannels)||this.numberOfChannels<=0)throw new TypeError("getNumberOfChannels() must return a positive integer.");if(this.timestamp=e.getTimestamp(),!Number.isFinite(this.timestamp))throw new TypeError("getTimestamp() must return a finite number.");this.duration=this.numberOfFrames/this.sampleRate}else{if(!e||"object"!=typeof e)throw new TypeError("Invalid AudioDataInit: must be an object.");if(!Is.has(e.format))throw new TypeError("Invalid AudioDataInit: invalid format.");if(!Number.isFinite(e.sampleRate)||e.sampleRate<=0)throw new TypeError("Invalid AudioDataInit: sampleRate must be > 0.");if(!Number.isInteger(e.numberOfChannels)||0===e.numberOfChannels)throw new TypeError("Invalid AudioDataInit: numberOfChannels must be an integer > 0.");if(!Number.isFinite(e?.timestamp))throw new TypeError("init.timestamp must be a number.");const t=e.data.byteLength/(Ns(e.format)*e.numberOfChannels);if(!Number.isInteger(t))throw new TypeError("Invalid AudioDataInit: data size is not a multiple of frame size.");let r;if(this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=t,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp,this.duration=t/e.sampleRate,e.data instanceof ArrayBuffer)r=new Uint8Array(e.data);else{if(!ArrayBuffer.isView(e.data))throw new TypeError("Invalid AudioDataInit: data is not a BufferSource.");r=new Uint8Array(e.data.buffer,e.data.byteOffset,e.data.byteLength)}const i=this.numberOfFrames*this.numberOfChannels*Ns(this.format);if(r.byteLength<i)throw new TypeError("Invalid AudioDataInit: insufficient data size.");this._data=r}fs?.register(this,{type:"audio",data:this._data},this)}allocationSize(e){if(!e||"object"!=typeof e)throw new TypeError("options must be an object.");if(!Number.isInteger(e.planeIndex)||e.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(void 0!==e.format&&!Is.has(e.format))throw new TypeError("Invalid format.");if(void 0!==e.frameOffset&&(!Number.isInteger(e.frameOffset)||e.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(void 0!==e.frameCount&&(!Number.isInteger(e.frameCount)||e.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");const t=e.format??this.format,r=e.frameOffset??0;if(r>=this.numberOfFrames)throw new RangeError("frameOffset out of range");const i=void 0!==e.frameCount?e.frameCount:this.numberOfFrames-r;if(i>this.numberOfFrames-r)throw new RangeError("frameCount out of range");const n=Ns(t),a=Rs(t);if(a&&e.planeIndex>=this.numberOfChannels)throw new RangeError("planeIndex out of range");if(!a&&0!==e.planeIndex)throw new RangeError("planeIndex out of range");return(a?i:i*this.numberOfChannels)*n}copyTo(e,t){if(!E(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(!t||"object"!=typeof t)throw new TypeError("options must be an object.");if(!Number.isInteger(t.planeIndex)||t.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(void 0!==t.format&&!Is.has(t.format))throw new TypeError("Invalid format.");if(void 0!==t.frameOffset&&(!Number.isInteger(t.frameOffset)||t.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(void 0!==t.frameCount&&(!Number.isInteger(t.frameCount)||t.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");const{format:r,frameCount:i,frameOffset:n}=t;let{planeIndex:a}=t;const s=this.format,o=r??this.format;if(!o)throw new Error("Destination format not determined");const c=this.numberOfFrames,d=this.numberOfChannels,l=n??0;if(l>=c)throw new RangeError("frameOffset out of range");const u=void 0!==i?i:c-l;if(u>c-l)throw new RangeError("frameCount out of range");const h=Ns(o),f=Rs(o);if(f&&a>=d)throw new RangeError("planeIndex out of range");if(!f&&0!==a)throw new RangeError("planeIndex out of range");const m=(f?u:u*d)*h;if(e.byteLength<m)throw new RangeError("Destination buffer is too small");const p=y(e),g=Fs(o);if(Bs(this._data))te()&&d>2&&o!==s?Ds(this._data,p,s,o,d,a,l,u):this._data.copyTo(e,{planeIndex:a,frameOffset:l,frameCount:u,format:o});else{const e=Os(s),t=Ns(s),r=Rs(s);let i;if(this._data instanceof $s){const e=e=>{const i=this._data.getDataPlane(e);if(!(i instanceof Uint8Array))throw new TypeError("getDataPlane() must return a Uint8Array.");const n=c*t*(r?1:d);if(i.byteLength!==n)throw new TypeError(`Data plane ${e}
1 has invalid size. Expected exactly ${n} bytes, got ${i.byteLength} bytes.`);return i};if(r)if(f)i=e(a),a=0;else{i=new Uint8Array(c*t*d);for(let r=0;r<d;r++){const n=e(r);i.set(n,r*c*t)}}else i=e(0)}else i=this._data;const n=y(i);for(let i=0;i<u;i++)if(f){let s;s=r?(a*c+(i+l))*t:((i+l)*d+a)*t;g(p,i*h,e(n,s))}else for(let a=0;a<d;a++){let s;s=r?(a*c+(i+l))*t:((i+l)*d+a)*t;g(p,(i*d+a)*h,e(n,s))}}}clone(){if(this._closed)throw new Error("AudioSample is closed.");if(this._data instanceof $s){const e=new _s(this._data);return e.setTimestamp(this.timestamp),e}if(Bs(this._data)){const e=new _s(this._data.clone());return e.setTimestamp(this.timestamp),e}return new _s({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.timestamp,data:this._data})}trim(e,t=this.numberOfFrames){if(!Number.isInteger(e)||e<0)throw new TypeError("startSample must be a non-negative integer.");if(!Number.isInteger(t)||t<0)throw new TypeError("endSample must be a non-negative integer.");if(e>this.numberOfFrames)throw new RangeError("startSample out of range.");if(t>this.numberOfFrames)throw new RangeError("endSample out of range.");if(t<e)throw new RangeError("endSample must not be less than startSample.");if(this._closed)throw new Error("AudioSample is closed.");const r=t-e,i=Ns(this.format);let n;if(Rs(this.format)){const t=r*i;if(n=new Uint8Array(t*this.numberOfChannels),r>0)for(let i=0;i<this.numberOfChannels;i++)this.copyTo(n.subarray(i*t,(i+1)*t),{planeIndex:i,format:this.format,frameOffset:e,frameCount:r})}else n=new Uint8Array(r*this.numberOfChannels*i),r>0&&this.copyTo(n,{planeIndex:0,format:this.format,frameOffset:e,frameCount:r});return new _s({data:n,format:this.format,sampleRate:this.sampleRate,numberOfChannels:this.numberOfChannels,timestamp:this.timestamp+e/this.sampleRate})}close(){this._closed||(fs?.unregister(this),this._data instanceof $s?(this._data._referenceCount--,0===this._data._referenceCount&&this._data.close()):Bs(this._data)?this._data.close():this._data=new Uint8Array(0),this._closed=!0)}toAudioData(){if(this._closed)throw new Error("AudioSample is closed.");return this._data instanceof $s?this._createAudioDataFromData():Bs(this._data)?this._data.timestamp===this.microsecondTimestamp?this._data.clone():this._createAudioDataFromData():new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:this._data.buffer instanceof ArrayBuffer?this._data.buffer:this._data.slice()})}_createAudioDataFromData(){if(Rs(this.format)){const e=this.allocationSize({planeIndex:0,format:this.format}),t=new ArrayBuffer(e*this.numberOfChannels);for(let r=0;r<this.numberOfChannels;r++)this.copyTo(new Uint8Array(t,r*e,e),{planeIndex:r,format:this.format});return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:t})}{const e=new ArrayBuffer(this.allocationSize({planeIndex:0,format:this.format}));return this.copyTo(e,{planeIndex:0,format:this.format}),new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:e})}}toAudioBuffer(){if(this._closed)throw new Error("AudioSample is closed.");const e=new AudioBuffer({numberOfChannels:this.numberOfChannels,length:this.numberOfFrames,sampleRate:this.sampleRate}),t=new Float32Array(this.allocationSize({planeIndex:0,format:"f32-planar"})/4);for(let r=0;r<this.numberOfChannels;r++)this.copyTo(t,{planeIndex:r,format:"f32-planar"}),e.copyToChannel(t,r);return e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}[Symbol.dispose](){this.close()}static*_fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");const r=e.numberOfChannels,i=e.sampleRate,n=e.length,a=Math.floor(24e4/r);let s=0,o=n;for(;o>0;){const n=Math.min(a,o),c=new Float32Array(r*n);for(let t=0;t<r;
1t++)e.copyFromChannel(c.subarray(t*n,(t+1)*n),t,s);yield new _s({format:"f32-planar",sampleRate:i,numberOfFrames:n,numberOfChannels:r,timestamp:t+s/i,data:c}),s+=n,o-=n}}static fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");const r=e.numberOfChannels,i=e.sampleRate,n=e.length,a=Math.floor(24e4/r);let s=0,o=n;const c=[];for(;o>0;){const n=Math.min(a,o),d=new Float32Array(r*n);for(let t=0;t<r;t++)e.copyFromChannel(d.subarray(t*n,(t+1)*n),t,s);const l=new _s({format:"f32-planar",sampleRate:i,numberOfFrames:n,numberOfChannels:r,timestamp:t+s/i,data:d});c.push(l),s+=n,o-=n}return c}}const Ns=e=>{switch(e){case"u8":case"u8-planar":return 1;case"s16":case"s16-planar":return 2;case"s32":case"s32-planar":case"f32":case"f32-planar":return 4;default:throw new Error("Unknown AudioSampleFormat")}},Rs=e=>{switch(e){case"u8-planar":case"s16-planar":case"s32-planar":case"f32-planar":return!0;default:return!1}},Os=e=>{switch(e){case"u8":case"u8-planar":return(e,t)=>(e.getUint8(t)-128)/128;case"s16":case"s16-planar":return(e,t)=>e.getInt16(t,!0)/32768;case"s32":case"s32-planar":return(e,t)=>e.getInt32(t,!0)/2147483648;case"f32":case"f32-planar":return(e,t)=>e.getFloat32(t,!0)}},Fs=e=>{switch(e){case"u8":case"u8-planar":return(e,t,r)=>e.setUint8(t,W(127.5*(r+1),0,255));case"s16":case"s16-planar":return(e,t,r)=>e.setInt16(t,W(Math.round(32767*r),-32768,32767),!0);case"s32":case"s32-planar":return(e,t,r)=>e.setInt32(t,W(Math.round(2147483647*r),-2147483648,2147483647),!0);case"f32":case"f32-planar":return(e,t,r)=>e.setFloat32(t,r,!0)}},Bs=e=>"undefined"!=typeof AudioData&&e instanceof AudioData,Ds=(e,t,r,i,n,a,s,o)=>{const c=Os(r),d=Fs(i),l=Ns(r),u=Ns(i),h=Rs(r);if(Rs(i))if(h){const i=new ArrayBuffer(o*l),n=y(i);e.copyTo(i,{planeIndex:a,frameOffset:s,frameCount:o,format:r});for(let e=0;e<o;e++){d(t,e*u,c(n,e*l))}}else{const i=new ArrayBuffer(o*n*l),h=y(i);e.copyTo(i,{planeIndex:0,frameOffset:s,frameCount:o,format:r});for(let e=0;e<o;e++){d(t,e*u,c(h,(e*n+a)*l))}}else if(h){const i=new ArrayBuffer(o*l),a=y(i);for(let h=0;h<n;h++){e.copyTo(i,{planeIndex:h,frameOffset:s,frameCount:o,format:r});for(let e=0;e<o;e++){d(t,(e*n+h)*u,c(a,e*l))}}}else{const i=new ArrayBuffer(o*n*l),a=y(i);e.copyTo(i,{planeIndex:0,frameOffset:s,frameCount:o,format:r});for(let e=0;e<o;e++)for(let r=0;r<n;r++){const i=e*n+r;d(t,i*u,c(a,i*l))}}};const Ms=e=>{if(!e||"object"!=typeof e)throw new TypeError("options must be an object.");if(void 0!==e.metadataOnly&&"boolean"!=typeof e.metadataOnly)throw new TypeError("options.metadataOnly, when defined, must be a boolean.");if(void 0!==e.verifyKeyPackets&&"boolean"!=typeof e.verifyKeyPackets)throw new TypeError("options.verifyKeyPackets, when defined, must be a boolean.");if(e.verifyKeyPackets&&e.metadataOnly)throw new TypeError("options.verifyKeyPackets and options.metadataOnly cannot be enabled together.");if(void 0!==e.skipLiveWait&&"boolean"!=typeof e.skipLiveWait)throw new TypeError("options.skipLiveWait, when defined, must be a boolean.")},js=e=>{if(!pe(e))throw new TypeError("timestamp must be a number.")},Ls=(e,t,r)=>r.verifyKeyPackets?t.then(async t=>{if(!t||"delta"===t.type)return t;const r=await e.determinePacketType(t);return r&&(t.type=r),t}):t;class Us{constructor(e){if(!(e instanceof eo))throw new TypeError("track must be an InputTrack.");this._track=e}async getFirstPacket(e={}){if(Ms(e),this._track.input._disposed)throw new InputDisposedError;return Ls(this._track,this._track._backing.getFirstPacket(e),e)}async getFirstKeyPacket(e={}){Ms(e);const t=await this.getFirstPacket(e);return t?"key"===t.type?t:this.getNextKeyPacket(t,e):null}async getPacket(e,t={}){if(js(e),Ms(t),this._track.input._disposed)throw new InputDisposedError;return Ls(this._track,this._track._backing.getPacket(e,t),t)}async getNextPacket(e,t={}){if(!(e instanceof Yt))throw new TypeError("packet must be an EncodedPacket.");if(Ms(t),this._track.input._disposed)throw new InputDisposedError;return Ls(this._track,this._track._backing.getNextPacket(e,t),t)}async getKeyPacket(e,t={}){if(js(e),Ms(t),this._track.input._disposed)throw new InputDisposedError;if(!t.verifyKeyPackets)return this._track._backing.getKeyPacket(e,t);const r=await this._track._backing.getKeyPacket(e,t);if(!r)return r;l("key"===r.type);return"delta"===await this._track.determinePacketType(r)?this.getKeyPacket(r.timestamp-1/await this._track.getTimeResolution(),t):r}async getNextKeyPacket(e,t={}){if(!(e instanceof Yt))throw new TypeError("packet must be an EncodedPacket.");if(Ms(t),this._track.input._disposed)throw new InputDisposedError;if(!t.verifyKeyPackets)return this._track._backing.getNextKeyPacket(e,t);const r=await this._track._backing.getNextKeyPacket(e,t);if(!r)return r;l("key"===r.type);return"delta"===await this._track.determinePacketType(r)?this.getNextKeyPacket(r,t):r}packets(e,t,r={}){if(void 0!==e&&!(e instanceof Yt))throw new TypeError("startPacket must be an EncodedPacket.");if(void 0!==e&&e.isMetadataOnly&&!r?.metadataOnly)throw new TypeError("startPacket can only be metadata-only if options.metadataOnly is enabled.");
1if(void 0!==t&&!(t instanceof Yt))throw new TypeError("endPacket must be an EncodedPacket.");if(Ms(r),this._track.input._disposed)throw new InputDisposedError;const i=[];let{promise:n,resolve:a}=B(),{promise:s,resolve:o}=B(),c=!1,d=!1,l=null;const u=[],h=()=>Math.max(2,u.length);(async()=>{let l=e??await this.getFirstPacket(r);for(;l&&!d&&!this._track.input._disposed&&!(t&&l.sequenceNumber>=t?.sequenceNumber);)i.length>h()?(({promise:s,resolve:o}=B()),await s):(i.push(l),a(),({promise:n,resolve:a}=B()),l=await this.getNextPacket(l,r));c=!0,a()})().catch(e=>{l||(l=e,a())});const f=this._track;return{async next(){for(;;){if(f.input._disposed)throw new InputDisposedError;if(d)return{value:void 0,done:!0};if(l)throw l;if(i.length>0){const e=i.shift(),t=performance.now();for(u.push(t);u.length>0&&t-u[0]>=1e3;)u.shift();return o(),{value:e,done:!1}}if(c)return{value:void 0,done:!0};await n}},return:async()=>(d=!0,o(),a(),{value:void 0,done:!0}),async throw(e){throw e},[Symbol.asyncIterator](){return this}}}}class zs{constructor(e,t){this.onSample=e,this.onError=t}}class Ws{mediaSamplesInRange(e=-1/0,t=1/0,r){js(e),js(t);const i=[];let n=!1,a=null,{promise:s,resolve:o}=B(),{promise:c,resolve:d}=B(),l=!1,u=!1,h=!1,f=null;const m={...r,verifyKeyPackets:!0,metadataOnly:!1};(async()=>{const r=await this._createDecoder(r=>{d(),r.timestamp>=t&&(u=!0),u?r.close():(a&&(r.timestamp>e?(i.push(a),n=!0):a.close()),r.timestamp>=e&&(i.push(r),n=!0),a=n?null:r,i.length>0&&(o(),({promise:s,resolve:o}=B())))},e=>{f||(f=e,o())}),p=this._createPacketSink(),g=await p.getKeyPacket(e,m)??await p.getFirstKeyPacket(m);let y=g;const b=p.packets(g??void 0,void 0,m);for(await b.next();y&&!u&&!this._track.input._disposed;){const e=Vs(i.length);if(i.length+r.getDecodeQueueSize()>e){({promise:c,resolve:d}=B()),await c;continue}r.decode(y);const t=await b.next();if(t.done)break;y=t.value}await b.return(),h||this._track.input._disposed||await r.flush(),r.close(),!n&&a&&i.push(a),l=!0,o()})().catch(e=>{f||(f=e,o())});const p=this._track,g=()=>{a?.close();for(const e of i)e.close()};return{async next(){for(;;){if(p.input._disposed)throw g(),new InputDisposedError;if(h)return{value:void 0,done:!0};if(f)throw g(),f;if(i.length>0){const e=i.shift();return d(),{value:e,done:!1}}if(l)return{value:void 0,done:!0};await s}},return:async()=>(h=!0,u=!0,d(),o(),g(),{value:void 0,done:!0}),async throw(e){throw e},[Symbol.asyncIterator](){return this}}}mediaSamplesAtTimestamps(e,t){(e=>{if(!(Symbol.iterator in e)&&!(Symbol.asyncIterator in e))throw new TypeError("Argument must be an iterable or async iterable.")})(e);const r=async function*(e){Symbol.iterator in e?yield*e[Symbol.iterator]():yield*e[Symbol.asyncIterator]()}(e),i=[],n=[];let{promise:a,resolve:s}=B(),{promise:o,resolve:c}=B(),d=!1,u=!1,h=null;const f=e=>{n.push(e),s(),({promise:a,resolve:s}=B())},m={...t,verifyKeyPackets:!0,metadataOnly:!1};(async()=>{const e=await this._createDecoder(e=>{if(c(),u)return void e.close();let t=0;for(;i.length>0&&e.timestamp-i[0]>-1e-10;)t++,i.shift();if(t>0)for(let r=0;r<t;r++)f(r<t-1?e.clone():e);else e.close()},e=>{h||(h=e,s())}),t=this._createPacketSink();let a=null,p=null,g=-1;const y=async()=>{l(p);let r=p;for(e.decode(r);r.sequenceNumber<g;){const i=Vs(n.length);for(;n.length+e.getDecodeQueueSize()>i&&!u;)({promise:o,resolve:c}=B()),await o;if(u)break;const a=await t.getNextPacket(r,m);l(a),e.decode(a),r=a}g=-1},b=async()=>{await e.flush();for(let e=0;e<i.length;e++)f(null);i.length=0};for await(const e of r){if(js(e),u||this._track.input._disposed)break;const r=await t.getPacket(e,m),n=r&&await t.getKeyPacket(e,m);n?(a&&(n.sequenceNumber!==p.sequenceNumber||r.timestamp<a.timestamp)&&(await y(),await b()),i.push(r.timestamp),g=Math.max(r.sequenceNumber,g),a=r,p=n):(-1!==g&&(await y(),await b()),f(null),a=null)}u||this._track.input._disposed||(-1!==g&&await y(),await b()),e.close(),d=!0,s()})().catch(e=>{h||(h=e,s())});const p=this._track,g=()=>{for(const e of n)e?.close()};return{async next(){for(;;){if(p.input._disposed)throw g(),new InputDisposedError;if(u)return{value:void 0,done:!0};if(h)throw g(),h;if(n.length>0){const e=n.shift();return l(void 0!==e),c(),{value:e,done:!1}}if(d)return{value:void 0,done:!0};await a}},return:async()=>(u=!0,c(),s(),g(),{value:void 0,done:!0}),async throw(e){throw e},[Symbol.asyncIterator](){return this}}}}const Vs=e=>0===e?40:8;class qs extends zs{constructor(e,t,r,i,n,a){super(e,t),this.codec=r,this.decoderConfig=i,this.rotation=n,this.timeResolution=a,this.decoder=null,this.customDecoder=null,this.customDecoderCallSerializer
1=new Z,this.customDecoderQueueSize=0,this.inputTimestamps=[],this.sampleQueue=[],this.currentPacketIndex=0,this.raslSkipped=!1,this.alphaDecoder=null,this.alphaHadKeyframe=!1,this.colorQueue=[],this.alphaQueue=[],this.merger=null,this.decodedAlphaChunkCount=0,this.alphaDecoderQueueSize=0,this.nullAlphaFrameQueue=[],this.currentAlphaPacketIndex=0,this.alphaRaslSkipped=!1,this.frameHandlerSerializer=new Z;const s=as.find(e=>e.supports(r,i));if(s)this.customDecoder=new s,this.customDecoder.codec=r,this.customDecoder.config=i,this.customDecoder.onSample=e=>{if(!(e instanceof ys))throw new TypeError("The argument passed to onSample must be a VideoSample.");this.finalizeAndEmitSample(e)},this.customDecoderCallSerializer.call(()=>this.customDecoder.init());else{const e=e=>{this.frameHandlerSerializer.call(async()=>{if(this.alphaQueue.length>0){const t=this.alphaQueue.shift();l(void 0!==t),await this.mergeAlpha(e,t)}else this.colorQueue.push(e)}).catch(e=>this.onError(e))};if("avc"===r&&this.decoderConfig.description&&ae()){const e=mt(g(this.decoderConfig.description));if(e&&e.sequenceParameterSets.length>0){const t=gt(e.sequenceParameterSets[0]);t&&0===t.frameMbsOnlyFlag&&(this.decoderConfig={...this.decoderConfig,hardwareAcceleration:"prefer-software"})}}const t=new Error("Decoding error").stack;this.decoder=new VideoDecoder({output:t=>{try{e(t)}catch(e){this.onError(e)}},error:e=>{e.stack=t,this.onError(e)}}),this.decoder.configure(this.decoderConfig)}}getDecodeQueueSize(){return this.customDecoder?this.customDecoderQueueSize:(l(this.decoder),Math.max(this.decoder.decodeQueueSize,this.alphaDecoder?.decodeQueueSize??0))}decode(e){if("hevc"===this.codec&&this.currentPacketIndex>
10&&!this.raslSkipped){if(this.hasHevcRaslPicture(e.data))return;this.raslSkipped=!0}if(this.customDecoder)this.customDecoderQueueSize++,this.customDecoderCallSerializer.call(()=>this.customDecoder.decode(e)).then(()=>this.customDecoderQueueSize--);else{if(l(this.decoder),te()||F(this.inputTimestamps,e.timestamp,e=>e),ae()&&0===this.currentPacketIndex)if("avc"===this.codec){const t=[];for(const r of ot(e.data,this.decoderConfig)){const i=ct(e.data[r.offset]);i===it.AUD&&(t.length=0),i>=20&&i<=31||t.push(e.data.subarray(r.offset,r.offset+r.length))}const r=((e,t)=>{if(t.description){const r=3&g(t.description)[4];return ht(e,r+1)}return ut(e)})(t,this.decoderConfig);e=new Yt(r,e.type,e.timestamp,e.duration)}else if("hevc"===this.codec){const t=$t(e.data,this.decoderConfig);t&&(e=new Yt(t,e.type,e.timestamp,e.duration))}this.decoder.decode(e.toEncodedVideoChunk()),this.decodeAlphaData(e)}this.currentPacketIndex++}decodeAlphaData(e){if(!e.sideData.alpha)return void this.pushNullAlphaFrame();if(this.merger||(this.merger=new Gs),!this.alphaDecoder){const e=e=>{this.frameHandlerSerializer.call(async()=>{if(this.colorQueue.length>0){const t=this.colorQueue.shift();l(void 0!==t),await this.mergeAlpha(t,e)}else this.alphaQueue.push(e);for(this.decodedAlphaChunkCount++;this.nullAlphaFrameQueue.length>0&&this.nullAlphaFrameQueue[0]===this.decodedAlphaChunkCount;)if(this.nullAlphaFrameQueue.shift(),this.colorQueue.length>0){const e=this.colorQueue.shift();l(void 0!==e),await this.mergeAlpha(e,null)}else this.alphaQueue.push(null);this.alphaDecoderQueueSize--}).catch(e=>this.onError(e))},t=new Error("Decoding error").stack;this.alphaDecoder=new VideoDecoder({output:t=>{try{e(t)}catch(e){this.onError(e)}},error:e=>{e.stack=t,this.onError(e)}}),this.alphaDecoder.configure(this.decoderConfig)}const t=Dt(this.codec,this.decoderConfig,e.sideData.alpha);if(this.alphaHadKeyframe||(this.alphaHadKeyframe="key"===t),this.alphaHadKeyframe){if("hevc"===this.codec&&this.currentAlphaPacketIndex>
10&&!this.alphaRaslSkipped){if(this.hasHevcRaslPicture(e.sideData.alpha))return void this.pushNullAlphaFrame();this.alphaRaslSkipped=!0}this.currentAlphaPacketIndex++,this.alphaDecoder.decode(e.alphaToEncodedVideoChunk(t??e.type)),this.alphaDecoderQueueSize++}else this.pushNullAlphaFrame()}pushNullAlphaFrame(){0===this.alphaDecoderQueueSize?this.alphaQueue.push(null):this.nullAlphaFrameQueue.push(this.decodedAlphaChunkCount+this.alphaDecoderQueueSize)}hasHevcRaslPicture(e){for(const t of bt(e,this.decoderConfig)){const r=wt(e[t.offset]);if(r===nt.RASL_N||r===nt.RASL_R)return!0}return!1}sampleHandler(e){if(te()){if(this.sampleQueue.length>0&&e.timestamp>=h(this.sampleQueue).timestamp){for(const e of this.sampleQueue)this.finalizeAndEmitSample(e);this.sampleQueue.length=0}F(this.sampleQueue,e,e=>e.timestamp)}else{const t=this.inputTimestamps.shift();l(void 0!==t),e.setTimestamp(t),this.finalizeAndEmitSample(e)}}finalizeAndEmitSample(e){e.setTimestamp(Math.round(e.timestamp*this.timeResolution)/this.timeResolution),e.setDuration(Math.round(e.duration*this.timeResolution)/this.timeResolution),e.setRotation(this.rotation),this.onSample(e)}async mergeAlpha(e,t){if(!t){const t=new ys(e);return void this.sampleHandler(t)}l(this.merger);const r=await this.merger.update(e,t),i=new ys(r);this.sampleHandler(i)}async flush(){if(this.customDecoder?await this.customDecoderCallSerializer.call(()=>this.customDecoder.flush()):(l(this.decoder),await Promise.all([this.decoder.flush(),this.alphaDecoder?.flush()]),await this.frameHandlerSerializer.currentPromise,this.colorQueue.forEach(e=>e.close()),this.colorQueue.length=0,this.alphaQueue.forEach(e=>e?.close()),this.alphaQueue.length=0,this.alphaHadKeyframe=!1,this.decodedAlphaChunkCount=0,this.alphaDecoderQueueSize=0,this.nullAlphaFrameQueue.length=0,this.currentAlphaPacketIndex=0,this.alphaRaslSkipped=!1),te()){for(const e of this.sampleQueue)this.finalizeAndEmitSample(e);this.sampleQueue.length=0}this.currentPacketIndex=0,this.raslSkipped=!1}close(){this.customDecoder?this.customDecoderCallSerializer.call(()=>this.customDecoder.close()):(l(this.decoder),this.decoder.close(),this.alphaDecoder?.close(),this.colorQueue.forEach(e=>e.close()),this.colorQueue.length=0,this.alphaQueue.forEach(e=>e?.close()),this.alphaQueue.length=0,this.merger?.close());for(const e of this.sampleQueue)e.close();this.sampleQueue.length=0}}let Hs=!1;class Gs{constructor(){this.canvas=null,this.gl=null,this.program=null,this.vao=null,this.colorTexture=null,this.alphaTexture=null,this.worker=null,this.pendingRequests=new Map,this.nextRequestId=0;const e="undefined"!=typeof OffscreenCanvas||"undefined"!=typeof document&&"function"==typeof document.createElement;if(!Gs.forceCpu&&e&&!Hs)try{"undefined"!=typeof OffscreenCanvas?this.canvas=new OffscreenCanvas(300,150):this.canvas=document.createElement("canvas");const e=this.canvas.getContext("webgl2",{premultipliedAlpha:!1});if(!e)throw new Error("Couldn't acquire WebGL 2 context.");this.gl=e,this.program=this.createProgram(),this.vao=this.createVAO(),this.colorTexture=this.createTexture(),this.alphaTexture=this.createTexture(),this.gl.useProgram(this.program),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_colorTexture"),0),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_alphaTexture"),1)}catch(e){this.gl=null,this.canvas=null,Hs=!0,d._warn("Falling back to CPU for color/alpha merging.",e)}}async update(e,t){return this.gl?this.updateGpu(e,t):this.updateCpu(e,t)}createProgram(){l(this.gl);const e=this.createShader(this.gl.VERTEX_SHADER,"#version 300 es\n\t\t\tin vec2 a_position;\n\t\t\tin vec2 a_texCoord;\n\t\t\tout vec2 v_texCoord;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tgl_Position = vec4(a_position, 0.0, 1.0);\n\t\t\t\tv_texCoord = a_texCoord;\n\t\t\t}\n\t\t"),t=this.createShader(this.gl.FRAGMENT_SHADER,"#version 300 es\n\t\t\tprecision highp float;\n\t\t\t\n\t\t\tuniform sampler2D u_colorTexture;\n\t\t\tuniform sampler2D u_alphaTexture;\n\t\t\tin vec2 v_texCoord;\n\t\t\tout vec4 fragColor;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tvec3 color = texture(u_colorTexture, v_texCoord).rgb;\n\t\t\t\tfloat alpha = texture(u_alphaTexture, v_texCoord).r;\n\t\t\t\tfragColor = vec4(color, alpha);\n\t\t\t}\n\t\t"),r=this.gl.createProgram();return this.gl.attachShader(r,e),this.gl.attachShader(r,t),this.gl.linkProgram(r),r}createShader(e,t){l(this.gl);const r=this.gl.createShader(e);return this.gl.shaderSource(r,t),this.gl.compileShader(r),r}
1createVAO(){l(this.gl),l(this.program);const e=this.gl.createVertexArray();this.gl.bindVertexArray(e);const t=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),r=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,r),this.gl.bufferData(this.gl.ARRAY_BUFFER,t,this.gl.STATIC_DRAW);const i=this.gl.getAttribLocation(this.program,"a_position"),n=this.gl.getAttribLocation(this.program,"a_texCoord");return this.gl.enableVertexAttribArray(i),this.gl.vertexAttribPointer(i,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(n),this.gl.vertexAttribPointer(n,2,this.gl.FLOAT,!1,16,8),e}createTexture(){l(this.gl);const e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),e}updateGpu(e,t){l(this.gl),l(this.canvas),e.displayWidth===this.canvas.width&&e.displayHeight===this.canvas.height||(this.canvas.width=e.displayWidth,this.canvas.height=e.displayHeight),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.colorTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this.alphaTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4);const r=new VideoFrame(this.canvas,{timestamp:e.timestamp,duration:e.duration??void 0});return e.close(),t.close(),r}updateCpu(e,t){if(!this.worker){const e=new Blob([`(${Ks.toString()})()`],{type:"application/javascript"}),t=URL.createObjectURL(e);this.worker=new Worker(t),URL.revokeObjectURL(t),this.worker.addEventListener("message",e=>{const t=e.data,r=this.pendingRequests.get(t.id);r&&(this.pendingRequests.delete(t.id),"error"in t?r.reject(new Error(t.error)):r.resolve(t.frame))}),this.worker.addEventListener("error",e=>{const t=new Error(e.message||"Color/alpha merge worker error.");for(const e of this.pendingRequests.values())e.reject(t);this.pendingRequests.clear()})}const r=this.nextRequestId++,i=B();return this.pendingRequests.set(r,i),this.worker.postMessage({id:r,color:e,alpha:t},{transfer:[e,t]}),i.promise}close(){this.gl?.getExtension("WEBGL_lose_context")?.loseContext(),this.gl=null,this.canvas=null,this.worker?.terminate(),this.worker=null;const e=new Error("Color/alpha merger closed.");for(const t of this.pendingRequests.values())t.reject(e);this.pendingRequests.clear()}}Gs.forceCpu=!0;const Ks=()=>{let e=null,t=null,r=Promise.resolve();self.addEventListener("message",e=>{const{id:t,color:n,alpha:a}=e.data;r=r.then(async()=>{try{const e=await i(n,a);self.postMessage({id:t,frame:e},{transfer:[e]})}catch(e){self.postMessage({id:t,error:e.message})}finally{n.close(),a.close()}})});const i=async(e,t)=>{const r=e.format,i=t.format;if(!r||!i)throw new Error("CPU color/alpha merging requires a known VideoFrame format.");const o=r.includes("P10"),c=r.includes("P12"),d=i.includes("P10"),l=i.includes("P12");if(d!==o||l!==c)throw new Error(`CPU color/alpha merging requires the alpha frame to have the same bit depth as the color frame (color: '${r}', alpha: '${i}').`);const u=e.codedWidth,h=e.codedHeight;if("RGBX"===r||"RGBA"===r||"BGRX"===r||"BGRA"===r)return await n(e,t,u,h,r);if("I420"===r||"I420P10"===r||"I420P12"===r||"I422"===r||"I422P10"===r||"I422P12"===r||"I444"===r||"I444P10"===r||"I444P12"===r)return await a(e,t,u,h,r);if("NV12"===r)return await s(e,t,u,h);throw new Error(`CPU color/alpha merging does not support format '${r}'.`)},n=async(e,t,r,i,n)=>{const a=r*i,s=new Uint8Array(4*a);await e.copyTo(s);const c=await o(t,r,i,1);for(let e=0,t=3;e<a;e++,t+=4)s[t]=c[e];const d={format:"RGBX"===n||"RGBA"===n?"RGBA":"BGRA",codedWidth:r,codedHeight:i,timestamp:e.timestamp,duration:e.duration??void 0,transfer:[s.buffer]};return new VideoFrame(s,d)},a=async(e,t,r,i,n)=>{const a=n.includes("P10"),s=n.includes("P12"),c=a||s?2:1;let d,l;n.startsWith("I420")?(d=Math.ceil(r/2),l=Math.ceil(i/2)):n.startsWith("I422")?(d=Math.ceil(r/2),l=i):(d=r,l=i);const u=r*i,h=u*c,f=d*l*c,m=new Uint8Array(h+2*f+u*c);await e.copyTo(m);const p=await o(t,r,i,c),g=h+2*f;m.set(p,g);const y={format:n.slice(0,4)+"A"+n.slice(4),codedWidth:r,codedHeight:i,timestamp:e.timestamp,duration:e.duration??void 0,transfer:[m.buffer]};return new VideoFrame(m,y)},s=async(e,r,i,n)=>{const a=i*n,s=Math.ceil(i/2)*Math.ceil(n/2),c=e.allocationSize();t&&t.byteLength===c||(t=new Uint8Array(c)),await e.copyTo(t);const d=new Uint8Array(a+2*s+a);d.set(t.subarray(0,a),0);const l=a,u=a+s,h=a;for(let e=0;e<s;e++)d[l+e]=t[h+2*e],d[u+e]=t[h+2*e+1];const f=await o(r,i,n,1);d.set(f,a+2*s);
1const m={format:"I420A",codedWidth:i,codedHeight:n,timestamp:e.timestamp,duration:e.duration??void 0,transfer:[d.buffer]};return new VideoFrame(d,m)},o=async(t,r,i,n)=>{const a=t.allocationSize();e&&e.byteLength===a||(e=new Uint8Array(a)),await t.copyTo(e);const s=t.format;if("RGBA"===s||"BGRA"===s||"RGBX"===s||"BGRX"===s){const t="RGBA"===s||"RGBX"===s?0:2,n=r*i;for(let r=0;r<n;r++)e[r]=e[4*r+t];return e.subarray(0,n)}return e.subarray(0,r*i*n)}},Ys=e=>{if(!e||"object"!=typeof e)throw new TypeError("decoderOptions must be an object.");if(void 0!==e.hardwareAcceleration&&!["no-preference","prefer-hardware","prefer-software"].includes(e.hardwareAcceleration))throw new TypeError("decoderOptions.hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.");if(void 0!==e.optimizeForLatency&&"boolean"!=typeof e.optimizeForLatency)throw new TypeError("decoderOptions.optimizeForLatency, when provided, must be a boolean.")};class Xs extends Ws{constructor(e,t={}){if(!(e instanceof io))throw new TypeError("videoTrack must be an InputVideoTrack.");Ys(t),super(),this._track=e,this._decoderOptions=t}async _createDecoder(e,t){if(!await this._track.canDecode())throw new Error("This video track cannot be decoded by this browser. Make sure to check decodability before using a track.");const r=await this._track.getCodec(),i=await this._track.getRotation();let n=await this._track.getDecoderConfig();const a=await this._track.getTimeResolution();return l(r&&n),n={...n,hardwareAcceleration:this._decoderOptions.hardwareAcceleration,optimizeForLatency:this._decoderOptions.optimizeForLatency},new qs(e,t,r,n,i,a)}_createPacketSink(){return new Us(this._track)}async getSample(e,t={}){js(e);for await(const r of this.mediaSamplesAtTimestamps([e],t))return r;throw new Error("Internal error: Iterator returned nothing.")}samples(e,t,r={}){return this.mediaSamplesInRange(e,t,r)}samplesAtTimestamps(e,t={}){return this.mediaSamplesAtTimestamps(e,t)}}
1class Qs extends zs{constructor(e,t,r,i){super(e,t),this.decoder=null,this.customDecoder=null,this.customDecoderCallSerializer=new Z,this.customDecoderQueueSize=0,this.currentTimestamp=null,this.expectedFirstTimestamp=null,this.timestampOffset=0;const n=t=>{let r=t.timestamp;this.expectedFirstTimestamp&&null===this.currentTimestamp&&(this.timestampOffset=this.expectedFirstTimestamp-r),r+=this.timestampOffset,(null===this.currentTimestamp||Math.abs(r-this.currentTimestamp)>=t.duration)&&(this.currentTimestamp=r);const n=this.currentTimestamp;if(this.currentTimestamp+=t.duration,0===t.numberOfFrames)return void t.close();const a=i.sampleRate;t.setTimestamp(Math.round(n*a)/a),e(t)},a=ss.find(e=>e.supports(r,i));if(a)this.customDecoder=new a,this.customDecoder.codec=r,this.customDecoder.config=i,this.customDecoder.onSample=e=>{if(!(e instanceof _s))throw new TypeError("The argument passed to onSample must be an AudioSample.");n(e)},this.customDecoderCallSerializer.call(()=>this.customDecoder.init());else{const e=new Error("Decoding error").stack;this.decoder=new AudioDecoder({output:e=>{try{n(new _s(e))}catch(e){this.onError(e)}},error:t=>{t.stack=e,this.onError(t)}}),this.decoder.configure(i)}}getDecodeQueueSize(){return this.customDecoder?this.customDecoderQueueSize:(l(this.decoder),this.decoder.decodeQueueSize)}decode(e){this.customDecoder?(this.customDecoderQueueSize++,this.customDecoderCallSerializer.call(()=>this.customDecoder.decode(e)).then(()=>this.customDecoderQueueSize--)):(l(this.decoder),this.expectedFirstTimestamp??=e.timestamp,this.decoder.decode(e.toEncodedAudioChunk()))}async flush(){this.customDecoder?await this.customDecoderCallSerializer.call(()=>this.customDecoder.flush()):(l(this.decoder),await this.decoder.flush()),this.currentTimestamp=null,this.expectedFirstTimestamp=null,this.timestampOffset=0}close(){this.customDecoder?this.customDecoderCallSerializer.call(()=>this.customDecoder.close()):(l(this.decoder),this.decoder.close())}}class Js extends zs{constructor(e,t,r){super(e,t),this.decoderConfig=r,this.currentTimestamp=null,l(Ae.includes(r.codec)),this.codec=r.codec;const{dataType:i,sampleSize:n,littleEndian:a}=Ve(this.codec);switch(this.inputSampleSize=n,n){case 1:"unsigned"===i?this.readInputValue=(e,t)=>e.getUint8(t)-128:"signed"===i?this.readInputValue=(e,t)=>e.getInt8(t):"ulaw"===i?this.readInputValue=(e,t)=>(e=>{let t=0,r=0,i=~e;128&i&&(i&=-129,t=-1),r=5+((240&i)>>4);const n=(1<<r|(15&i)<<r-4|1<<r-5)-33;return 0===t?n:-n})(e.getUint8(t)):"alaw"===i?this.readInputValue=(e,t)=>(e=>{let t=0,r=0,i=85^e;128&i&&(i&=-129,t=-1),r=4+((240&i)>>4);let n=0;return n=4!==r?1<<r|(15&i)<<r-4|1<<r-5:i<<1|1,0===t?n:-n})(e.getUint8(t)):l(!1);break;case 2:"unsigned"===i?this.readInputValue=(e,t)=>e.getUint16(t,a)-32768:"signed"===i?this.readInputValue=(e,t)=>e.getInt16(t,a):l(!1);break;case 3:"unsigned"===i?this.readInputValue=(e,t)=>U(e,t,a)-2**23:"signed"===i?this.readInputValue=(e,t)=>((e,t,r)=>U(e,t,r)<<8>>8)(e,t,a):l(!1);break;case 4:"unsigned"===i?this.readInputValue=(e,t)=>e.getUint32(t,a)-2**31:"signed"===i?this.readInputValue=(e,t)=>e.getInt32(t,a):"float"===i?this.readInputValue=(e,t)=>e.getFloat32(t,a):l(!1);break;case 8:"float"===i?this.readInputValue=(e,t)=>e.getFloat64(t,a):l(!1);break;default:L(n),l(!1)}switch(n){case 1:"ulaw"===i||"alaw"===i?(this.outputSampleSize=2,this.outputFormat="s16",this.writeOutputValue=(e,t,r)=>e.setInt16(t,r,!0)):(this.outputSampleSize=1,this.outputFormat="u8",this.writeOutputValue=(e,t,r)=>e.setUint8(t,r+128));break;case 2:this.outputSampleSize=2,this.outputFormat="s16",this.writeOutputValue=(e,t,r)=>e.setInt16(t,r,!0);break;case 3:this.outputSampleSize=4,this.outputFormat="s32",this.writeOutputValue=(e,t,r)=>e.setInt32(t,r<<8,!0);break;case 4:this.outputSampleSize=4,"float"===i?(this.outputFormat="f32",this.writeOutputValue=(e,t,r)=>e.setFloat32(t,r,!0)):(this.outputFormat="s32",this.writeOutputValue=(e,t,r)=>e.setInt32(t,r,!0));break;case 8:this.outputSampleSize=4,this.outputFormat="f32",this.writeOutputValue=(e,t,r)=>e.setFloat32(t,r,!0);break;default:L(n),l(!1)}}getDecodeQueueSize(){return 0}decode(e){const t=y(e.data),r=e.byteLength/this.decoderConfig.numberOfChannels/this.inputSampleSize,i=r*this.decoderConfig.numberOfChannels*this.outputSampleSize,n=new ArrayBuffer(i),a=new DataView(n);for(let e=0;e<r*this.decoderConfig.numberOfChannels;e++){const r=e*this.inputSampleSize,i=e*this.outputSampleSize,n=this.readInputValue(t,r);this.writeOutputValue(a,i,n)}const s=r/this.decoderConfig.sampleRate;(null===this.currentTimestamp||Math.abs(e.timestamp-this.currentTimestamp)>=s)&&(this.currentTimestamp=e.timestamp);const o=this.currentTimestamp;this.currentTimestamp+=s;const c=new _s({format:this.outputFormat,data:n,numberOfChannels:this.decoderConfig.numberOfChannels,sampleRate:this.decoderConfig.sampleRate,numberOfFrames:r,timestamp:o});this.onSample(c)}async flush(){}close(){}}class Zs extends Ws{constructor(e){if(!(e instanceof no))throw new TypeError("audioTrack must be an InputAudioTrack.");super(),this._track=e}async _createDecoder(e,t){if(!await this._track.canDecode())throw new Error("This audio track cannot be decoded by this browser. Make sure to check decodability before using a track.");const r=await this._track.getCodec(),i=await this._track.getDecoderConfig();return l(r&&i),Ae.includes(i.codec)?new Js(e,t,i):new Qs(e,t,r,i)}_createPacketSink(){return new Us(this._track)}async getSample(e,t={}){js(e);for await(const r of this.mediaSamplesAtTimestamps([e],t))return r;throw new Error("Internal error: Iterator returned nothing.")}samples(e,t,r={}){return this.mediaSamplesInRange(e,t,r)}samplesAtTimestamps(e,t={}){return this.mediaSamplesAtTimestamps(e,t)}}class eo{constructor(e,t){this.input=e,this._backing=t}isVideoTrack(){return this instanceof io}isAudioTrack(){return this instanceof no}get id(){return this._backing.getId()}get number(){return this._backing.getNumber()}async getInternalCodecId(){return this._backing.getInternalCodecId()}get internalCodecId(){return to(this._backing.getInternalCodecId(),"internalCodecId","getInternalCodecId")}async getLanguageCode(){return this._backing.getLanguageCode()}get languageCode(){return to(this._backing.getLanguageCode(),"languageCode","getLanguageCode")}async getName(){return this._backing.getName()}get name(){return to(this._backing.getName(),"name","getName")}async getTimeResolution(){return this._backing.getTimeResolution()}get timeResolution(){return to(this._backing.getTimeResolution(),"timeResolution","getTimeResolution")}async isRelativeToUnixEpoch(){return this._backing.isRelativeToUnixEpoch()}async getUnixTimeForTimestamp(e){return this._backing.getUnixTimeForTimestamp(e)}async hasUnixTimeMapping(){return null!==await this._backing.getUnixTimeForTimestamp(await this.getFirstTimestamp())}async getDisposition(){return this._backing.getDisposition()}get disposition(){return to(this._backing.getDisposition(),"disposition","getDisposition")}async getBitrate(){return this._backing.getBitrate()}async getAverageBitrate(){return this._backing.getAverageBitrate()}async getFirstTimestamp(){const e=await this._backing.getFirstPacket({metadataOnly:!0});return e?.timestamp??0}async computeDuration(e){const t=await this._backing.getPacket(1/0,{metadataOnly:!0,...e});return G((t?.timestamp??0)+(t?.duration??0),await this.getTimeResolution())}async getDurationFromMetadata(e={}){return this._backing.getDurationFromMetadata(e)}
1async computePacketStats(e=1/0,t){const r=new Us(this);let i=1/0,n=-1/0,a=0,s=0;for await(const o of r.packets(void 0,void 0,{metadataOnly:!0,...t})){if(a>=e&&o.timestamp>=n)break;i=Math.min(i,o.timestamp),n=Math.max(n,o.timestamp+o.duration),a++,s+=o.byteLength}return{packetCount:a,averagePacketRate:a?Number((a/(n-i)).toPrecision(16)):0,averageBitrate:a?Number((8*s/(n-i)).toPrecision(16)):0}}async isLive(){return null!==await this._backing.getLiveRefreshInterval()}async getLiveRefreshInterval(){return this._backing.getLiveRefreshInterval()}canBePairedWith(e){if(!(e instanceof eo))throw new TypeError("other must be an InputTrack.");return this.input===e.input&&this!==e&&0n!==(this._backing.getPairingMask()&e._backing.getPairingMask())}async getPairableTracks(e){return this.input.getTracks(co({filter:e=>e.canBePairedWith(this)},e))}async getPairableVideoTracks(e){return this.input.getVideoTracks(co({filter:e=>e.canBePairedWith(this)},e))}async getPairableAudioTracks(e){return this.input.getAudioTracks(co({filter:e=>e.canBePairedWith(this)},e))}async getPrimaryPairableVideoTrack(e){return this.input.getPrimaryVideoTrack(co({filter:e=>e.canBePairedWith(this)},e))}async getPrimaryPairableAudioTrack(e){return this.input.getPrimaryAudioTrack(co({filter:e=>e.canBePairedWith(this)},e))}async hasPairableTrack(e){e&&=ro(e);const t=await this.input.getTracks();for(const r of t)if(this.canBePairedWith(r)&&(!e||await e(r)))return!0;return!1}hasPairableVideoTrack(e){return e&&=ro(e),this.hasPairableTrack(async t=>t.isVideoTrack()&&(!e||await e(t)))}hasPairableAudioTrack(e){return e&&=ro(e),this.hasPairableTrack(async t=>t.isAudioTrack()&&(!e||await e(t)))}}const to=(e,t,r)=>{if(e instanceof Promise)throw new Error(`'${t}' is deprecated and not available synchronously for this track. Use the preferred '${r}()' instead.`);return e},ro=e=>{if(void 0!==e&&"function"!=typeof e)throw new TypeError("predicate, when provided, must be a function.");return e?t=>{const r=e=>{if("boolean"!=typeof e)throw new TypeError("predicate must return or resolve to a boolean value.");return e},i=e(t);return i instanceof Promise?i.then(r):r(i)}:void 0};class io extends eo{constructor(e,t){super(e,t),this._pixelAspectRatioCache=null,this._backing=t}get type(){return"video"}async getCodec(){return this._backing.getCodec()}get codec(){return to(this._backing.getCodec(),"codec","getCodec")}async hasOnlyKeyPackets(){return await(this._backing.getHasOnlyKeyPackets?.())??!1}async getCodedWidth(){return this._backing.getCodedWidth()}get codedWidth(){return to(this._backing.getCodedWidth(),"codedWidth","getCodedWidth")}async getCodedHeight(){return this._backing.getCodedHeight()}get codedHeight(){return to(this._backing.getCodedHeight(),"codedHeight","getCodedHeight")}async getRotation(){return this._backing.getRotation()}get rotation(){return to(this._backing.getRotation(),"rotation","getRotation")}async getSquarePixelWidth(){return this._backing.getSquarePixelWidth()}get squarePixelWidth(){return to(this._backing.getSquarePixelWidth(),"squarePixelWidth","getSquarePixelWidth")}async getSquarePixelHeight(){return this._backing.getSquarePixelHeight()}get squarePixelHeight(){return to(this._backing.getSquarePixelHeight(),"squarePixelHeight","getSquarePixelHeight")}async getPixelAspectRatio(){return this._pixelAspectRatioCache??=we({num:await this.get
1SquarePixelWidth()*await this.getCodedHeight(),den:await this.getSquarePixelHeight()*await this.getCodedWidth()})}get pixelAspectRatio(){return this._pixelAspectRatioCache??=we({num:to(this._backing.getSquarePixelWidth(),"pixelAspectRatio","getPixelAspectRatio")*to(this._backing.getCodedHeight(),"pixelAspectRatio","getPixelAspectRatio"),den:to(this._backing.getSquarePixelHeight(),"pixelAspectRatio","getPixelAspectRatio")*to(this._backing.getCodedWidth(),"pixelAspectRatio","getPixelAspectRatio")})}async getDisplayWidth(){const e=await(this._backing.getMetadataDisplayWidth?.());if(null!=e)return e;return await this.getRotation()%180==0?this.getSquarePixelWidth():this.getSquarePixelHeight()}get displayWidth(){const e=this._backing.getMetadataDisplayWidth?.();if(void 0!==e){const t=to(e,"displayWidth","getDisplayWidth");if(null!==t)return t}const t=to(this._backing.getRotation(),"displayWidth","getDisplayWidth")%180==0?this._backing.getSquarePixelWidth():this._backing.getSquarePixelHeight();return to(t,"displayWidth","getDisplayWidth")}async getDisplayHeight(){const e=await(this._backing.getMetadataDisplayHeight?.());if(null!=e)return e;return await this.getRotation()%180==0?this.getSquarePixelHeight():this.getSquarePixelWidth()}get displayHeight(){const e=this._backing.getMetadataDisplayHeight?.();if(void 0!==e){const t=to(e,"displayHeight","getDisplayHeight");if(null!==t)return t}const t=to(this._backing.getRotation(),"displayHeight","getDisplayHeight")%180==0?this._backing.getSquarePixelHeight():this._backing.getSquarePixelWidth();return to(t,"displayHeight","getDisplayHeight")}async getColorSpace(){return this._backing.getColorSpace()}async hasHighDynamicRange(){const e=await this._backing.getColorSpace();return"bt2020"===e.primaries||"smpte432"===e.primaries||"pq"===e.transfer||"hlg"===e.transfer||"bt2020-ncl"===e.matrix}
1async canBeTransparent(){return this._backing.canBeTransparent()}async getDecoderConfig(){return this._backing.getDecoderConfig()}async getCodecParameterString(){const e=await(this._backing.getMetadataCodecParameterString?.());if(null!=e)return e;const t=await this._backing.getDecoderConfig();return t?.codec??null}async canDecode(){try{const e=await this._backing.getDecoderConfig();if(!e)return!1;const t=await this._backing.getCodec();if(l(null!==t),as.some(r=>r.supports(t,e)))return!0;if("undefined"==typeof VideoDecoder)return!1;return!0===(await VideoDecoder.isConfigSupported(e)).supported}catch(e){return d._error("Error during decodability check:",e),!1}}async determinePacketType(e){if(!(e instanceof Yt))throw new TypeError("packet must be an EncodedPacket.");if(e.isMetadataOnly)throw new TypeError("packet must not be metadata-only to determine its type.");const t=await this.getCodec();if(null===t)return null;const r=await this.getDecoderConfig();return l(r),Dt(t,r,e.data)}}class no extends eo{constructor(e,t){super(e,t),this._backing=t}get type(){return"audio"}async getCodec(){return this._backing.getCodec()}get codec(){return to(this._backing.getCodec(),"codec","getCodec")}async hasOnlyKeyPackets(){return await(this._backing.getHasOnlyKeyPackets?.())??!0}async getNumberOfChannels(){return this._backing.getNumberOfChannels()}get numberOfChannels(){return to(this._backing.getNumberOfChannels(),"numberOfChannels","getNumberOfChannels")}async getSampleRate(){return this._backing.getSampleRate()}get sampleRate(){return to(this._backing.getSampleRate(),"sampleRate","getSampleRate")}async getDecoderConfig(){return this._backing.getDecoderConfig()}async getCodecParameterString(){const e=await(this._backing.getMetadataCodecParameterString?.());if(null!=e)return e;const t=await this._backing.getDecoderConfig();return t?.codec??null}async canDecode(){try{const e=await this._backing.getDecoderConfig();if(!e)return!1;const t=await this._backing.getCodec();if(l(null!==t),ss.some(r=>r.supports(t,e)))return!0;if(e.codec.startsWith("pcm-"))return!0;if("undefined"==typeof AudioDecoder)return!1;return!0===(await AudioDecoder.isConfigSupported(e)).supported}catch(e){return d._error("Error during decodability check:",e),!1}}async determinePacketType(e){if(!(e instanceof Yt))throw new TypeError("packet must be an EncodedPacket.");return null===await this.getCodec()?null:"key"}}const ao=e=>-(e??-1/0),so=e=>-e,oo=e=>{if("object"!=typeof e||!e)throw new TypeError("query must be an object.");if(void 0!==e.filter&&"function"!=typeof e.filter)throw new TypeError("query.filter, when provided, must be a function.");if(void 0!==e.sortBy&&"function"!=typeof e.sortBy)throw new TypeError("query.sortBy, when provided, must be a function.");return{filter:e.filter?t=>{const r=e=>{if("boolean"!=typeof e)throw new TypeError("query.filter must return or resolve to a boolean.");return e},i=e.filter(t);return i instanceof Promise?i.then(r):r(i)}:void 0,sortBy:e.sortBy?t=>{const r=e=>{if(!("number"==typeof e||Array.isArray(e)&&e.every(e=>"number"==typeof e)))throw new TypeError("query.sortBy must return or resolve to a number or an array of numbers.");return e},i=e.sortBy(t);return i instanceof Promise?i.then(r):r(i)}:void 0}},co=(e,t)=>({filter:e?.filter||t?.filter?r=>{const i=e?.filter?.(r)??!0,n=e=>!1!==e&&(t?.filter?.(r)??!0);return i instanceof Promise?i.then(n):n(i)}:void 0,sortBy:e?.sortBy||t?.sortBy?r=>{const i=e?.sortBy?.(r)??[],n=t?.sortBy?.(r)??[],a=(e,t)=>[...Array.isArray(e)?e:[e],...Array.isArray(t)?t:[t]];return i instanceof Promise||n instanceof Promise?Promise.all([i,n]).then(([e,t])=>a(e,t)):a(i,n)}:void 0}),lo=async(e,t)=>{let r=e;if(t?.filter){const i=e.map(e=>t.filter(e));if(i.some(e=>e instanceof Promise)){const t=await Promise.all(i);r=e.filter((e,r)=>t[r])}else r=e.filter((e,t)=>i[t])}if(!t?.sortBy)return r;const i=r.map(e=>t.sortBy(e)),n=i.some(e=>e instanceof Promise)?await Promise.all(i):i;return r.map((e,t)=>({track:e,sortValue:n[t]})).sort((e,t)=>{const r=Array.isArray(e.sortValue)?e.sortValue:[e.sortValue],i=Array.isArray(t.sortValue)?t.sortValue:[t.sortValue],n=Math.max(r.length,i.length);for(let e=0;e<n;e++){const t=r[e]??0,n=i[e]??0;if(t!==n)return t-n}return 0}).map(e=>e.track)};me();const uo=2;class ho extends xe{get disposed(){return this._disposed}constructor(e){if(super(),this._demuxerPromise=null,this._format=null,this._trackBackingsCache=null,this._backingToTrack=new Map,this._disposed=!1,this._nextSourceCacheAge=0,this._sourceRefs=[],this._sourceCache=[],this._sourceCachePromises=[],this._onFormatDetermined=null,!e||"object"!=typeof e)throw new TypeError("options must be an object.");if(!Array.isArray(e.formats)||e.formats.some(e=>!(e instanceof Oa)))throw new TypeError("options.formats must be an array of InputFormat.");if(!(e.source instanceof ar||e.source instanceof sr))throw new TypeError("options.source must be a Source or SourceRef.");if(e.source instanceof ar&&e.source._disposed)throw new TypeError("options.source must not be a disposed Source.");if(void 0!==e.initInput&&!(e.initInput instanceof ho))throw new TypeError("options.initInput, when provided, must be an Input.");void 0!==e.formatOptions&&((e,t)=>{if(!e||"object"!=typeof e)throw new TypeError(`${t}, when provided, must be an object.`);if(void 0!==e.isobmff){if(!e.isobmff||"object"!=typeof e.isobmff)throw new TypeError(`${t}.isobmff, when provided, must be an object.`);if(void 0!==e.isobmff.resolveKeyId&&"function"!=typeof e.isobmff.resolveKeyId)throw new TypeError(`${t}.isobmff.resolveKeyId, when provided, must be a function.`)}if(void 0!==e.hls){if(!e.hls||"object"!=typeof e.hls)throw new TypeError(`${t}.hls, when provided, must be an object.`);if(void 0!==e.hls.offsetTimestampsByDateTime&&"boolean"!=typeof e.hls.offsetTimestampsByDateTime)throw new TypeError(`${t}.hls.offsetTimestampsByDateTime, when provided, must be a boolean.`)}})(e.formatOptions,"formatOptions"),this._formats=e.formats,this._initInput=e.initInput??null,this._formatOptions=e.formatOptions??{},e.source instanceof ar?this._rootRef=e.source.ref():this._rootRef=e.source,this._sourceRefs.push(this._rootRef)}get _rootSource(){return this._rootRef.source}async _getSourceUncached(e){l(this._rootSource instanceof or);const t=await this._rootSource._resolveRequest(e);return this._emit("source",{source:t.source,request:e,isRoot:e.isRoot}),t}_getSourceCached(e,t=1){const r=this._sourceCache.find(r=>r.cacheGroup===t&&cr(r.request,e));if(r)return r.age++,Promise.resolve(r.sourceRef.source.ref());const i=this._sourceCachePromises.find(r=>r.cacheGroup===t&&cr(r.request,e));if(i)return i.promise.then(e=>e.sourceRef.source.ref());const n=(async()=>{const r=await this._getSourceUncached(e);if(ye(this._sourceCache,e=>e.cacheGroup===t&&1===e.sourceRef.source._refCount)>=4){const e=be(this._sourceCache,e=>e.cacheGroup===t&&1===e.sourceRef.source._refCount?e.age:1/0);l(-1!==e);const r=this._sourceCache[e];
1this._sourceCache.splice(e,1),r.sourceRef.free(),D(this._sourceRefs,r.sourceRef)}this._sourceRefs.push(r);const i=this._sourceCachePromises.findIndex(t=>t.request===e);l(-1!==i),this._sourceCachePromises.splice(i,1);return{request:e,sourceRef:r,age:this._nextSourceCacheAge++,cacheGroup:t}})();return this._sourceCachePromises.push({request:e,cacheGroup:t,promise:n}),n.then(e=>{const t=e.sourceRef.source.ref();return this._sourceCache.push(e),t})}_getDemuxer(){return this._demuxerPromise??=(async()=>{this._reader=new pr(this._rootSource),this._emit("source",{source:this._rootSource,request:null,isRoot:!0});for(const e of this._formats){if(await e._canReadInput(this))return this._format=e,this._onFormatDetermined?.(e),e._createDemuxer(this)}throw new UnsupportedInputFormatError})()}get source(){return this._rootSource}async getFormat(){return await this._getDemuxer(),l(this._format),this._format}async canRead(){try{return await this._getDemuxer(),!0}catch(e){if(e instanceof UnsupportedInputFormatError)return!1;throw e}}async getFirstTimestamp(e){e??=await this.getTracks();const t=e.filter(e=>null!==e);if(0===t.length)return 0;const r=await Promise.all(t.map(e=>e.getFirstTimestamp()));return Math.min(...r)}async computeDuration(e,t){e??=await this.getTracks();const r=e.filter(e=>null!==e);if(0===r.length)return 0;const i=await Promise.all(r.map(e=>e.computeDuration(t)));return Math.max(...i)}async getDurationFromMetadata(e,t){e??=await this.getTracks();const r=e.filter(e=>null!==e),i=(await Promise.all(r.map(e=>e.getDurationFromMetadata(t)))).filter(e=>null!==e);return 0===i.length?null:Math.max(...i)}async getTracks(e){e&&=oo(e);const t=(await this._getTrackBackings()).map(e=>this._wrapBackingAsTrack(e));return lo(t,e)}async getVideoTracks(e){e&&=oo(e);const t=(await this.getTracks()).filter(e=>e.isVideoTrack());return lo(t,e)}async getAudioTracks(e){e&&=oo(e);const t=(await this.getTracks()).filter(e=>e.isAudioTrack());return lo(t,e)}async getPrimaryVideoTrack(e){e&&=oo(e);const t=co(e,{sortBy:async e=>[so((await e.getDisposition()).default),so(await e.hasPairableAudioTrack()),so(!await e.hasOnlyKeyPackets()),ao(await e.getBitrate())]});return(await this.getVideoTracks(t))[0]??null}async getPrimaryAudioTrack(e){e&&=oo(e);const t=await this.getPrimaryVideoTrack(),r=co(e,{sortBy:async e=>[so(!t||e.canBePairedWith(t)),so((await e.getDisposition()).default),ao(await e.getBitrate())]});return(await this.getAudioTracks(r))[0]??null}async _getTrackBackings(){const e=await this._getDemuxer();return this._trackBackingsCache??=await e.getTrackBackings()}_wrapBackingAsTrack(e){const t=this._backingToTrack.get(e);if(t)return t;const r="video"===e.getType()?new io(this,e):new no(this,e);return this._backingToTrack.set(e,r),r}async getMimeType(){return(await this._getDemuxer()).getMimeType()}async getMetadataTags(){return(await this._getDemuxer()).getMetadataTags()}dispose(){if(!this._disposed){this._disposed=!0;for(const e of this._sourceRefs)e.free();this._sourceRefs.length=0,this._demuxerPromise&&this._demuxerPromise.then(e=>e.dispose()).catch(()=>{})}}[Symbol.dispose](){this.dispose()}}class UnsupportedInputFormatError extends Error{constructor(e="Input has an unsupported or unrecognizable format."){super(e),this.name="UnsupportedInputFormatError"}}class InputDisposedError extends Error{constructor(e="Input has been disposed."){super(e),this.name="InputDisposedError"}}class fo{constructor(e){this.mutex=new I,this.trackTimestampInfo=new WeakMap,this.output=e}onTrackClose(e){}validateTimestamp(e,t,r){if(t<0)throw new Error(`Timestamps must be non-negative (got ${t}s).`);let i=this.trackTimestampInfo.get(e);if(i){if(r&&(i.maxTimestampBeforeLastKeyPacket=i.maxTimestamp),null!==i.maxTimestampBeforeLastKeyPacket&&t<i.maxTimestampBeforeLastKeyPacket)throw new Error(`Timestamps cannot be smaller than the largest timestamp of the previous GOP (a GOP begins with a key packet and ends right before the next key packet). Got ${t}s, but largest timestamp is ${i.maxTimestampBeforeLastKeyPacket}s.`);i.maxTimestamp=Math.max(i.maxTimestamp,t)}else{if(!r)throw new Error("First packet must be a key packet.");i={maxTimestamp:t,maxTimestampBeforeLastKeyPacket:null},this.trackTimestampInfo.set(e,i)}}}const mo=/<(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})>/g;const po=/(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})/,go=e=>{const t=po.exec(e);if(!t)throw new Error("Expected match.");return 36e5*Number(t[1]||"0")+6e4*Number(t[2])+1e3*Number(t[3])+Number(t[4])},yo=e=>{const t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),i=Math.floor(e%6e4/1e3),n=e%1e3;return t.toString().padStart(2,"0")+":"+r.toString().padStart(2,"0")+":"+i.toString().padStart(2,"0")+"."+n.toString().padStart(3,"0")};class bo{constructor(e){this.writer=e,this.helper=new Uint8Array(8),this.helperView=new DataView(this.helper.buffer),this.offsets=new WeakMap}writeU32(e){this.helperView.setUint32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}writeU64(e){this.helperView.setUint32(0,Math.floor(e/2**32),!1),this.helperView.setUint32(4,e,!1),this.writer.write(this.helper.subarray(0,8))}writeAscii(e){for(let t=0;t<e.length;t++)this.helperView.setUint8(t%8,e.charCodeAt(t)),t%8==7&&this.writer.write(this.helper);e.length%8!=0&&this.writer.write(this.helper.subarray(0,e.length%8))}writeBox(e){if(this.offsets.set(e,this.writer.getPos()),e.contents&&!e.children)this.writeBoxHeader(e,e.size??e.contents.byteLength+8),this.writer.write(e.contents);else{const t=this.writer.getPos();if(this.writeBoxHeader(e,0),e.contents&&this.writer.write(e.contents),e.children)for(const t of e.children)t&&this.writeBox(t);const r=this.writer.getPos(),i=e.size??r-t;this.writer.seek(t),this.writeBoxHeader(e,i),this.writer.seek(r)}}writeBoxHeader(e,t){this.writeU32(e.largeSize?1:t),this.writeAscii(e.type),e.largeSize&&this.writeU64(t)}measureBoxHeader(e){return 8+(e.largeSize?8:0)}patchBox(e){const t=this.offsets.get(e);l(void 0!==t);const r=this.writer.getPos();this.writer.seek(t),this.writeBox(e),this.writer.seek(r)}measureBox(e){if(e.contents&&!e.children){return this.measureBoxHeader(e)+e.contents.byteLength}{let t=this.measureBoxHeader(e);if(e.contents&&(t+=e.contents.byteLength),e.children)for(const r of e.children)r&&(t+=this.measureBox(r));return t}}}const wo=new Uint8Array(8),vo=new DataView(wo.buffer),ko=e=>[(e%256+256)%256],To=e=>(vo.setUint16(0,e,!1),[wo[0],wo[1]]),xo=e=>(vo.setInt16(0,e,!1),[wo[0],wo[1]]),So=e=>(vo.setUint32(0,e,!1),[wo[1],wo[2],wo[3]]),Co=e=>(vo.setUint32(0,e,!1),[wo[0],wo[1],wo[2],wo[3]]),Po=e=>(vo.setInt32(0,e,!1),[wo[0],wo[1],wo[2],wo[3]]),Ao=e=>(vo.setUint32(0,Math.floor(e/2**32),!1),vo.setUint32(4,e,!1),[wo[0],wo[1],wo[2],wo[3],wo[4],wo[5],wo[6],wo[7]]),Eo=e=>(vo.setInt32(0,Math.floor(e/2**32),!1),vo.setUint32(4,e,!1),[wo[0],wo[1],wo[2],wo[3],wo[4],wo[5],wo[6],wo[7]]),Io=e=>(vo.setInt16(0,256*e,!1),[wo[0],wo[1]]),$o=e=>
1(vo.setInt32(0,65536*e,!1),[wo[0],wo[1],wo[2],wo[3]]),_o=e=>(vo.setInt32(0,2**30*e,!1),[wo[0],wo[1],wo[2],wo[3]]),No=(e,t)=>{const r=[];let i=e;do{let e=127&i;i>>=7,r.length>0&&(e|=128),r.push(e),void 0!==t&&t--}while(i>0||t);return r.reverse()},Ro=(e,t=!1)=>{const r=Array(e.length).fill(null).map((t,r)=>e.charCodeAt(r));return t&&r.push(0),r},Oo=e=>{const t=e*(Math.PI/180),r=Math.round(Math.cos(t)),i=Math.round(Math.sin(t));return[r,i,0,-i,r,0,0,0,1]},Fo=Oo(0),Bo=e=>[$o(e[0]),$o(e[1]),_o(e[2]),$o(e[3]),$o(e[4]),_o(e[5]),$o(e[6]),$o(e[7]),_o(e[8])],Do=(e,t,r)=>({type:e,contents:t&&new Uint8Array(t.flat(10)),children:r}),Mo=(e,t,r,i,n)=>Do(e,[ko(t),So(r),i??[]],n),jo=()=>Do("styp",[Ro("iso5"),Co(0),Ro("iso5"),Ro("iso6"),Ro("mp41"),Ro("cmfc"),Ro("dash")]),Lo=(e,t)=>{let r=e.maxWrittenEndTimestamp-e.minWrittenTimestamp;return Number.isFinite(r)||(r=0),Mo("sidx",1,0,[Co(1),Co(ud),Ao(fd(e.minWrittenTimestamp,ud)),Ao(0),To(0),To(1),Co(2147483647&t),Co(fd(r,ud)),Co(0)])},Uo=e=>({type:"mdat",largeSize:e}),zo=e=>Do("moov",void 0,[Wo(e.creationTime,e.trackDatas),...e.trackDatas.map(t=>qo(t,e.creationTime)),e.isFragmented?Ec(e.trackDatas):null,zc(e)]),Wo=(e,t)=>{const r=Math.max(0,...t.map(e=>fd(Vo(e),ud)+fd(e.startTimestampOffset??0,ud))),i=Math.max(0,...t.map(e=>e.track.id))+1,n=!f(e)||!f(r),a=n?Ao:Co;return Mo("mvhd",+n,0,[a(e),a(e),Co(ud),a(r),$o(1),Io(1),Array(10).fill(0),Bo(Fo),Array(24).fill(0),Co(i)])},Vo=e=>{if(0===e.samples.length)return 0;let t=1/0,r=-1/0;for(let i=0;i<e.samples.length;i++){const n=e.samples[i];n.timestamp<t&&(t=n.timestamp),n.timestamp+n.duration>r&&(r=n.timestamp+n.duration)}return t===1/0?0:r-t},qo=(e,t)=>{const r=hd(e),i=null!==e.startTimestampOffset&&e.startTimestampOffset>0;return Do("trak",void 0,[Ho(e,t),i?Go(e,e.startTimestampOffset):null,Ko(e,t),void 0!==r.name?Do("udta",void 0,[Do("name",[...w.encode(r.name)])]):null])},Ho=(e,t)=>{const r=fd(Vo(e),ud)+fd(e.startTimestampOffset??0,ud),i=!f(t)||!f(r),n=i?Ao:Co;let a;if("video"===e.type){const t=e.track.metadata.rotation;a=Oo(t??0)}else a=Fo;let s=2;return!1!==e.track.metadata.disposition?.default&&(s|=1),Mo("tkhd",+i,s,[n(t),n(t),Co(e.track.id),Co(0),n(r),Array(8).fill(0),To(0),To(e.track.id),Io("audio"===e.type?1:0),To(0),Bo(a),$o("video"===e.type?e.info.width:0),$o("video"===e.type?e.info.height:0)])},Go=(e,t)=>{const r=fd(t,ud),i=fd(Vo(e),ud),n=!f(r)||!f(i),a=n?Ao:Co,s=n?Eo:Po;return Do("edts",void 0,[Mo("elst",n?1:0,0,[Co(2),a(r),s(-1),$o(1),a(i),s(0),$o(1)])])},Ko=(e,t)=>Do("mdia",void 0,[Yo(e,t),Jo(!0,Xo[e.type],Qo[e.type]),Zo(e)]),Yo=(e,t)=>{const r=fd(Vo(e),e.timescale),i=!f(t)||!f(r),n=i?Ao:Co;return Mo("mdhd",+i,0,[n(t),n(t),Co(e.timescale),n(r),To(rd(e.track.metadata.languageCode??V)),To(0)])},Xo={video:"vide",audio:"soun",subtitle:"text"},Qo={video:"MediabunnyVideoHandler",audio:"MediabunnySoundHandler",subtitle:"MediabunnyTextHandler"},Jo=(e,t,r,i="\0\0\0\0")=>Mo("hdlr",0,0,[e?Ro("mhlr"):Co(0),Ro(t),Ro(i),Co(0),Co(0),Ro(r,!0)]),Zo=e=>Do("minf",void 0,[ec[e.type](),tc(),nc(e)]),ec={video:()=>Mo("vmhd",0,1,[To(0),To(0),To(0),To(0)]),audio:()=>Mo("smhd",0,0,[To(0),To(0)]),subtitle:()=>Mo("nmhd",0,0)},tc=()=>Do("dinf",void 0,[rc()]),rc=()=>Mo("dref",0,0,[Co(1)],[ic()]),ic=()=>Mo("url ",0,1),nc=e=>{const t=e.compositionTimeOffsetTable.length>1||e.compositionTimeOffsetTable.some(e=>0!==e.sampleCompositionTimeOffset);return Do("stbl",void 0,[ac(e),kc(e),t?Pc(e):null,t?Ac(e):null,xc(e),Sc(e),Cc(e),Tc(e)])},ac=e=>{let t;if("video"===e.type)t=sc(Xc(e.track.source._codec,e.info.decoderConfig.codec),e);else if("audio"===e.type){const r=Jc(e.track.source._codec,e.muxer.isQuickTime);l(r),t=lc(r,e)}else"subtitle"===e.type&&(t=vc(ed[e.track.source._codec],e));return l(t),Mo("stsd",0,0,[Co(1)],[t])},sc=(e,t)=>Do(e,[Array(6).fill(0),To(1),To(0),To(0),Array(12).fill(0),To(t.info.width),To(t.info.height),Co(4718592),Co(4718592),Co(0),To(1),Array(32).fill(0),To(24),xo(65535)],[Qc[t.track.source._codec](t),oc(t),A(t.info.decoderConfig.colorSpace)?cc(t):null]),oc=e=>e.info.pixelAspectRatio.num===e.info.pixelAspectRatio.den?null:Do("pasp",[Co(e.info.pixelAspectRatio.num),Co(e.info.pixelAspectRatio.den)]),cc=e=>Do("colr",[Ro(e.muxer.isQuickTime?"nclc":"nclx"),To(k[e.info.decoderConfig.colorSpace.primaries]),To(x[e.info.decoderConfig.colorSpace.transfer]),To(C[e.info.decoderConfig.colorSpace.matrix]),e.muxer.isQuickTime?[]:ko((e.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),dc=e=>{if(!e.info.decoderConfig)return null;const t=e.info.decoderConfig,r=t.codec.split("."),i=Number(r[1]),n=Number(r[2]),a=(Number(r[3])<<4)+((r[4]?Number(r[4]):1)<<1)+(r[8]?Number(r[8]):Number(t.colorSpace?.fullRange??0)),s=r[5]?Number(r[5]):t.colorSpace?.primaries?k[t.colorSpace.primaries]:2,o=r[6]?Number(r[6]):t.colorSpace?.transfer?x[t.colorSpace.transfer]:2,c=r[7]?Number(r[7]):t.colorSpace?.matrix?C[t.colorSpace.matrix]:2;
1return Mo("vpcC",1,0,[ko(i),ko(n),ko(a),ko(s),ko(o),ko(c),To(0)])},lc=(e,t)=>{let r,i=0,n=16;const a=Ae.includes(t.track.source._codec);if(a){const e=t.track.source._codec,{sampleSize:r}=Ve(e);n=8*r,n>16&&(i=1)}if(t.muxer.isQuickTime&&(i=1),0===i)r=[Array(6).fill(0),To(1),To(i),To(0),Co(0),To(t.info.numberOfChannels),To(n),To(0),To(0),To(t.info.sampleRate<65536?t.info.sampleRate:0),To(0)];else{const e=a?0:-2;r=[Array(6).fill(0),To(1),To(i),To(0),Co(0),To(t.info.numberOfChannels),To(Math.min(n,16)),xo(e),To(0),To(t.info.sampleRate<65536?t.info.sampleRate:0),To(0),a?[Co(1),Co(n/8),Co(t.info.numberOfChannels*n/8)]:[Co(0),Co(0),Co(0)],Co(2)]}return Do(e,r,[Zc(t.track.source._codec,t.muxer.isQuickTime)?.(t)??null])},uc=e=>{let t;switch(e.track.source._codec){case"aac":t=64;break;case"mp3":t=107;break;case"vorbis":t=221;break;default:throw new Error(`Unhandled audio codec: ${e.track.source._codec}`)}let r=[...ko(t),...ko(21),...So(0),...Co(0),...Co(0)];if(e.info.decoderConfig.description){const t=g(e.info.decoderConfig.description);r=[...r,...ko(5),...No(t.byteLength),...t]}return r=[...To(1),...ko(0),...ko(4),...No(r.length),...r,...ko(6),...ko(1),...ko(2)],r=[...ko(3),...No(r.length),...r],Mo("esds",0,0,r)},hc=e=>Do("wave",void 0,[fc(e),mc(e),Do("\0\0\0\0")]),fc=e=>Do("frma",[Ro(Jc(e.track.source._codec,e.muxer.isQuickTime))]),mc=e=>{const{littleEndian:t}=Ve(e.track.source._codec);return Do("enda",[To(+t)])},pc=e=>{let t=e.info.numberOfChannels,r=3840,i=e.info.sampleRate,n=0,a=0,s=new Uint8Array(0);const o=e.info.decoderConfig?.description;if(o){l(o.byteLength>=18);const e=g(o),c=Ot(e);t=c.outputChannelCount,r=c.preSkip,i=c.inputSampleRate,n=c.outputGain,a=c.channelMappingFamily,c.channelMappingTable&&(s=c.channelMappingTable)}return Do("dOps",[ko(0),ko(t),To(r),Co(i),xo(n),ko(a),...s])},gc=e=>{const t=e.info.decoderConfig?.description;l(t);const r=g(t);return Mo("dfLa",0,0,[...r.subarray(4)])},yc=e=>{const{littleEndian:t,sampleSize:r}=Ve(e.track.source._codec);return Mo("pcmC",0,0,[ko(+t),ko(8*r)])},bc=e=>{const t=Ut(e.info.firstPacket.data);if(!t)throw new Error("Couldn't extract AC-3 frame info from the audio packet. Ensure the packets contain valid AC-3 sync frames (as specified in ETSI TS 102 366).");const r=new Uint8Array(3),n=new i(r);return n.writeBits(2,t.fscod),n.writeBits(5,t.bsid),n.writeBits(3,t.bsmod),n.writeBits(3,t.acmod),n.writeBits(1,t.lfeon),n.writeBits(5,t.bitRateCode),n.writeBits(5,0),Do("dac3",[...r])},wc=e=>{const t=Vt(e.info.firstPacket.data);if(!t)throw new Error("Couldn't extract E-AC-3 frame info from the audio packet. Ensure the packets contain valid E-AC-3 sync frames (as specified in ETSI TS 102 366).");let r=16;for(const e of t.substreams)r+=23,e.numDepSub>0?r+=9:r+=1;const n=Math.ceil(r/8),a=new Uint8Array(n),s=new i(a);s.writeBits(13,t.dataRate),s.writeBits(3,t.substreams.length-1);for(const e of t.substreams)s.writeBits(2,e.fscod),s.writeBits(5,e.bsid),s.writeBits(1,0),s.writeBits(1,0),s.writeBits(3,e.bsmod),s.writeBits(3,e.acmod),s.writeBits(1,e.lfeon),s.writeBits(3,0),s.writeBits(4,e.numDepSub),e.numDepSub>0?s.writeBits(9,e.chanLoc):s.writeBits(1,0);return Do("dec3",[...a])},vc=(e,t)=>Do(e,[Array(6).fill(0),To(1)],[td[t.track.source._codec](t)]),kc=e=>Mo("stts",0,0,[Co(e.timeToSampleTable.length),e.timeToSampleTable.map(e=>[Co(e.sampleCount),Co(e.sampleDelta)])]),Tc=e=>{if(e.samples.every(e=>"key"===e.type))return null;const t=[...e.samples.entries()].filter(([,e])=>"key"===e.type);return Mo("stss",0,0,[Co(t.length),t.map(([e])=>Co(e+1))])},xc=e=>Mo("stsc",0,0,[Co(e.compactlyCodedChunkTable.length),e.compactlyCodedChunkTable.map(e=>[Co(e.firstChunk),Co(e.samplesPerChunk),Co(1)])]),Sc=e=>{if("audio"===e.type&&e.info.requiresPcmTransformation){const{sampleSize:t}=Ve(e.track.source._codec);return Mo("stsz",0,0,[Co(t*e.info.numberOfChannels),Co(e.samples.reduce((t,r)=>t+fd(r.duration,e.timescale),0))])}return Mo("stsz",0,0,[Co(0),Co(e.samples.length),e.samples.map(e=>Co(e.size))])},Cc=e=>e.finalizedChunks.length>0&&h(e.finalizedChunks).offset>=2**32?Mo("co64",0,0,[Co(e.finalizedChunks.length),e.finalizedChunks.map(e=>Ao(e.offset))]):Mo("stco",0,0,[Co(e.finalizedChunks.length),e.finalizedChunks.map(e=>Co(e.offset))]),Pc=e=>Mo("ctts",1,0,[Co(e.compositionTimeOffsetTable.length),e.compositionTimeOffsetTable.map(e=>
1[Co(e.sampleCount),Po(e.sampleCompositionTimeOffset)])]),Ac=e=>{let t=1/0,r=-1/0,i=1/0,n=-1/0;l(e.compositionTimeOffsetTable.length>0),l(e.samples.length>0);for(let i=0;i<e.compositionTimeOffsetTable.length;i++){const n=e.compositionTimeOffsetTable[i];t=Math.min(t,n.sampleCompositionTimeOffset),r=Math.max(r,n.sampleCompositionTimeOffset)}for(let t=0;t<e.samples.length;t++){const r=e.samples[t];i=Math.min(i,fd(r.timestamp,e.timescale)),n=Math.max(n,fd(r.timestamp+r.duration,e.timescale))}const a=Math.max(-t,0);return n>=2**31?null:Mo("cslg",0,0,[Po(a),Po(t),Po(r),Po(i),Po(n)])},Ec=e=>Do("mvex",void 0,e.map(Ic)),Ic=e=>Mo("trex",0,0,[Co(e.track.id),Co(1),Co(0),Co(0),Co(0)]),$c=(e,t)=>Do("moof",void 0,[_c(e),...t.map(Rc)]),_c=e=>Mo("mfhd",0,0,[Co(e)]),Nc=e=>{let t=0,r=0;const i="delta"===e.type;return r|=+i,t|=i?1:2,t<<24|r<<16},Rc=e=>Do("traf",void 0,[Oc(e),Fc(e),Bc(e)]),Oc=e=>{l(e.currentChunk);let t=0;t|=8,t|=16,t|=32,t|=131072;const r=e.currentChunk.samples[1]??e.currentChunk.samples[0],i={duration:r.timescaleUnitsToNextSample,size:r.size,flags:Nc(r)};return Mo("tfhd",0,131128,[Co(e.track.id),Co(i.duration),Co(i.size),Co(i.flags)])},Fc=e=>(l(e.currentChunk),Mo("tfdt",1,0,[Ao(fd(e.currentChunk.startTimestamp,e.timescale))])),Bc=e=>{l(e.currentChunk);const t=e.currentChunk.samples.map(e=>e.timescaleUnitsToNextSample),r=e.currentChunk.samples.map(e=>e.size),i=e.currentChunk.samples.map(Nc),n=e.currentChunk.samples.map(t=>fd(t.timestamp-t.decodeTimestamp,e.timescale)),a=new Set(t),s=new Set(r),o=new Set(i),c=new Set(n),d=2===o.size&&i[0]!==i[1],u=a.size>1,h=s.size>1,f=!d&&o.size>1,m=c.size>1||[...c].some(e=>0!==e);let p=0;return p|=1,p|=4*+d,p|=256*+u,p|=512*+h,p|=1024*+f,p|=2048*+m,Mo("trun",1,p,[Co(e.currentChunk.samples.length),Co(e.currentChunk.offset-e.currentChunk.moofOffset||0),d?Co(i[0]):[],e.currentChunk.samples.map((e,a)=>[u?Co(t[a]):[],h?Co(r[a]):[],f?Co(i[a]):[],m?Po(n[a]):[]])])},Dc=(e,t)=>Mo("tfra",1,0,[Co(e.track.id),Co(63),Co(e.finalizedChunks.length),e.finalizedChunks.map(r=>[Ao(fd(r.samples[0].timestamp,e.timescale)),Ao(r.moofOffset),Co(t+1),Co(1),Co(1)])]),Mc=()=>Mo("mfro",0,0,[Co(0)]),jc=()=>Do("vtte"),Lc=(e,t,r,i,n)=>Do("vttc",void 0,[null!==n?Do("vsid",[Po(n)]):null,null!==r?Do("iden",[...w.encode(r)]):null,null!==t?Do("ctim",[...w.encode(yo(t))]):null,null!==i?Do("sttg",[...w.encode(i)]):null,Do("payl",[...w.encode(e)])]),Uc=e=>Do("vtta",[...w.encode(e)]),zc=e=>{const t=[],r=e.format._options.metadataFormat??"auto",i=e.output._metadataTags;if("mdir"===r||"auto"===r&&!e.isQuickTime){const e=Gc(i);e&&t.push(e)}else if("mdta"===r){const e=Kc(i);e&&t.push(e)}else("udta"===r||"auto"===r&&e.isQuickTime)&&Wc(t,e.output._metadataTags);return 0===t.length?null:Do("udta",void 0,t)},Wc=(e,t)=>{for(const{key:r,value:i}of le(t))switch(r){case"title":e.push(Vc("©nam",i));break;case"description":e.push(Vc("©des",i));break;case"artist":e.push(Vc("©ART",i));break;case"album":e.push(Vc("©alb",i));break;case"albumArtist":e.push(Vc("albr",i));break;case"genre":e.push(Vc("©gen",i));break;case"date":e.push(Vc("©day",i.toISOString().slice(0,10)));break;case"comment":e.push(Vc("©cmt",i));break;case"lyrics":e.push(Vc("©lyr",i));break;case"raw":case"discNumber":case"discsTotal":case"trackNumber":case"tracksTotal":case"images":break;default:L(r)}if(t.raw)for(const r in t.raw){const i=t.raw[r];null==i||4!==r.length||e.some(e=>e.type===r)||("string"==typeof i?e.push(Vc(r,i)):i instanceof Uint8Array&&e.push(Do(r,Array.from(i))))}},Vc=(e,t)=>{const r=w.encode(t);return Do(e,[To(r.length),To(rd("und")),Array.from(r)])},qc={"image/jpeg":13,"image/png":14,"image/bmp":27},Hc=(e,t)=>{const r=[];for(const{key:i,value:n}of le(e))switch(i){case"title":r.push({key:t?"title":"©nam",value:Yc(n)});break;case"description":r.push({key:t?"description":"©des",value:Yc(n)});break;case"artist":r.push({key:t?"artist":"©ART",value:Yc(n)});break;case"album":r.push({key:t?"album":"©alb",value:Yc(n)});break;case"albumArtist":r.push({key:t?"album_artist":"aART",value:Yc(n)});break;case"comment":r.push({key:t?"comment":"©cmt",value:Yc(n)});break;case"genre":r.push({key:t?"genre":"©gen",value:Yc(n)});break;case"lyrics":r.push({key:t?"lyrics":"©lyr",value:Yc(n)});break;case"date":r.push({key:t?"date":"©day",value:Yc(n.toISOString().slice(0,10))});break;case"images":for(const e of n)"coverFront"===e.kind&&r.push({key:"covr",value:Do("data",[Co(qc[e.mimeType]??0),Co(0),Array.from(e.data)])});break;case"trackNumber":if(t){const t=void 0!==e.tracksTotal?`${n}/${e.tracksTotal}`:n.toString();r.push({key:"track",value:Yc(t)})}else r.push({key:"trkn",value:Do("data",[Co(0),Co(0),To(0),To(n),To(e.tracksTotal??0),To(0)])});break;case"discNumber":t||r.push({key:"disc",value:Do("data",[Co(0),Co(0),To(0),To(n),To(e.discsTotal??0),To(0)])});break;case"tracksTotal":case"discsTotal":case"raw":break;default:L(i)}if(e.raw)for(const i in e.raw){const n=e.raw[i];null==n||!t&&4!==i.length||r.some(e=>e.key===i)||("string"==typeof n?r.push({key:i,value:Yc(n)}):n instanceof Uint8Array?r.push({key:i,value:Do("data",[Co(0),Co(0),Array.from(n)])}):n instanceof Zt&&r.push({key:i,value:Do("data",[Co(qc[n.mimeType]??0),Co(0),Array.from(n.data)])}))}return r},Gc=e=>{const t=Hc(e,!1);return 0===t.length?null:Mo("meta",0,0,void 0,[Jo(!1,"mdir","","appl"),Do("ilst",void 0,t.map(e=>
1Do(e.key,void 0,[e.value])))])},Kc=e=>{const t=Hc(e,!0);return 0===t.length?null:Do("meta",void 0,[Jo(!1,"mdta",""),Mo("keys",0,0,[Co(t.length)],t.map(e=>Do("mdta",[...w.encode(e.key)]))),Do("ilst",void 0,t.map((e,t)=>{const r=String.fromCharCode(...Co(t+1));return Do(r,void 0,[e.value])}))])},Yc=e=>Do("data",[Co(1),Co(0),...w.encode(e)]),Xc=(e,t)=>{switch(e){case"avc":return t.startsWith("avc3")?"avc3":"avc1";case"hevc":return"hvc1";case"vp8":return"vp08";case"vp9":return"vp09";case"av1":return"av01"}},Qc={avc:e=>e.info.decoderConfig&&Do("avcC",[...g(e.info.decoderConfig.description)]),hevc:e=>e.info.decoderConfig&&Do("hvcC",[...g(e.info.decoderConfig.description)]),vp8:dc,vp9:dc,av1:e=>Do("av1C",je(e.info.decoderConfig.codec))},Jc=(e,t)=>{switch(e){case"aac":case"mp3":case"vorbis":return"mp4a";case"opus":return"Opus";case"flac":return"fLaC";case"ulaw":return"ulaw";case"alaw":return"alaw";case"pcm-u8":return"raw ";case"pcm-s8":return"sowt";case"ac3":return"ac-3";case"eac3":return"ec-3"}if(t)switch(e){case"pcm-s16":return"sowt";case"pcm-s16be":return"twos";case"pcm-s24":case"pcm-s24be":return"in24";case"pcm-s32":case"pcm-s32be":return"in32";case"pcm-f32":case"pcm-f32be":return"fl32";case"pcm-f64":case"pcm-f64be":return"fl64"}else switch(e){case"pcm-s16":case"pcm-s16be":case"pcm-s24":case"pcm-s24be":case"pcm-s32":case"pcm-s32be":return"ipcm";case"pcm-f32":case"pcm-f32be":case"pcm-f64":case"pcm-f64be":return"fpcm"}},Zc=(e,t)=>{switch(e){case"aac":case"mp3":case"vorbis":return uc;case"opus":return pc;case"flac":return gc;case"ac3":return bc;case"eac3":return wc}if(t)switch(e){case"pcm-s24":case"pcm-s24be":case"pcm-s32":case"pcm-s32be":case"pcm-f32":case"pcm-f32be":case"pcm-f64":case"pcm-f64be":return hc}else switch(e){case"pcm-s16":case"pcm-s16be":case"pcm-s24":case"pcm-s24be":case"pcm-s32":case"pcm-s32be":case"pcm-f32":case"pcm-f32be":case"pcm-f64":case"pcm-f64be":return yc}return null},ed={webvtt:"wvtt"},td={webvtt:e=>Do("vttC",[...w.encode(e.info.config.description)])},rd=e=>{l(3===e.length);let t=0;for(let r=0;r<3;r++)t<<=5,t+=e.charCodeAt(r)-96;return t};class id{constructor(e,t){if(this.finalized=!1,this.started=!1,this.pos=0,this.trackedWrites=null,this.trackedStart=-1,this.trackedEnd=-1,e._writerAcquired)throw new Error("Can't have multiple Writers for the same Target.");this.target=e,e._setMonotonicity(t),e._writerAcquired=!0}start(){l(!this.started),this.target._start(),this.started=!0}write(e){l(this.started&&!this.finalized),this.maybeTrackWrites(e),this.target._write(e,this.pos),this.pos+=e.byteLength}seek(e){this.pos=e}getPos(){return this.pos}async flush(){return l(this.started&&!this.finalized),this.target._flush()}async finalize(){l(this.started&&!this.finalized),await this.target._finalize(),this.finalized=!0}maybeTrackWrites(e){if(!this.trackedWrites)return;let t=this.getPos();if(t<this.trackedStart){if(t+e.byteLength<=this.trackedStart)return;e=e.subarray(this.trackedStart-t),t=0}const r=t+e.byteLength-this.trackedStart;let i=this.trackedWrites.byteLength;for(;i<r;)i*=2;if(i!==this.trackedWrites.byteLength){const e=new Uint8Array(i);e.set(this.trackedWrites,0),this.trackedWrites=e}this.trackedWrites.set(e,t-this.trackedStart),this.trackedEnd=Math.max(this.trackedEnd,t+e.byteLength)}startTrackingWrites(){this.trackedWrites=new Uint8Array(1024),this.trackedStart=this.getPos(),this.trackedEnd=this.trackedStart}stopTrackingWrites(){if(!this.trackedWrites)throw new Error("Internal error: Can't get tracked writes since nothing was tracked.");const e={data:this.trackedWrites.subarray(0,this.trackedEnd-this.trackedStart),start:this.trackedStart,end:this.trackedEnd};return this.trackedWrites=null,e}}class nd extends xe{constructor(){super(...arguments),this._writerAcquired=!1,this._monotonicity=null,this.onwrite=null}_setMonotonicity(e){!1!==this._monotonicity&&(this._monotonicity=e)}_dispatchWrite(e,t){this.onwrite?.(e,t),this._emit("write",{start:e,end:t})}slice(e){if(!Number.isInteger(e)||e<0)throw new TypeError("offset must be a non-negative integer.");return new dd(this,e)}}const ad=65536,sd=2**32;class od extends nd{constructor(e={}){if(super(),this.buffer=null,this._maxPos=0,!e||"object"!=typeof e)throw new TypeError("BufferTarget options, when provided, must be an object.");if(void 0!==e.onFinalize&&"function"!=typeof e.onFinalize)throw new TypeError("options.onFinalize, when provided, must be a function.");
1if(this._options=e,this._supportsResize="resize"in new ArrayBuffer(0),this._supportsResize)try{this._buffer=new ArrayBuffer(ad,{maxByteLength:sd})}catch{this._buffer=new ArrayBuffer(ad),this._supportsResize=!1}else this._buffer=new ArrayBuffer(ad);this._bytes=new Uint8Array(this._buffer)}_ensureSize(e){let t=this._buffer.byteLength;for(;t<e;)t*=2;if(t!==this._buffer.byteLength){if(t>sd)throw new Error("ArrayBuffer exceeded maximum size of 4294967296 bytes. Please consider using another target.");if(this._supportsResize)this._buffer.resize(t);else{const e=new ArrayBuffer(t),r=new Uint8Array(e);r.set(this._bytes,0),this._buffer=e,this._bytes=r}}}_start(){}_write(e,t){this._ensureSize(t+e.byteLength),this._bytes.set(e,t),this._maxPos=Math.max(this._maxPos,t+e.byteLength),this._dispatchWrite(t,t+e.byteLength)}async _flush(){}async _finalize(){this.buffer=this._buffer.slice(0,this._maxPos),this._options.onFinalize&&await this._options.onFinalize(this.buffer),this._emit("finalized")}async _close(){}_getSlice(e,t){return this._bytes.slice(e,t)}}class cd extends nd{_start(){}_write(e,t){this._dispatchWrite(t,t+e.byteLength)}async _flush(){}async _finalize(){this._emit("finalized")}async _close(){}}class dd extends nd{constructor(e,t){super(),this._baseTarget=e,this._offset=t}_start(){}_write(e,t){this._baseTarget._write(e,this._offset+t),this._dispatchWrite(t,t+e.byteLength)}_flush(){return this._baseTarget._flush()}async _finalize(){this._emit("finalized")}async _close(){}_setMonotonicity(e){super._setMonotonicity(e),this._baseTarget._setMonotonicity(e)}}class ld{constructor(e,t){if(this.rootPath=e,this.getTarget=t,"string"!=typeof e)throw new TypeError("rootPath must be a string.");if("function"!=typeof t)throw new TypeError("getTarget must be a function.")}}const ud=57600,hd=e=>{const t={},r=e.track;return void 0!==r.metadata.name&&(t.name=r.metadata.name),t},fd=(e,t,r=!0)=>{const i=e*t;return r?Math.round(i):i};class md extends fo{constructor(e,t){super(e),this.writer=null,this.boxWriter=null,this.initWriter=null,this.initBoxWriter=null,this.auxTarget=new od,this.auxWriter=new id(this.auxTarget,!1),this.auxBoxWriter=new bo(this.auxWriter),this.mdat=null,this.ftypSize=null,this.trackDatas=[],this.allTracksKnown=B(),this.creationTime=Math.floor(Date.now()/1e3)+2082844800,this.finalizedChunks=[],this.nextFragmentNumber=1,this.maxWrittenTimestamp=-1/0,this.minWrittenTimestamp=1/0,this.maxWrittenEndTimestamp=-1/0,this.segmentHeaderSize=null,this.format=t,this.isQuickTime=t instanceof ol,this.isCmaf=t instanceof sl,this.minimumFragmentDuration=t._options.minimumFragmentDuration??(t instanceof sl?1/0:1)}async start(){const e=await this.mutex.acquire();if(this.isCmaf?(this.fastStart="fragmented",this.isFragmented=!0):(this.writer=await this.output._getRootWriter(e=>void 0!==this.format._options.fastStart?"fragmented"===this.format._options.fastStart:e instanceof od),this.boxWriter=new bo(this.writer),this.fastStart=this.format._options.fastStart??(this.writer.target instanceof od&&"in-memory"),this.isFragmented="fragmented"===this.fastStart),this.isCmaf){if(!this.output._hasInitTarget())throw new Error("CMAF outputs require the initTarget field in OutputOptions to be set; the init segment will be written to it.");const e=await this.output._getInitTarget(),t=new id(e,!0);t.start(),this.initWriter=t,this.initBoxWriter=new bo(t)}const t=this.output._tracks.some(e=>e.isVideoTrack()&&"avc"===e.source._codec);{const e=this.initBoxWriter??this.boxWriter;if(l(e),this.format._options.onFtyp&&e.writer.startTrackingWrites(),e.writeBox((e=>{const t=512;return e.isQuickTime?Do("ftyp",[Ro("qt "),Co(t),Ro("qt ")]):e.fragmented?e.cmaf?Do("ftyp",[Ro("iso5"),Co(t),Ro("iso5"),Ro("iso6"),Ro("mp41"),Ro("cmfc"),Ro("dash")]):Do("ftyp",[Ro("iso5"),Co(t),Ro("iso5"),Ro("iso6"),Ro("mp41")]):Do("ftyp",[Ro("isom"),Co(t),Ro("isom"),e.holdsAvc?Ro("avc1"):[],Ro("mp41")])})({isQuickTime:this.isQuickTime,holdsAvc:t,fragmented:this.isFragmented,cmaf:this.isCmaf})),this.format._options.onFtyp){const{data:t,start:r}=e.writer.stopTrackingWrites();this.format._options.onFtyp(t,r)}this.ftypSize=e.writer.getPos(),this.isCmaf&&await this.initWriter.flush()}if("in-memory"===this.fastStart);else if("reserve"===this.fastStart){for(const e of this.output._tracks)if(void 0===e.metadata.maximumPacketCount)throw new Error("All tracks must specify maximumPacketCount in their metadata when using fastStart: 'reserve'.")}else this.isFragmented||(l(this.writer),l(this.boxWriter),this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=Uo(!0),this.boxWriter.writeBox(this.mdat));await(this.writer?.flush()),e()}allTracksAreKnown(){for(const e of this.output._tracks)if(!e.source._closed&&!this.trackDatas.some(t=>t.track===e))return!1;return!0}async getMimeType(){await this.allTracksKnown.promise;const e=this.trackDatas.map(e=>{if("video"===e.type)return e.info.decoderConfig.codec;if("audio"===e.type)return e.info.decoderConfig.codec;return{webvtt:"wvtt"}[e.track.source._codec]});return Xt({isQuickTime:this.isQuickTime,hasVideo:this.trackDatas.some(e=>"video"===e.type),hasAudio:this.trackDatas.some(e=>"audio"===e.type),codecStrings:e})}getVideoTrackData(e,t,r){const i=this.trackDatas.find(t=>t.track===e);if(i)return i;Qe(r),l(r),l(r.decoderConfig);const n={...r.decoderConfig};l(void 0!==n.codedWidth),l(void 0!==n.codedHeight);let a=!1;if("avc"!==e.source._codec||n.description){if("hevc"===e.source._codec&&!n.description){const e=kt(t.data);if(!e)throw new Error("Couldn't extract an HEVCDecoderConfigurationRecord from the HEVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.265) when not providing a description, or provide a description (must be an HEVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in HEVC format.");n.description=(e=>{const t=[];t.push(e.configurationVersion),t.push((3&e.generalProfileSpace)<<6|(1&e.generalTierFlag)<<5|31&e.generalProfileIdc),t.push(e.generalProfileCompatibilityFlags>>>24&255),t.push(e.generalProfileCompatibilityFlags>>>16&255),t.push(e.generalProfileCompatibilityFlags>>>8&255),t.push(255&e.generalProfileCompatibilityFlags),t.push(...e.generalConstraintIndicatorFlags),t.push(255&e.generalLevelIdc),t.push(240|e.minSpatialSegmentationIdc>>8&15),t.push(255&e.minSpatialSegmentationIdc),t.push(252|3&e.parallelismType),t.pu
1sh(252|3&e.chromaFormatIdc),t.push(248|7&e.bitDepthLumaMinus8),t.push(248|7&e.bitDepthChromaMinus8),t.push(e.avgFrameRate>>8&255),t.push(255&e.avgFrameRate),t.push((3&e.constantFrameRate)<<6|(7&e.numTemporalLayers)<<3|(1&e.temporalIdNested)<<2|3&e.lengthSizeMinusOne),t.push(255&e.arrays.length);for(const r of e.arrays){t.push((1&r.arrayCompleteness)<<7|63&r.nalUnitType),t.push(r.nalUnits.length>>8&255),t.push(255&r.nalUnits.length);for(const e of r.nalUnits){t.push(e.length>>8&255),t.push(255&e.length);for(let r=0;r<e.length;r++)t.push(e[r])}}return new Uint8Array(t)})(e),a=!0}}else{const e=ft(t.data);if(!e)throw new Error("Couldn't extract an AVCDecoderConfigurationRecord from the AVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.264) when not providing a description, or provide a description (must be an AVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in AVCC format.");n.description=(e=>{const t=[];t.push(e.configurationVersion),t.push(e.avcProfileIndication),t.push(e.profileCompatibility),t.push(e.avcLevelIndication),t.push(252|3&e.lengthSizeMinusOne),t.pu
1sh(224|31&e.sequenceParameterSets.length);for(const r of e.sequenceParameterSets){const e=r.byteLength;t.push(e>>8),t.push(255&e);for(let i=0;i<e;i++)t.push(r[i])}t.push(e.pictureParameterSets.length);for(const r of e.pictureParameterSets){const e=r.byteLength;t.push(e>>8),t.push(255&e);for(let i=0;i<e;i++)t.push(r[i])}if(100===e.avcProfileIndication||110===e.avcProfileIndication||122===e.avcProfileIndication||144===e.avcProfileIndication){l(null!==e.chromaFormat),l(null!==e.bitDepthLumaMinus8),l(null!==e.bitDepthChromaMinus8),l(null!==e.sequenceParameterSetExt),t.push(252|3&e.chromaFormat),t.push(248|7&e.bitDepthLumaMinus8),t.push(248|7&e.bitDepthChromaMinus8),t.push(e.sequenceParameterSetExt.length);for(const r of e.sequenceParameterSetExt){const e=r.byteLength;t.push(e>>8),t.push(255&e);for(let i=0;i<e;i++)t.push(r[i])}}return new Uint8Array(t)})(e),a=!0}const s=((e,t)=>{const r=e<0?-1:1;let i=0,n=1,a=1,s=0,o=e=Math.abs(e);for(;;){const e=Math.floor(o),c=e*a+i,d=e*s+n;if(d>t)return{num:r*a,den:s};if(i=a,n=s,a=c,s=d,o=1/(o-e),!isFinite(o))break}return{num:r*a,den:s}})(1/(e.metadata.frameRate??ud),1e6).den,o=n.displayAspectWidth,c=n.displayAspectHeight,d=void 0===o||void 0===c?{num:1,den:1}:we({num:o*n.codedHeight,den:c*n.codedWidth}),u={muxer:this,track:e,type:"video",info:{width:n.codedWidth,height:n.codedHeight,pixelAspectRatio:d,decoderConfig:n,requiresAnnexBTransformation:a},timescale:s,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,startTimestampOffset:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],closed:!1};return this.trackDatas.push(u),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),u}getAudioTrackData(e,t,r){const i=this.trackDatas.find(t=>t.track===e);if(i)return i;Ze(r),l(r),l(r.decoderConfig);const s={...r.decoderConfig};let c=!1;if("aac"===e.source._codec&&!s.description){const e=Dn(gr.tempFromBytes(t.data));if(!e)throw new Error("Couldn't parse ADTS header from the AAC packet. Make sure the packets are in ADTS format (as specified in ISO 13818-7) when not providing a description, or provide a description (must be an AudioSpecificConfig as specified in ISO 14496-3) and ensure the packets are raw AAC data.");const r=n[e.samplingFrequencyIndex],i=a[e.channelConfiguration];if(void 0===r||void 0===i)throw new Error("Invalid ADTS frame header.");s.description=o({objectType:e.objectType,sampleRate:r,numberOfChannels:i}),c=!0}const d={muxer:this,track:e,type:"audio",info:{numberOfChannels:r.decoderConfig.numberOfChannels,sampleRate:r.decoderConfig.sampleRate,decoderConfig:s,requiresPcmTransformation:!this.isFragmented&&Ae.includes(e.source._codec),expectedNextPcmPacketTimestamp:null,requiresAdtsStripping:c,firstPacket:t},timescale:s.sampleRate,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,startTimestampOffset:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],closed:!1};return this.trackDatas.push(d),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),d}getSubtitleTrackData(e,t){const r=this.trackDatas.find(t=>t.track===e);if(r)return r;et(t),l(t),l(t.config);const i={muxer:this,track:e,type:"subtitle",info:{config:t.config},timescale:1e3,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,startTimestampOffset:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],closed:!1,lastCueEndTimestamp:0,cueQueue:[],nextSourceId:0,cueToSourceId:new WeakMap};return this.trackDatas.push(i),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),i}async addEncodedVideoPacket(e,t,r){const i=await this.mutex.acquire();try{const i=this.getVideoTrackData(e,t,r);let n=t.data;if(i.info.requiresAnnexBTransformation){const e=[...at(n)].map(e=>n.subarray(e.offset,e.offset+e.length));if(0===e.length)throw new Error("Failed to transform packet data. Make sure all packets are provided in Annex B format, as specified in ITU-T-REC-H.264 and ITU-T-REC-H.265.");n=ht(e,4)}this.validateTimestamp(i.track,t.timestamp,"key"===t.type);const a=this.createSampleForTrack(i,n,t.timestamp,t.duration,t.type);await this.registerSample(i,a)}finally{i()}}async addEncodedAudioPacket(e,t,r){const i=await this.mutex.acquire();try{const i=this.getAudioTrackData(e,t,r);let n=t.data;if(i.info.requiresAdtsStripping){const e=Dn(gr.tempFromBytes(n));if(!e)throw new Error("Expected ADTS frame, didn't get one.");const t=null===e.crcCheck?7:9;n=n.subarray(t)}this.validateTimestamp(i.track,t.timestamp,"key"===t.type);let a=t.timestamp,s=t.duration;if(i.info.requiresPcmTransformation){const e=Ve(i.info.decoderConfig.codec).sampleSize*i.info.numberOfChannels;if(s=n.byteLength/e/i.info.sampleRate,null!==i.info.expectedNextPcmPacketTimestamp){const e=a-i.info.expectedNextPcmPacketTimestamp;if(e<.01)a=i.info.expectedNextPcmPacketTimestamp;else{const t=await this.padWithSilence(i,i.info.expectedNextPcmPacketTimestamp,e);a=i.info.expectedNextPcmPacketTimestamp+t}}i.info.expectedNextPcmPacketTimestamp=a+s}const o=this.createSampleForTrack(i,n,a,s,t.type);await this.registerSample(i,o)}finally{i()}}async padWithSilence(e,t,r){const i=fd(r,e.timescale);if(r=i/e.timescale,i>0){const{sampleSize:n,silentValue:a}=Ve(e.info.decoderConfig.codec),s=i*e.info.numberOfChannels,o=new Uint8Array(n*s).fill(a),c=this.createSampleForTrack(e,new Uint8Array(o.buffer),t,r,"key");await this.registerSample(e,c)}return r}async addSubtitleCue(e,t,r){const i=await this.mutex.acquire();try{const i=this.getSubtitleTrackData(e,r);this.validateTimestamp(i.track,t.timestamp,!0),"webvtt"===e.source._codec&&(i.cueQueue.push(t),await this.processWebVTTCues(i,t.timestamp))}finally{i()}}async processWebVTTCues(e,t){for(;e.cueQueue.length>0;){const r=new Set([]);for(const i of e.cueQueue)l(i.timestamp<=t),l(e.lastCueEndTimestamp<=i.timestamp+i.duration),r.add(Math.max(i.timestamp,e.lastCueEndTimestamp)),r.add(i.timestamp+i.duration);const i=[...r].sort((e,t)=>
1e-t),n=i[0],a=i[1]??n;if(t<a)break;if(e.lastCueEndTimestamp<n){this.auxWriter.seek(0);const t=jc();this.auxBoxWriter.writeBox(t);const r=this.auxTarget._getSlice(0,this.auxWriter.getPos()),i=this.createSampleForTrack(e,r,e.lastCueEndTimestamp,n-e.lastCueEndTimestamp,"key");await this.registerSample(e,i),e.lastCueEndTimestamp=n}this.auxWriter.seek(0);for(let t=0;t<e.cueQueue.length;t++){const r=e.cueQueue[t];if(r.timestamp>=a)break;mo.lastIndex=0;const i=mo.test(r.text),s=r.timestamp+r.duration;let o=e.cueToSourceId.get(r);if(void 0===o&&a<s&&(o=e.nextSourceId++,e.cueToSourceId.set(r,o)),r.notes){const e=Uc(r.notes);this.auxBoxWriter.writeBox(e)}const c=Lc(r.text,i?n:null,r.identifier??null,r.settings??null,o??null);this.auxBoxWriter.writeBox(c),s===a&&e.cueQueue.splice(t--,1)}const s=this.auxTarget._getSlice(0,this.auxWriter.getPos()),o=this.createSampleForTrack(e,s,n,a-n,"key");await this.registerSample(e,o),e.lastCueEndTimestamp=a}}createSampleForTrack(e,t,r,i,n){return{timestamp:r,decodeTimestamp:r,duration:i,data:t,size:t.byteLength,type:n,timescaleUnitsToNextSample:fd(i,e.timescale)}}processTimestamps(e,t){if(0===e.timestampProcessingQueue.length)return;if("audio"===e.type&&e.info.requiresPcmTransformation){this.isFragmented||(e.startTimestampOffset??=e.timestampProcessingQueue[0].timestamp);let t=0;for(let r=0;r<e.timestampProcessingQueue.length;r++){const i=e.timestampProcessingQueue[r];t+=fd(i.duration,e.timescale)}if(0===e.timeToSampleTable.length)e.timeToSampleTable.push({sampleCount:t,sampleDelta:1});else{h(e.timeToSampleTable).sampleCount+=t}return void(e.timestampProcessingQueue.length=0)}const r=e.timestampProcessingQueue.map(e=>e.timestamp).sort((e,t)=>e-t);this.isFragmented||(e.startTimestampOffset??=r[0]);for(let t=0;t<e.timestampProcessingQueue.length;t++){const i=e.timestampProcessingQueue[t];i.decodeTimestamp=r[t];const n=fd(i.timestamp-i.decodeTimestamp,e.timescale),a=fd(i.duration,e.timescale);if(null!==e.lastTimescaleUnits){l(e.lastSample);const t=fd(i.decodeTimestamp,e.timescale,!1),r=Math.round(t-e.lastTimescaleUnits);if(l(r>=0),e.lastTimescaleUnits+=r,e.lastSample.timescaleUnitsToNextSample=r,!this.isFragmented){let t=h(e.timeToSampleTable);if(l(t),1===t.sampleCount){t.sampleDelta=r;const i=e.timeToSampleTable[e.timeToSampleTable.length-2];i&&i.sampleDelta===r&&(i.sampleCount++,e.timeToSampleTable.pop(),t=i)}else t.sampleDelta!==r&&(t.sampleCount--,e.timeToSampleTable.push(t={sampleC
1ount:1,sampleDelta:r}));t.sampleDelta===a?t.sampleCount++:e.timeToSampleTable.push({sampleCount:1,sampleDelta:a});const i=h(e.compositionTimeOffsetTable);l(i),i.sampleCompositionTimeOffset===n?i.sampleCount++:e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:n})}}else e.lastTimescaleUnits=fd(i.decodeTimestamp,e.timescale,!1),this.isFragmented||(e.timeToSampleTable.push({sampleCount:1,sampleDelta:a}),e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:n}));e.lastSample=i}if(e.timestampProcessingQueue.length=0,l(e.lastSample),l(null!==e.lastTimescaleUnits),void 0!==t&&0===e.lastSample.timescaleUnitsToNextSample){l("key"===t.type);const r=fd(t.timestamp,e.timescale,!1),i=Math.round(r-e.lastTimescaleUnits);e.lastSample.timescaleUnitsToNextSample=i}}async registerSample(e,t){"key"===t.type&&this.processTimestamps(e,t),e.timestampProcessingQueue.push(t),this.isFragmented?(e.sampleQueue.push(t),await this.interleaveSamples()):"reserve"===this.fastStart?await this.registerSampleFastStartReserve(e,t):await this.addSampleToTrack(e,t)}async addSampleToTrack(e,t){if(!this.isFragmented&&(e.samples.push(t),"reserve"===this.fastStart)){const t=e.track.metadata.maximumPacketCount;if(l(void 0!==t),e.samples.length>t)throw new Error(`Track #${e.track.id} has already reached the maximum packet count (${t}). Either add less packets or increase the maximum packet count.`)}let r=!1;if(e.currentChunk){e.currentChunk.startTimestamp=Math.min(e.currentChunk.startTimestamp,t.timestamp);const i=t.timestamp-e.currentChunk.startTimestamp;if(this.isFragmented){const n=this.trackDatas.every(r=>{if(e===r)return"key"===t.type;const i=r.sampleQueue[0];return i?"key"===i.type:r.closed});i>=this.minimumFragmentDuration&&n&&t.timestamp>this.maxWrittenTimestamp&&(r=!0,await this.finalizeFragment())}else r=i>=.5}else r=!0;r&&(e.currentChunk&&await this.finalizeCurrentChunk(e),e.currentChunk={startTimestamp:t.timestamp,samples:[],offset:null,moofOffset:null}),l(e.currentChunk),e.currentChunk.samples.push(t),this.isFragmented&&(this.maxWrittenTimestamp=Math.max(this.maxWrittenTimestamp,t.timestamp),this.maxWrittenEndTimestamp=Math.max(this.maxWrittenEndTimestamp,t.timestamp+t.duration),this.minWrittenTimestamp=Math.min(this.minWrittenTimestamp,t.timestamp))}async finalizeCurrentChunk(e){if(l(!this.isFragmented),l(this.writer),!e.currentChunk)return;e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk);let t=e.currentChunk.samples.length;if("audio"===e.type&&e.info.requiresPcmTransformation&&(t=e.currentChunk.samples.reduce((t,r)=>t+fd(r.duration,e.timescale),0)),0!==e.compactlyCodedChunkTable.length&&h(e.compactlyCodedChunkTable).samplesPerChunk===t||e.compactlyCodedChunkTable.push({firstChunk:e.finalizedChunks.length,samplesPerChunk:t}),"in-memory"!==this.fastStart){e.currentChunk.offset=this.writer.getPos();for(const t of e.currentChunk.samples)l(t.data),this.writer.write(t.data),t.data=null;await this.writer.flush()}else e.currentChunk.offset=0}async interleaveSamples(e=!1){if(l(this.isFragmented),e||this.allTracksAreKnown())e:for(;;){let t=null,r=1/0;for(const i of this.trackDatas){if(!e&&0===i.sampleQueue.length&&!i.closed)break e;i.sampleQueue.length>0&&i.sampleQueue[0].timestamp<r&&(t=i,r=i.sampleQueue[0].timestamp)}if(!t)break;const i=t.sampleQueue.shift();await this.addSampleToTrack(t,i)}}async finalizeFragment(e=!this.isCmaf){l(this.isFragmented);const t=this.nextFragmentNumber++;if(1===t){const e=this.initBoxWriter??this.boxWriter;l(e),this.format._options.onMoov&&e.writer.startTrackingWrites(),this.ensureOneEnabledTrack();const t=zo(this);if(e.writeBox(t),this.format._options.onMoov){const{data:t,start:r}=e.writer.stopTrackingWrites();this.format._options.onMoov(t,r)}if(this.isCmaf){l(this.initWriter),await this.initWriter.flush(),await this.initWriter.finalize(),this.writer=await this.output._getRootWriter(!0),this.boxWriter=new bo(this.writer);const e=this.boxWriter.measureBox(jo()),t=this.boxWriter.measureBox(Lo(this,0));this.segmentHeaderSize=e+t,this.writer.seek(this.segmentHeaderSize)}}l(this.writer),l(this.boxWriter);const r=this.trackDatas.filter(e=>e.currentChunk),i=$c(t,r),n=this.writer.getPos(),a=n+this.boxWriter.measureBox(i);let s=a+8,o=1/0;for(const e of r){e.currentChunk.offset=s,e.currentChunk.moofOff
1set=n;for(const t of e.currentChunk.samples)s+=t.size;o=Math.min(o,e.currentChunk.startTimestamp)}const c=s-a,d=c>=2**32;if(d)for(const e of r)e.currentChunk.offset+=8;this.format._options.onMoof&&this.writer.startTrackingWrites();const u=$c(t,r);if(this.boxWriter.writeBox(u),this.format._options.onMoof){const{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoof(e,t,o)}l(this.writer.getPos()===a),this.format._options.onMdat&&this.writer.startTrackingWrites();const h=Uo(d);h.size=c,this.boxWriter.writeBox(h),this.writer.seek(a+(d?Fr:8));for(const e of r)for(const t of e.currentChunk.samples)this.writer.write(t.data),t.data=null;if(this.format._options.onMdat){const{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMdat(e,t)}for(const e of r)e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk),e.currentChunk=null;e&&await this.writer.flush()}async registerSampleFastStartReserve(e,t){if(l(this.writer),l(this.boxWriter),this.allTracksAreKnown()){if(!this.mdat){this.ensureOneEnabledTrack();const e=zo(this),t=this.boxWriter.measureBox(e)+this.computeSampleTableSizeUpperBound()+4096;l(null!==this.ftypSize),this.writer.seek(this.ftypSize+t),this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=Uo(!0),this.boxWriter.writeBox(this.mdat);for(const e of this.trackDatas){for(const t of e.sampleQueue)await this.addSampleToTrack(e,t);e.sampleQueue.length=0}}await this.addSampleToTrack(e,t)}else e.sampleQueue.push(t)}computeSampleTableSizeUpperBound(){l("reserve"===this.fastStart);let e=0;for(const t of this.trackDatas){const r=t.track.metadata.maximumPacketCount;l(void 0!==r),e+=8*Math.ceil(2/3*r),e+=4*r,e+=8*Math.ceil(2/3*r),e+=12*Math.ceil(2/3*r),e+=4*r,e+=8*r}return e}async onTrackClose(e){const t=await this.mutex.acquire(),r=this.trackDatas.find(t=>t.track===e);r&&(r.closed=!0,"subtitle"===r.type&&"webvtt"===e.source._codec&&await this.processWebVTTCues(r,1/0),this.processTimestamps(r)),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),this.isFragmented&&await this.interleaveSamples(),t()}ensureOneEnabledTrack(){for(const e of["video","audio","subtitle"]){const t=this.trackDatas.filter(t=>t.type===e);if(0===t.length)continue;if(!t.some(e=>!1!==e.track.metadata.disposition?.default)){const e=t[0];e.track.metadata.disposition={...e.track.metadata.disposition,default:!0}}}}async finalize(){const e=await this.mutex.acquire();this.allTracksKnown.resolve(),this.ensureOneEnabledTrack();for(const e of this.trackDatas)e.closed=!0,"subtitle"===e.type&&"webvtt"===e.track.source._codec&&await this.processWebVTTCues(e,1/0),this.processTimestamps(e);if(this.isFragmented)await this.interleaveSamples(!0),await this.finalizeFragment(!1);else for(const e of this.trackDatas){await this.finalizeCurrentChunk(e),l(null!==e.startTimestampOffset);for(let t=0;t<e.samples.length;t++){const r=e.samples[t];r.timestamp-=e.startTimestampOffset,r.decodeTimestamp-=e.startTimestampOffset}}if(l(this.writer),l(this.boxWriter),"in-memory"===this.fastStart){let e;this.mdat=Uo(!1);for(let t=0;t<2;t++){const t=zo(this),r=this.boxWriter.measureBox(t);e=this.boxWriter.measureBox(this.mdat);let i=this.writer.getPos()+r+e;for(const t of this.finalizedChunks){t.offset=i;for(const{data:r}of t.samples)l(r),i+=r.byteLength,e+=r.byteLength}if(i<2**32)break;e>=2**32&&(this.mdat.largeSize=!0)}this.format._options.onMoov&&this.writer.startTrackingWrites();const t=zo(this);if(this.boxWriter.writeBox(t),this.format._options.onMoov){const{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoov(e,t)}this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat.size=e,this.boxWriter.writeBox(this.mdat);for(const e of this.finalizedChunks)for(const t of e.samples)l(t.data),this.writer.write(t.data),t.data=null;if(this.format._options.onMdat){const{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMdat(e,t)}}else if(this.isFragmented)if(this.isCmaf){const e=null!==this.segmentHeaderSize?this.writer.getPos()-this.segmentHeaderSize:0;this.writer.seek(0),this.boxWriter.writeBox(jo()),this.boxWriter.writeBox(Lo(this,e))}else{const e=this.writer.getPos(),r=(t=this.trackDatas,Do("mfra",void 0,[...t.map(Dc),Mc()]));this.boxWriter.writeBox(r);const i=this.writer.getPos()-e;this.writer.seek(this.writer.getPos()-4),this.boxWriter.writeU32(i)}else{l(this.mdat);const e=this.boxWriter.offsets.get(this.mdat);l(void 0!==e);const t=this.writer.getPos()-e;if(this.mdat.size=t,this.mdat.largeSize=t>=2**32,this.boxWriter.patchBox(this.mdat),this.format._options.onMdat){const{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMdat(e,t)}const r=zo(this);if("reserve"===this.fastStart){l(null!==this.ftypSize),this.writer.seek(this.ftypSize),this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(r);const e=this.boxWriter.offsets.get(this.mdat)-this.writer.getPos();this.boxWriter.writeBox({type:"free",size:e})}else this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(r);if(this.format._options.onMoov){const{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoov(e,t)}}var t;e()}}const pd="Mediabunny",gd={video:1,audio:2,subtitle:17};class yd extends fo{constructor(e,t){super(e),this.trackDatas=[],this.allTracksKnown=B(),this.segment=null,this.segmentInfo=null,this.seekHead=null,this.tracksElement=null,this.tagsElement=null,this.attachmentsElement=null,this.segmentDuration=null,this.cues=null,this.currentCluster=null,this.currentClusterStartMsTimestamp=null,this.currentClusterMa
1xMsTimestamp=null,this.trackDatasInCurrentCluster=new Map,this.startTimestamp=1/0,this.endTimestamp=-1/0,this.format=t}async start(){const e=await this.mutex.acquire();this.writer=await this.output._getRootWriter(!!this.format._options.appendOnly),this.ebmlWriter=new Pi(this.writer),this.writeEBMLHeader(),this.createSegmentInfo(),this.createCues(),await this.writer.flush(),e()}writeEBMLHeader(){this.format._options.onEbmlHeader&&this.writer.startTrackingWrites();const e={id:wi.EBML,data:[{id:wi.EBMLVersion,data:1},{id:wi.EBMLReadVersion,data:1},{id:wi.EBMLMaxIDLength,data:4},{id:wi.EBMLMaxSizeLength,data:8},{id:wi.DocType,data:this.format instanceof dl?"webm":"matroska"},{id:wi.DocTypeVersion,data:2},{id:wi.DocTypeReadVersion,data:2}]};if(this.ebmlWriter.writeEBML(e),this.format._options.onEbmlHeader){const{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onEbmlHeader(e,t)}}maybeCreateSeekHead(e){if(this.format._options.appendOnly)return;const t=new Uint8Array([28,83,187,107]),r=new Uint8Array([21,73,169,102]),i=new Uint8Array([22,84,174,107]),n=new Uint8Array([25,65,164,105]),a=new Uint8Array([18,84,195,103]),s={id:wi.SeekHead,data:[{id:wi.Seek,data:[{id:wi.SeekID,data:t},{id:wi.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.cues)-this.segmentDataOffset:0}]},{id:wi.Seek,data:[{id:wi.SeekID,data:r},{id:wi.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.segmentInfo)-this.segmentDataOffset:0}]},{id:wi.Seek,data:[{id:wi.SeekID,data:i},{id:wi.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.tracksElement)-this.segmentDataOffset:0}]},this.attachmentsElement?{id:wi.Seek,data:[{id:wi.SeekID,data:n},{id:wi.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.attachmentsElement)-this.segmentDataOffset:0}]}:null,this.tagsElement?{id:wi.Seek,data:[{id:wi.SeekID,data:a},{id:wi.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.tagsElement)-this.segmentDataOffset:0}]}:null]};this.seekHead=s}createSegmentInfo(){const e={id:wi.Duration,data:new gi(0)};this.segmentDuration=e;const t={id:wi.Info,data:[{id:wi.TimestampScale,data:1e6},{id:wi.MuxingApp,data:pd},{id:wi.WritingApp,data:pd},this.format._options.appendOnly?null:e]};this.segmentInfo=t}createTracks(){const e={id:wi.Tracks,data:[]};this.tracksElement=e;for(const t of this.trackDatas){const r=ji[t.track.source._codec];l(r);let i=0;if("audio"===t.type&&"opus"===t.track.source._codec){i=8e7;const e=t.info.decoderConfig.description;if(e){const t=g(e),r=Ot(t);i=Math.round(r.preSkip/48e3*1e9)}}e.data.push({id:wi.TrackEntry,data:[{id:wi.TrackNumber,data:t.track.id},{id:wi.TrackUID,data:t.track.id},{id:wi.TrackType,data:gd[t.type]},!1===t.track.metadata.disposition?.default?{id:wi.FlagDefault,data:0}:null,t.track.metadata.disposition?.forced?{id:wi.FlagForced,data:1}:null,t.track.metadata.disposition?.hearingImpaired?{id:wi.FlagHearingImpaired,data:1}:null,t.track.metadata.disposition?.visuallyImpaired?{id:wi.FlagVisualImpaired,data:1}:null,t.track.metadata.disposition?.original?{id:wi.FlagOriginal,data:1}:null,t.track.metadata.disposition?.commentary?{id:wi.FlagCommentary,data:1}:null,{id:wi.FlagLacing,data:0},{id:wi.Language,data:t.track.metadata.languageCode??V},{id:wi.CodecID,data:r},{id:wi.CodecDelay,data:0},{id:wi.SeekPreRoll,data:i},void 0!==t.track.metadata.name?{id:wi.Name,data:new bi(t.track.metadata.name)}:null,"video"===t.type?this.videoSpecificTrackInfo(t):null,"audio"===t.type?this.audioSpecificTrackInfo(t):null,"subtitle"===t.type?this.subtitleSpecificTrackInfo(t):null]})}}videoSpecificTrackInfo(e){const{frameRate:t,rotation:r}=e.track.metadata,i=[e.info.decoderConfig.description?{id:wi.CodecPrivate,data:g(e.info.decoderConfig.description)}:null,t?{id:wi.DefaultDuration,data:1e9/t}:null],n=r?u(-r):0,a=!!e.info.aspectRatio&&e.info.aspectRatio.num*e.info.height!==e.info.aspectRatio.den*e.info.width,s=e.info.decoderConfig.colorSpace,o={id:wi.Video,data:[{id:wi.PixelWidth,data:e.info.width},{id:wi.PixelHeight,data:e.info.height},a?{id:wi.DisplayWidth,data:e.info.aspectRatio.num}:null,a?{id:wi.DisplayHeight,data:e.info.aspectRatio.den}:null,a?{id:wi.DisplayUnit,data:3}:null,e.info.alphaMode?{id:wi.AlphaMode,data:1}:null,A(s)?{id:wi.Colour,data:[{id:wi.MatrixCoefficients,data:C[s.matrix]},{id:wi.TransferCharacteristics,data:x[s.transfer]},{id:wi.Primaries,data:k[s.primaries]},{id:wi.Range,data:s.fullRange?2:1}]}:null,n?{id:wi.Projection,data:[{id:wi.ProjectionType,data:0},{id:wi.ProjectionPoseRoll,data:new pi((n+180)%360-180)}]}:null]};return i.push(o),i}audioSpecificTrackInfo(e){const t=Ae.includes(e.track.source._codec)?Ve(e.track.source._codec):null;
1return[e.info.decoderConfig.description?{id:wi.CodecPrivate,data:g(e.info.decoderConfig.description)}:null,{id:wi.Audio,data:[{id:wi.SamplingFrequency,data:new pi(e.info.sampleRate)},{id:wi.Channels,data:e.info.numberOfChannels},t?{id:wi.BitDepth,data:8*t.sampleSize}:null]}]}subtitleSpecificTrackInfo(e){return[{id:wi.CodecPrivate,data:w.encode(e.info.config.description)}]}maybeCreateTags(){const e=[],t=(t,r)=>{e.push({id:wi.SimpleTag,data:[{id:wi.TagName,data:new bi(t)},"string"==typeof r?{id:wi.TagString,data:new bi(r)}:{id:wi.TagBinary,data:r}]})},r=this.output._metadataTags,i=new Set;for(const{key:e,value:n}of le(r))switch(e){case"title":t("TITLE",n),i.add("TITLE");break;case"description":t("DESCRIPTION",n),i.add("DESCRIPTION");break;case"artist":t("ARTIST",n),i.add("ARTIST");break;case"album":t("ALBUM",n),i.add("ALBUM");break;case"albumArtist":t("ALBUM_ARTIST",n),i.add("ALBUM_ARTIST");break;case"genre":t("GENRE",n),i.add("GENRE");break;case"comment":t("COMMENT",n),i.add("COMMENT");break;case"lyrics":t("LYRICS",n),i.add("LYRICS");break;case"date":t("DATE",n.toISOString().slice(0,10)),i.add("DATE");break;case"trackNumber":t("PART_NUMBER",void 0!==r.tracksTotal?`${n}/${r.tracksTotal}`:n.toString()),i.add("PART_NUMBER");break;case"discNumber":t("DISC",void 0!==r.discsTotal?`${n}/${r.discsTotal}`:n.toString()),i.add("DISC");break;case"tracksTotal":case"discsTotal":case"images":case"raw":break;default:L(e)}if(r.raw)for(const e in r.raw){const n=r.raw[e];null==n||i.has(e)||("string"==typeof n||n instanceof Uint8Array)&&t(e,n)}0!==e.length&&(this.tagsElement={id:wi.Tags,data:[{id:wi.Tag,data:[{id:wi.Targets,data:[{id:wi.TargetTypeValue,data:50},{id:wi.TargetType,data:"MOVIE"}]},...e]}]})}maybeCreateAttachments(){const e=this.output._metadataTags,t=[],r=new Set,i=e.images??[];for(const e of i){let i,n=e.name;if(void 0===n){n=("coverFront"===e.kind?"cover":"coverBack"===e.kind?"back":"image")+(ue(e.mimeType)??"")}for(;;){i=0n;for(let e=0;e<8;e++)i<<=8n,i|=BigInt(Math.floor(256*Math.random()));if(0n!==i&&!r.has(i))break}r.add(i),t.push({id:wi.AttachedFile,data:[void 0!==e.description?{id:wi.FileDescription,data:new bi(e.description)}:null,{id:wi.FileName,data:new bi(n)},{id:wi.FileMediaType,data:e.mimeType},{id:wi.FileData,data:e.data},{id:wi.FileUID,data:i}]})}for(const[r,n]of Object.entries(e.raw??{})){if(!(n instanceof er))continue;/^\d+$/.test(r)&&(i.find(e=>
1e.mimeType===n.mimeType&&fe(e.data,n.data))||t.push({id:wi.AttachedFile,data:[void 0!==n.description?{id:wi.FileDescription,data:new bi(n.description)}:null,{id:wi.FileName,data:new bi(n.name??"")},{id:wi.FileMediaType,data:n.mimeType??""},{id:wi.FileData,data:n.data},{id:wi.FileUID,data:BigInt(r)}]}))}0!==t.length&&(this.attachmentsElement={id:wi.Attachments,data:t})}createSegment(){this.createTracks(),this.maybeCreateTags(),this.maybeCreateAttachments(),this.maybeCreateSeekHead(!1);const e={id:wi.Segment,size:this.format._options.appendOnly?-1:6,data:[this.seekHead,this.segmentInfo,this.tracksElement,this.attachmentsElement,this.tagsElement]};if(this.segment=e,this.format._options.onSegmentHeader&&this.writer.startTrackingWrites(),this.ebmlWriter.writeEBML(e),this.format._options.onSegmentHeader){const{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onSegmentHeader(e,t)}}createCues(){this.cues={id:wi.Cues,data:[]}}get segmentDataOffset(){return l(this.segment),this.ebmlWriter.dataOffsets.get(this.segment)}allTracksAreKnown(){for(const e of this.output._tracks)if(!e.source._closed&&!this.trackDatas.some(t=>t.track===e))return!1;return!0}async getMimeType(){await this.allTracksKnown.promise;const e=this.trackDatas.map(e=>{if("video"===e.type)return e.info.decoderConfig.codec;if("audio"===e.type)return e.info.decoderConfig.codec;return{webvtt:"wvtt"}[e.track.source._codec]});return Ui({isWebM:this.format instanceof dl,hasVideo:this.trackDatas.some(e=>"video"===e.type),hasAudio:this.trackDatas.some(e=>"audio"===e.type),codecStrings:e})}getVideoTrackData(e,t,r){const i=this.trackDatas.find(t=>t.track===e);if(i)return i;Qe(r),l(r),l(r.decoderConfig),l(void 0!==r.decoderConfig.codedWidth),l(void 0!==r.decoderConfig.codedHeight);const n=r.decoderConfig.displayAspectWidth,a=r.decoderConfig.displayAspectHeight,s=void 0===n||void 0===a?null:we({num:n,den:a}),o={track:e,type:"video",info:{width:r.decoderConfig.codedWidth,height:r.decoderConfig.codedHeight,aspectRatio:s,decoderConfig:r.decoderConfig,alphaMode:!!t.sideData.alpha},chunkQueue:[],lastWrittenMsTimestamp:null,closed:!1};return"vp9"===e.source._codec?o.info.decoderConfig={...o.info.decoderConfig,description:new Uint8Array(Me(o.info.decoderConfig.codec))}:"av1"===e.source._codec&&(o.info.decoderConfig={...o.info.decoderConfig,description:new Uint8Array(je(o.info.decoderConfig.codec))}),this.trackDatas.push(o),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),o}getAudioTrackData(e,t,r){const i=this.trackDatas.find(t=>t.track===e);if(i)return i;Ze(r),l(r),l(r.decoderConfig);const s={...r.decoderConfig};let c=!1;if("aac"===e.source._codec&&!s.description){const e=Dn(gr.tempFromBytes(t.data));if(!e)throw new Error("Couldn't parse ADTS header from the AAC packet. Make sure the packets are in ADTS format (as specified in ISO 13818-7) when not providing a description, or provide a description (must be an AudioSpecificConfig as specified in ISO 14496-3) and ensure the packets are raw AAC data.");const r=n[e.samplingFrequencyIndex],i=a[e.channelConfiguration];if(void 0===r||void 0===i)throw new Error("Invalid ADTS frame header.");s.description=o({objectType:e.objectType,sampleRate:r,numberOfChannels:i}),c=!0}const d={track:e,type:"audio",info:{numberOfChannels:r.decoderConfig.numberOfChannels,sampleRate:r.decoderConfig.sampleRate,decoderConfig:s,requiresAdtsStripping:c},chunkQueue:[],lastWrittenMsTimestamp:null,closed:!1};return this.trackDatas.push(d),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),d}getSubtitleTrackData(e,t){const r=this.trackDatas.find(t=>t.track===e);if(r)return r;et(t),l(t),l(t.config);const i={track:e,type:"subtitle",info:{config:t.config},chunkQueue:[],lastWrittenMsTimestamp:null,closed:!1};return this.trackDatas.push(i),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),i}async addEncodedVideoPacket(e,t,r){const i=await this.mutex.acquire();try{const i=this.getVideoTrackData(e,t,r),n="key"===t.type;this.validateTimestamp(i.track,t.timestamp,n);let a=t.timestamp,s=t.duration;void 0!==e.metadata.frameRate&&(a=G(a,e.metadata.frameRate),s=G(s,e.metadata.frameRate));const o=i.info.alphaMode?t.sideData.alpha??null:null,c=this.createInternalChunk(t.data,a,s,t.type,o);
1"vp9"===e.source._codec&&this.fixVP9ColorSpace(i,c),i.chunkQueue.push(c),await this.interleaveChunks()}finally{i()}}async addEncodedAudioPacket(e,t,r){const i=await this.mutex.acquire();try{const i=this.getAudioTrackData(e,t,r);let n=t.data;if(i.info.requiresAdtsStripping){const e=Dn(gr.tempFromBytes(n));if(!e)throw new Error("Expected ADTS frame, didn't get one.");const t=null===e.crcCheck?7:9;n=n.subarray(t)}const a="key"===t.type;this.validateTimestamp(i.track,t.timestamp,a);const s=this.createInternalChunk(n,t.timestamp,t.duration,t.type);i.chunkQueue.push(s),await this.interleaveChunks()}finally{i()}}async addSubtitleCue(e,t,r){const i=await this.mutex.acquire();try{const i=this.getSubtitleTrackData(e,r);this.validateTimestamp(i.track,t.timestamp,!0);let n=t.text;const a=Math.round(1e3*t.timestamp);mo.lastIndex=0,n=n.replace(mo,e=>{const t=go(e.slice(1,-1));return`<${yo(t-a)}>`});const s=w.encode(n),o=`${t.settings??""}\n${t.identifier??""}\n${t.notes??""}`,c=this.createInternalChunk(s,t.timestamp,t.duration,"key",o.trim()?w.encode(o):null);i.chunkQueue.push(c),await this.interleaveChunks()}finally{i()}}async interleaveChunks(e=!1){if(e||this.allTracksAreKnown()){e:for(;;){let t=null,r=1/0;for(const i of this.trackDatas){if(!e&&0===i.chunkQueue.length&&!i.closed)break e;i.chunkQueue.length>0&&i.chunkQueue[0].timestamp<r&&(t=i,r=i.chunkQueue[0].timestamp)}if(!t)break;const i=t.chunkQueue.shift();this.writeBlock(t,i)}e||await this.writer.flush()}}fixVP9ColorSpace(e,t){if("key"!==t.type)return;if(!e.info.decoderConfig.colorSpace||!e.info.decoderConfig.colorSpace.matrix)return;const r=new i(t.data);r.skipBits(2);const n=r.readBits(1),a=(r.readBits(1)<<1)+n;3===a&&r.skipBits(1);if(r.readBits(1))return;if(0!==r.readBits(1))return;r.skipBits(2);if(4817730!==r.readBits(24))return;a>=2&&r.skipBits(1);const s={rgb:7,bt709:2,bt470bg:1,smpte170m:3}[e.info.decoderConfig.colorSpace.matrix];((e,t,r,i)=>{for(let n=t;n<r;n++){const t=Math.floor(n/8);let a=e[t];const s=7-(7&n);a&=~(1<<s),a|=(i&1<<r-n-1)>>r-n-1<<s,e[t]=a}})(t.data,r.pos,r.pos+3,s)}createInternalChunk(e,t,r,i,n=null){return{data:e,type:i,timestamp:t,duration:r,additions:n}}writeBlock(e,t){this.segment||this.createSegment();const r=Math.round(1e3*t.timestamp),i=this.trackDatas.every(r=>{if(e===r)return"key"===t.type;const i=r.chunkQueue[0];return i?"key"===i.type:r.closed});let n=!1;if(this.currentCluster){l(null!==this.currentClusterStartMsTimestamp),l(null!==this.currentClusterMaxMsTimestamp);const e=r-this.currentClusterStartMsTimestamp;n=i&&r>this.currentClusterMaxMsTimestamp&&e>=1e3*(this.format._options.minimumClusterDuration??1)||e>32767}else n=!0;n&&this.createNewCluster(r);const a=r-this.currentClusterStartMsTimestamp;if(a<-32768)return;const s=new Uint8Array(4),o=new DataView(s.buffer);o.setUint8(0,128|e.track.id),o.setInt16(1,a,!1);const c=Math.round(1e3*t.duration);if(t.additions){const i={id:wi.BlockGroup,data:[{id:wi.Block,data:[s,t.data]},"delta"===t.type?{id:wi.ReferenceBlock,data:new yi(e.lastWrittenMsTimestamp-r)}:null,t.additions?{id:wi.BlockAdditions,data:[{id:wi.BlockMore,data:[{id:wi.BlockAddID,data:1},{id:wi.BlockAdditional,data:t.additions}]}]}:null,c>0?{id:wi.BlockDuration,data:c}:null]};this.ebmlWriter.writeEBML(i)}else{o.setUint8(3,Number("key"===t.type)<<7);const e={id:wi.SimpleBlock,data:[s,t.data]};this.ebmlWriter.writeEBML(e)}this.startTimestamp=Math.min(this.startTimestamp,r),this.endTimestamp=Math.max(this.endTimestamp,r+c),e.lastWrittenMsTimestamp=r,this.trackDatasInCurrentCluster.has(e)||this.trackDatasInCurrentCluster.set(e,{firstMsTimestamp:r}),this.currentClusterMaxMsTimestamp=Math.max(this.currentClusterMaxMsTimestamp,r)}createNewCluster(e){this.currentCluster&&this.finalizeCurrentCluster(),this.format._options.onCluster&&this.writer.startTrackingWrites(),this.currentCluster={id:wi.Cluster,size:this.format._options.appendOnly?-1:5,data:[{id:wi.Timestamp,data:e}]},this.ebmlWriter.writeEBML(this.currentCluster),this.currentClusterStartMsTimestamp=e,this.currentClusterMaxMsTimestamp=e,this.trackDatasInCurrentCluster.clear()}finalizeCurrentCluster(){if(l(this.currentCluster),!this.format._options.appendOnly){const e=this.writer.getPos()-this.ebmlWriter.dataOffsets.get(this.currentCluster),t=this.writer.getPos();this.writer.seek(this.ebmlWriter.offsets.get(this.currentCluster)+4),this.ebmlWriter.writeVarInt(e,5),this.writer.seek(t)}if(this.format._options.onCluster){l(null!==this.currentClusterStartMsTimestamp);const{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onCluster(e,t,this.currentClusterStartMsTimestamp/1e3)}const e=this.ebmlWriter.offsets.get(this.currentCluster)-this.segmentDataOffset,t=new Map;for(const[e,{firstMsTimestamp:r}]of this.trackDatasInCurrentCluster)t.has(r)||t.set(r,[]),t.get(r).push(e);const r=[...t.entries()].sort((e,t)=>
1e[0]-t[0]);for(const[t,i]of r)l(this.cues),this.cues.data.push({id:wi.CuePoint,data:[{id:wi.CueTime,data:t},...i.map(t=>({id:wi.CueTrackPositions,data:[{id:wi.CueTrack,data:t.track.id},{id:wi.CueClusterPosition,data:e}]}))]})}async onTrackClose(e){const t=await this.mutex.acquire(),r=this.trackDatas.find(t=>t.track===e);r&&(r.closed=!0),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),await this.interleaveChunks(),t()}async finalize(){const e=await this.mutex.acquire();this.allTracksKnown.resolve();for(const e of this.trackDatas)e.closed=!0;if(this.segment||this.createSegment(),await this.interleaveChunks(!0),this.currentCluster&&this.finalizeCurrentCluster(),l(this.cues),this.ebmlWriter.writeEBML(this.cues),!this.format._options.appendOnly){const e=this.writer.getPos()-this.segmentDataOffset;this.writer.seek(this.ebmlWriter.offsets.get(this.segment)+4),this.ebmlWriter.writeVarInt(e,6);const t=this.startTimestamp===1/0?0:this.endTimestamp-this.startTimestamp;this.segmentDuration.data=new gi(t),this.writer.seek(this.ebmlWriter.offsets.get(this.segmentDuration)),this.ebmlWriter.writeEBML(this.segmentDuration),l(this.seekHead),this.writer.seek(this.ebmlWriter.offsets.get(this.seekHead)),this.maybeCreateSeekHead(!0),this.ebmlWriter.writeEBML(this.seekHead)}e()}}new Uint8Array([9,240]),new Uint8Array([70,1]);const bd=new Uint32Array(256);for(let e=0;e<256;e++){let t=e<<24;for(let e=0;e<8;e++)t=2147483648&t?t<<1^79764919:t<<1;bd[e]=t>>>0&4294967295}const wd=e=>{let t=4294967295;for(let r=0;r<e.length;r++){const i=e[r];t=(t<<8^bd[t>>>24^i])>>>0}return t},vd=new Uint8Array(16);{const e=y(vd);vd[0]=0,e.setUint16(1,45069,!1),e.setUint16(3,1,!1),vd[5]=193,vd[6]=0,vd[7]=0,e.setUint16(8,1,!1),e.setUint16(10,61440,!1),e.setUint32(12,wd(vd.subarray(0,12)),!1)}const kd=new Map,Td=new Map,xd=e=>{if(!e||"object"!=typeof e)throw new TypeError("Encoding config must be an object.");if(!Pe.includes(e.codec))throw new TypeError(`Invalid video codec '${e.codec}'. Must be one of: ${Pe.join(", ")}.`);if(!(e.bitrate instanceof Id)&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw new TypeError("config.bitrate must be a positive integer or a quality.");
1if(void 0!==e.keyFrameInterval&&(!Number.isFinite(e.keyFrameInterval)||e.keyFrameInterval<0))throw new TypeError("config.keyFrameInterval, when provided, must be a non-negative number.");if(void 0!==e.sizeChangeBehavior&&!["deny","passThrough","fill","contain","cover"].includes(e.sizeChangeBehavior))throw new TypeError("config.sizeChangeBehavior, when provided, must be 'deny', 'passThrough', 'fill', 'contain' or 'cover'.");if(void 0!==e.transform){if("object"!=typeof e.transform||!e.transform)throw new TypeError("config.transform, when provided, must be an object.");if(void 0!==e.transform.width&&(!Number.isInteger(e.transform.width)||e.transform.width<=0))throw new TypeError("config.transform.width, when provided, must be a positive integer.");if(void 0!==e.transform.height&&(!Number.isInteger(e.transform.height)||e.transform.height<=0))throw new TypeError("config.transform.height, when provided, must be a positive integer.");if(void 0!==e.transform.fit&&!["fill","contain","cover"].includes(e.transform.fit))throw new TypeError('config.transform.fit, when provided, must be one of "fill", "contain", or "cover".');if(void 0!==e.transform.width&&void 0!==e.transform.height&&void 0===e.transform.fit&&!["fill","contain","cover"].includes(e.sizeChangeBehavior))throw new TypeError("When both config.transform.width and config.transform.height are provided, config.transform.fit must also be provided.");if(void 0!==e.transform.fit&&["fill","contain","cover"].includes(e.sizeChangeBehavior)&&e.transform.fit!==e.sizeChangeBehavior)throw new TypeError("config.transform.fit, when provided, cannot differ from config.sizeChangeBehavior when config.sizeChangeBehavior is 'fill', 'contain' or 'cover', as sizeChangeBehavior already determines the fitting algorithm.");if(void 0!==e.transform.rotate&&![0,90,180,270].includes(e.transform.rotate))throw new TypeError("config.transform.rotate, when provided, must be 0, 90, 180 or 270.");if(void 0!==e.transform.crop&&Cs(e.transform.crop,"config.transform."),void 0!==e.transform.process&&"function"!=typeof e.transform.process)throw new TypeError("config.transform.process, when provided, must be a function.");if(void 0!==e.transform.frameRate&&(!Number.isFinite(e.transform.frameRate)||e.transform.frameRate<=0))throw new TypeError("config.transform.frameRate, when provided, must be a finite positive number.");if(void 0!==e.transform.force&&"boolean"!=typeof e.transform.force)throw new TypeError("config.transform.force, when provided, must be a boolean.")}if(void 0!==e.onEncodedPacket&&"function"!=typeof e.onEncodedPacket)throw new TypeError("config.onEncodedPacket, when provided, must be a function.");if(void 0!==e.onEncoderConfig&&"function"!=typeof e.onEncoderConfig)throw new TypeError("config.onEncoderConfig, when provided, must be a function.");if(void 0!==e.onEncodedSample&&"function"!=typeof e.onEncodedSample)throw new TypeError("config.onEncodedSample, when provided, must be a function.");Sd(e.codec,e)},Sd=(e,t)=>{if(!t||"object"!=typeof t)throw new TypeError("Encoding options must be an object.");if(void 0!==t.alpha&&!["discard","keep"].includes(t.alpha))throw new TypeError("options.alpha, when provided, must be 'discard' or 'keep'.");if(void 0!==t.bitrateMode&&!["constant","variable"].includes(t.bitrateMode))throw new TypeError("bitrateMode, when provided, must be 'constant' or 'variable'.");if(void 0!==t.latencyMode&&!["quality","realtime"].includes(t.latencyMode))throw new TypeError("latencyMode, when provided, must be 'quality' or 'realtime'.");if(void 0!==t.fullCodecString&&"string"!=typeof t.fullCodecString)throw new TypeError("fullCodecString, when provided, must be a string.");if(void 0!==t.fullCodecString&&qe(t.fullCodecString)!==e)throw new TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`);if(void 0!==t.hardwareAcceleration&&!["no-preference","prefer-hardware","prefer-software"].includes(t.hardwareAcceleration))throw new TypeError("hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.");if(void 0!==t.scalabilityMode&&"string"!=typeof t.scalabilityMode)throw new TypeError("scalabilityMode, when provided, must be a string.");if(void 0!==t.contentHint&&"string"!=typeof t.contentHint)throw new TypeError("contentHint, when provided, must be a string.")},Cd=e=>{const t=e.bitrate instanceof Id?e.bitrate._toVideoBitrate(e.codec,e.
1width,e.height):e.bitrate;return{codec:e.fullCodecString??De(e.codec,e.width,e.height,t),width:e.width,height:e.height,displayWidth:e.squarePixelWidth,displayHeight:e.squarePixelHeight,bitrate:t,bitrateMode:e.bitrateMode,alpha:e.alpha??"discard",framerate:e.framerate,latencyMode:e.latencyMode,hardwareAcceleration:e.hardwareAcceleration,scalabilityMode:e.scalabilityMode,contentHint:e.contentHint,...(r=e.codec,"avc"===r?{avc:{format:"avc"}}:"hevc"===r?{hevc:{format:"hevc"}}:{})};var r},Pd=e=>{if(!e||"object"!=typeof e)throw new TypeError("Encoding config must be an object.");if(!Ie.includes(e.codec))throw new TypeError(`Invalid audio codec '${e.codec}'. Must be one of: ${Ie.join(", ")}.`);if(void 0===e.bitrate&&!Ae.includes(e.codec)&&"flac"!==e.codec)throw new TypeError("config.bitrate must be provided for compressed audio codecs.");if(void 0!==e.bitrate&&!(e.bitrate instanceof Id)&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw new TypeError("config.bitrate, when provided, must be a positive integer or a quality.");if(void 0!==e.transform){if("object"!=typeof e.transform||!e.transform)throw new TypeError("config.transform, when provided, must be an object.");if(void 0!==e.transform.numberOfChannels&&(!Number.isInteger(e.transform.numberOfChannels)||e.transform.numberOfChannels<=0))throw new TypeError("config.transform.numberOfChannels, when provided, must be a positive integer.");if(void 0!==e.transform.sampleRate&&(!Number.isInteger(e.transform.sampleRate)||e.transform.sampleRate<=0))throw new TypeError("config.transform.sampleRate, when provided, must be a positive integer.");if(void 0!==e.transform.sampleFormat&&!["u8","s16","s32","f32"].includes(e.transform.sampleFormat))throw new TypeError("config.transform.sampleFormat, when provided, must be one of: u8, s16, s32, f32.");if(void 0!==e.transform.process&&"function"!=typeof e.transform.process)throw new TypeError("config.transform.process, when provided, must be a function.")}if(void 0!==e.onEncodedPacket&&"function"!=typeof e.onEncodedPacket)throw new TypeError("config.onEncodedPacket, when provided, must be a function.");if(void 0!==e.onEncoderConfig&&"function"!=typeof e.onEncoderConfig)throw new TypeError("config.onEncoderConfig, when provided, must be a function.");if(void 0!==e.onEncodedSample&&"function"!=typeof e.onEncodedSample)throw new TypeError("config.onEncodedSample, when provided, must be a function.");Ad(e.codec,e)},Ad=(e,t)=>{if(!t||"object"!=typeof t)throw new TypeError("Encoding options must be an object.");if(void 0!==t.bitrateMode&&!["constant","variable"].includes(t.bitrateMode))throw new TypeError("bitrateMode, when provided, must be 'constant' or 'variable'.");if(void 0!==t.fullCodecString&&"string"!=typeof t.fullCodecString)throw new TypeError("fullCodecString, when provided, must be a string.");if(void 0!==t.fullCodecString&&qe(t.fullCodecString)!==e)throw new TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`)},Ed=e=>{const t=e.bitrate instanceof Id?e.bitrate._toAudioBitrate(e.codec):e.bitrate;return{codec:e.fullCodecString??Ue(e.codec,e.numberOfChannels,e.sampleRate),numberOfChannels:e.numberOfChannels,sampleRate:e.sampleRate,bitrate:t,bitrateMode:e.bitrateMode,...(r=e.codec,"aac"===r?{aac:{format:"aac"}}:"opus"===r?{opus:{format:"opus"}}:{})};var r};class Id{constructor(e){this._factor=e}_toVideoBitrate(e,t,r){const i=t*r,n=3e6*Math.pow(i/2073600,.95)*{avc:1,hevc:.6,vp9:.6,av1:.4,vp8:1.2}[e]*this._factor;return 1e3*Math.ceil(n/1e3)}_toAudioBitrate(e){if(Ae.includes(e)||"flac"===e)return;const t={aac:128e3,opus:64e3,mp3:16e4,vorbis:64e3,ac3:384e3,eac3:192e3}[e];if(!t)throw new Error(`Unhandled codec: ${e}`);let r=t*this._factor;if("aac"===e){r=[96e3,128e3,16e4,192e3].reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e)}else if("opus"===e||"vorbis"===e)r=Math.max(6e3,r);else if("mp3"===e){r=[8e3,16e3,24e3,32e3,4e4,48e3,64e3,8e4,96e3,112e3,128e3,16e4,192e3,224e3,256e3,32e4].reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e)}return 1e3*Math.round(r/1e3)}}const $d=new Id(2),_d=async(e,t={})=>{const{width:r=1280,height:i=720,bitrate:n=1e6,...a}=t;if(!Pe.includes(e))return!1;if(!Number.isInteger(r)||r<=0)throw new TypeError("width must be a positive integer.");if(!Number.isInteger(i)||i<=0)throw new TypeError("height must be a positive integer.");if(!(n instanceof Id)&&(!Number.isInteger(n)||n<=0))throw new TypeError("bitrate must be a positive integer or a quality.");Sd(e,a);const s=Cd({codec:e,width:r,height:i,bitrate:n,framerate:void 0,...a,alpha:"discard"}),o=JSON.stringify(s),c=kd.get(o);if(c)return c;const d=(async()=>
1{if(os.some(t=>t.supports(e,s)))return!0;if("undefined"==typeof VideoEncoder)return!1;if((r%2==1||i%2==1)&&("avc"===e||"hevc"===e))return!1;return!!(await VideoEncoder.isConfigSupported(s)).supported&&(!ie()||new Promise(async e=>{try{const t=new VideoEncoder({output:()=>{},error:()=>e(!1)});t.configure(s);const n=new Uint8Array(r*i*4),a=new VideoFrame(n,{format:"RGBA",codedWidth:r,codedHeight:i,timestamp:0});t.encode(a),a.close(),await t.flush(),e(!0)}catch{e(!1)}}))})();return kd.set(o,d),d},Nd=async(e,t={})=>{const{numberOfChannels:r=2,sampleRate:i=48e3,bitrate:n=128e3,...a}=t;if(!Ie.includes(e))return!1;if(!Number.isInteger(r)||r<=0)throw new TypeError("numberOfChannels must be a positive integer.");if(!Number.isInteger(i)||i<=0)throw new TypeError("sampleRate must be a positive integer.");if(!(n instanceof Id)&&(!Number.isInteger(n)||n<=0))throw new TypeError("bitrate must be a positive integer.");Ad(e,a);const s=Ed({codec:e,numberOfChannels:r,sampleRate:i,bitrate:n,...a}),o=JSON.stringify(s),c=Td.get(o);if(c)return c;const d=(async()=>{if(cs.some(t=>t.supports(e,s)))return!0;if(Ae.includes(e))return!0;if("undefined"==typeof AudioEncoder)return!1;return!0===(await AudioEncoder.isConfigSupported(s)).supported})();return Td.set(o,d),d},Rd=async(e=Ie,t)=>{const r=await Promise.all(e.map(e=>Nd(e,t)));return e.filter((e,t)=>r[t])};class Od{constructor(e){this.sourceSampleRate=null,this.sourceNumberOfChannels=null,this.startTime=null,this.bufferStartFrame=0,this.maxWrittenFrame=null,this.targetSampleRate=e.targetSampleRate,this.targetNumberOfChannels=e.targetNumberOfChannels,this.onSample=e.onSample,this.bufferSizeInFrames=Math.floor(5*this.targetSampleRate),this.bufferSizeInSamples=this.bufferSizeInFrames*this.targetNumberOfChannels,this.outputBuffer=new Float32Array(this.bufferSizeInSamples)}doChannelMixerSetup(){l(null!==this.sourceNumberOfChannels);const e=this.sourceNumberOfChannels,t=this.targetNumberOfChannels;this.channelMixer=1===e&&2===t?(t,r)=>t[r*e]:1===e&&4===t?(t,r,i)=>t[r*e]*+(i<2):1===e&&6===t?(t,r,i)=>t[r*e]*+(2===i):2===e&&1===t?(t,r)=>{const i=r*e;return.5*(t[i]+t[i+1])}:2===e&&4===t||2===e&&6===t?(t,r,i)=>t[r*e+i]*+(i<2):4===e&&1===t?(t,r)=>{const i=r*e;return.25*(t[i]+t[i+1]+t[i+2]+t[i+3])}:4===e&&2===t?(t,r,i)=>{const n=r*e;return.5*(t[n+i]+t[n+i+2])}:4===e&&6===t?(t,r,i)=>{const n=r*e;return i<2?t[n+i]:2===i||3===i?0:t[n+i-2]}:6===e&&1===t?(t,r)=>{const i=r*e;return Math.SQRT1_2*(t[i]+t[i+1])+t[i+2]+.5*(t[i+4]+t[i+5])}:6===e&&2===t?(t,r,i)=>{const n=r*e;return t[n+i]+Math.SQRT1_2*(t[n+2]+t[n+i+4])}:6===e&&4===t?(t,r,i)=>{const n=r*e;return i<2?t[n+i]+Math.SQRT1_2*t[n+2]:t[n+i+2]}:(t,r,i)=>i<e?t[r*e+i]:0}ensureTempBufferSize(e){let t=this.tempSourceBuffer.length;for(;t<e;)t*=2;if(t!==this.tempSourceBuffer.length){const e=new Float32Array(t);e.set(this.tempSourceBuffer),this.tempSourceBuffer=e}}async add(e){null===this.sourceSampleRate&&(this.sourceSampleRate=e.sampleRate,this.sourceNumberOfChannels=e.numberOfChannels,this.startTime=e.timestamp,this.tempSourceBuffer=new Float32Array(this.sourceSampleRate*this.sourceNumberOfChannels),this.doChannelMixerSetup()),l(null!==this.startTime);const t=e.numberOfFrames*e.numberOfChannels;this.ensureTempBufferSize(t);const r=e.allocationSize({planeIndex:0,format:"f32"}),i=new Float32Array(this.tempSourceBuffer.buffer,0,r/4);e.copyTo(i,{planeIndex:0,format:"f32"});const n=e.timestamp-this.startTime,a=n+e.duration,s=Math.floor(n*this.targetSampleRate),o=Math.ceil(a*this.targetSampleRate);for(let t=s;t<o;t++){if(t<this.bufferStartFrame)continue;for(;t>=this.bufferStartFrame+this.bufferSizeInFrames;)await this.finalizeCurrentBuffer(),this.bufferStartFrame+=this.bufferSizeInFrames;const r=t-this.bufferStartFrame;l(r<this.bufferSizeInFrames);const a=(t/this.targetSampleRate-n)*this.sourceSampleRate,s=Math.floor(a),o=Math.ceil(a),c=a-s;for(let t=0;t<this.targetNumberOfChannels;t++){let n=0,a=0;s>=0&&s<e.numberOfFrames&&(n=this.channelMixer(i,s,t)),o>=0&&o<e.numberOfFrames&&(a=this.channelMixer(i,o,t));const d=n+c*(a-n),l=r*this.targetNumberOfChannels+t;this.outputBuffer[l]+=d}null===this.maxWrittenFrame?this.maxWrittenFrame=r:this.maxWrittenFrame=Math.max(this.maxWrittenFrame,r)}}async finalizeCurrentBuffer(){if(null===this.maxWrittenFrame)return;l(null!==this.startTime);const e=(this.maxWrittenFrame+1)*this.targetNumberOfChannels,t=new Float32Array(e);t.set(this.outputBuffer.subarray(0,e));const r=new _s({format:"f32",sampleRate:this.targetSampleRate,numberOfChannels:this.targetNumberOfChannels,timestamp:this.startTime+this.bufferStartFrame/this.targetSampleRate,data:t});await this.onSample(r),this.outputBuffer.fill(0),this.maxWrittenFrame=null}finalize(){return this.finalizeCurrentBuffer()}}class Fd{constructor(){this._connectedTrack=null,this._closingPromise=null,this._closed=!1}
1_ensureValidAdd(){if(!this._connectedTrack)throw new Error("Source is not connected to an output track.");if("canceled"===this._connectedTrack.output.state)throw new Error("Output has been canceled.");if("finalizing"===this._connectedTrack.output.state||"finalized"===this._connectedTrack.output.state)throw new Error("Output has been finalized.");if("pending"===this._connectedTrack.output.state)throw new Error("Output has not started.");if(this._closed)throw new Error("Source is closed.")}async _start(){}async _flushAndClose(e){}close(){if(this._closingPromise)return;const e=this._connectedTrack;if(!e)throw new Error("Cannot call close without connecting the source to an output track.");if("pending"===e.output.state)throw new Error("Cannot call close before output has been started.");this._closingPromise=(async()=>{await this._flushAndClose(!1),this._closed=!0,"finalizing"!==e.output.state&&"finalized"!==e.output.state&&e.output._muxer.onTrackClose(e)})()}async _flushOrWaitForOngoingClose(e){return this._closingPromise??=(async()=>{await this._flushAndClose(e),this._closed=!0})()}}class Bd extends Fd{constructor(e){if(super(),this._connectedTrack=null,!Pe.includes(e))throw new TypeError(`Invalid video codec '${e}'. Must be one of: ${Pe.join(", ")}.`);this._codec=e}}const Dd=(e,t)=>{if(e.metadata.hasOnlyKeyPackets&&"key"!==t.type)throw new Error("Cannot add non-key packets to a hasOnlyKeyPackets video track.")};class Md extends Bd{constructor(e){super(e)}add(e,t){if(!(e instanceof Yt))throw new TypeError("packet must be an EncodedPacket.");if(e.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be added.");if(void 0!==t&&(!t||"object"!=typeof t))throw new TypeError("meta, when provided, must be an object.");return this._ensureValidAdd(),Dd(this._connectedTrack,e),this._connectedTrack.output._muxer.addEncodedVideoPacket(this._connectedTrack,e,t)}}class jd{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastMultipleOfKeyFrameInterval=-1,this.emittedEncoderPackets=0,this.codedWidth=null,this.co
1dedHeight=null,this.outputWidth=null,this.outputHeight=null,this.frameRateLastSample=null,this.frameRateLastTimestamp=null,this.frameRateLastEndTimestamp=null,this.preciseTimings=[],this.customEncoder=null,this.customEncoderCallSerializer=new Z,this.customEncoderQueueSize=0,this.alphaEncoder=null,this.splitter=null,this.splitterCreationFailed=!1,this.alphaFrameQueue=[],this.error=null,this.closed=!1,this.lastMuxerPromise=Promise.resolve()}async add(e,t,r){const i=e;try{this.checkForEncoderError(),this.source._ensureValidAdd();const n=this.encodingConfig,a=n.sizeChangeBehavior??"deny";let s=!1;if(null!==this.codedWidth&&null!==this.codedHeight){if((e.codedWidth!==this.codedWidth||e.codedHeight!==this.codedHeight)&&(s=!0,"deny"===a))throw new Error(`Video sample size must remain constant. Expected ${this.codedWidth}x${this.codedHeight}, got ${e.codedWidth}x${e.codedHeight}. To allow the sample size to change over time, set \`sizeChangeBehavior\` to a value other than 'deny' in the encoding options.`)}else this.codedWidth=e.codedWidth,this.codedHeight=e.codedHeight;const o=void 0!==n.transform?.width||void 0!==n.transform?.height||void 0!==n.transform?.rotate||void 0!==n.transform?.crop||!0===n.transform?.force;if(o||s&&"passThrough"!==a){let r=n.transform?.width,i=n.transform?.height,o=n.transform?.fit??"fill";s&&"passThrough"!==a&&(l(this.outputWidth),l(this.outputHeight),l("deny"!==a),r=this.outputWidth,i=this.outputHeight,o=a);const c=await e.transform({width:r,height:i,roundDimensionsTo:2,crop:n.transform?.crop,rotate:n.transform?.rotate,fit:o,alpha:n.alpha});null!==this.outputWidth&&null!==this.outputHeight||(this.outputWidth=c.displayWidth,this.outputHeight=c.displayHeight),t&&e.close(),e=c,t=!0}else null!==this.outputWidth&&null!==this.outputHeight||(this.outputWidth=e.codedWidth,this.outputHeight=e.codedHeight);const c=n.transform?.frameRate;if(void 0!==c){const n=e.timestamp+e.duration,a=Y(e.timestamp,c);if(null!==this.frameRateLastSample){if(a<=this.frameRateLastTimestamp)return this.frameRateLastSample.close(),this.frameRateLastSample=e.clone(),void(this.frameRateLastEndTimestamp=n);await this.padFrameRate(a,r)}e===i&&(e=e.clone(),t=!0),e.setTimestamp(a),e.setDuration(1/c),this.frameRateLastSample?.close(),this.frameRateLastSample=e.clone(),this.frameRateLastTimestamp=a,this.frameRateLastEndTimestamp=n}await this.processAndEncode(e,r)}finally{t&&e.close()}}async processAndEncode(e,t){const r=this.encodingConfig;let i;if(r.transform?.process){let t=r.transform.process(e);if(t instanceof Promise&&(t=await t),null===t)return;Array.isArray(t)||(t=[t]),i=t.map(t=>t instanceof ys?t:"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?new ys(t):new ys(t,{timestamp:e.timestamp,duration:e.duration}))}else i=[e];try{for(const e of i){if(this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),l(this.encoderInitialized),this.closed)break;const r=this.encodingConfig.keyFrameInterval??2,i=Math.floor(e.timestamp/r),n={...e.encodeOptions,...t},a={...n,keyFrame:void 0!==n.keyFrame?n.keyFrame:0===r||i!==this.lastMultipleOfKeyFrameInterval};if(this.lastMultipleOfKeyFrameInterval=i,this.encodingConfig.onEncodedSample?.(e),this.customEncoder){this.customEncoderQueueSize++;const t=e.clone(),r=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(t,a)).then(()=>this.customEncoderQueueSize--).catch(e=>this.error??=e).finally(()=>{t.close()});this.customEncoderQueueSize>=4&&await r}else{l(this.encoder);const t=e.toVideoFrame(),r=O(this.preciseTimings,t.timestamp,e=>e.microsecondTimestamp),i=-1!==r?this.preciseTimings[r]:null;if(i&&i.microsecondTimestamp===t.timestamp?(i.timestamp!==e.timestamp&&(i.timestampIsValid=!1),i.duration!==e.duration&&(i.durationIsValid=!1)):(this.preciseTimings.splice(r+1,0,{microsecondTimestamp:t.timestamp,timestamp:e.timestamp,duration:e.duration,timestampIsValid:!0,durationIsValid:!0}),this.preciseTimings.length>128&&this.preciseTimings.shift()),this.alphaEncoder){if(!!t.format&&!t.format.includes("A")||this.splitterCreationFailed)this.alphaFrameQueue.push(null),this.encoder.encode(t,a),t.close();else{const e=t.displayWidth,r=t.displayHeight;this.splitter||(this.splitter=new Ud(e,r));const{colorFrame:i,alphaFrame:n}=await this.splitter.update(t);this.alphaFrameQueue.push(n),this.encoder.encode(i,a),i.close()}}else this.encoder.encode(t,a),t.close();this.encoder.encodeQueueSize>=4&&await new Promise(e=>this.encoder.addEventListener("dequeue",e,{once:!0}))}await this.lastMuxerPromise}}finally{for(const t of i)t!==e&&t.close()}}async padFrameRate(e,t){const r=this.encodingConfig.transform.frameRate;l(this.frameRateLastSample);const i=Math.round((e-this.frameRateLastTimestamp)*r);for(let e=1;e<i;e++){const i=this.frameRateLastSample.clone();i.setTimestamp(this.frameRateLastTimestamp+e/r),i.setDuration(1/r),await this.processAndEncode(i,t),i.close()}}ensureEncoder(e){this.ensureEncoderPromise=(async()=>{const t=Cd({...this.encodingConfig,width:e.codedWidth,height:e.codedHeight,squarePixelWidth:e.squarePixelWidth,squarePixelHeight:e.squarePixelHeight,framerate:this.source._connectedTrack?.metadata.frameRate});this.encodingConfig.onEncoderConfig?.(t);const r=os.find(e=>e.supports(this.encodingConfig.codec,t));if(r)this.customEncoder=new r,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=t,this.customEncoder.onPacket=(e,t)=>{if(!(e instanceof Yt))throw new TypeError("The first argument passed to onPacket must be an EncodedPacket.");if(void 0!==t&&(!t||"object"!=typeof t))throw new TypeError("The second argument passed to onPacket must be an object or undefined.");Dd(this.source._connectedTrack,e),this.encodingConfig.onEncodedPacket?.(e,t),this.lastMuxerPromise=this.muxer.addEncodedVideoPacket(this.source._connectedTrack,e,t).catch(e=>{this.error??=e})},await this.customEncoder.init();else{if("undefined"==typeof VideoEncoder)throw new Error("VideoEncoder is not supported by this browser.");t.alpha="discard","keep"===this.encodingConfig.alpha&&(t.latencyMode="quality");if((t.width%2==1||t.height%2==1)&&("avc"===this.encodingConfig.codec||"hevc"===this.encodingConfig.codec))throw new Error(`The dimensions ${t.width}x${t.height} are not supported for codec '${this.encodingConfig.codec}'; both width and height must be even numbers. Make sure to round your dimensions to the nearest even number.`);if(!(await VideoEncoder.isConfigSupported(t)).supported)throw new Error(`This specific encoder configuration (${t.codec}, ${t.bitrate} bps, ${t.width}x${t.height}, hardware acceleration: ${t.hardwareAcceleration??"no-preference"}) is not supported by this browser. Consider using another codec or changing your video parameters.`);const e=[],r=[];let i=0,n=0;const a=(e,t,r)=>{const i={};if(t){const e=new Uint8Array(t.byteLength);t.copyTo(e),i.alpha=e}let n=Yt.fromEncodedChunk(e,i);
1const a=O(this.preciseTimings,e.timestamp,e=>e.microsecondTimestamp),s=-1!==a?this.preciseTimings[a]:null;let o=null;0===this.emittedEncoderPackets&&"delta"===n.type&&r?.decoderConfig&&(o=Dt(this.encodingConfig.codec,r.decoderConfig,n.data)),(s&&s.microsecondTimestamp===e.timestamp||null!==o)&&(n=n.clone({timestamp:s?.timestampIsValid?s.timestamp:void 0,duration:s?.durationIsValid?s.duration:void 0,type:o??void 0})),Dd(this.source._connectedTrack,n),this.encodingConfig.onEncodedPacket?.(n,r),this.lastMuxerPromise=this.muxer.addEncodedVideoPacket(this.source._connectedTrack,n,r).catch(e=>{this.error??=e}),this.emittedEncoderPackets++},s=new Error("Encoding error").stack;if(this.encoder=new VideoEncoder({output:(t,s)=>{if(!this.alphaEncoder)return void a(t,null,s);const o=this.alphaFrameQueue.shift();l(void 0!==o),o?(this.alphaEncoder.encode(o,{keyFrame:"key"===t.type}),n++,o.close(),e.push({chunk:t,meta:s})):0===n?a(t,null,s):(r.push(i+n),e.push({chunk:t,meta:s}))},error:e=>{e.stack=s,this.error??=e}}),this.encoder.configure(t),"keep"===this.encodingConfig.alpha){const s=new Error("Encoding error").stack;
1this.alphaEncoder=new VideoEncoder({output:(t,s)=>{n--;const o=e.shift();for(l(void 0!==o),a(o.chunk,t,o.meta),i++;r.length>0&&r[0]===i;){r.shift();const t=e.shift();l(void 0!==t),a(t.chunk,null,t.meta)}},error:e=>{e.stack=s,this.error??=e}}),this.alphaEncoder.configure(t)}}l(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}async flushAndClose(e){if(e||this.checkForEncoderError(),!e&&this.frameRateLastSample){const e=this.encodingConfig.transform.frameRate,t=Y(this.frameRateLastEndTimestamp,e);await this.padFrameRate(t)}this.closed=!0,this.frameRateLastSample?.close(),this.frameRateLastSample=null,this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||(await this.encoder.flush(),await(this.alphaEncoder?.flush())),"closed"!==this.encoder.state&&this.encoder.close(),this.alphaEncoder&&"closed"!==this.alphaEncoder.state&&this.alphaEncoder.close(),this.alphaFrameQueue.forEach(e=>e?.close()),this.splitter?.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.error}}let Ld=!1;class Ud{constructor(e,t){this.canvas=null,this.gl=null,this.colorProgram=null,this.alphaProgram=null,this.vao=null,this.sourceTexture=null,this.alphaResolutionLocation=null,this.worker=null,this.pendingRequests=new Map,this.nextRequestId=0;const r="undefined"!=typeof OffscreenCanvas||"undefined"!=typeof document&&"function"==typeof document.createElement;if(!Ud.forceCpu&&r&&!Ld)try{"undefined"!=typeof OffscreenCanvas?this.canvas=new OffscreenCanvas(e,t):(this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=t);const r=this.canvas.getContext("webgl2",{alpha:!0});if(!r)throw new Error("Couldn't acquire WebGL 2 context.");this.gl=r,this.colorProgram=this.createColorProgram(),this.alphaProgram=this.createAlphaProgram(),this.vao=this.createVAO(),this.sourceTexture=this.createTexture(),this.alphaResolutionLocation=this.gl.getUniformLocation(this.alphaProgram,"u_resolution"),this.gl.useProgram(this.colorProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.colorProgram,"u_sourceTexture"),0),this.gl.useProgram(this.alphaProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.alphaProgram,"u_sourceTexture"),0)}catch(e){this.gl=null,this.canvas=null,Ld=!0,d._warn("Falling back to CPU for color/alpha splitting.",e)}}async update(e){return this.gl?this.updateGpu(e):this.updateCpu(e)}updateGpu(e){l(this.gl),l(this.canvas),e.displayWidth===this.canvas.width&&e.displayHeight===this.canvas.height||(this.canvas.width=e.displayWidth,this.canvas.height=e.displayHeight),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e);const t=this.runColorProgram(e),r=this.runAlphaProgram(e);return e.close(),{colorFrame:t,alphaFrame:r}}createVertexShader(){return l(this.gl),this.createShader(this.gl.VERTEX_SHADER,"#version 300 es\n\t\t\tin vec2 a_position;\n\t\t\tin vec2 a_texCoord;\n\t\t\tout vec2 v_texCoord;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tgl_Position = vec4(a_position, 0.0, 1.0);\n\t\t\t\tv_texCoord = a_texCoord;\n\t\t\t}\n\t\t")}createColorProgram(){l(this.gl);const e=this.createVertexShader(),t=this.createShader(this.gl.FRAGMENT_SHADER,"#version 300 es\n\t\t\tprecision highp float;\n\t\t\t\n\t\t\tuniform sampler2D u_sourceTexture;\n\t\t\tin vec2 v_texCoord;\n\t\t\tout vec4 fragColor;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tvec4 source = texture(u_sourceTexture, v_texCoord);\n\t\t\t\tfragColor = vec4(source.rgb, 1.0);\n\t\t\t}\n\t\t"),r=this.gl.createProgram();return this.gl.attachShader(r,e),this.gl.attachShader(r,t),this.gl.linkProgram(r),r}createAlphaProgram(){l(this.gl);const e=this.createVertexShader(),t=this.createShader(this.gl.FRAGMENT_SHADER,"#version 300 es\n\t\t\tprecision highp float;\n\t\t\t\n\t\t\tuniform sampler2D u_sourceTexture;\n\t\t\tuniform vec2 u_resolution; // The width and height of the canvas\n\t\t\tin vec2 v_texCoord;\n\t\t\tout vec4 fragColor;\n\n\t\t\t// This function determines the value for a single byte in the YUV stream\n\t\t\tfloat getByteValue(float byteOffset) {\n\t\t\t\tfloat width = u_resolution.x;\n\t\t\t\tfloat height = u_resolution.y;\n\n\t\t\t\tfloat yPlaneSize = width * height;\n\n\t\t\t\tif (byteOffset < yPlaneSize) {\n\t\t\t\t\t// This byte is in the luma plane. Find the corresponding pixel coordinates to sample from\n\t\t\t\t\tfloat y = floor(byteOffset / width);\n\t\t\t\t\tfloat x = mod(byteOffset, width);\n\t\t\t\t\t\n\t\t\t\t\t// Add 0.5 to sample the center of the texel\n\t\t\t\t\tvec2 sampleCoord = (vec2(x, y) + 0.5) / u_resolution;\n\t\t\t\t\t\n\t\t\t\t\t// The luma value is the alpha from the source texture\n\t\t\t\t\treturn texture(u_sourceTexture, sampleCoord).a;\n\t\t\t\t} else {\n\t\t\t\t\t// Write a fixed value for chroma and beyond\n\t\t\t\t\treturn 128.0 / 25
15.0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\t// Each fragment writes 4 bytes (R, G, B, A)\n\t\t\t\tfloat pixelIndex = floor(gl_FragCoord.y) * u_resolution.x + floor(gl_FragCoord.x);\n\t\t\t\tfloat baseByteOffset = pixelIndex * 4.0;\n\n\t\t\t\tvec4 result;\n\t\t\t\tfor (int i = 0; i < 4; i++) {\n\t\t\t\t\tfloat currentByteOffset = baseByteOffset + float(i);\n\t\t\t\t\tresult[i] = getByteValue(currentByteOffset);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfragColor = result;\n\t\t\t}\n\t\t"),r=this.gl.createProgram();return this.gl.attachShader(r,e),this.gl.attachShader(r,t),this.gl.linkProgram(r),r}createShader(e,t){l(this.gl);const r=this.gl.createShader(e);return this.gl.shaderSource(r,t),this.gl.compileShader(r),this.gl.getShaderParameter(r,this.gl.COMPILE_STATUS)||d._error("Shader compile error:",this.gl.getShaderInfoLog(r)),r}createVAO(){l(this.gl),l(this.colorProgram);const e=this.gl.createVertexArray();this.gl.bindVertexArray(e);const t=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),r=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,r),this.gl.bufferData(this.gl.ARRAY_BUFFER,t,this.gl.STATIC_DRAW);const i=this.gl.getAttribLocation(this.colorProgram,"a_position"),n=this.gl.getAttribLocation(this.colorProgram,"a_texCoord");return this.gl.enableVertexAttribArray(i),this.gl.vertexAttribPointer(i,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(n),this.gl.vertexAttribPointer(n,2,this.gl.FLOAT,!1,16,8),e}createTexture(){l(this.gl);const e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),e}runColorProgram(e){return l(this.gl),l(this.canvas),this.gl.useProgram(this.colorProgram),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),new VideoFrame(this.canvas,{timestamp:e.timestamp,duration:e.duration??void 0,alpha:"discard"})}runAlphaProgram(e){l(this.gl),l(this.canvas),this.gl.useProgram(this.alphaProgram),this.gl.uniform2f(this.alphaResolutionLocation,this.canvas.width,this.canvas.height),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4);const{width:t,height:r}=this.canvas,i=t*r+2*(Math.ceil(t/2)*Math.ceil(r/2)),n=Math.ceil(i/(4*t));let a=new Uint8Array(4*t*n);this.gl.readPixels(0,0,t,n,this.gl.RGBA,this.gl.UNSIGNED_BYTE,a),a=a.subarray(0,i),l(128===a[t*r]),l(128===a[a.length-1]);const s={format:"I420",codedWidth:t,codedHeight:r,timestamp:e.timestamp,duration:e.duration??void 0,transfer:[a.buffer]};return new VideoFrame(a,s)}updateCpu(e){if(!this.worker){const e=new Blob([`(${zd.toString()})()`],{type:"application/javascript"}),t=URL.createObjectURL(e);this.worker=new Worker(t),URL.revokeObjectURL(t),this.worker.addEventListener("message",e=>{const t=e.data,r=this.pendingRequests.get(t.id);r&&(this.pendingRequests.delete(t.id),"error"in t?r.reject(new Error(t.error)):r.resolve({colorFrame:t.colorFrame,alphaFrame:t.alphaFrame}))}),this.worker.addEventListener("error",e=>{const t=new Error(e.message||"Color/alpha splitter worker error.");for(const e of this.pendingRequests.values())e.reject(t);this.pendingRequests.clear()})}const t=this.nextRequestId++,r=B();return this.pendingRequests.set(t,r),this.worker.postMessage({id:t,sourceFrame:e},{transfer:[e]}),r.promise}close(){this.gl?.getExtension("WEBGL_lose_context")?.loseContext(),this.gl=null,this.canvas=null,this.worker?.terminate(),this.worker=null;const e=new Error("Color/alpha splitter closed.");for(const t of this.pendingRequests.values())t.reject(e);this.pendingRequests.clear()}}Ud.forceCpu=!0;const zd=()=>{let e=null,t=Promise.resolve();self.addEventListener("message",e=>{const{id:i,sourceFrame:n}=e.data;t=t.then(async()=>{try{const{colorFrame:e,alphaFrame:t}=await r(n);self.postMessage({id:i,colorFrame:e,alphaFrame:t},{transfer:[e,t]})}catch(e){self.postMessage({id:i,error:e.message})}finally{n.close()}})});const r=async t=>{const r=t.format;if(!r)throw new Error("CPU color/alpha splitting requires a known VideoFrame format.");const a=t.codedWidth,s=t.codedHeight,o=t.allocationSize();if(e&&e.byteLength===o||(e=new Uint8Array(o)),await t.copyTo(e),"RGBA"===r||"BGRA"
1===r)return i(e,a,s,r,t);if("I420A"===r||"I420AP10"===r||"I420AP12"===r||"I422A"===r||"I422AP10"===r||"I422AP12"===r||"I444A"===r||"I444AP10"===r||"I444AP12"===r)return n(e,a,s,r,t);throw new Error(`CPU color/alpha splitting does not support format '${r}'.`)},i=(e,t,r,i,n)=>{const a=t*r,s=Math.ceil(t/2),o=Math.ceil(r/2),c=new Uint8Array(a+s*o*2);for(let t=0,r=3;t<a;t++,r+=4)c[t]=e[r];c.fill(128,a);const d=new VideoFrame(e,{format:"RGBA"===i?"RGBX":"BGRX",codedWidth:t,codedHeight:r,timestamp:n.timestamp,duration:n.duration??void 0}),l={format:"I420",codedWidth:t,codedHeight:r,timestamp:n.timestamp,duration:n.duration??void 0,transfer:[c.buffer]};return{colorFrame:d,alphaFrame:new VideoFrame(c,l)}},n=(e,t,r,i,n)=>{const a=i.includes("P10"),s=i.includes("P12"),o=a||s?2:1;let c,d;i.startsWith("I420")?(c=Math.ceil(t/2),d=Math.ceil(r/2)):i.startsWith("I422")?(c=Math.ceil(t/2),d=r):(c=t,d=r);const l=t*r,u=l*o,h=l*o+2*(c*d*o),f=i.replace("A",""),m=Math.ceil(t/2)*Math.ceil(r/2),p=new Uint8Array(u+2*(m*o)),g=h;p.set(e.subarray(g,g+u),0);const y=u,b=a?512:s?2048:128;if(1===o)p.fill(b,y);else{new Uint16Array(p.buffer,y,2*m).fill(b)}const w=a?"I420P10":s?"I420P12":"I420",v=new VideoFrame(e.subarray(0,h),{format:f,codedWidth:t,codedHeight:r,timestamp:n.timestamp,duration:n.duration??void 0}),k={format:w,codedWidth:t,codedHeight:r,timestamp:n.timestamp,duration:n.duration??void 0,transfer:[p.buffer]};return{colorFrame:v,alphaFrame:new VideoFrame(p,k)}}};class Wd extends Bd{constructor(e){xd(e),super(e.codec),this._encoder=new jd(this,e)}add(e,t){if(!(e instanceof ys))throw new TypeError("videoSample must be a VideoSample.");return this._encoder.add(e,!1,t)}_flushAndClose(e){return this._encoder.flushAndClose(e)}}class Vd extends Fd{constructor(e){if(super(),this._connectedTrack=null,!Ie.includes(e))throw new TypeError(`Invalid audio codec '${e}'. Must be one of: ${Ie.join(", ")}.`);this._codec=e}}class qd extends Vd{constructor(e){super(e)}add(e,t){if(!(e instanceof Yt))throw new TypeError("packet must be an EncodedPacket.");if(e.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be added.");if(void 0!==t&&(!t||"object"!=typeof t))throw new TypeError("meta, when provided, must be an object.");return this._ensureValidAdd(),this._connectedTrack.output._muxer.addEncodedAudioPacket(this._connectedTrack,e,t)}}class Hd{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastNumberOfChannels=null,this.lastSampleRate=null,this.isPcmEncoder=!1,this.outputSampleSize=null,this.writeOutputValue=null,this.customEncoder=null,this.customEncoderCallSerializer=new Z,this.customEncoderQueueSize=0,this.lastEndSampleIndex=null,this.resampler=null,this.error=null,this.lastMuxerPromise=Promise.resolve(),this.closed=!1}async add(e,t){try{if(this.checkForEncoderError(),this.source._ensureValidAdd(),null!==this.lastNumberOfChannels&&null!==this.lastSampleRate){if(e.numberOfChannels!==this.lastNumberOfChannels||e.sampleRate!==this.lastSampleRate)throw new Error(`Audio parameters must remain constant. Expected ${this.lastNumberOfChannels} channels at ${this.lastSampleRate} Hz, got ${e.numberOfChannels} channels at ${e.sampleRate} Hz.`)}else this.lastNumberOfChannels=e.numberOfChannels,this.lastSampleRate=e.sampleRate;const r=this.encodingConfig;void 0!==r.transform?.numberOfChannels||void 0!==r.transform?.sampleRate?(this.resampler||(this.resampler=new Od({targetNumberOfChannels:r.transform.numberOfChannels??e.numberOfChannels,targetSampleRate:r.transform.sampleRate??e.sampleRate,onSample:async e=>{await this.processAndEncode(e,!0)}})),await this.resampler.add(e)):await this.processAndEncode(e,t)}finally{t&&e.close()}}async processAndEncode(e,t){const r=this.encodingConfig;if(void 0!==r.transform?.sampleFormat&&(e=>{switch(e){case"u8-planar":return"u8";case"s16-planar":return"s16";case"s32-planar":return"s32";case"f32-planar":return"f32";default:return e}})(e.format)!==r.transform.sampleFormat){const i=((e,t)=>{const r=e.allocationSize({format:t,planeIndex:0}),i=new ArrayBuffer(r);return e.copyTo(i,{format:t,planeIndex:0}),new _s({data:i,format:t,numberOfChannels:e.numberOfChannels,sampleRate:e.sampleRate,timestamp:e.timestamp,duration:e.duration})})(e,r.transform.sampleFormat);t&&e.close(),e=i,t=!0}if(r.transform?.process){let i=r.transform.process(e);if(i instanceof Promise&&(i=await i),null===i)return;Array.isArray(i)||(i=[i]);for(const e of i){if(!(e instanceof _s))throw new TypeError("The audio process function must return an AudioSample, null, or an array of AudioSamples.");await this.encodeSample(e,!0)}t&&e.close()}else await this.encodeSample(e,t)}async encodeSample(e,t){try{if(this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),l(this.encoderInitialized),this.closed)return;
1{const t=Math.round(e.timestamp*e.sampleRate),r=Math.round((e.timestamp+e.duration)*e.sampleRate);if(null===this.lastEndSampleIndex)this.lastEndSampleIndex=r;else{const r=t-this.lastEndSampleIndex;if(r>=64){const t=new _s({data:new Float32Array(r*e.numberOfChannels),format:"f32-planar",sampleRate:e.sampleRate,numberOfChannels:e.numberOfChannels,numberOfFrames:r,timestamp:this.lastEndSampleIndex/e.sampleRate});await this.encodeSample(t,!0)}this.lastEndSampleIndex+=e.numberOfFrames}}if(this.encodingConfig.onEncodedSample?.(e),this.customEncoder){this.customEncoderQueueSize++;const t=e.clone(),r=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(t)).then(()=>this.customEncoderQueueSize--).catch(e=>this.error??=e).finally(()=>{t.close()});this.customEncoderQueueSize>=4&&await r,await this.lastMuxerPromise}else if(this.isPcmEncoder)await this.doPcmEncoding(e,t);else{l(this.encoder);const r=e.toAudioData();this.encoder.encode(r),r.close(),t&&e.close(),this.encoder.encodeQueueSize>=4&&await new Promise(e=>this.encoder.addEventListener("dequeue",e,{once:!0})),await this.lastMuxerPromise}}finally{t&&e.close()}}async doPcmEncoding(e,t){l(this.outputSampleSize),l(this.writeOutputValue);const{numberOfChannels:r,numberOfFrames:i,sampleRate:n,timestamp:a}=e,s=2048,o=[];for(let t=0;t<i;t+=s){const i=Math.min(s,e.numberOfFrames-t),n=i*r*this.outputSampleSize,a=new ArrayBuffer(n),c=new DataView(a);o.push({frameCount:i,view:c})}const c=e.allocationSize({planeIndex:0,format:"f32-planar"}),d=new Float32Array(c/Float32Array.BYTES_PER_ELEMENT);for(let t=0;t<r;t++){e.copyTo(d,{planeIndex:t,format:"f32-planar"});for(let e=0;e<o.length;e++){const{frameCount:i,view:n}=o[e];for(let a=0;a<i;a++)this.writeOutputValue(n,(a*r+t)*this.outputSampleSize,d[e*s+a])}}t&&e.close();const u={decoderConfig:{codec:this.encodingConfig.codec,numberOfChannels:r,sampleRate:n}};for(let e=0;e<o.length;e++){const{frameCount:t,view:r}=o[e],i=r.buffer,c=e*s,d=new Yt(new Uint8Array(i),"key",a+c/n,t/n);this.encodingConfig.onEncodedPacket?.(d,u),await this.muxer.addEncodedAudioPacket(this.source._connectedTrack,d,u)}}ensureEncoder(e){this.ensureEncoderPromise=(async()=>{const{numberOfChannels:t,sampleRate:r}=e,i=Ed({numberOfChannels:t,sampleRate:r,...this.encodingConfig});this.encodingConfig.onEncoderConfig?.(i);const n=cs.find(e=>e.supports(this.encodingConfig.codec,i));if(n)this.customEncoder=new n,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=i,this.customEncoder.onPacket=(e,t)=>{if(!(e instanceof Yt))throw new TypeError("The first argument passed to onPacket must be an EncodedPacket.");if(void 0!==t&&(!t||"object"!=typeof t))throw new TypeError("The second argument passed to onPacket must be an object or undefined.");this.encodingConfig.onEncodedPacket?.(e,t),this.lastMuxerPromise=this.muxer.addEncodedAudioPacket(this.source._connectedTrack,e,t).catch(e=>{this.error??=e})},await this.customEncoder.init();else if(Ae.includes(this.encodingConfig.codec))this.initPcmEncoder();else{if("undefined"==typeof AudioEncoder)throw new Error("AudioEncoder is not supported by this browser.");if(!(await AudioEncoder.isConfigSupported(i)).supported)throw new Error(`This specific encoder configuration (${i.codec}, ${i.bitrate} bps, ${i.numberOfChannels} channels, ${i.sampleRate} Hz) is not supported by this browser. Consider using another codec or changing your audio parameters.`);const e=new Error("Encoding error").stack;this.encoder=new AudioEncoder({output:(e,t)=>{if("aac"===this.encodingConfig.codec&&t?.decoderConfig){let e=!1;if(!t.decoderConfig.description||t.decoderConfig.description.byteLength<2)e=!0;else{e=0===s(g(t.decoderConfig.description)).objectType}if(e){const e=Number(h(i.codec.split(".")));t.decoderConfig.description=o({objectType:e,numberOfChannels:t.decoderConfig.numberOfChannels,sampleRate:t.decoderConfig.sampleRate})}}let r=Yt.fromEncodedChunk(e);r=r.clone({timestamp:G(r.timestamp,i.sampleRate),duration:null!=e.duration?G(r.duration,i.sampleRate):void 0}),this.encodingConfig.onEncodedPacket?.(r,t),this.lastMuxerPromise=this.muxer.addEncodedAudioPacket(this.source._connectedTrack,r,t).catch(e=>{this.error??=e})},error:t=>{t.stack=e,this.error??=t}}),this.encoder.configure(i)}l(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}initPcmEncoder(){this.isPcmEncoder=!0;const e=this.encodingConfig.codec,{dataType:t,sampleSize:r,littleEndian:i}=Ve(e);switch(this.outputSampleSize=r,r){case 1:"unsigned"===t?this.writeOutputValue=(e,t,r)=>e.setUint8(t,W(127.5*(r+1),0,255)):"signed"===t?this.writeOutputValue=(e,t,r)=>{e.setInt8(t,W(Math.round(128*r),-128,127))}:"ulaw"===t?this.writeOutputValue=(e,t,r)=>{const i=W(Math.floor(32767*r),-32768,32767);e.setUint8(t,(e=>{let t=e,r=4096,i=0,n=12,a=0;for(t<0&&(t=-t,i=128),t+=33,t>8191&&(t=8191);(t&r)!==r&&n>=5;)r>>=1,n--;return a=t>>n-4&15,255&~(i|n-5<<4|a)})(i))}:"alaw"===t?this.writeOutputValue=(e,t,r)=>{const i=W(Math.floor(32767*r),-32768,32767);e.setUint8(t,(e=>{let t=2048,r=0,i=11,n=0,a=e;for(a<0&&(a=-a,r=128),a>4095&&(a=4095);(a&t)!==t&&i>=5;)t>>=1,i--;return n=a>>(4===i?1:i-4)&15,85^(r|i-4<<4|n)})(i))}:l(!1);break;case 2:"unsigned"===t?this.writeOutputValue=(e,t,r)=>e.setUint16(t,W(32767.5*(r+1),0,65535),i):"signed"===t?this.writeOutputValue=(e,t,r)=>e.setInt16(t,W(Math.round(32767*r),-32768,32767),i):l(!1);break;case 3:"unsigned"===t?this.writeOutputValue=(e,t,r)=>z(e,t,W(8388607.5*(r+1),0,16777215),i):"signed"===t?this.writeOutputValue=(e,t,r)=>((e,t,r,i)=>
1{(r=W(r,-8388608,8388607))<0&&(r=r+16777216&16777215),z(e,t,r,i)})(e,t,W(Math.round(8388607*r),-8388608,8388607),i):l(!1);break;case 4:"unsigned"===t?this.writeOutputValue=(e,t,r)=>e.setUint32(t,W(2147483647.5*(r+1),0,4294967295),i):"signed"===t?this.writeOutputValue=(e,t,r)=>e.setInt32(t,W(Math.round(2147483647*r),-2147483648,2147483647),i):"float"===t?this.writeOutputValue=(e,t,r)=>e.setFloat32(t,r,i):l(!1);break;case 8:"float"===t?this.writeOutputValue=(e,t,r)=>e.setFloat64(t,r,i):l(!1);break;default:L(r),l(!1)}}async flushAndClose(e){e||this.checkForEncoderError(),!e&&this.resampler&&await this.resampler.finalize(),this.resampler=null,this.closed=!0,this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||await this.encoder.flush(),"closed"!==this.encoder.state&&this.encoder.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.isPcmEncoder?0:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.error}}class Gd extends Vd{constructor(e){Pd(e),super(e.codec),this._encoder=new Hd(this,e)}add(e){if(!(e instanceof _s))throw new TypeError("audioSample must be an AudioSample.");return this._encoder.add(e,!1)}_flushAndClose(e){return this._encoder.flushAndClose(e)}}class Kd extends Fd{constructor(e){if(super(),this._connectedTrack=null,!$e.includes(e))throw new TypeError(`Invalid subtitle codec '${e}'. Must be one of: ${$e.join(", ")}.`);this._codec=e}}const Yd=["video","audio","subtitle"];class Xd{constructor(e,t,r,i,n){this.id=e,this.output=t,this.type=r,this.source=i,this.metadata=n}isVideoTrack(){return"video"===this.type}isAudioTrack(){return"audio"===this.type}isSubtitleTrack(){return"subtitle"===this.type}canBePairedWith(e){if(!(e instanceof Xd))throw new TypeError("other must be an OutputTrack.");if(this===e)return!1;const t=Te(this.metadata.group),r=Te(e.metadata.group);for(const i of t){if(this.type!==e.type&&r.some(e=>i===e))return!0;if(r.some(e=>i._pairedGroups.has(e)))return!0}return!1}}
1class Qd extends Xd{constructor(e,t,r,i){super(e,t,"video",r,i)}}class Jd extends Xd{constructor(e,t,r,i){super(e,t,"audio",r,i)}}class Zd extends Xd{constructor(e,t,r,i){super(e,t,"subtitle",r,i)}}class el{constructor(){this._pairedGroups=new Set}pairWith(e){if(!(e instanceof el))throw new TypeError("other must be an OutputTrackGroup.");if(this===e)throw new TypeError("Cannot pair a group with itself.");this._pairedGroups.add(e),e._pairedGroups.add(this)}}const tl=e=>{if(!e||"object"!=typeof e)throw new TypeError("metadata must be an object.");if(void 0!==e.languageCode&&!Q(e.languageCode))throw new TypeError("metadata.languageCode, when provided, must be a three-letter, ISO 639-2/T language code.");if(void 0!==e.name&&"string"!=typeof e.name)throw new TypeError("metadata.name, when provided, must be a string.");if(void 0!==e.disposition&&(e=>{if(!e||"object"!=typeof e)throw new TypeError("disposition must be an object.");if(void 0!==e.default&&"boolean"!=typeof e.default)throw new TypeError("disposition.default must be a boolean.");if(void 0!==e.primary&&"boolean"!=typeof e.primary)throw new TypeError("disposition.primary must be a boolean.");if(void 0!==e.forced&&"boolean"!=typeof e.forced)throw new TypeError("disposition.forced must be a boolean.");if(void 0!==e.original&&"boolean"!=typeof e.original)throw new TypeError("disposition.original must be a boolean.");if(void 0!==e.commentary&&"boolean"!=typeof e.commentary)throw new TypeError("disposition.commentary must be a boolean.");if(void 0!==e.hearingImpaired&&"boolean"!=typeof e.hearingImpaired)throw new TypeError("disposition.hearingImpaired must be a boolean.");if(void 0!==e.visuallyImpaired&&"boolean"!=typeof e.visuallyImpaired)throw new TypeError("disposition.visuallyImpaired must be a boolean.")})(e.disposition),void 0!==e.maximumPacketCount&&(!Number.isInteger(e.maximumPacketCount)||e.maximumPacketCount<0))throw new TypeError("metadata.maximumPacketCount, when provided, must be a non-negative integer.");if(void 0!==e.group&&!(e.group instanceof el)&&(!Array.isArray(e.group)||e.group.some(e=>!(e instanceof el))))throw new TypeError("metadata.group, when provided, must be an OutputTrackGroup instance or an array of OutputTrackGroup instances.")};class rl extends xe{get target(){const e="Output.target cannot be used when using PathedTarget with an async callback. Use the 'target' event instead.";if(this._rootTargetPromise)throw new TypeError(e);const t=this._getRootTarget();if(t instanceof Promise)throw new TypeError(e);return t}constructor(e){if(super(),this.state="pending",this.defaultTrackGroup=new el,this._onFinalize=null,this._unfinalizedTargets=new Set,this._rootWriterPromise=null,this._tracks=[],this._startPromise=null,this._cancelPromise=null,this._finalizePromise=null,this._mutex=new I,this._metadataTags={},this._rootTarget=null,this._rootTargetPromise=null,this._firstMediaStreamTimestamp=null,!e||"object"!=typeof e)throw new TypeError("options must be an object.");if(!(e.format instanceof il))throw new TypeError("options.format must be an OutputFormat.");if(!(e.target instanceof nd||e.target instanceof ld))throw new TypeError("options.target must be a Target or a PathedTarget.");if(e.target instanceof nd&&this._rememberTarget(e.target),void 0!==e.initTarget&&!(e.initTarget instanceof nd)&&"function"!=typeof e.initTarget)throw new Error("options.initTarget, when provided, must be a Target or a function that returns or resolves to a Target.");if(void 0!==e.onFinalize&&"function"!=typeof e.onFinalize)throw new TypeError("options.onFinalize, when provided, must be a function.");this.format=e.format,this._target=e.target,this._onFinalize=e.onFinalize??null,this._initTarget=e.initTarget??null,this._initTarget instanceof nd&&this._rememberTarget(this._initTarget),this._muxer=e.format._createMuxer(this)}_getTargetValidated(e){l(this._target instanceof ld);const t=this._target.getTarget(e),r=e=>{if(!(e instanceof nd))throw new TypeError("getTarget must return a Target.");return e};return t instanceof Promise?t.then(r):r(t)}async _getTarget(e){l(this._target instanceof ld);const t=await this._getTargetValidated(e);return this._emit("target",{target:t,request:e,isRoot:e.isRoot}),"canceled"===this.state?await t._close():this._rememberTarget(t),t}_rememberTarget(e){this._unfinalizedTargets.add(e),e.on("finalized",()=>this._unfinalizedTargets.delete(e),{once:!0})}
1async _getInitTarget(){if(l(null!==this._initTarget),this._initTarget instanceof nd)return this._initTarget;const e=await this._initTarget();return"canceled"===this.state?await e._close():this._rememberTarget(e),e}_hasInitTarget(){return null!==this._initTarget}_getRootTarget(){if(this._rootTarget)return this._rootTarget;if(this._rootTargetPromise)return this._rootTargetPromise;if(this._target instanceof nd)return this._emit("target",{target:this._target,request:null,isRoot:!0}),this._rootTarget=this._target,this._target;const e={path:this._target.rootPath,isRoot:!0,mimeType:this.format.mimeType},t=this._getTargetValidated(e),r=t=>("canceled"===this.state?t._close():this._rememberTarget(t),this._emit("target",{target:t,request:e,isRoot:!0}),this._rootTarget=t,t);return t instanceof Promise?this._rootTargetPromise=t.then(r):r(t)}_getRootWriter(e){return this._rootWriterPromise??=(async()=>{const t=await this._getRootTarget(),r=new id(t,"boolean"==typeof e?e:e(t));return r.start(),r})()}addVideoTrack(e,t={}){if(!(e instanceof Bd))throw new TypeError("source must be a VideoSource.");if(tl(t),void 0!==t.rotation&&![0,90,180,270].includes(t.rotation))throw new TypeError(`Invalid video rotation: ${t.rotation}. Has to be 0, 90, 180 or 270.`);if(!this.format.supportsVideoRotationMetadata&&t.rotation)throw new Error(`${this.format._name} does not support video rotation metadata.`);if(void 0!==t.frameRate&&(!Number.isFinite(t.frameRate)||t.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${t.frameRate}. Must be a positive number.`);const r={...t};return r.group??=this.defaultTrackGroup,this._addTrack(new Qd(this._tracks.length+1,this,e,r))}addAudioTrack(e,t={}){if(!(e instanceof Vd))throw new TypeError("source must be an AudioSource.");tl(t);const r={...t};return r.group??=this.defaultTrackGroup,this._addTrack(new Jd(this._tracks.length+1,this,e,r))}addSubtitleTrack(e,t={}){if(!(e instanceof Kd))throw new TypeError("source must be a SubtitleSource.");tl(t);const r={...t};return r.group??=this.defaultTrackGroup,this._addTrack(new Zd(this._tracks.length+1,this,e,r))}setMetadataTags(e){if(tr(e),"pending"!==this.state)throw new Error("Cannot set metadata tags after output has been started or canceled.");this._metadataTags=e}_addTrack(e){if("pending"!==this.state)throw new Error("Cannot add track after output has been started or canceled.");if(e.source._connectedTrack)throw new Error("Source is already used for a track.");const t=this.format.getSupportedTrackCounts(),r=this._tracks.reduce((t,r)=>t+(r.type===e.type?1:0),0),i=t[e.type].max;if(r===i)throw new Error(0===i?`${this.format._name} does not support ${e.type} tracks.`:`${this.format._name} does not support more than ${i} ${e.type} track`+(1===i?"":"s")+".");const n=t.total.max;if(this._tracks.length===n)throw new Error(`${this.format._name} does not support more than ${n} tracks`+(1===n?"":"s")+" in total.");if(e.isVideoTrack()){const t=this.format.getSupportedVideoCodecs();if(0===t.length)throw new Error(`${this.format._name} does not support video tracks.`+this.format._codecUnsupportedHint(e.source._codec));if(!t.includes(e.source._codec))throw new Error(`Codec '${e.source._codec}' cannot be contained within ${this.format._name}. Supported video codecs are: ${t.map(e=>`'${e}'`).join(", ")}.`+this.format._codecUnsupportedHint(e.source._codec))}else if(e.isAudioTrack()){const t=this.format.getSupportedAudioCodecs();if(0===t.length)throw new Error(`${this.format._name} does not support audio tracks.`+this.format._codecUnsupportedHint(e.source._codec));if(!t.includes(e.source._codec))throw new Error(`Codec '${e.source._codec}' cannot be contained within ${this.format._name}. Supported audio codecs are: ${t.map(e=>`'${e}'`).join(", ")}.`+this.format._codecUnsupportedHint(e.source._codec))}else if(e.isSubtitleTrack()){const t=this.format.getSupportedSubtitleCodecs();if(0===t.length)throw new Error(`${this.format._name} does not support subtitle tracks.`+this.format._codecUnsupportedHint(e.source._codec));if(!t.includes(e.source._codec))throw new Error(`Codec '${e.source._codec}' cannot be contained within ${this.format._name}. Supported subtitle codecs are: ${t.map(e=>`'${e}'`).join(", ")}.`+this.format._codecUnsupportedHint(e.source._codec))}return this._tracks.push(e),e.source._connectedTrack=e,e}
1async start(){const e=this.format.getSupportedTrackCounts();for(const t of Yd){const r=this._tracks.reduce((e,r)=>e+(r.type===t?1:0),0),i=e[t].min;if(r<i)throw new Error(i===e[t].max?`${this.format._name} requires exactly ${i} ${t} track${1===i?"":"s"}.`:`${this.format._name} requires at least ${i} ${t} track${1===i?"":"s"}.`)}const t=e.total.min;if(this._tracks.length<t)throw new Error(t===e.total.max?`${this.format._name} requires exactly ${t} track`+(1===t?"":"s")+".":`${this.format._name} requires at least ${t} track`+(1===t?"":"s")+".");if("canceled"===this.state)throw new Error("Output has been canceled.");return this._startPromise?(d._warn("Output has already been started."),this._startPromise):this._startPromise=(async()=>{this.state="started";const e=await this._mutex.acquire();try{await this._muxer.start();const e=this._tracks.map(e=>e.source._start());await Promise.all(e)}finally{e()}})()}getMimeType(){return this._muxer.getMimeType()}async cancel(){return this._cancelPromise?(d._warn("Output has already been canceled."),this._cancelPromise):"finalizing"!==this.state&&"finalized"!==this.state?this._cancelPromise=(async()=>{this.state="canceled";const e=await this._mutex.acquire();try{const e=this._tracks.map(e=>e.source._flushOrWaitForOngoingClose(!0));await Promise.all(e),await Promise.all([...this._unfinalizedTargets].map(e=>e._close())),this._unfinalizedTargets.clear()}finally{e()}})():void("finalized"===this.state&&d._warn("Output has already been finalized."))}async finalize(){if("pending"===this.state)throw new Error("Cannot finalize before starting.");if("canceled"===this.state)throw new Error("Cannot finalize after canceling.");return this._finalizePromise?(d._warn("Output has already been finalized."),this._finalizePromise):this._finalizePromise=(async()=>{this.state="finalizing";const e=await this._mutex.acquire();try{const e=this._tracks.map(e=>e.source._flushOrWaitForOngoingClose(!1));if(await Promise.all(e),await this._muxer.finalize(),this._rootWriterPromise){const e=await this._rootWriterPromise;e.finalized||(await e.flush(),await e.finalize())}this._onFinalize&&await this._onFinalize(),this.state="finalized"}finally{e()}})()}}class il{getSupportedVideoCodecs(){return this.getSupportedCodecs().filter(e=>Pe.includes(e))}getSupportedAudioCodecs(){return this.getSupportedCodecs().filter(e=>Ie.includes(e))}getSupportedSubtitleCodecs(){return this.getSupportedCodecs().filter(e=>$e.includes(e))}_codecUnsupportedHint(e){return""}}class nl extends il{constructor(e={}){if(!e||"object"!=typeof e)throw new TypeError("options must be an object.");if(void 0!==e.fastStart&&![!1,"in-memory","reserve","fragmented"].includes(e.fastStart))throw new TypeError("options.fastStart, when provided, must be false, 'in-memory', 'reserve', or 'fragmented'.");if(void 0!==e.minimumFragmentDuration&&(!Number.isFinite(e.minimumFragmentDuration)||e.minimumFragmentDuration<0))throw new TypeError("options.minimumFragmentDuration, when provided, must be a non-negative number.");if(void 0!==e.onFtyp&&"function"!=typeof e.onFtyp)throw new TypeError("options.onFtyp, when provided, must be a function.");if(void 0!==e.onMoov&&"function"!=typeof e.onMoov)throw new TypeError("options.onMoov, when provided, must be a function.");if(void 0!==e.onMdat&&"function"!=typeof e.onMdat)throw new TypeError("options.onMdat, when provided, must be a function.");if(void 0!==e.onMoof&&"function"!=typeof e.onMoof)throw new TypeError("options.onMoof, when provided, must be a function.");if(void 0!==e.metadataFormat&&!["mdir","mdta","udta","auto"].includes(e.metadataFormat))throw new TypeError("options.metadataFormat, when provided, must be either 'auto', 'mdir', 'mdta', or 'udta'.");super(),this._options=e}getSupportedTrackCounts(){const e=2**32-1;return{video:{min:0,max:e},audio:{min:0,max:e},subtitle:{min:0,max:e},total:{min:1,max:e}}}get supportsVideoRotationMetadata(){return!0}get supportsTimestampedMediaData(){return!0}_createMuxer(e){return new md(e,this)}}class al extends nl{constructor(e){super(e)}get _name(){return"MP4"}get fileExtension(){return".mp4"}get mimeType(){return"video/mp4"}getSupportedCodecs(){return[...Pe,...Ee,"pcm-s16","pcm-s16be","pcm-s24","pcm-s24be","pcm-s32","pcm-s32be","pcm-f32","pcm-f32be","pcm-f64","pcm-f64be",...$e]}
1_codecUnsupportedHint(e){return(new ol).getSupportedCodecs().includes(e)?" Switching to MOV will grant support for this codec.":""}}class sl extends nl{constructor(e){super(e)}get _name(){return"CMAF"}get fileExtension(){return".m4s"}get mimeType(){return"video/mp4"}getSupportedCodecs(){return[...Pe,...Ee,"pcm-s16","pcm-s16be","pcm-s24","pcm-s24be","pcm-s32","pcm-s32be","pcm-f32","pcm-f32be","pcm-f64","pcm-f64be",...$e]}}class ol extends nl{constructor(e){super(e)}get _name(){return"MOV"}get fileExtension(){return".mov"}get mimeType(){return"video/quicktime"}getSupportedCodecs(){return[...Pe,...Ie]}_codecUnsupportedHint(e){return(new al).getSupportedCodecs().includes(e)?" Switching to MP4 will grant support for this codec.":""}}class cl extends il{constructor(e={}){if(!e||"object"!=typeof e)throw new TypeError("options must be an object.");if(void 0!==e.appendOnly&&"boolean"!=typeof e.appendOnly)throw new TypeError("options.appendOnly, when provided, must be a boolean.");if(void 0!==e.minimumClusterDuration&&(!Number.isFinite(e.minimumClusterDuration)||e.minimumClusterDuration<0))throw new TypeError("options.minimumClusterDuration, when provided, must be a non-negative number.");if(void 0!==e.onEbmlHeader&&"function"!=typeof e.onEbmlHeader)throw new TypeError("options.onEbmlHeader, when provided, must be a function.");if(void 0!==e.onSegmentHeader&&"function"!=typeof e.onSegmentHeader)throw new TypeError("options.onHeader, when provided, must be a function.");if(void 0!==e.onCluster&&"function"!=typeof e.onCluster)throw new TypeError("options.onCluster, when provided, must be a function.");super(),this._options=e}_createMuxer(e){return new yd(e,this)}get _name(){return"Matroska"}getSupportedTrackCounts(){const e=127;return{video:{min:0,max:e},audio:{min:0,max:e},subtitle:{min:0,max:e},total:{min:1,max:e}}}get fileExtension(){return".mkv"}get mimeType(){return"video/x-matroska"}getSupportedCodecs(){return[...Pe,...Ee,...Ae.filter(e=>!["pcm-s8","pcm-f32be","pcm-f64be","ulaw","alaw"].includes(e)),...$e]}get supportsVideoRotationMetadata(){return!1}get supportsTimestampedMediaData(){return!0}}class dl extends cl{constructor(e){super(e)}getSupportedCodecs(){return[...Pe.filter(e=>["vp8","vp9","av1"].includes(e)),...Ie.filter(e=>["opus","vorbis"].includes(e)),...$e]}get _name(){return"WebM"}get fileExtension(){return".webm"}get mimeType(){return"video/webm"}_codecUnsupportedHint(e){return(new cl).getSupportedCodecs().includes(e)?" Switching to MKV will grant support for this codec.":""}}const ll=e=>{if(!e||"object"!=typeof e)throw new TypeError("options.video, when provided, must be an object.");if(void 0!==e?.discard&&"boolean"!=typeof e.discard)throw new TypeError("options.video.discard, when provided, must be a boolean.");if(void 0!==e?.forceTranscode&&"boolean"!=typeof e.forceTranscode)throw new TypeError("options.video.forceTranscode, when provided, must be a boolean.");if(void 0!==e?.codec&&!Pe.includes(e.codec))throw new TypeError(`options.video.codec, when provided, must be one of: ${Pe.join(", ")}.`);if(void 0!==e?.bitrate&&!(e.bitrate instanceof Id)&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw new TypeError("options.video.bitrate, when provided, must be a positive integer or a quality.");if(void 0!==e?.width&&(!Number.isInteger(e.width)||e.width<=0))throw new TypeError("options.video.width, when provided, must be a positive integer.");if(void 0!==e?.height&&(!Number.isInteger(e.height)||e.height<=0))throw new TypeError("options.video.height, when provided, must be a positive integer.");if(void 0!==e?.fit&&!["fill","contain","cover"].includes(e.fit))throw new TypeError("options.video.fit, when provided, must be one of 'fill', 'contain', or 'cover'.");if(void 0!==e?.width&&void 0!==e.height&&void 0===e.fit)throw new TypeError("When both options.video.width and options.video.height are provided, options.video.fit must also be provided.");if(void 0!==e?.rotate&&![0,90,180,270].includes(e.rotate))throw new TypeError("options.video.rotate, when provided, must be 0, 90, 180 or 270.");if(void 0!==e?.allowRotationMetadata&&"boolean"!=typeof e.allowRotationMetadata)throw new TypeError("options.video.allowRotationMetadata, when provided, must be a boolean.");if(void 0!==e?.crop&&Cs(e.crop,"options.video."),void 0!==e?.frameRate&&(!Number.isFinite(e.frameRate)||e.frameRate<=0))throw new TypeError("options.video.frameRate, when provided, must be a finite positive number.");if(void 0!==e?.alpha&&!["discard","keep"].includes(e.alpha))throw new TypeError("options.video.alpha, when provided, must be either 'discard' or 'keep'.");if(void 0!==e?.keyFrameInterval&&(!Number.isFinite(e.keyFrameInterval)||e.keyFrameInterval<0))throw new TypeError("options.video.keyFrameInterval, when provided, must be a non-negative number.");if(void 0!==e?.process&&"function"!=typeof e.process)throw new TypeError("options.video.process, when provided, must be a function.");
1if(void 0!==e?.processedWidth&&(!Number.isInteger(e.processedWidth)||e.processedWidth<=0))throw new TypeError("options.video.processedWidth, when provided, must be a positive integer.");if(void 0!==e?.processedHeight&&(!Number.isInteger(e.processedHeight)||e.processedHeight<=0))throw new TypeError("options.video.processedHeight, when provided, must be a positive integer.");if(void 0!==e?.hardwareAcceleration&&!["no-preference","prefer-hardware","prefer-software"].includes(e.hardwareAcceleration))throw new TypeError("options.video.hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.");if(void 0!==e?.group&&!(e.group instanceof el||Array.isArray(e.group)&&e.group.every(e=>e instanceof el)))throw new TypeError("options.video.group, when provided, must be an OutputTrackGroup or an array of OutputTrackGroups.")},ul=e=>{if(!e||"object"!=typeof e)throw new TypeError("options.audio, when provided, must be an object.");if(void 0!==e?.discard&&"boolean"!=typeof e.discard)throw new TypeError("options.audio.discard, when provided, must be a boolean.");if(void 0!==e?.forceTranscode&&"boolean"!=typeof e.forceTranscode)throw new TypeError("options.audio.forceTranscode, when provided, must be a boolean.");if(void 0!==e?.codec&&!Ie.includes(e.codec))throw new TypeError(`options.audio.codec, when provided, must be one of: ${Ie.join(", ")}.`);if(void 0!==e?.bitrate&&!(e.bitrate instanceof Id)&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw new TypeError("options.audio.bitrate, when provided, must be a positive integer or a quality.");if(void 0!==e?.numberOfChannels&&(!Number.isInteger(e.numberOfChannels)||e.numberOfChannels<=0))throw new TypeError("options.audio.numberOfChannels, when provided, must be a positive integer.");if(void 0!==e?.sampleRate&&(!Number.isInteger(e.sampleRate)||e.sampleRate<=0))throw new TypeError("options.audio.sampleRate, when provided, must be a positive integer.");if(void 0!==e?.sampleFormat&&!["u8","s16","s32","f32"].includes(e.sampleFormat))throw new TypeError("options.audio.sampleFormat, when provided, must be one of: u8, s16, s32, f32.");if(void 0!==e?.process&&"function"!=typeof e.process)throw new TypeError("options.audio.process, when provided, must be a function.");if(void 0!==e?.processedNumberOfChannels&&(!Number.isInteger(e.processedNumberOfChannels)||e.processedNumberOfChannels<=0))throw new TypeError("options.audio.processedNumberOfChannels, when provided, must be a positive integer.");if(void 0!==e?.processedSampleRate&&(!Number.isInteger(e.processedSampleRate)||e.processedSampleRate<=0))throw new TypeError("options.audio.processedSampleRate, when provided, must be a positive integer.");if(void 0!==e?.group&&!(e.group instanceof el||Array.isArray(e.group)&&e.group.every(e=>e instanceof el)))throw new TypeError("options.audio.group, when provided, must be an OutputTrackGroup or an array of OutputTrackGroups.")},hl=48e3;class fl{static async init(e){const t=new fl(e);return await t._init(),t}constructor(e){if(this._addedCounts={video:0,audio:0,subtitle:0},this._totalTrackCount=0,this._nextOutputTrackId=0,this._outputTrackIds=[],this._outputOwnTrackGroups=[],this._trackPromises=[],this._executed=!1,this._synchronizer=new ml,this._totalDuration=null,this._maxTimestamps=new Map,this._canceled=!1,this.onProgress=void 0,this._computeProgress=!1,this._lastProgress=0,this.isValid=!1,this.utilizedTracks=[],this.discardedTracks=[],!e||"object"!=typeof e)throw new TypeError("options must be an object.");if(!(e.input instanceof ho))throw new TypeError("options.input must be an Input.");if(!(e.output instanceof rl))throw new TypeError("options.output must be an Output.");if(void 0!==e.tracks&&"all"!==e.tracks&&"primary"!==e.tracks)throw new TypeError("options.tracks, when provided, must be either 'all' or 'primary'.");if(e.output._tracks.length>0||Object.keys(e.output._metadataTags).length>0||"pending"!==e.output.state)throw new TypeError("options.output must be fresh: no tracks or metadata tags added and not started.");if(void 0!==e.video&&"function"!=typeof e.video)if(Array.isArray(e.video))for(const t of e.video)ll(t);else ll(e.video);if(void 0!==e.audio&&"function"!=typeof e.audio)if(Array.isArray(e.audio))for(const t of e.audio)ul(t);else ul(e.audio);if(void 0!==e.trim&&(!e.trim||"object"!=typeof e.trim))throw new TypeError("options.trim, when provided, must be an object.");if(void 0!==e.trim?.start&&!Number.isFinite(e.trim.start))throw new TypeError("options.trim.start, when provided, must be a finite number.");if(void 0!==e.trim?.end&&!Number.isFinite(e.trim.end))throw new TypeError("options.trim.end, when provided, must be a finite number.");if(void 0!==e.trim?.start&&void 0!==e.trim.end&&e.trim.start>=e.trim.end)throw new TypeError("options.trim.start must be less than options.trim.end.");if(void 0!==e.tags&&("object"!=typeof e.tags||!e.tags)&&"function"!=typeof e.tags)throw new TypeError("options.tags, when provided, must be an object or a function.");
1if("object"==typeof e.tags&&tr(e.tags),void 0!==e.showWarnings&&"boolean"!=typeof e.showWarnings)throw new TypeError("options.showWarnings, when provided, must be a boolean.");this._options=e,this.input=e.input,this.output=e.output;const{promise:t,resolve:r}=B();this._started=t,this._start=r}async _init(){const e=await this.input.getFormat();let t,r=this._options.tracks;if(void 0===r){r=e.name.includes("(HLS)")?"primary":"all"}if("all"===r)t=await this.input.getTracks();else if("primary"===r){t=[await this.input.getPrimaryVideoTrack(),await this.input.getPrimaryAudioTrack()].filter(e=>null!==e)}else L(r),l(!1);const i=this.output.format.getSupportedTrackCounts();let n=1,a=1;const s=[],o=[];for(const e of t){let t;if(e.isVideoTrack())if(this._options.video)if("function"==typeof this._options.video){const r=await this._options.video(e,n)??{};if(Array.isArray(r))for(const e of r)ll(e);else ll(r);t=Array.isArray(r)?r:[r],n++}else t=Array.isArray(this._options.video)?this._options.video:[this._options.video];else t=[{}];else if(e.isAudioTrack())if(this._options.audio)if("function"==typeof this._options.audio){const r=await this._options.audio(e,a)??{};if(Array.isArray(r))for(const e of r)ul(e);else ul(r);t=Array.isArray(r)?r:[r],a++}else t=Array.isArray(this._options.audio)?this._options.audio:[this._options.audio];else t=[{}];else l(!1);const r=t.filter(e=>e.discard);for(const t of r)this.discardedTracks.push({track:e,reason:"discarded_by_user",trackOptions:t});if(t.length===r.length){0===t.length&&this.discardedTracks.push({track:e,reason:"discarded_by_user",trackOptions:{}});continue}const i=t.filter(e=>!e.discard);s.push(e),o.push(i)}void 0!==this._options.trim?.start?this._startTimestamp=this._options.trim.start:this._startTimestamp=Math.max(await this.input.getFirstTimestamp(s),0),this._endTimestamp=Math.max(this._options.trim?.end??1/0,this._startTimestamp);for(let e=0;e<s.length;e++){const t=s[e],r=o[e];for(const e of r){if(this._totalTrackCount===i.total.max){this.discardedTracks.push({track:t,reason:"max_track_count_reached",trackOptions:e});continue}if(this._addedCounts[t.type]===i[t.type].max){this.discardedTracks.push({track:t,reason:"max_track_count_of_type_reached",trackOptions:e});continue}const r=this._nextOutputTrackId++;t.isVideoTrack()?await this._processVideoTrack(t,e,r):t.isAudioTrack()?await this._processAudioTrack(t,e,r):l(!1)}}for(let e=0;e<this.utilizedTracks.length-1;e++)for(let t=e+1;t<this.utilizedTracks.length;t++){const r=this.utilizedTracks[e],i=this.utilizedTracks[t],n=this._outputOwnTrackGroups[e],a=this._outputOwnTrackGroups[t];l(void 0!==n),l(void 0!==a),n&&a&&r.canBePairedWith(i)&&n.pairWith(a)}const c=await this.input.getMetadataTags();let u;if(this._options.tags){const e="function"==typeof this._options.tags?await this._options.tags(c):this._options.tags;tr(e),u=e}else u=c;const h=e.mimeType===this.output.format.mimeType,f=c.raw===u.raw;if(c.raw&&f&&!h&&delete u.raw,this.output.setMetadataTags(u),this.isValid=this._totalTrackCount>=i.total.min&&this._addedCounts.video>=i.video.min&&this._addedCounts.audio>=i.audio.min&&this._addedCounts.subtitle>=i.subtitle.min,this._options.showWarnings??!0){const e=[],t=this.discardedTracks.filter(e=>"discarded_by_user"!==e.reason);t.length>0&&e.push("Some tracks had to be discarded from the conversion:",t),this.isValid||(e.length>0&&e.push("\n\n"),e.push(this._getInvalidityExplanation().join(""))),e.length>0&&d._warn(...e)}}_getInvalidityExplanation(){const e=[];if(0===this.discardedTracks.length)e.push("Due to missing tracks, this conversion cannot be executed.");else{const t=this.discardedTracks.every(e=>"discarded_by_user"===e.reason||"no_encodable_target_codec"===e.reason)&&this.discardedTracks.some(e=>"no_encodable_target_codec"===e.reason);if(e.push("Due to discarded tracks, this conversion cannot be executed."),t){const t=this.discardedTracks.flatMap(e=>"discarded_by_user"===e.reason?[]:"video"===e.track.type?this.output.format.getSupportedVideoCodecs():"audio"===e.track.type?this.output.format.getSupportedAudioCodecs():this.output.format.getSupp
1ortedSubtitleCodecs()),r=[...new Set(t)];1===r.length?e.push(`\nTracks were discarded because your environment is not able to encode '${r[0]}'.`):e.push(`\nTracks were discarded because your environment is not able to encode any of the following codecs: ${r.map(e=>`'${e}'`).join(", ")}.`),r.includes("mp3")&&e.push("\nThe @mediabunny/mp3-encoder extension package provides support for encoding MP3."),r.includes("aac")&&e.push("\nThe @mediabunny/aac-encoder extension package provides support for encoding AAC."),(r.includes("ac3")||r.includes("eac3"))&&e.push("\nThe @mediabunny/ac3 extension package provides support for encoding and decoding AC-3/E-AC-3."),r.includes("flac")&&e.push("\nThe @mediabunny/flac-encoder extension package provides support for encoding FLAC.")}else e.push("\nCheck the discardedTracks field for more info.")}return e}async execute(){if(!this.isValid)throw new Error("Cannot execute this conversion because its output configuration is invalid. Make sure to always check the isValid field before executing a conversion.\n"+this._getInvalidityExplanation().join(""));if(this._executed)throw new Error("Conversion cannot be executed twice.");this._executed=!0;for(const e of this._outputTrackIds)this._synchronizer.declareTrack(e);if(this.onProgress){const e=[...new Set(this.utilizedTracks)].map(async e=>await e.isLive()?1/0:await e.getDurationFromMetadata()??await e.computeDuration()),t=Math.max(0,...await Promise.all(e));this._computeProgress=!0,this._totalDuration=Math.min(t-this._startTimestamp,this._endTimestamp-this._startTimestamp);for(const e of this._outputTrackIds)this._maxTimestamps.set(e,0);this.onProgress?.(0,0)}await this.output.start(),this._start();try{await Promise.all(this._trackPromises)}catch(e){throw this._canceled||this.cancel(),e}if(this._canceled)throw new ConversionCanceledError;if(await this.output.finalize(),this._computeProgress){const e=Math.min(...this._maxTimestamps.values());this.onProgress?.(1,e)}}async cancel(){"finalizing"!==this.output.state&&"finalized"!==this.output.state&&(this._canceled?d._warn("Conversion already canceled."):(this._canceled=!0,await this.output.cancel()))}async _processVideoTrack(e,t,r){const i=await e.getCodec();if(!i)return void this.discardedTracks.push({track:e,reason:"unknown_source_codec",trackOptions:t});let n;const a=await e.getRotation(),s=u(a+(t.rotate??0));let o=s;const c=this.output.format.supportsVideoRotationMetadata&&(t.allowRotationMetadata??!0),h=await e.getSquarePixelWidth(),f=await e.getSquarePixelHeight(),[m,p]=s%180==0?[h,f]:[f,h];let g=t.crop;g&&(g=Ss(g,m,p));const[y,b]=g?[g.width,g.height]:[m,p];let w=y,v=b;
1const k=w/v;void 0!==t.width&&void 0===t.height?(w=Se(t.width),v=Se(Math.round(w/k))):void 0===t.width&&void 0!==t.height?(v=Se(t.height),w=Se(Math.round(v*k))):void 0!==t.width&&void 0!==t.height&&(w=Se(t.width),v=Se(t.height));const T=await e.getFirstTimestamp();let x=this.output.format.getSupportedVideoCodecs();const S=!!t.forceTranscode||T<this._startTimestamp||!!t.frameRate||void 0!==t.keyFrameInterval||void 0!==t.process||void 0!==t.bitrate||!x.includes(i)||t.codec&&t.codec!==i||w!==y||v!==b||0!==s&&!c||!!g,C=t.alpha??"discard";if(S){if(!await e.canDecode())return void this.discardedTracks.push({track:e,reason:"undecodable_source_codec",trackOptions:t});t.codec&&(x=x.filter(e=>e===t.codec));const i=t.bitrate??$d,m=await(async(e,t)=>{for(const r of e)if(await _d(r,t))return r;return null})(x,{width:t.process&&t.processedWidth?t.processedWidth:w,height:t.process&&t.processedHeight?t.processedHeight:v,bitrate:i});if(!m)return void this.discardedTracks.push({track:e,reason:"no_encodable_target_codec",trackOptions:t});const p={codec:m,bitrate:i,keyFrameInterval:t.keyFrameInterval,sizeChangeBehavior:t.fit??"passThrough",alpha:C,hardwareAcceleration:t.hardwareAcceleration,transform:{}};l(p.transform);let k=w!==y||v!==b||0!==s&&(!c||void 0!==t.process)||!!g||h!==await e.getCodedWidth()||f!==await e.getCodedHeight();if(!k){const t=new rl({format:new al,target:new cd}),r=new Wd(p);t.addVideoTrack(r),await t.start();const i=new Xs(e),n=await i.getSample(T);if(n)try{await r.add(n),n.close(),await t.finalize()}catch(e){d._info("Error when probing encoder support. Falling back to rerender path.",e),k=!0,t.cancel()}else await t.cancel()}t.frameRate&&(p.transform.frameRate=t.frameRate),t.process&&(p.transform.process=t.process),k&&(o=0,p.transform.width=w,p.transform.height=v,p.transform.fit=t.fit??"fill",p.transform.rotate=u(s-a),p.transform.crop=g,p.transform.alpha=C);let S=null;p.onEncodedSample=e=>{S=e.timestamp};const P=new Wd(p);n=P,this._trackPromises.push((async()=>{await this._started;const t=new Xs(e);for await(const e of t.samples(this._startTimestamp,this._endTimestamp)){if(this._canceled)return void e.close();const t=Math.max(e.timestamp-this._startTimestamp,0);e.setTimestamp(t),this._reportProgress(r,e.timestamp+e.duration),await P.add(e),null!==S&&this._synchronizer.shouldWait(r,S)&&await this._synchronizer.wait(S),e.close()}P.close(),this._synchronizer.closeTrack(r)})())}else{const t=new Md(i);n=t,this._trackPromises.push((async()=>{await this._started;const i=new Us(e),n={decoderConfig:await e.getDecoderConfig()??void 0};for await(const e of i.packets(void 0,void 0,{verifyKeyPackets:!0})){if(this._canceled)return;if(e.timestamp>=this._endTimestamp)break;const i=e.clone({timestamp:e.timestamp-this._startTimestamp,sideData:"discard"===C?{}:e.sideData});l(i.timestamp>=0),this._reportProgress(r,i.timestamp+i.duration),await t.add(i,n),this._synchronizer.shouldWait(r,i.timestamp)&&await this._synchronizer.wait(i.timestamp)}t.close(),this._synchronizer.closeTrack(r)})())}let P=null;t.group||(P=new el);const A=await e.getLanguageCode();this.output.addVideoTrack(n,{frameRate:t.frameRate,languageCode:Q(A)?A:void 0,name:await e.getName()??void 0,disposition:await e.getDisposition(),rotation:o,group:P??t.group}),this._addedCounts.video++,this._totalTrackCount++,this.utilizedTracks.push(e),this._outputTrackIds.push(r),this._outputOwnTrackGroups.push(P)}async _processAudioTrack(e,t,r){const i=await e.getCodec();if(!i)return void this.discardedTracks.push({track:e,reason:"unknown_source_codec",trackOptions:t});let n;const a=await e.getNumberOfChannels(),s=await e.getSampleRate(),o=await e.getFirstTimestamp();let c=t.numberOfChannels??a,d=t.sampleRate??s;const u=o<this._startTimestamp,h=o>this._startTimestamp&&!this.output.format.supportsTimestampedMediaData;let f=this.output.format.getSupportedAudioCodecs();if(t.forceTranscode||t.bitrate||c!==a||d!==s||u||h||!f.includes(i)||t.codec&&t.codec!==i||t.process||void 0!==t.sampleFormat){if(!await e.canDecode())return void this.discardedTracks.push({track:e,reason:"undecodable_source_codec",trackOptions:t});let i=null;t.codec&&(f=f.filter(e=>e===t.codec));const u=t.bitrate??$d,m=await Rd(f,{numberOfChannels:t.process&&t.processedNumberOfChannels?t.processedNumberOfChannels:c,sampleRate:t.process&&t.processedSampleRate?t.processedSampleRate:d,bitrate:u});if(m.some(e=>Ee.includes(e))||!f.some(e=>Ee.includes(e))||2===c&&d===hl)i=m[0]??null;else{const e=(await Rd(f,{numberOfChannels:2,sampleRate:hl,bitrate:u})).find(e=>Ee.includes(e));e&&(i=e,c=2,d=hl)}if(null===i)return void this.discardedTracks.push({track:e,reason:"no_encodable_target_co
1dec",trackOptions:t});const p={codec:i,bitrate:u,transform:{sampleFormat:t.sampleFormat,process:t.process}};l(p.transform),c!==a&&(p.transform.numberOfChannels=c),d!==s&&(p.transform.sampleRate=d);let g=null;p.onEncodedSample=e=>{g=e.timestamp};const y=new Gd(p);n=y,this._trackPromises.push((async()=>{if(await this._started,h){const e=o-this._startTimestamp,t=Math.round(e*s),i=new _s({data:new Float32Array(t*a),format:"f32-planar",numberOfChannels:a,sampleRate:s,timestamp:0});await this._registerAudioSample(i,y,r,()=>g)}const t=new Zs(e);for await(let e of t.samples(this._startTimestamp,this._endTimestamp)){if(this._canceled)return void e.close();let t=0,i=e.numberOfFrames;if(e.timestamp<this._startTimestamp&&(t=Math.round((this._startTimestamp-e.timestamp)*e.sampleRate)),e.timestamp+e.duration>this._endTimestamp&&(i=Math.round((this._endTimestamp-e.timestamp)*e.sampleRate)),t>0||i<e.numberOfFrames){const r=e.trim(t,i);if(e.close(),e=r,0===e.numberOfFrames){e.close();continue}}e.setTimestamp(e.timestamp-this._startTimestamp),await this._registerAudioSample(e,y,r,()=>g)}y.close(),this._synchronizer.closeTrack(r)})())}else{const t=new qd(i);n=t,this._trackPromises.push((async()=>{await this._started;const i=new Us(e),n={decoderConfig:await e.getDecoderConfig()??void 0};for await(const e of i.packets()){if(this._canceled)return;if(e.timestamp>=this._endTimestamp)break;const i=e.clone({timestamp:e.timestamp-this._startTimestamp});l(i.timestamp>=0),this._reportProgress(r,i.timestamp+i.duration),await t.add(i,n),this._synchronizer.shouldWait(r,i.timestamp)&&await this._synchronizer.wait(i.timestamp)}t.close(),this._synchronizer.closeTrack(r)})())}let m=null;t.group||(m=new el);const p=await e.getLanguageCode();this.output.addAudioTrack(n,{languageCode:Q(p)?p:void 0,name:await e.getName()??void 0,disposition:await e.getDisposition(),group:m??t.group}),this._addedCounts.audio++,this._totalTrackCount++,this.utilizedTracks.push(e),this._outputTrackIds.push(r),this._outputOwnTrackGroups.push(m)}async _registerAudioSample(e,t,r,i){this._reportProgress(r,e.timestamp+e.duration),await t.add(e),e.close();const n=i();null!==n&&this._synchronizer.shouldWait(r,n)&&await this._synchronizer.wait(n)}_reportProgress(e,t){if(!this._computeProgress)return;l(null!==this._totalDuration),this._maxTimestamps.set(e,Math.max(t,this._maxTimestamps.get(e)));const r=Math.min(...this._maxTimestamps.values()),i=W(r/this._totalDuration,0,1);i!==this._lastProgress&&(this._lastProgress=i,this.onProgress?.(i,r))}}class ConversionCanceledError extends Error{constructor(e="Conversion has been canceled."){super(e),this.name="ConversionCanceledError"}}class ml{constructor(){this.maxTimestamps=new Map,this.resolvers=[]}declareTrack(e){this.maxTimestamps.set(e,0)}shouldWait(e,t){const r=this.maxTimestamps.get(e);l(void 0!==r),this.maxTimestamps.set(e,Math.max(t,r));return t-this.computeMinAndMaybeResolve()>1}wait(e){const{promise:t,resolve:r}=B();return this.resolvers.push({timestamp:e,resolve:r}),t}closeTrack(e){this.maxTimestamps.delete(e),this.computeMinAndMaybeResolve()}computeMinAndMaybeResolve(){let e=1/0;for(const[,t]of this.maxTimestamps)e=Math.min(e,t);for(let t=0;t<this.resolvers.length;t++){const r=this.resolvers[t];r.timestamp-e<1&&(r.resolve(),this.resolvers.splice(t,1),t--)}return e}}function pl(e){return e<.1}function gl(e){const t=[];for(let r=0;r<e.numberOfChannels;r++){const i=new Float32Array(e.allocationSize({format:"f32-planar",planeIndex:r})/4);e.copyTo(i,{format:"f32-planar",planeIndex:r}),t.push(i)}return t}async function yl(e,t){const r=await e.getFormat(),i=r instanceof ja?new dl:r instanceof Ma?new cl:new al({fastStart:"in-memory"}),n=new od,a=new rl({format:i,target:n}),s=await fl.init({input:e,output:a,audio:async e=>await e.canDecode()?{process:e=>function(e,t){const r=gl(e),i=r[0]?.length??0,n=new Float32Array(i*e.numberOfChannels);for(let e=0;e<r.length;e++){const a=r[e];for(let e=0;e<a.length;e++){const r=a[e]*t;a[e]=r>1?1:r<-1?-1:r}n.set(a,e*i)}return new _s({data:n,format:"f32-planar",numberOfChannels:e.numberOfChannels,sampleRate:e.sampleRate,timestamp:e.timestamp})}(e,t)}:{discard:!0},showWarnings:!1});if(!s.isValid||!s.utilizedTracks.some(e=>e.isAudioTrack()))throw new Error("Unable to amplify video audio");if(await s.execute(),!n.buffer)throw new Error("Amplified video is empty");const o=i.mimeType;return{blob:new Blob([new Uint8Array(n.buffer)],{type:o}),mimeType:o}}async function bl(e,{trimRange:t,volumeGain:r=1}={}){const i=new ho({formats:ns,source:new lr(e)}),n=await i.computeDuration();let a=e,s=e.type;try{const o=await async function(e){const t=await async function(e){return e.getPrimaryAudioTrack({filter:e=>e.canDecode()})}(e);if(!t)return(await e.getAudioTracks()).length>0?1:0;const r=new Zs(t),i=await t.computeDuration(),n=Math.min(Math.ceil(i/.05),200),a=Array.from({length:n},(e,t)=>t*i/Math.max(1,n-1));let s=0,o=0;for await(const e of r.samplesAtTimestamps(a)){if(!e)continue;const t=gl(e);let r=0,i=0,n=0;for(const e of t){for(let t=0;t<e.length;t++){const n=Math.abs(e[t]);n>i&&(i=n),r+=e[t]**2}n+=e.length}const a=n>0?Math.sqrt(r/n):0;i>s&&(s=i),a>o&&(o=a),e.close()}const c=Math.max(.7*s+.3*o,o);return Math.min(1,Math.max(0,c))}(i),c=function(e,t=.6){return!Number.isFinite(e)||e<=0||e>=t?1:t/e}(o)*r;if(Math.abs(c-1)>.001)try{const e=await yl(i,c);a=e.blob,s=e.mimeType}catch(t){console.log(t),a=e,s=e.type}const d=t&&(t.start>0||t.end<n);return d&&(a=await async function(e,{start:t,end:r}){const i=new ho({formats:ns,source:new lr(e)}),n=new rl({format:new al,target:new od}),a=await fl.init({input:i,output:n,trim:{start:t,end:r},showWarnings:!1});await a.execute();const s=n.target.buffer;if(!s)throw new Error("Trimmed video output was not created");return new Blob([s],{type:"video/mp4"})}(a,t),s=a.type),{blob:a,mimeType:s,analysis:{isSilent:pl(o),durationInSeconds:d?t.end-t.start:n}}}catch(e){return console.log(e),{blob:a,mimeType:s,analysis:{isSilent:!1,durationInSeconds:t?t.end-t.start:n}}}}},14505(e,t,r){"use strict";r.d(t,{A:()=>FacebookButton});var i=r(36171),n=r(19363),a=r(26730),s=r(85906),o=r(4155),c=r.n(o),d=r(85412),l=r(63197),u=r(20975);class EmailAddressWasNotGrantedError extends u.A{constructor(){super("Email address was not granted")}}function FacebookConnectWrapper(e){const{logger:t}
1=(0,s.useContext)(l.A),[r,i]=(0,s.useState)({status:"loading"}),[n,a]=(0,s.useState)(!1),o=(0,s.useRef)(!1),u=(0,s.useRef)(void 0);(0,s.useEffect)(()=>{"error"===r.status&&a(!0)},[r.status]),(0,s.useEffect)(()=>(o.current=!0,u.current=(0,d.Ay)(c().facebook.sdkUrl,t=>{if(o.current){if(t)return i({status:"error",error:t}),void e.onFail?.(t);FB.init({appId:c().facebook.appId,version:c().facebook.graphVersion,status:!0}),i({status:"ready"})}}),()=>{o.current=!1,u.current&&u.current()}),[]);const h=t=>{i({status:"error",error:t}),e.onFail?.(t)},f=async r=>{try{if("object"==typeof r&&"string"==typeof r.accessToken)return await e.onSuccess(r),r;throw new Error("Facebook login response did not return a valid access token")}catch(e){t.error(e,{metadata:{response:r}}),h(e)}},m=e=>e.grantedScopes?e.grantedScopes.includes("email")?"yes":"no":"unknown";return e.children(()=>new Promise((e,t)=>{const r=FB.getAuthResponse();if(!n&&r)return"no"===m(r)?(FB.logout(),t(new EmailAddressWasNotGrantedError)):e(r);FB.login(r=>"connected"===r.status&&r.authResponse?"no"===m(r.authResponse)?t(new EmailAddressWasNotGrantedError):e(r.authResponse):r.authResponse?(FB.logout(),t(r)):t(r),{scope:"email",return_scopes:!0,auth_type:"rerequest"})}).then(f,h),r)}FacebookConnectWrapper.EmailAddressWasNotGrantedError=EmailAddressWasNotGrantedError;const h=FacebookConnectWrapper;var f=r(62227),m=r(89348),p=r(74954),g=r(14202);function FacebookButton(e){const{isLoading:t,label:r="Continue with Facebook",onAuthenticate:s,onFail:o,trackingId:c="facebook_button",...d}=e;return(0,g.jsx)(h,{onSuccess:s,onFail:o,children:(e,s)=>(0,g.jsxs)(n.h,{keep:!0,children:["error"===s.status&&(0,g.jsx)(i.A,{alertStyle:"danger",marginBottom:4,children:(0,g.jsx)(p.sA,{id:"shared.login.facebook_button.error",defaultMessage:'{errorType, select,\n email_address_not_granted {Email address not granted}\n unauthorized {Permissions not granted}\n other {Facebook login failed}\n}. Try again or use the button "Continue with your email address" below.',values:{errorType:s.error instanceof h.EmailAddressWasNotGrantedError?"email_address_not_granted":s.error instanceof m.A&&400===s.error.response.status?"unauthorized":"other"}})}),(0,g.jsx)(n.h,{testId:"ready"===s.status?"facebook_button_loaded":"facebook_button_loading",display:"flex",flexDirection:"column",marginX:"auto",style:{width:320},children:(0,g.jsxs)(a.A,{...d,onClick:e,buttonStyle:"facebook",icon:"left",isLoading:t||"loading"===s.status,nowrap:!0,tracking:{id:c},children:[(0,g.jsx)(f.A,{name:"facebook"}),r]})})]})})}},48275(e,t,r){"use strict";r.d(t,{A:()=>GoogleButton});var i=r(36171),n=r(19363),a=r(45919),s=r(85906),o=r(4155),c=r.n(o),d=r(85412);function GoogleConnectWrapper(e){const[t,r]=(0,s.useState)({status:window.gapiLoaded?"ready":"loading"}),i=(0,s.useRef)(!1),n=(0,s.useRef)(void 0),a=(0,s.useRef)(void 0);return(0,s.useEffect)(()=>(i.current=!0,n.current=(0,d.Ay)(c().google.identityScriptUrl,t=>{if(!i.current)return;if(t)return r({status:"error",error:t}),void e.onFail?.(t);const n=()=>
1{if(i.current)if(google.accounts.id.initialize({client_id:c().google.clientId,callback:t=>{if(i.current){if(!t.credential){const t=new Error("Empty credential");return r({status:"error",error:t}),void e.onFail?.(t)}e.onSuccess({credential:t.credential})}}}),window.gapiLoaded=!0,e.prompt&&google.accounts.id.prompt(),a.current)google.accounts.id.renderButton(a.current,{locale:"en_AU",type:"standard",size:"large",logo_alignment:"center",theme:"outline",shape:"rectangular",text:"continue_with",width:320}),r({status:"ready"});else{const t=new Error("Failed to render Google Login button");r({status:"error",error:t}),e.onFail?.(t)}};window.gapiLoaded?n():window.onGoogleLibraryLoad=n}),()=>{i.current=!1,n.current&&n.current()}),[]),e.children(a,t)}var l=r(62227),u=r(89348),h=r(74954),f=r(14202);function GoogleButton(e){const{isLoading:t,label:r="Continue with Google",onAuthenticate:s,onFail:o,prompt:c,trackingId:d="google_button",...m}=e;return(0,f.jsx)(GoogleConnectWrapper,{onSuccess:s,onFail:o,prompt:c,children:(e,s)=>(0,f.jsxs)(n.h,{keep:!0,children:["error"===s.status&&(0,f.jsx)(i.A,{alertStyle:"danger",marginBottom:4,children:(0,f.jsx)(h.sA,{id:"shared.login.facebook_button.error",defaultMessage:'{errorType, select,\n unauthorized {Permissions not granted}\n other {Google login failed}\n}. Try again or use the button "Continue with your email address" below.',values:{errorType:s.error instanceof u.A&&400===s.error.response.status?"unauthorized":"other"}})}),(0,f.jsxs)(n.h,{testId:"ready"===s.status?"google_button_loaded":"google_button_loading",display:"flex",flexDirection:"column",marginX:"auto",position:"relative",style:{width:320},children:[(0,f.jsx)(n.h,{backgroundColor:"white",position:"absolute-center",children:(0,f.jsx)(n.h,{ref:e})}),(0,f.jsxs)(a.A.Button,{...m,buttonStyle:"light",icon:"left",isLoading:t||"loading"===s.status,fontWeight:"bold",nowrap:!0,tracking:{id:d},children:[(0,f.jsx)(l.A,{name:"google"}),r]})]})]})})}},36389(e,t,r){"use strict";r.d(t,{A:()=>CurrencySuffixPrefixWrapper});var i=r(79400),n=r.n(i),a=r(19363),s=r(35447),o=r(14202);function InputGroup(e){const{className:t,...r}=e;return(0,o.jsx)(a.h,{className:n()("input-group",t),...r})}InputGroup.Addon=function InputGroupAddon(e){const{className:t,...r}=e;return(0,o.jsx)(s.A,{className:n()("input-group-text",t),...r})},InputGroup.Button=function InputGroupButton(e){const{className:t,...r}=e;return(0,o.jsx)(a.h,{className:n()("input-group-btn",t),...r})};const c=InputGroup,d={AUD:"$",USD:"$",EUR:"â¬"};function CurrencySuffixPrefixWrapper(e){const t=e.prefix&&!e.hidePrefix,r=e.suffix&&!e.hideSuffix;return e.currency||t||r?(0,o.jsxs)(c,{flexWrap:"nowrap",children:[t&&(0,o.jsx)(c.Addon,{children:e.prefix}),e.currency&&(0,o.jsx)(c.Addon,{children:d[e.currency]}),e.children,r&&(0,o.jsx)(c.Addon,{children:e.suffix})]}):e.children}},53552(e,t,r){"use strict";r.d(t,{A:()=>h});var i=r(85906),n=r(78801),a=r.n(n),s=r(36171),o=r(19107),c=(r(74954),r(49075));var d=r(14202);const l=(0,i.lazy)(()=>r.e("shared_components_upload_ImageCropper_tsx").then(()=>r(15948))),u=a().bind({"modal-imageCropper":"rUBzRF"});function h(e,t){return{title:"Edit your image",closeable:!1,size:"xlarge",headerProps:{noBorder:"bottom"},bodyProps:{display:"flex",flexDirection:"column",className:u("modal-imageCropper")},...t,content:(t,r)=>(0,d.jsxs)(i.Fragment,{children:[(0,d.jsx)(s.A,{alertStyle:"info",borderRadius:"none",children:"Ensure your image is resized to fit in the container. We recommend minimising the amount of empty space around your image."}),(0,d.jsx)(i.Suspense,{fallback:(0,d.jsx)(o.A,{}),children:(0,d.jsx)(l,{...e,onCancel:(...t)=>{e.onCancel&&e.onCancel(...t),r(new c.A)},onCrop:(...r)=>{e.onCrop(...r),t(...r)}})})]})}}},90849(e,t,r){"use strict";function i(e){return e?e.replace(/[^a-zA-Z0-9 ]/g,"").trim().split(/\s+/).length:0}r.d(t,{A:()=>i})},28402(e,t,r){"use strict";r.d(t,{A:()=>n});const i=/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/i;function n(e){return 36===e?.length&&i.test(e)}},73518(e,t,r){"use strict";r.d(t,{A:()=>l});
1var i=r(85906),n=r(19738),a=r(50020),s=r(55279);const o={"am-AM":/^(\+?374|0)((10|[9|7][0-9])\d{6}$|[2-4]\d{7}$)/,"ar-AE":/^((\+?971)|0)?5[024568]\d{7}$/,"ar-BH":/^(\+?973)?(3|6)\d{7}$/,"ar-DZ":/^(\+?213|0)(5|6|7)\d{8}$/,"ar-LB":/^(\+?961)?((3|81)\d{6}|7\d{7})$/,"ar-EG":/^((\+?20)|0)?1[0125]\d{8}$/,"ar-IQ":/^(\+?964|0)?7[0-9]\d{8}$/,"ar-JO":/^(\+?962|0)?7[789]\d{7}$/,"ar-KW":/^(\+?965)[569]\d{7}$/,"ar-LY":/^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/,"ar-MA":/^(?:(?:\+|00)212|0)[5-7]\d{8}$/,"ar-OM":/^((\+|00)968)?(9[1-9])\d{6}$/,"ar-SA":/^(!?(\+?966)|0)?5\d{8}$/,"ar-SY":/^(!?(\+?963)|0)?9\d{8}$/,"ar-TN":/^(\+?216)?[2459]\d{7}$/,"az-AZ":/^(\+994|0)(5[015]|7[07]|99)\d{7}$/,"bs-BA":/^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/,"be-BY":/^(\+?375)?(24|25|29|33|44)\d{7}$/,"bg-BG":/^(\+?359|0)?8[789]\d{7}$/,"bn-BD":/^(\+?880|0)1[13456789][0-9]{8}$/,"ca-AD":/^(\+376)?[346]\d{5}$/,"cs-CZ":/^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,"da-DK":/^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,"de-DE":/^((\+49|0)[1|3])([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7,9}$/,"de-AT":/^(\+43|0)\d{1,4}\d{3,12}$/,"de-CH":/^(\+41|0)([1-9])\d{1,9}$/,"de-LU":/^(\+352)?((6\d1)\d{6})$/,"el-GR":/^(\+?30|0)?(69\d{8})$/,"en-AU":/^(\+?61|0)4\d{8}$/,"en-GB":/^(\+?44|0)7\d{9}$/,"en-GG":/^(\+?44|0)1481\d{6}$/,"en-GH":/^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/,"en-HK":/^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/,"en-MO":/^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,"en-IE":/^(\+?353|0)8[356789]\d{7}$/,"en-IN":/^(\+?91|0)?[6789]\d{9}$/,"en-KE":/^(\+?254|0)(7|1)\d{8}$/,"en-MT":/^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/,"en-MU":/^(\+?230|0)?\d{8}$/,"en-NG":/^(\+?234|0)?[789]\d{9}$/,"en-NZ":/^(\+?64|0)[28]\d{7,9}$/,"en-PK":/^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,"en-PH":/^(09|\+639)\d{9}$/,"en-RW":/^(\+?250|0)?[7]\d{8}$/,"en-SG":/^(\+65)?[3689]\d{7}$/,"en-SL":/^(\+?232|0)\d{8}$/,"en-TZ":/^(\+?255|0)?[67]\d{8}$/,"en-UG":/^(\+?256|0)?[7]\d{8}$/,"en-US":/^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,"en-ZA":/^(\+?27|0)\d{9}$/,"en-ZM":/^(\+?26)?09[567]\d{7}$/,"en-ZW":/^(\+263)[0-9]{9}$/,"es-AR":/^\+?549(11|[2368]\d)\d{8}$/,"es-BO":/^(\+?591)?(6|7)\d{7}$/,"es-CO":/^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/,"es-CL":/^(\+?56|0)[2-9]\d{1}\d{7}$/,"es-CR":/^(\+506)?[2-8]\d{7}$/,"es-DO":/^(\+?1)?8[024]9\d{7}$/,"es-HN":/^(\+?504)?[9|8]\d{7}$/,"es-EC":/^(\+?593|0)([2-7]|9[2-9])\d{7}$/,"es-ES":/^(\+?34)?[6|7]\d{8}$/,"es-PE":/^(\+?51)?9\d{8}$/,"es-MX":/^(\+?52)?(1|01)?\d{10,11}$/,"es-PA":/^(\+?507)\d{7,8}$/,"es-PY":/^(\+?595|0)9[9876]\d{7}$/,"es-UY":/^(\+598|0)9[1-9][\d]{6}$/,"et-EE":/^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,"fa-IR":/^(\+?98[-\s]?|0)9[0-39]\d[-\s]?\d{3}[-\s]?\d{4}$/,"fi-FI":/^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,"fj-FJ":/^(\+?679)?\s?\d{3}\s?\d{4}$/,"fo-FO":/^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,"fr-FR":/^(\+?33|0)[67]\d{8}$/,"fr-GF":/^(\+?594|0|00594)[67]\d{8}$/,"fr-GP":/^(\+?590|0|00590)[67]\d{8}$/,"fr-MQ":/^(\+?596|0|00596)[67]\d{8}$/,"fr-RE":/^(\+?262|0|00262)[67]\d{8}$/,"he-IL":/^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,"hu-HU":/^(\+?36)(20|30|70)\d{7}$/,"id-ID":/^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,"it-IT":/^(\+?39)?\s?3\d{2} ?\d{6,7}$/,"it-SM":/^((\+378)|(0549)|(\+390549)|(\+3780549))?6\d{5,9}$/,"ja-JP":/^(\+81[ -]?(\(0\))?|0)[6789]0[ -]?\d{4}[ -]?\d{4}$/,"ka-GE":/^(\+?995)?(5|79)\d{7}$/,"kk-KZ":/^(\+?7|8)?7\d{9}$/,"kl-GL":/^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,"ko-KR":/^((\+?82)[ -]?)?0?1([0|1|6|7|8|9]{1})[ -]?\d{3,4}[ -]?\d{4}$/,"lt-LT":/^(\+370|8)\d{8}$/,"lv-LV":/^(\+?371)2\d{7}$/,"ms-MY":/^(\+?6?01){1}(([0145]{1}(-|\s)?\d{7,8})|([236789]{1}(\s|-)?\d{7}))$/,"mz-MZ":/^(\+?258)?8[234567]\d{7}$/,"nb-NO":/^(\+?47)?[49]\d{7}$/,"ne-NP":/^(\+?977)?9[78]\d{8}$/,"nl-BE":/^(\+?32|0)4?\d{8}$/,"nl-NL":/^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/,"nn-NO":/^(\+?47)?[49]\d{7}$/,"pl-PL":/^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,"pt-BR":/^((\+?55 ?[1-9]{2} ?)|(\+?55 ?\([1-9]{2}\) ?)|(0[1-9]{2} ?)|(\([1-9]{2}\) ?)|([1-9]{2} ?))((\d{4}-?\d{4})|(9[2-9]{1}\d{3}-?\d{4}))$/,"pt-PT":/^(\+?351)?9[1236]\d{7}$/,"pt-AO":/^(\+244)\d{9}$/,"ro-RO":/^(\+?4?0)\s?7\d{2}(\/|\s|\.|-)?\d{3}(\s|\.|-)?\d{3}$/,"ru-RU":/^(\+?7|8)?9\d{9}$/,"si-LK":/^(?:0|94|\+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/,"sl-SI":/^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/,"sk-SK":/^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,"sq-AL":/^(\+355|0)6[789]\d{6}$/,"sr-RS":/^(\+3816|06)[- \d]{5,9}$/,"sv-SE":/^(\+?46|0)[\s-]?7[\s-]?[02369]([\s-]?\d){7}$/,"th-TH":/^(\+66|66|0)\d{9}$/,"tr-TR":/^(\+?90|0)?5\d{9}$/,"uk-UA":/^(\+?38|8)?0\d{9}$/,"uz-UZ":/^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,"vi-VN":/^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,"zh-CN":/^((\+|00)86)?1([3456789][0-9]|4[579]|6[2567]|7[01235678]|9[012356789])[0-9]{8}$/,"zh-TW":/^(\+?886-?|0)?9\d{8}$/};var c=r(73442);const d={isPending:!1,numberOfRequests:0,numberOfEmailChecks:0,numberOfPhoneNumberChecks:0};function l(e,t){const r=(0,c.A)(),l=(0,s.A)(),[u,h]=(0,i.useState)(d),f=(0,i.useRef)(e),m=(0,i.useRef)(t),p=(0,i.useRef)(null),g=async(i,a)=>
1{if(p.current&&p.current.cancel(),!i&&!a)return{isEmailAddressRegistered:void 0,isPhoneNumberRegistered:void 0};const s=new n.Ay;p.current=s;const o=r.post(l.generate("api.public.user.check_registration"),{data:{emailAddress:i,phoneNumber:a},cancelToken:s});h(e=>({isPending:!0,promise:o,numberOfRequests:e.numberOfRequests+1,numberOfEmailChecks:i?e.numberOfEmailChecks+1:e.numberOfEmailChecks,numberOfPhoneNumberChecks:i?e.numberOfPhoneNumberChecks+1:e.numberOfPhoneNumberChecks}));try{const{isEmailAddressRegistered:e,isPhoneNumberRegistered:t}=await o;return h(r=>({isRegistered:e||t,isEmailAddressRegistered:e,isPhoneNumberRegistered:t,isPending:!1,numberOfRequests:r.numberOfRequests,numberOfEmailChecks:r.numberOfEmailChecks,numberOfPhoneNumberChecks:r.numberOfPhoneNumberChecks})),{isEmailAddressRegistered:e,isPhoneNumberRegistered:t}}catch(r){r instanceof n.AL?e!==f.current&&t!==m.current||h(e=>({isRegistered:!1,isPending:!1,numberOfRequests:e.numberOfRequests,numberOfEmailChecks:e.numberOfEmailChecks,numberOfPhoneNumberChecks:e.numberOfPhoneNumberChecks})):h(e=>({error:r,isRegistered:void 0,isPending:!1,numberOfRequests:e.numberOfRequests,numberOfEmailChecks:e.numberOfEmailChecks,numberOfPhoneNumberChecks:e.numberOfPhoneNumberChecks}))}return{isEmailAddressRegistered:void 0,isPhoneNumberRegistered:void 0}};return(0,i.useEffect)(()=>()=>{p.current?.cancel()},[]),(0,i.useEffect)(()=>{let r;f.current=e;const i=e&&(0,a.A)(e)?e:void 0,n=t&&function(e,t){if(t){const r=o[t];if(!r)throw new TypeError(`isMobilePhone(value, locale): locale "${t}" is not known.`);return r.test(e)}for(const t in o)if(o[t].test(e))return!0;return!1}(t)?t:void 0;return i||n?(h(e=>({isRegistered:void 0,isPending:!0,numberOfRequests:e.numberOfRequests,numberOfEmailChecks:e.numberOfEmailChecks,numberOfPhoneNumberChecks:e.numberOfPhoneNumberChecks})),r=setTimeout(()=>g(i,n),200),()=>{clearTimeout(r)}):(p.current?.cancel(),void h(e=>({...d,numberOfRequests:e.numberOfRequests})))},[e,t]),{isRegisteredState:u,checkIsRegistered:g}}},6431(e,t,r){"use strict";r.d(t,{A:()=>$});var i=r(85906);const n={version:4,country_calling_codes:{1:["US","AG","AI","AS","BB","BM","BS","CA","DM","DO","GD","GU","JM","KN","KY","LC","MP","MS","PR","SX","TC","TT","VC","VG","VI"],7:["RU","KZ"],20:["EG"],27:["ZA"],30:["GR"],31:["NL"],32:["BE"],33:["FR"],34:["ES"],36:["HU"],39:["IT","VA"],40:["RO"],41:["CH"],43:["AT"],44:["GB","GG","IM","JE"],45:["DK"],46:["SE"],47:["NO","SJ"],48:["PL"],49:["DE"],51:["PE"],52:["MX"],53:["CU"],54:["AR"],55:["BR"],56:["CL"],57:["CO"],58:["VE"],60:["MY"],61:["AU","CC","CX"],62:["ID"],63:["PH"],64:["NZ"],65:["SG"],66:["TH"],81:["JP"],82:["KR"],84:["VN"],86:["CN"],90:["TR"],91:["IN"],92:["PK"],93:["AF"],94:["LK"],95:["MM"],98:["IR"],211:["SS"],212:["MA","EH"],213:["DZ"],216:["TN"],218:["LY"],220:["GM"],221:["SN"],222:["MR"],223:["ML"],224:["GN"],225:["CI"],226:["BF"],227:["NE"],228:["TG"],229:["BJ"],230:["MU"],231:["LR"],232:["SL"],233:["GH"],234:["NG"],235:["TD"],236:["CF"],237:["CM"],238:["CV"],239:["ST"],240:["GQ"],241:["GA"],242:["CG"],243:["CD"],244:["AO"],245:["GW"],246:["IO"],247:["AC"],248:["SC"],249:["SD"],250:["RW"],251:["ET"],252:["SO"],253:["DJ"],254:["KE"],255:["TZ"],256:["UG"],257:["BI"],258:["MZ"],260:["ZM"],261:["MG"],262:["RE","YT"],263:["ZW"],264:["NA"],265:["MW"],266:["LS"],267:["BW"],268:["SZ"],269:["KM"],290:["SH","TA"],291:["ER"],297:["AW"],298:["FO"],299:["GL"],350:["GI"],351:["PT"],352:["LU"],353:["IE"],354:["IS"],355:["AL"],356:["MT"],357:["CY"],358:["FI","AX"],359:["BG"],370:["LT"],371:["LV"],372:["EE"],373:["MD"],374:["AM"],375:["BY"],376:["AD"],377:["MC"],378:["SM"],380:["UA"],381:["RS"],382:["ME"],383:["XK"],385:["HR"],386:["SI"],387:["BA"],389:["MK"],420:["CZ"],421:["SK"],423:["LI"],500:["FK"],501:["BZ"],502:["GT"],503:["SV"],504:["HN"],505:["NI"],506:["CR"],507:["PA"],508:["PM"],509:["HT"],590:["GP","BL","MF"],591:["BO"],592:["GY"],593:["EC"],594:["GF"],595:["PY"],596:["MQ"],597:["SR"],598:["UY"],599:["CW","BQ"],670:["TL"],672:["NF"],673:["BN"],674:["NR"],675:["PG"],676:["TO"],677:["SB"],678:["VU"],679:["FJ"],680:["PW"],681:["WF"],682:["CK"],683:["NU"],685:["WS"],686:["KI"],687:["NC"],688:["TV"],689:["PF"],690:["TK"],691:["FM"],692:["MH"],850:["KP"],852:["HK"],853:["MO"],855:["KH"],856:["LA"],880:["BD"],886:["TW"],960:["MV"],961:["LB"],962:["JO"],963:["SY"],964:["IQ"],965:["KW"],966:["SA"],967:["YE"],968:["OM"],970:["PS"],971:["AE"],972:["IL"],973:["BH"],974:["QA"],975:["BT"],976:["MN"],977:["NP"],992:["TJ"],993:["TM"],994:["AZ"],995:["GE"],996:["KG"],998:["UZ"]},countries:{AC:["247","00","(?:[01589]\\d|[2-467])\\d{4}",[5,6],0,0,0,0,0,0,0,[0,["[2-47]\\d{4}",[5]]]],AD:["376","00","(?:1|6\\d)\\d{7}|[135-9]\\d{5}",[6,8,9],[["(\\d{3})(\\d{3})","$1 $2",["[135-9]"]],["(\\d{4})(\\d{4})","$1 $2",["1"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]],0,0,0,0,0,0,[0,["690\\d{6}|[356]\\d{5}",[6,9]]]],AE:["971","00","(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}",[5,6,7,8,9,10,11,12],[["(\\d{3})(\\d{2,9})","$1 $2",["60|8"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[236]|[479][2-8]"],"0$1"],["(\\d{3})(\\d)(\\d{5})","$1 $2 $3",["[479]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"]],"0",0,0,0,0,0,[0,["5[02-68]\\d{7}",[9]]]],AF:["93","00","[2-7]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"]],"0",0,0,0,0,0,[0,["7\\d{8}"]]],AG:["1","011","(?:268|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([457]\\d{6})$|1","268$1",0,"268",[0,["268(?:464|7(?:1[3-9]|[28]\\d|3[0246]|64|7[0-689]))\\d{4}"]]],AI:["1","011","(?:264|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2457]\\d{6})$|1","264$1",0,"264",[0,["264(?:235|4(?:69|7[67])|5(?:3[6-9]|8[1-4])|7(?:29|72))\\d{4}"]]],AL:["355","00","(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}",[6,7,8,9],[["(\\d{3})(\\d{3,4})","$1 $2",["80|9"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2358][2-5]|4"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["[23578]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["6"],"0$1"]],"0",0,0,0,0,0,[0,["6(?:[78][2-9]|9\\d)\\d{6}",[9]]]],AM:["374","00","(?:[1-489]\\d|55|60|77)\\d{6}",[8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[89]0"],"0 $1"],["(\\d{3})(\\d{5})","$1 $2",["2|3[12]"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["1|47"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[3-9]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:33|4[1349]|55|77|88|9[13-9])\\d{6}"]]],AO:["244","00","[29]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[29]"]]],0,0,0,0,0,0,[0,["9[1-79]\\d{7}"]]],AR:["54","00","(?:11|[89]\\d\\d)\\d{8}|[2368]\\d{9}",[10,11],[["(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])","2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8]))|2(?:2[24-9]|3[1-59]|47)","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5[56][46]|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|58|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|54(?:4|5[13-7]|6[89])|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:454|85[56])[46]|3(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["[23]"],"0$1",1],["(\\d)(\\d{4})(\\d{2})(\\d{4})","$2 15-$3-$4",["9(?:2[2-469]|3[3-578])","9(?:2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9]))","9(?:2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8])))|92(?:2[24-9]|3[1-59]|47)","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5(?:[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|5(?:4(?:4|5[13-7]|6[89])|[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",0,"$1 $2 $3-$4"],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 15-$3-$4",["91"],"0$1",0,"$1 $2 $3-$4"],["(\\d{3})(\\d{3})(\\d{5})","$1-$2-$3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 15-$3-$4",["9"],"0$1",0,"$1 $2 $3-$4"]],"0",0,"0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-4
16-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?","9$1",0,0,[0,["93(?:7(?:1[15]|81)|8(?:21|4[16]|69|9[12]))[46]\\d{5}|9(?:2(?:2(?:2[59]|44|52)|3(?:26|44)|47[35]|9(?:[07]2|2[26]|34|46))|3327)[45]\\d{5}|9(?:2(?:657|9(?:54|66))|3(?:48[27]|7(?:55|77)|8(?:65|78)))[2-8]\\d{5}|9(?:2(?:284|3(?:02|23)|477|622|920)|3(?:4(?:46|89|92)|541))[2-7]\\d{5}|(?:675\\d|9(?:11[0-8]\\d|2(?:2(?:0[45]|1[2-6]|3[3-6])|3(?:[06]4|7[45])|494|6(?:04|1[2-8]|[36][45]|4[3-6])|80[45]|9(?:[17][4-6]|[48][45]|9[3-6]))|3(?:364|4(?:1[2-8]|[25][4-6]|3[3-6]|84)|5(?:1[2-9]|[38][4-6])|6(?:2[45]|44)|7[069][45]|8(?:0[45]|1[2-7]|3[4-6]|5[3-6]|7[2-6]|8[3-68]))))\\d{6}|9(?:2(?:2(?:62|81)|320|9(?:42|83))|3(?:329|4(?:62|7[16])|5(?:43|64)|7(?:18|5[17])))[2-6]\\d{5}|92(?:2(?:21|4[23]|6[145]|7[1-4]|8[356]|9[267])|3(?:16|3[13-8]|43|5[346-8]|9[3-5])|6(?:2[46]|4[78]|5[1568])|9(?:03|2[1457-9]|3[1356]|4[08]|[56][23]|82))4\\d{5}|9(?:2(?:257|3(?:24|46|92)|9(?:01|23|64))|3(?:4(?:42|64)|5(?:25|37|4[47]|71)|7(?:35|72)|825))[3-6]\\d{5}|9(?:2(?:2(?:02|2[3467]|4[156]|5[45]|6[6-8]|91)|3(?:1[47]|25|[45][25]|96)|47[48]|625|932)|3(?:38[2578]|4(?:0[0-24-9]|3[78]|4[457]|58|6[035-9]|72|83|9[136-8])|5(?:2[124]|[368][23]|4[2689]|7[2-6])|7(?:16|2[15]|3[14]|4[13]|5[468]|7[3-5]|8[26])|8(?:2[67]|3[278]|4[3-5]|5[78]|6[1-378]|[78]7|94)))[4-6]\\d{5}"]]],AS:["1","011","(?:[58]\\d\\d|684|900)\\d{7}",[10],0,"1",0,"([267]\\d{6})$|1","684$1",0,"684",[0,["684(?:2(?:48|5[2468]|7[246])|7(?:3[13]|70|82))\\d{4}"]]],AT:["43","00","1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}",[4,5,6,7,8,9,10,11,12,13],[["(\\d)(\\d{3,12})","$1 $2",["1(?:11|[2-9])"],"0$1"],["(\\d{3})(\\d{2})","$1 $2",["517"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["5[079]"],"0$1"],["(\\d{3})(\\d{3,10})","$1 $2",["(?:31|4)6|51|6(?:48|5[0-3579]|[6-9])|7(?:20|32|8)|[89]","(?:31|4)6|51|6(?:485|5[0-3579]|[6-9])|7(?:20|32|8)|[89]"],"0$1"],["(\\d{4})(\\d{3,9})","$1 $2",["[2-467]|5[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["5"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,7})","$1 $2 $3",["5"],"0$1"]],"0",0,0,0,0,0,[0,["6(?:485|(?:5[0-3579]|6[013-9]|[7-9]\\d)\\d)\\d{3,9}",[7,8,9,10,11,12,13]]]],AU:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{7}(?:\\d(?:\\d{2})?)?|8[0-24-9]\\d{7})|[2-478]\\d{8}|1\\d{4,7}",[5,6,7,8,9,10,12],[["(\\d{2})(\\d{3,4})","$1 $2",["16"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,4})","$1 $2 $3",["16"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["14|4"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[2378]"],"(0$1)"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:30|[89])"]]],"0",0,"(183[12])|0",0,0,0,[0,["4(?:79[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-9])\\d{6}",[9]]],"0011"],AW:["297","00","(?:[25-79]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[25-9]"]]],0,0,0,0,0,0,[0,["(?:290|5[69]\\d|6(?:[03]0|22|4[0-2]|[69]\\d)|7(?:[34]\\d|7[07])|9(?:6[45]|9[4-8]))\\d{4}"]]],AX:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}",[5,6,7,8,9,10,11,12],0,"0",0,0,0,0,"18",[0,["4946\\d{2,6}|(?:4[0-8]|50)\\d{4,8}",[6,7,8,9,10]]],"00"],AZ:["994","00","365\\d{6}|(?:[124579]\\d|60|88)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[28]|2|365|46","1[28]|2|365[45]|46","1[28]|2|365(?:4|5[02])|46"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-9]"],"0$1"]],"0",0,0,0,0,0,[0,["36554\\d{4}|(?:[16]0|4[04]|5[015]|7[07]|99)\\d{7}"]]],BA:["387","00","6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-3]|[7-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]|6[56]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6"],"0$1"]],"0",0,0,0,0,0,[0,["6040\\d{5}|6(?:03|[1-356]|44|7\\d)\\d{6}"]]],BB:["1","011","(?:246|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","246$1",0,"246",[0,["246(?:(?:2(?:[3568]\\d|4[0-57-9])|3(?:5[2-9]|6[0-6])|4(?:46|5\\d)|69[5-7]|8(?:[2-5]\\d|83))\\d|52(?:1[147]|20))\\d{3}"]]],BD:["880","00","[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{4,6})","$1-$2",["31[5-8]|[459]1"],"0$1"],["(\\d{3})(\\d{3,7})","$1-$2",["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:[15]|28|4[14])|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"],"0$1"],["(\\d{4})(\\d{3,6})","$1-$2",["[13-9]|2[23]"],"0$1"],["(\\d)(\\d{7,8})","$1-$2",["2"],"0$1"]],"0",0,0,0,0,0,[0,["(?:1[13-9]\\d|644)\\d{7}|(?:3[78]|44|66)[02-9]\\d{7}",[10]]]],BE:["32","00","4\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[239]|4[23]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[15-8]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4"],"0$1"]],"0",0,0,0,0,0,[0,["4[5-9]\\d{7}",[9]]]],BF:["226","00","[024-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[024-7]"]]],0,0,0,0,0,0,[0,["(?:0[1-7]|4[4-6]|5[0-8]|[67]\\d)\\d{6}"]]],BG:["359","00","00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",[6,7,8,9,12],[["(\\d)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["43[1-6]|70[1-9]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:70|8)0"],"0$1"],["(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[1-7]|7"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[48]|9[08]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"]],"0",0,0,0,0,0,[0,["(?:43[07-9]|99[69]\\d)\\d{5}|(?:8[7-9]|98)\\d{7}",[8,9]]]],BH:["973","00","[136-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[13679]|8[02-4679]"]]],0,0,0,0,0,0,[0,["(?:3(?:[0-79]\\d|8[0-57-9])\\d|6(?:3(?:00|33|6[16])|441|6(?:3[03-9]|[69]\\d|7[0-689])))\\d{4}"]]],BI:["257","00","(?:[267]\\d|31)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2367]"]]],0,0,0,0,0,0,[0,["(?:29|6[1-9]|7[125-9])\\d{6}"]]],BJ:["229","00","(?:01\\d|8)\\d{7}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["0"]]],0,0,0,0,0,0,[0,["01(?:2[5-9]|[4-69]\\d)\\d{6}",[10]]]],BL:["590","00","7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[0,["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"]]],BM:["1","011","(?:441|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","441$1",0,"441",[0,["441(?:[2378]\\d|5[0-39]|9[02])\\d{5}"]]],BN:["673","00","[2-578]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-578]"]]],0,0,0,0,0,0,[0,["(?:22[89]|[78]\\d\\d)\\d{4}"]]],BO:["591","00(?:1\\d)?","(?:[2-7]\\d\\d|8001)\\d{5}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[23]|4[46]|50"]],["(\\d{8})","$1",["[5-7]"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["8"]]],"0",0,"0(1\\d)?",0,0,0,[0,["(?:57|[67]\\d)\\d{6}",[8]]]],BQ:["599","00","(?:[34]1|7\\d)\\d{5}",[7],0,0,0,0,0,0,"[347]",[0,["(?:31(?:8[14-8]|9[14578])|416[14-9]|7(?:0[01]|7[07]|8\\d|9[056])\\d)\\d{3}"]]],BR:["55","00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","[1-467]\\d{9,10}
1|55[0-46-9]\\d{8}|[34]\\d{7}|55\\d{7,8}|(?:5[0-46-9]|[89]\\d)\\d{7,9}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37|86)","300|4(?:0(?:0|20)|370|864)"]],["(\\d{3})(\\d{2,3})(\\d{4})","$1 $2 $3",["(?:[358]|90)0"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"],"($1)"],["(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[16][1-9]|[2-57-9]"],"($1)"]],"0",0,"(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2",0,0,[0,["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])(?:7|9\\d)\\d{7}",[10,11]]]],BS:["1","011","(?:242|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([3-8]\\d{6})$|1","242$1",0,"242",[0,["242(?:3(?:5[79]|7[56]|95)|4(?:[23][1-9]|4[1-35-9]|5[1-8]|6[2-8]|7\\d|81)|5(?:2[45]|3[35]|44|5[1-46-9]|65|77)|6[34]6|7(?:27|38)|8(?:0[1-9]|1[02-9]|2\\d|3[0-4]|[89]9))\\d{4}"]]],BT:["975","00","[178]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-6]|7[246]|8[2-4]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|[78]"]]],0,0,0,0,0,0,[0,["(?:1[67]|[78]7)\\d{6}",[8]]]],BW:["267","00","(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}",[7,8,10],[["(\\d{2})(\\d{5})","$1 $2",["90"]],["(\\d{3})(\\d{4})","$1 $2",["[24-6]|3[15-9]"]],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37]"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["8"]]],0,0,0,0,0,0,[0,["(?:321|7(?:[1-8]\\d|9[03]))\\d{5}",[8]]]],BY:["375","810","(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3})","$1 $2",["800"],"8 $1"],["(\\d{3})(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"],["(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:[56]|7[467])|2[1-3]"],"8 0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-4]"],"8 0$1"],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["[89]"],"8 $1"]],"8",0,"0|80?",0,0,0,[0,["(?:2(?:5[5-79]|9[1-9])|(?:33|44)\\d)\\d{6}",[9]]],"8~10"],BZ:["501","00","(?:0800\\d|[2-8])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],["(\\d)(\\d{3})(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]],0,0,0,0,0,0,[0,["6[0-35-7]\\d{5}",[7]]]],CA:["1","011","[2-9]\\d{9}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[0,["(?:2(?:04|[23]6|[48]9|5[07]|63)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|7[39])|9(?:0[25]|42))[2-9]\\d{6}",[10]]]],CC:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[0,["4(?:79[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-9])\\d{6}",[9]]],"0011"],CD:["243","00","(?:(?:[189]|5\\d)\\d|2)\\d{7}|[1-68]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["5"],"0$1"]],"0",0,0,0,0,0,[0,["88\\d{5}|(?:8[0-69]|9[016-9])\\d{7}",[7,9]]]],CF:["236","00","8776\\d{4}|(?:[27]\\d|61)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-8]"]]],0,0,0,0,0,0,[0,["7[02-7]\\d{6}"]]],CG:["242","00","222\\d{6}|(?:0\\d|80)\\d{7}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]]],0,0,0,0,0,0,[0,["026(?:1[0-5]|6[6-9])\\d{4}|0(?:[14-6]\\d\\d|2(?:40|5[5-8]|6[07-9]))\\d{5}"]]],CH:["41","00","8\\d{11}|[2-9]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]|81"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["8"],"0$1"]],"0",0,0,0,0,0,[0,["(?:6[89]|7[235-9])\\d{7}",[9]]]],CI:["225","00","[02]\\d{9}",[10],[["(\\d{2})(\\d{2})(\\d)(\\d{5})","$1 $2 $3 $4",["2"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3 $4",["0"]]],0,0,0,0,0,0,[0,["0[157]\\d{8}"]]],CK:["682","00","[2-578]\\d{4}",[5],[["(\\d{2})(\\d{3})","$1 $2",["[2-578]"]]],0,0,0,0,0,0,[0,["[578]\\d{4}"]]],CL:["56","(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0","12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}",[9,10,11],[["(\\d{5})(\\d{4})","$1 $2",["219","2196"],"($1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["60|809"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["44"]],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[1-36]"],"($1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9(?:10|[2-9])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-8]|[1-9])"],"($1)"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{3})(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"]]],0,0,0,0,0,0,[0,["2(?:1982[0-6]|3314[05-9])\\d{3}|(?:2(?:1(?:160|962)|3(?:(?:[24]\\d|50)\\d|3(?:[0346-9]\\d|1[0-35-9]|2[1-9]|5[0-24-9])|600)|646[59])|80[1-8]\\d\\d|9(?:(?:10[0-2]|7[1-9]\\d)\\d|3(?:[0-57-9]\\d\\d|6(?:0[02-9]|[1-9]\\d))|6(?:[0-8]\\d\\d|9(?:[02-79]\\d|1[05-9]))|9(?:[03-9]\\d\\d|1(?:[0235-9]\\d|4[0-24-9])|2(?:[0-79]\\d|8[0-46-9]))))\\d{4}|(?:22|3[2-5]|[47][1-35]|5[1-3578]|6[13-57]|8[1-9]|9[2458])\\d{7}",[9]]]],CM:["237","00","[26]\\d{8}|88\\d{6,7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["88"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]|88"]]],0,0,0,0,0,0,[0,["(?:24[23]|6(?:[25-9]\\d|4[0-2]))\\d{6}",[9]]]],CN:["86","00|1(?:[12]\\d|79)\\d\\d00","(?:(?:1[03-689]|2\\d)\\d\\d|6)\\d{8}|1\\d{10}|[126]\\d{6}(?:\\d(?:\\d{2})?)?|86\\d{5,6}|(?:[3-579]\\d|8[0-57-9])\\d{5,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]","(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123"],"0$1"],["(\\d{3})(\\d{5,6})","$1 $2",["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]","(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]","85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])","85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["(?:4|80)0"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|2(?:[02-57-9]|1[1-9])","10|2(?:[02-57-9]|1[1-9])","10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4}
1)","$1 $2 $3",["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"],"0$1",1],["(\\d{3})(\\d{7,8})","$1 $2",["9"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[3-578]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-9]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[12]"],"0$1",1]],"0",0,"(1(?:[12]\\d|79)\\d\\d)|0",0,0,0,[0,["1(?:610\\d|740[0-5])\\d{6}|1(?:[38]\\d|4[57]|[59][0-35-9]|6[25-7]|7[0-35-8])\\d{8}",[11]]],"00"],CO:["57","00(?:4(?:[14]4|56)|[579])","(?:46|60\\d\\d)\\d{6}|(?:1\\d|[39])\\d{9}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["46"]],["(\\d{3})(\\d{7})","$1 $2",["6|90"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|9[14]"]],["(\\d)(\\d{3})(\\d{7})","$1-$2-$3",["1"],"0$1",0,"$1 $2 $3"]],"0",0,"0([3579]|4(?:[14]4|56))?",0,0,0,[0,["333301[0-5]\\d{3}|3333(?:00|2[5-9]|[3-9]\\d)\\d{4}|(?:3(?:(?:0[0-5]|1\\d|5[01]|70)\\d|2(?:[0-3]\\d|4[1-9])|3(?:00|3[0-24-9]))|9(?:101|408))\\d{6}",[10]]]],CR:["506","00","(?:8\\d|90)\\d{8}|(?:[24-8]\\d{3}|3005)\\d{4}",[8,10],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[3-9]"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]"]]],0,0,"(19(?:0[0-2468]|1[09]|20|66|77|99))",0,0,0,[0,["(?:3005\\d|6500[01])\\d{3}|(?:5[07]|6[0-4]|7[0-3]|8[3-9])\\d{6}",[8]]]],CU:["53","119","(?:[2-7]|8\\d\\d)\\d{7}|[2-47]\\d{6}|[34]\\d{5}",[6,7,8,10],[["(\\d{2})(\\d{4,6})","$1 $2",["2[1-4]|[34]"],"(0$1)"],["(\\d)(\\d{6,7})","$1 $2",["7"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["[56]"],"0$1"],["(\\d{3})(\\d{7})","$1 $2",["8"],"0$1"]],"0",0,0,0,0,0,[0,["(?:5\\d|6[2-4])\\d{6}",[8]]]],CV:["238","0","(?:[2-59]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2-589]"]]],0,0,0,0,0,0,[0,["(?:36|5[1-389]|9\\d)\\d{5}"]]],CW:["599","00","(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[3467]"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["9[4-8]"]]],0,0,0,0,0,"[69]",[0,["953[01]\\d{4}|9(?:5[12467]|6[5-9])\\d{5}"]]],CX:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[0,["4(?:79[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-9])\\d{6}",[9]]],"0011"],CY:["357","00","(?:[279]\\d|[58]0)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[257-9]"]]],0,0,0,0,0,0,[0,["9(?:10|[4-79]\\d)\\d{5}"]]],CZ:["420","00","(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",[9,10,11,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["96"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]],0,0,0,0,0,0,[0,["7060\\d{5}|(?:60[1-8]|7(?:0[2-5]|19|[2379]\\d))\\d{6}",[9]]]],DE:["49","00","[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}",[4,5,6,7,8,9,10,11,12,13,14,15],[["(\\d{2})(\\d{3,13})","$1 $2",["3[02]|40|[68]9"],"0$1"],["(\\d{3})(\\d{3,12})","$1 $2",["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1","2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"],"0$1"],["(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]","[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["138"],"0$1"],["(\\d{5})(\\d{2,10})","$1 $2",["3"],"0$1"],["(\\d{3})(\\d{5,11})","$1 $2",["181"],"0$1"],["(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["1(?:3|80)|9"],"0$1"],["(\\d{3})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],["(\\d{3})(\\d{7,12})","$1 $2",["8"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["18[68]"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["15[1279]"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["15[03568]","15(?:[0568]|3[13])"],"0$1"],["(\\d{3})(\\d{8})","$1 $2",["18"],"0$1"],["(\\d{3})(\\d{2})(\\d{7,8})","$1 $2 $3",["1(?:6[023]|7)"],"0$1"],["(\\d{4})(\\d{2})(\\d{7})","$1 $2 $3",["15[279]"],"0$1"],["(\\d{3})(\\d{2})(\\d{8})","$1 $2 $3",["15"],"0$1"]],"0",0,0,0,0,0,[0,["1(?:6[023]|7\\d)\\d{7,8}|15(?:[0-25-9]\\d\\d|3(?:10|33))\\d{6}
1",[10,11]]]],DJ:["253","00","(?:2\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[27]"]]],0,0,0,0,0,0,[0,["77\\d{6}"]]],DK:["45","00","[2-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-9]"]]],0,0,0,0,0,0,[0,["(?:2[6-8]|37|6[78]|96)\\d{6}|(?:2[0-59]|3[0-689]|[457]\\d|6[0-69]|8[126-9]|9[1-47-9])[1-9]\\d{5}"]]],DM:["1","011","(?:[58]\\d\\d|767|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","767$1",0,"767",[0,["767(?:2(?:[2-4689]5|7[5-7])|31[5-7]|61[1-8]|70[1-6])\\d{4}"]]],DO:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,0,0,0,"8001|8[024]9",[0,["8[024]9[2-9]\\d{6}"]]],DZ:["213","00","(?:[1-4]|[5-79]\\d|80)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-8]"],"0$1"]],"0",0,0,0,0,0,[0,["5(?:4[0-29]|6[0-4])\\d{6}|(?:55|6\\d|7[7-9])\\d{7}",[9]]]],EC:["593","00","1\\d{9,10}|(?:[2-7]|9\\d)\\d{7}",[8,9,10,11],[["(\\d)(\\d{3})(\\d{4})","$1 $2-$3",["[2-7]"],"(0$1)",0,"$1-$2-$3"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{3})(\\d{3,4})","$1 $2 $3",["1"]]],"0",0,0,0,0,0,[0,["964[0-2]\\d{5}|9(?:39|[57][89]|6[0-36-9]|[89]\\d)\\d{6}",[9]]]],EE:["372","00","8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]|88","[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]|88"]],["(\\d{4})(\\d{3,4})","$1 $2",["[45]|8(?:00|[1-49])","[45]|8(?:00[1-9]|[1-49])"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]],0,0,0,0,0,0,[0,["(?:5\\d{5}|8(?:1(?:0(?:0(?:00|[178]\\d)|[3-9]\\d\\d)|(?:1(?:0[2-6]|1\\d)|[2-79]\\d\\d)\\d)|2(?:0(?:0(?:00|4\\d)|(?:19|[2-7]\\d)\\d)|(?:(?:[124-69]\\d|3[5-9])\\d|7(?:[
10-79]\\d|8[013-9])|8(?:[2-6]\\d|7[01]))\\d)|[349]\\d{4}))\\d\\d|5(?:(?:[02]\\d|5[0-478])\\d|1(?:[0-8]\\d|95)|6(?:4[0-4]|5[1-589]))\\d{3}",[7,8]]]],EG:["20","00","[189]\\d{8,9}|[24-6]\\d{8}|[135]\\d{7}",[8,9,10],[["(\\d)(\\d{7,8})","$1 $2",["[23]"],"0$1"],["(\\d{2})(\\d{6,7})","$1 $2",["1[35]|[4-6]|8[2468]|9[235-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{8})","$1 $2",["1"],"0$1"]],"0",0,0,0,0,0,[0,["1[0-25]\\d{8}",[10]]]],EH:["212","00","[5-8]\\d{8}",[9],0,"0",0,0,0,0,0,[0,["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[016-8]\\d|2[0-8]|3[01]|5[0-5]))\\d{6}"]]],ER:["291","00","[178]\\d{6}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[178]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:17[1-3]|7\\d\\d)\\d{4}"]]],ES:["34","00","(?:400|[5-9]\\d\\d)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]00"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[4-9]"]]],0,0,0,0,0,0,[0,["96906(?:09|10)\\d\\d|(?:590(?:10[0-2]|600)|97390\\d)\\d{3}|(?:6\\d|7[1-48])\\d{7}"]]],ET:["251","00","(?:11|[2-57-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-57-9]"],"0$1"]],"0",0,0,0,0,0,[0,["700[1-9]\\d{5}|(?:7(?:0[1-9]|1[0-8]|2[1-35-79]|3\\d|77|86|99)|(?:8[01]|9\\d)\\d)\\d{6}"]]],FI:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",[5,6,7,8,9,10,11,12],[["(\\d{5})","$1",["20[2-59]"],"0$1"],["(\\d{3})(\\d{3,7})","$1 $2",["(?:[1-3]0|[68])0|70[07-9]"],"0$1"],["(\\d{2})(\\d{4,8})","$1 $2",["[14]|2[09]|50|7[135]"],"0$1"],["(\\d{2})(\\d{6,10})","$1 $2",["7"],"0$1"],["(\\d)(\\d{4,9})","$1 $2",["(?:19|[2568])[1-8]|3(?:0[1-9]|[1-9])|9"],"0$1"]],"0",0,0,0,0,"1[03-79]|[2-9]",[0,["4946\\d{2,6}|(?:4[0-8]|50)\\d{4,8}",[6,7,8,9,10]]],"00"],FJ:["679","0(?:0|52)","45\\d{5}|(?:0800\\d|[235-9])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1 $2",["[235-9]|45"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]]],0,0,0,0,0,0,[0,["(?:[279]\\d|45|5[01568]|8[034679])\\d{5}",[7]]],"00"],FK:["500","00","[2-7]\\d{4}",[5],0,0,0,0,0,0,0,[0,["[56]\\d{4}"]]],FM:["691","00","(?:[39]\\d\\d|820)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[389]"]]],0,0,0,0,0,0,[0,["31(?:00[67]|208|309)\\d\\d|(?:3(?:[2357]0[1-9]|602|804|905)|(?:820|9[2-7]\\d)\\d)\\d{3}"]]],FO:["298","00","[2-9]\\d{5}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[2-9]"]]],0,0,"(10(?:01|[12]0|88))",0,0,0,[0,["(?:[27][1-9]|5\\d|9[16])\\d{4}"]]],FR:["33","00","[1-9]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:6(?:[0-24-8]\\d|3[0-8]|9[589])|7[3-9]\\d)\\d{6}"]]],GA:["241","00","(?:[067]\\d|11)\\d{6}|[2-7]\\d{6}",[7,8],[["(\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["11|[67]"],"0$1"]],0,0,"0(11\\d{6}|60\\d{6}|61\\d{6}|6[256]\\d{6}|7[467]\\d{6})","$1",0,0,[0,["(?:(?:0[2-7]|7[467])\\d|6(?:0[0-4]|10|[256]\\d))\\d{5}|[2-7]\\d{6}"]]],GB:["44","00","[1-357-9]\\d{9}|[18]\\d{8}|8\\d{6}",[7,9,10],[["(\\d{3})(\\d{4})","$1 $2",["800","8001","80011","800111","8001111"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["845","8454","84546","845464"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["800"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["1(?:38|5[23]|69|76|94)","1(?:(?:38|69)7|5(?:24|39)|768|946)","1(?:3873|5(?:242|39[4-6])|(?:697|768)[347]|9467)"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["1(?:[2-69][02-9]|[78])"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[25]|7(?:0|6[02-9])","[25]|7(?:0|6(?:[03-9]|2[356]))"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[1389]"],"0$1"]],"0",0,"0|180020",0,0,0,[0,["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}",[10]]],0," x"],GD:["1","011","(?:473|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","473$1",0,"473",[0,["473(?:4(?:0[2-79]|1[04-9]|2[0-5]|49|5[6-8])|5(?:2[01]|3[3-8])|901)\\d{4}"]]],GE:["995","00","(?:[3-57]\\d\\d|800)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["32"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[57]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"]],"0",0,0,0,0,0,[0,["5(?:(?:(?:0555|1(?:[17]77|555))[5-9]|757(?:7[7-9]|8[01]))\\d|22252[0-4])\\d\\d|5(?:0(?:0(?:1[09]|70)|505)|1(?:0[01]0|1(?:07|33|51))|2(?:0[02]0|2[25]2)|3(?:0[03]0|3[35]3)|4(?:0[04]0|411)|5222|9000)[0-4]\\d{3}|(?:5(?:0(?:0(?:0\\d|1[12]|2[02]|3[0-6]|4[04]|5[05]|77|88|9[09])|(?:[14]\\d|77)\\d|22[02])|1(?:1(?:[03][01]|[124]\\d|5[02-6]|7[0-6])|4\\d\\d)|2(?:228|555)|3555|4(?:4(?:[02-9]\\d|14)|555)|5(?:[0157-9]\\d\\d|200|333|4(?:44|55))|6[89]\\d\\d|7(?:(?:[0147-9]\\d|22)\\d|5(?:00|[57]5))|8(?:0(?:[018]\\d|2[0-4])|5(?:55|8[89])|8(?:55|88))|9(?:090|[1-35-9]\\d\\d))|790\\d\\d)\\d{4}"]]],GF:["594","00","(?:694\\d|7093)\\d{5}|(?:59|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]|80[6-9]|9[47]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[89]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:694(?:[0-249]\\d|3[0-8])|7093[0-3])\\d{4}"]]],GG:["44","00","(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?",[7,9,10],0,"0",0,"([25-9]\\d{5})$|0|180020","1481$1",0,0,[0,["7(?:(?:781|839)\\d|911[17])\\d{5}",[10]]]],GH:["233","00","[235]\\d{8}|800\\d{5,6}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2358]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:2(?:[0346-9]\\d|5[67])|5(?:[03-7]\\d|9[1-9]))\\d{6}",[9]]]],GI:["350","00","(?:[25]\\d|60)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["2"]]],0,0,0,0,0,0,[0,["5251[0-4]\\d{3}|(?:5(?:[146-8]\\d\\d|250)|60(?:1[01]|6\\d))\\d{4}"]]],GL:["299","00","(?:19|[2-689]\\d|70)\\d{4}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["19|[2-9]"]]],0,0,0,0,0,0,[0,["[245]\\d{5}"]]],GM:["220","00","[48]\\d{8}|[2-9]\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["[235-9]|4(?:[0-35]|4[16-9])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[48]"]]],0,0,0,0,0,0,[0,["(?:(?:[23679]\\d|4[015]|8(?:(?:3[35]|6[68]|99)\\d|7(?:[27]\\d|4[015])))\\d|5(?:[0-489]\\d|56))\\d{4}|8[4-7]\\d{5}"]]],GN:["224","00","722\\d{6}|(?:3|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]],0,0,0,0,0,0,[0,["6[0-356]\\d{7}",[9]]]],GP:["590","00","7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|80[6-9]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[0,["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"]]],GQ:["240","00","222\\d{6}|(?:3\\d|55|[89]0)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],["(\\d{3})(\\d{6})","$1 $2",["[89]"]]],0,0,0,0,0,0,[0,["(?:222|55\\d)\\d{6}
1"]]],GR:["30","00","5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",[10,11,12],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],["(\\d{4})(\\d{6})","$1 $2",["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2689]"]],["(\\d{3})(\\d{3,4})(\\d{5})","$1 $2 $3",["8"]]],0,0,0,0,0,0,[0,["68[57-9]\\d{7}|(?:69|94)\\d{8}",[10]]]],GT:["502","00","80\\d{6}|(?:1\\d{3}|[2-7])\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1 $2",["[2-8]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]],0,0,0,0,0,0,[0,["(?:[3-5]\\d\\d|80[0-4])\\d{5}",[8]]]],GU:["1","011","(?:[58]\\d\\d|671|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","671$1",0,"671",[0,["671(?:2\\d\\d|3(?:00|3[39]|4[349]|55|6[26])|4(?:00|56|7[1-9]|8[02-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[235-9])|7(?:[0479]7|2[0167]|3[45]|8[7-9])|8(?:[2-57-9]8|6[478])|9(?:2[29]|6[79]|7[1279]|8[7-9]|9[16-9]))\\d{4}"]]],GW:["245","00","[49]\\d{8}|4\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["40"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"]]],0,0,0,0,0,0,[0,["9(?:5\\d|6[569]|77)\\d{6}",[9]]]],GY:["592","001","(?:[2-8]\\d{3}|9008)\\d{3}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]],0,0,0,0,0,0,[0,["(?:51[01]|6\\d\\d|7(?:[0-5]\\d|6[0-79]|70|8[067]))\\d{4}"]]],HK:["852","00(?:30|5[09]|[126-9]?)","8[0-46-9]\\d{6,7}|9\\d{4,7}|(?:[2-7]|9\\d{3})\\d{7}",[5,6,7,8,9,11],[["(\\d{3})(\\d{2,5})","$1 $2",["900","9003"]],["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[1-4]|9(?:0[1-9]|[1-8])"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{3})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]],0,0,0,0,0,0,[0,["(?:4(?:0(?:6[0-3]|9[3-6])|24[3-6]|44[0-35-9]|6(?:4[0-57-9]|6[0-6])|7(?:4[0-48]|6[0-5]))|5(?:25[3-7]|35[4-8]|73[0-6]|95[0-8])|6(?:26[013-8]|(?:66|78)[0-5])|70(?:7[1-8]|8[0-8])|84(?:4[0-2]|8[0-35-9])|9(?:29[013-9]|39[014-9]|59[0-467]|899))\\d{4}|(?:4(?:4[0-35-9]|6[0-357-9]|7[0-35])|5(?:[1-59][0-46-9]|6[0-4689]|7[0-246-9])|6(?:0[1-9]|[13-59]\\d|[268][0-57-9]|7[0-79])|70[1-59]|84[0-39]|9(?:0[1-9]|1[02-9]|[2358][0-8]|[467]\\d))\\d{5}",[8]]],"00"],HN:["504","00","8\\d{10}|[237-9]\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1-$2",["[237-9]"]]],0,0,0,0,0,0,[0,["[37-9]\\d{7}",[8]]]],HR:["385","00","[2-69]\\d{8}|80\\d{5,7}|[1-79]\\d{7}|6\\d{6}",[7,8,9],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["6[01]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{4})(\\d{3})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6|7[245]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-57]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],"0",0,0,0,0,0,[0,["9(?:(?:0[1-9]|[12589]\\d)\\d\\d|7(?:[0679]\\d\\d|5(?:[01]\\d|44|55|77|9[5-79])))\\d{4}|98\\d{6}",[8,9]]]],HT:["509","00","[2-589]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[2-589]"]]],0,0,0,0,0,0,[0,["(?:[34]\\d|5[568])\\d{6}"]]],HU:["36","00","[235-7]\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27][2-9]|3[2-7]|4[24-9]|5[2-79]|6|8[2-57-9]|9[2-69]"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"06 $1"]],"06",0,0,0,0,0,[0,["(?:[257]0|3[01])\\d{7}",[9]]]],ID:["62","00[89]","00[1-9]\\d{9,14}|(?:[1-36]|8\\d{5})\\d{6}|00\\d{9}|[1-9]\\d{8,10}|[2-9]\\d{7}",[7,8,9,10,11,12,13,14,15,16,17],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["15"]],["(\\d{2})(\\d{5,9})","$1 $2",["2[124]|[36]1"],"(0$1)"],["(\\d{3})(\\d{5,7})","$1 $2",["800"],"0$1"],["(\\d{3})(\\d{5,8})","$1 $2",["[2-79]"],"(0$1)"],["(\\d{3})(\\d{3,4})(\\d{3})","$1-$2-$3",["8[1-35-9]"],"0$1"],["(\\d{3})(\\d{6,8})","$1 $2",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["804"],"0$1"],["(\\d{3})(\\d)(\\d{3})(\\d{3})","$1 $2 $3 $4",["80"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1-$2-$3",["8"],"0$1"]],"0",0,0,0,0,0,[0,["8[1-35-9]\\d{7,10}",[9,10,11,12]]]],IE:["353","00","(?:1\\d|[2569])\\d{6,8}|4\\d{6,9}|7\\d{8}|8\\d{8,9}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["2[24-9]|47|58|6[237-9]|9[35-9]"],"(0$1)"],["(\\d{3})(\\d{5})","$1 $2",["[45]0"],"(0$1)"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["1"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2569]|4[1-69]|7[14]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["81"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[78]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["4"],"(0$1)"],["(\\d{2})(\\d)(\\d{3})(\\d{4})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[0,["8(?:22|[35-9]\\d)\\d{6}",[9]]]],IL:["972","0(?:0|1(?:05|[2-9]))","1\\d{6}(?:\\d{3,5})?|[57]\\d{8}|[1-489]\\d{7}",[7,8,9,10,11,12],[["(\\d{4})(\\d{3})","$1-$2",["125"]],["(\\d{4})(\\d{2})(\\d{2})","$1-$2-$3",["121"]],["(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[2-489]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1-$2-$3",["12"]],["(\\d{4})(\\d{6})","$1-$2",["159"]],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3-$4",["1[7-9]"]],["(\\d{3})(\\d{1,2})(\\d{3})(\\d{4}
1)","$1-$2 $3-$4",["15"]]],"0",0,0,0,0,0,[0,["55(?:4(?:0[0-3]|10|6[015-9])|57[0-289]|8[06][0-2])\\d{4}|5(?:(?:[0-2][02-9]|[36]\\d|[49][2-9]|8[3-7])\\d|5(?:01|2\\d|3[0-3]|4[3-5]|5[0-25689]|6[6-8]|7[0-267]|8[7-9]|9[1-9]))\\d{5}",[9]]]],IM:["44","00","1624\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([25-8]\\d{5})$|0|180020","1624$1",0,"74576|(?:16|7[56])24",[0,["76245[06]\\d{4}|7(?:4576|[59]24\\d|624[0-4689])\\d{5}"]]],IN:["91","00","(?:000800|[2-9]\\d\\d)\\d{7}|1\\d{7,12}",[8,9,10,11,12,13],[["(\\d{8})","$1",["5(?:0|2[23]|3[03]|[67]1|88)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|888)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|8888)"],0,1],["(\\d{4})(\\d{4,5})","$1 $2",["180","1800"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["140"],0,1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["11|2[02]|33|4[04]|79[1-7]|80[2-46]","11|2[02]|33|4[04]|79(?:[1-6]|7[19])|80(?:[2-4]|6[0-589])","11|2[02]|33|4[04]|79(?:[124-6]|3(?:[02-9]|1[0-24-9])|7(?:1|9[1-6]))|80(?:[2-4]|6[0-589])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:2[0-249]|3[0-25]|4[145]|[68]|7[1257])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|5[12]|[78]1)|6(?:12|[2-4]1|5[17]|6[13]|80)|7(?:12|3[134]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67)[14]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|674|7(?:(?:3[34]|5[15])[2-6]|61[346]|88[0-8])|8(?:70[2-6]|84[235-7]|91[3-7])|(?:1(?:29|60|8[06])|261|552|6(?:12|[2-47]1|5[17]|6[13]|80)|7(?:12|31)|8(?:16|2[014]|3[126]|6[136]|7[78]|83))[2-7]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|6(?:12(?:[2-6]|7[0-8])|74[2-7])|7(?:3171|5[15][2-6]|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|8(?:16|2[014]|3[126]|6[136]|7[78]|83)(?:[2-6]|7[19])|(?:1(?:29|60|8[06])|261|552|6(?:[2-4]1|5[17]|6[13]|7(?:1|4[0189])|80)|7(?:12|88[01]))[2-7]"],"0$1",1],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2[2457-9]|3[2-5]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1[013-9]|3[129]|5[29]|6[02-5]|70)|807","1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2(?:[2457]|84|95)|3(?:[2-4]|55)|4[235-7]|5[2-689]|6[24578]|7(?:[23569]|8[0-57-9])|8[1-6])|7(?:1(?:[013-8]|9[6-9])|3(?:17|2[0-49]|9[2-57])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4|5[0-367])|70[13-7])|807[19]","1(?:[2-479]|5(?:[0236-9]|5[013-9]))|[2-5]|6(?:2(?:84|95)|355|8(?:28[235-7]|3))|73179|807(?:1|9[1-3])|(?:1552|6(?:(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578])\\d|7(?:[23569]\\d|8[0-57-9])|8(?:[14-6]\\d|2[0-79]))|7(?:1(?:[013-8]\\d|9[6-9])|3(?:2[0-49]|9[2-57])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4\\d|5[0-367])|70[13-7]))[2-7]"],"0$1",1],["(\\d{5})(\\d{5})","$1 $2",["16|[6-9]"],"0$1",1],["(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["18[06]","18[06]0"],0,1],["(\\d{4})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["18"],0,1]],"0",0,0,0,0,0,[0,["(?:6(?:1279|828[01489])|7(?:887[02-9]|9(?:313|79[07-9]))|8(?:079[04-9]|(?:84|91)7[02-8]))\\d{5}|(?:160[01]|6(?:(?:12|[2-4]1|5[17]|6[13]|80)[0189]|7(?:1[0189]|86))|7(?:1(?:2[0189]|9[0-5])|3(?:2[5-8]|[34][017-9]|9[016-9])|5(?:[15][017-9]|2[04-9]|9[7-9])|6(?:0[0-47]|1[0-257-9]|2[0-4]|3[19]|5[4589])|70[0289]|88[089]|97[02-8])|8(?:0(?:6[67]|7[02-8])|70[017-9]|84[01489]|91[0-289]))\\d{6}|(?:731|8(?:16|2[014]|3[126]|6[136]|7[78]|83))(?:[0189]\\d|7[02-8])\\d{5}|(?:6(?:(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578])\\d|7(?:[23569]\\d|4[0189]|8[0-57-9])|8(?:[14-6]\\d|2[0-79]))|7(?:1(?:[013-8]\\d|9[6-9])|3(?:2[0-49]|9[2-5])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4\\d|5[0-367])|70[13-7]|881))[0189]\\d{5}|(?:6(?:[09]\\d|1[04679]|2[03689]|3[05-9]|4[0489]|50|6[069]|7[07]|8[7-9])|7(?:[024]\\d|3[05-8]|5[0346-8]|6[6-9]|7[1-9]|8[0-79]|9[089])|8(?:0[01589]|1[0-57-9]|2[235-9]|3[03-57-9]|[45]\\d|6[02457-9]|7[1-69]|8[0-25-9]|9[02-9])|9\\d\\d)\\d{7}",[10]]]],IO:["246","00","3\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["3"]]],0,0,0,0,0,0,[0,["38\\d{5}"]]],IQ:["964","00","(?:1|7\\d\\d)\\d{7}|[2-6]\\d{7,8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-6]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,[0,["7[3-9]\\d{8}",[10]]]],IR:["98","00","[1-9]\\d{9}|(?:[1-8]\\d\\d|9)\\d{3,4}",[4,5,6,7,10],[["(\\d{4,5})","$1",["96"],"0$1"],["(\\d{2})(\\d{4,5})","$1 $2",["(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])[12689]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[1-8]"],"0$1"]],"0",0,0,0,0,0,[0,["9(?:(?:0[0-5]|[13]\\d|2[0-3])\\d\\d|9(?:[0-46]\\d\\d|5(?:10|5\\d)|8(?:[12]\\d|3[0-2]|88)|9(?:[01359]\\d|21|69|77|8[7-9])))\\d{5}",[10]]]],IS:["354","00|1(?:0(?:01|[12]0)|100)","(?:38\\d|[4-9])\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["[4-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["3"]]],0,0,0,0,0,0,[0,["(?:38[589]\\d\\d|6(?:1[1-8]|2[0-6]|3[026-9]|4[014679]|5[0159]|6[0-69]|70|8[06-8]|9\\d)|7(?:5[057]|[6-9]\\d)|8(?:2[0-59]|[3-69]\\d|8[238]))\\d{4}"]],"00"],IT:["39","00","0\\d{5,11}|1\\d{8,10}|3(?:[0-8]\\d{7,10}|9\\d{7,8})|(?:43|55|70)\\d{8}|8\\d{5}(?:\\d{2,4})?",[6,7,8,9,10,11,12],[["(\\d{2})(\\d{4,6})","$1 $2",["0[26]"]],["(\\d{3})(\\d{3,6})","$1 $2",["0[13-57-9][0159]|8(?:03|4[17]|9[2-5])","0[13-57-9][0159]|8(?:03|4[17]|9(?:2|3[04]|[45][0-4]))"]],["(\\d{4})(\\d{2,6})","$1 $2",["0(?:[13-579][2-46-8]|8[236-8])"]],["(\\d{4})(\\d{4})","$1 $2",["894"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[26]|5"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["1(?:44|[679])|[378]|43"]],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[13-57-9][0159]|14"]],["(\\d{2})(\\d{4})(\\d{5})","$1 $2 $3",["0[26]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[03]"]]],0,0,0,0,0,0,[0,["3[2-9]\\d{7,8}|(?:31|43)\\d{8}",[9,10]]]],JE:["44","00","1534\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([0-24-8]\\d{5})$|0|180020","1534$1",0,0,[0,["7(?:(?:(?:50|82)9|937)\\d|7(?:00[378]|97\\d))\\d{5}"]]],JM:["1","011","(?:[58]\\d\\d|658|900)\\d{7}",[10],0,"1",0,0,0,0,"658|876",[0,["(?:6582(?:[0-4]\\d|95)|876(?:2(?:0[1-9]|[13-9]\\d|2[013-9])|[348]\\d\\d|5(?:0[1-9]|[1-9]\\d)|6(?:4[89]|6[
167])|7(?:0[07]|7\\d|8[1-47-9]|9[0-36-9])|9(?:[01]9|9[0579])))\\d{4}"]]],JO:["962","00","(?:(?:[2689]|7\\d)\\d|32|427|53)\\d{6}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2356]|87"],"(0$1)"],["(\\d{3})(\\d{5,6})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["70"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[47]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:427|7(?:11|[29]\\d|[78][0-25-9]))\\d{6}",[9]]]],JP:["81","010","00[1-9]\\d{6,14}|[25-9]\\d{9}|(?:00|[1-9]\\d\\d)\\d{6}",[8,9,10,11,12,13,14,15,16,17],[["(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1"],["(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|499|5(?:76|97)|746|8(?:3[89]|47|51)|9(?:80|9[16])","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:76|97)9|7468|8(?:3(?:8[7-9]|96)|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:769|979[2-69])|7468|8(?:3(?:8[7-9]|96[2457-9])|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["3|4(?:2[09]|7[01])|6[1-9]","3|4(?:2(?:0|9[02-69])|7(?:0[019]|1))|6[1-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1(?:1|5[45]|77|88|9[69])|2(?:2[1-37]|3[0-269]|4[59]|5|6[24]|7[1-358]|8[1369]|9[0-38])|4(?:[28][1-9]|3[0-57]|[45]|6[248]|7[2-579]|9[29])|5(?:2|3[0459]|4[0-369]|5[29]|8[02389]|9[0-389])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9[2-6])|8(?:2[124589]|3[26-9]|49|51|6|7[0-468]|8[68]|9[019])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9[1-489])","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2(?:[127]|3[014-9])|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9[19])|62|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|8[1-9]|9[29])|5(?:2|3(?:[045]|9[0-8])|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0-2469])|3(?:[29]|60)|49|51|6(?:[0-24]|36|5[0-3589]|7[23]|9[01459])|7[0-468]|8[68])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3[34]|4[0178]))|(?:264|837)[016-9]|2(?:57|93)[015-9]|(?:25[0468]|422|838)[01]|(?:47[59]|59[89]|8(?:6[68]|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3(?:[045]|9(?:[0-58]|6[4-9]|7[0-35689]))|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0169])|3(?:[29]|60|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[2-57-9]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|7(?:2[2-468]|3[78])|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:8294|96)[1-3]|2(?:57|93)[015-9]|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|8292|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]"],"0$1"],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["[14]|[289][2-9]|5[3-9]|7[2-4679]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[25-9]"],"0$1"]],"0",0,"(000[2569]\\d{4,6})$|(?:(?:003768)0?)|0","$1",0,0,[0,["[6-9]0[1-9]\\d{7}",[10]]]],KE:["254","000","(?:[17]\\d\\d|900)\\d{6}|(?:2|80)0\\d{6,7}|[4-6]\\d{6,8}",[7,8,9,10],[["(\\d{2})(\\d{5,7})","$1 $2",["[24-6]"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[17]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:1(?:0[0-8]|[18]\\d|2[014]|30|4[0-5])|7\\d\\d)\\d{6}",[9]]]],KG:["996","00","8\\d{9}|[235-9]\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["3(?:1[346]|[24-79])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-79]|88"],"0$1"],["(\\d{3})(\\d{3})(\\d)(\\d{2,3})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[0,["312(?:58\\d|973)\\d{3}|(?:2(?:0[0-35]|2\\d)|5[0-24-7]\\d|600|7(?:[07]\\d|55)|88[08]|9(?:12|9[05-9]))\\d{6}",[9]]]],KH:["855","00[14-9]","1\\d{9}|[1-9]\\d{7,8}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0",0,0,0,0,0,[0,["(?:(?:1[28]|3[18]|9[67])\\d|6[016-9]|7(?:[07-9]|[16]\\d)|8
1(?:[013-79]|8\\d))\\d{6}|(?:1\\d|9[0-57-9])\\d{6}|(?:2[3-6]|3[2-6]|4[2-4]|[5-7][2-5])48\\d{5}",[8,9]]]],KI:["686","00","(?:[37]\\d|6[0-79])\\d{6}|(?:[2-48]\\d|50)\\d{3}",[5,8],0,"0",0,0,0,0,0,[0,["(?:6200[01]|7(?:310[1-9]|5(?:02[03-9]|12[0-47-9]|22[0-7]|[34](?:0[1-9]|8[02-9])|50[1-9])))\\d{3}|(?:63\\d\\d|7(?:(?:[0146-9]\\d|2[0-689])\\d|3(?:[02-9]\\d|1[1-9])|5(?:[0-2][013-9]|[34][1-79]|5[1-9]|[6-9]\\d)))\\d{4}",[8]]]],KM:["269","00","[3478]\\d{6}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[3478]"]]],0,0,0,0,0,0,[0,["[34]\\d{6}"]]],KN:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","869$1",0,"869",[0,["869(?:48[89]|55[6-8]|66\\d|76[02-7])\\d{4}"]]],KP:["850","00|99","85\\d{6}|(?:19\\d|[2-7])\\d{7}",[8,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"]],"0",0,0,0,0,0,[0,["19[1-3]\\d{7}",[10]]]],KR:["82","00(?:[125689]|3(?:[46]5|91)|7(?:00|27|3|55|6[126]))","00[1-9]\\d{8,11}|(?:[12]|5\\d{3})\\d{7}|[13-6]\\d{9}|(?:[1-6]\\d|80)\\d{7}|[3-6]\\d{4,5}|(?:00|7)0\\d{8}",[5,6,8,9,10,11,12,13,14],[["(\\d{2})(\\d{3,4})","$1-$2",["(?:3[1-3]|[46][1-4]|5[1-5])1"],"0$1"],["(\\d{4})(\\d{4})","$1-$2",["1"]],["(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[36]0|8"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["[1346]|5[1-5]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{2})(\\d{5})(\\d{4})","$1-$2-$3",["5"],"0$1"]],"0",0,"0(8(?:[1-46-8]|5\\d\\d))?",0,0,0,[0,["1(?:05(?:[0-8]\\d|9[0-6])|22[13]\\d)\\d{4,5}|1(?:0[0-46-9]|[16-9]\\d|2[013-9])\\d{6,7}",[9,10]]]],KW:["965","00","18\\d{5}|(?:[2569]\\d|41)\\d{6}",[7,8],[["(\\d{4})(\\d{3,4})","$1 $2",["[169]|2(?:[235]|4[1-35-9])|52"]],["(\\d{3})(\\d{5})","$1 $2",["[245]"]]],0,0,0,0,0,0,[0,["(?:41\\d\\d|5(?:(?:[05]\\d|1[0-7]|6[56])\\d|2(?:22|5[25])|7(?:55|77)|88[58])|6(?:(?:0[034679]|5[015-9]|6\\d)\\d|1(?:00|11|6[16])|2[26]2|3[36]3|4[46]4|7(?:0[013-9]|[67]\\d)|8[68]8|9(?:[069]\\d|3[039]))|9(?:(?:[04679]\\d|8[057-9])\\d|1(?:00|1[01]|99)|2(?:00|2\\d)|3(?:00|3[03])|5(?:00|5\\d)))\\d{4}",[8]]]],KY:["1","011","(?:345|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","345$1",0,"345",[0,["345(?:32[1-9]|4(?:1[2-6]|2[0-4])|5(?:1[67]|2[5-79]|4[6-9]|50|76)|649|82[56]|9(?:1[679]|2[2-9]|3[06-9]|90))\\d{4}"]]],KZ:["7","810","8\\d{13}|[78]\\d{9}",[10,14],0,"8",0,0,0,0,"7",[0,["7(?:0[0-25-8]|47|6[0-4]|7[15-8]|85)\\d{7}",[10]]],"8~10"],LA:["856","00","[23]\\d{9}|3\\d{8}|(?:[235-8]\\d|41)\\d{6}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2[13]|3[14]|[4-8]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["3"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:20(?:[23579]\\d|8[78])|30[24]\\d)\\d{6}|30\\d{7}",[9,10]]]],LB:["961","00","[27-9]\\d{7}|[13-9]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[13-69]|7(?:[2-57]|62|8[0-6]|9[04-9])|8[02-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27-9]"]]],"0",0,0,0,0,0,[0,["(?:(?:3|81)\\d|7(?:[01]\\d|6[013-9]|8[7-9]|9[0-4]))\\d{5}"]]],LC:["1","011","(?:[58]\\d\\d|758|900)\\d{7}",[10],0,"1",0,"([2-8]\\d{6})$|1","758$1",0,"758",[0,["758(?:28[4-7]|384|4(?:6[01]|8[4-9])|5(?:1[89]|20|84)|7(?:1[2-9]|2\\d|3[0-3])|812)\\d{4}"]]],LI:["423","00","[68]\\d{8}|(?:[2378]\\d|90)\\d{5}",[7,9],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2379]|8(?:0[09]|7)","[2379]|8(?:0(?:02|9)|7)"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["69"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]],"0",0,"(1001)|0",0,0,0,[0,["(?:6(?:(?:4[5-9]|5\\d)\\d|6(?:[024-68]\\d|1[01]|3[7-9]|7[02]))\\d|7(?:[37-9]\\d|42|56))\\d{4}"]]],LK:["94","00","[1-9]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[1-689]"],"0$1"]],"0",0,0,0,0,0,[0,["7(?:[0-25-8]\\d|4[0-4])\\d{6}"]]],LR:["231","00","(?:[2457]\\d|33|88)\\d{7}|(?:2\\d|[4-6])\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["4[67]|[56]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4}
1)","$1 $2 $3",["[2-578]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:(?:(?:22|33)0|555|7(?:6[01]|7\\d)|88\\d)\\d|4(?:240|[67]))\\d{5}|[56]\\d{6}",[7,9]]]],LS:["266","00","(?:[256]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2568]"]]],0,0,0,0,0,0,[0,["[56]\\d{7}"]]],LT:["370","00","(?:[3469]\\d|52|[78]0)\\d{6}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["52[0-7]"],"(0-$1)",1],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"0 $1",1],["(\\d{2})(\\d{6})","$1 $2",["37|4(?:[15]|6[1-8])"],"(0-$1)",1],["(\\d{3})(\\d{5})","$1 $2",["[3-6]"],"(0-$1)",1]],"0",0,"[08]",0,0,0,[0,["6\\d{7}"]]],LU:["352","00","35[013-9]\\d{4,8}|6\\d{8}|35\\d{2,4}|(?:[2457-9]\\d|3[0-46-9])\\d{2,9}",[4,5,6,7,8,9,10,11],[["(\\d{2})(\\d{3})","$1 $2",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["20[2-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4",["20"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,5})","$1 $2 $3 $4",["[3-57]|8[13-9]|9(?:0[89]|[2-579])|(?:2|80)[2-9]"]],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["80[01]|90[015]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["20"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4 $5",["20"]]],0,0,"(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)",0,0,0,[0,["6(?:[26][18]|5[1568]|7[189]|81|9[128])\\d{6}",[9]]]],LV:["371","00","(?:[268]\\d|78|90)\\d{6}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2679]|8[01]"]]],0,0,0,0,0,0,[0,["2333[0-8]\\d{3}|2(?:[0-24-9]\\d\\d|3(?:0[07]|[14-9]\\d|2[02-9]|3[0-24-9]))\\d{4}"]]],LY:["218","00","[2-9]\\d{8}",[9],[["(\\d{2})(\\d{7})","$1-$2",["[2-9]"],"0$1"]],"0",0,0,0,0,0,[0,["9[1-6]\\d{7}"]]],MA:["212","00","[5-8]\\d{8}",[9],[["(\\d{4})(\\d{5})","$1-$2",["892"],"0$1"],["(\\d{2})(\\d{7})","$1-$2",["8(?:0[0-7]|9)"],"0$1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[5-8]"],"0$1"]],"0",0,0,0,0,"[5-8]",[0,["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[016-8]\\d|2[0-8]|3[01]|5[0-5]))\\d{6}"]]],MC:["377","00","(?:[3489]|[67]\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["4"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[389]"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[67]"],"0$1"]],"0",0,0,0,0,0,[0,["4(?:[46]\\d|5[1-9])\\d{5}|(?:3|[67]\\d)\\d{7}"]]],MD:["373","00","(?:[235-7]\\d|[89]0)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["22|3"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[25-7]"],"0$1"]],"0",0,0,0,0,0,[0,["562\\d{5}|(?:6\\d|7[16-9])\\d{6}"]]],ME:["382","00","(?:20|[3-79]\\d)\\d{6}|80\\d{6,7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"0$1"]],"0",0,0,0,0,0,[0,["6(?:[07-9]\\d|3[024]|6[0-25])\\d{5}",[8]]]],MF:["590","00","7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[0,["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"]]],MG:["261","00","[23]\\d{8}",[9],[["(\\d{2})(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,"([24-9]\\d{6})$|0","20$1",0,0,[0,["3[2-9]\\d{7}"]]],MH:["692","011","329\\d{4}|(?:[256]\\d|45)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1-$2",["[2-6]"]]],"1",0,0,0,0,0,[0,["(?:(?:23|54)5|329|45[35-8])\\d{4}"]]],MK:["389","00","[2-578]\\d{7}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2|34[47]|4(?:[37]7|5[47]|64)"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],"0",0,0,0,0,0,[0,["7(?:3555|(?:474|9[019]7)7)\\d{3}|7(?:[0-25-8]\\d\\d|3(?:[1-478]\\d|6[01])|4(?:2\\d|60|7[01578])|9(?:[2-4]\\d|5[01]|7[015]))\\d{4}"]]],ML:["223","00","[24-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-9]"]]],0,0,0,0,0,0,[0,["2(?:0(?:01|79)|17\\d)\\d{4}|(?:5[0-3]|[679]\\d|8[2-59])\\d{6}"]]],MM:["95","00","1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}",[6,7,8,9,10],[["(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["4(?:[2-46]|5[3-5])|5|6(?:[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-5]|(?:60|86)[23]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|452|678|86","[12]|452|6788|86"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[4-7]|8[1-35]"],"0$1"],["(\\d)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92"],"0$1"],["(\\d)(\\d{5})(\\d{4})","$1 $2 $3",["9"],"0$1"]],"0",0,0,0,0,0,[0,["(?:17[01]|9(?:2(?:[0-4]|[56]\\d\\d)|(?:3(?:[0-36]|4\\d)|(?:6\\d|8[89]|9[4-8])\\d|7(?:3|40|[5-9]\\d))\\d|4(?:(?:[0245]\\d|[1379])\\d|88)|5[0-6])\\d)\\d{4}|9[69]1\\d{6}|9(?:[68]\\d|9[089])\\d{5}",[7,8,9,10]]]],MN:["976","001","[12]\\d{7,9}|[5-9]\\d{7}",[8,9,10],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["11|2[16]"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[5-9]"]],["(\\d{3})(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["[12](?:27|3[2-8]|4[2-68]|5[1-4689])","[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["[12]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:87[01]|92[0139])\\d{5}|(?:5[05]|6[069]|7[28]|8[0135689]|9[013-9])\\d{6}",[8]]]],MO:["853","00","0800\\d{3}|(?:28|[68]\\d)\\d{6}",[7,8],[["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{4})(\\d{4})","$1 $2",["[268]"]]],0,0,0,0,0,0,[0,["6800[0-79]\\d{3}|6(?:[235]\\d\\d|6(?:0[0-5]|[1-9]\\d)|8(?:0[1-9]|[14-8]\\d|2[5-9]|[39][0-4]))\\d{4}",[8]]]],MP:["1","011","[58]\\d{9}|(?:67|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","670$1",0,"670",[0,["670(?:2(?:3[3-7]|56|8[4-8])|32[1-38]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)\\d{4}"]]],MQ:["596","00","7091\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|8(?:0[6-9]|[36])"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[0,["(?:69[67]\\d\\d|7091[0-3])\\d{4}"]]],MR:["222","00","(?:[2-4]\\d\\d|800)\\d{5}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-48]"]]],0,0,0,0,0,0,[0,["[2-4][0-46-9]\\d{6}"]]],MS:["1","011","(?:[58]\\d\\d|664|900)\\d{7}",[10],0,"1",0,"([34]\\d{6})$|1","664$1",0,"664",[0,["664(?:3(?:49|9[1-6])|49[2-6])\\d{4}"]]],MT:["356","00","3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2357-9]"]]],0,0,0,0,0,0,[0,["(?:7(?:210|[79]\\d\\d)|9(?:[29]\\d\\d|69[67]|8(?:1[1-3]|89|97)))\\d{4}"]]],MU:["230","0(?:0|[24-7]0|3[03])","(?:[57]|8\\d\\d)\\d{7}|[2-468]\\d{6}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[2-46]|8[013]"]],["(\\d{4})(\\d{4})","$1 $2",["[57]"]],["(\\d{5})(\\d{5})","$1 $2",["8"]]],0,0,0,0,0,0,[0,["5(?:4(?:2[1-389]|7[1-9])|87[15-8])\\d{4}|(?:5(?:2[5-9]|4[3-689]|[57]\\d|8[0-689]|9[0-8])|7(?:0[0-7]|3[013]))\\d{5}",[8]]],"020"],MV:["960","0(?:0|19)","(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}",[7,10],[["(\\d{3})(\\d{4})","$1-$2",["[34679]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,[0,["(?:46[46]|[79]\\d\\d)\\d{4}",[7]]],"00"],MW:["265","00","(?:[1289]\\d|31|77)\\d{7}|1\\d{6}",[7,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[2-9]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-37-9]"],"0$1"]],"0",0,0,0,0,0,[0,["111\\d{6}|(?:2[12]|31|77|[89][89])\\d{7}",[9]]]],MX:["52","0[09]","[2-9]\\d{9}",[10],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|5[56]|81"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2-9]"]]],0,0,0,0,0,0,[0,["(?:2(?:2\\d|3[1-35-8]|4[13-9]|7[1-689]|8[1-578]|9[467])|3(?:1[1-79]|[2458][1-9]|3\\d|7[1-8]|9[1-5])|4(?:1[1-57-9]|[267][1-9]|3[1-8]|[45]\\d|8[1-35-9]|9[2-689])|5(?:[56]\\d|88|9[1-79])|6(?:1[2-68]|[2-4][1-9]|5[1-36-9]|6[0-57-9]|7[1-7]|8[67]|9[4-8])|7(?:[1346][1-9]|[27]\\d|5[13-9]|8[1-69]|9[17])|8(?:1\\d|2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[0-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|[69]\\d|7[12]|8[1-8]))\\d{7}"]],"00"],MY:["60","00","1\\d{8,9}|(?:3\\d|[4-9])\\d{7}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["[4-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1-$2 $3",["1(?:[02469]|[378][1-9]|53)|8","1(?:[02469]|[37][1-9]|53|8(?:[1-46-9]|5[7-9]))|8"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2 $3",["3"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3-$4",["1(?:[367]|80)"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2 $3",["15"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2 $3",["1"],"0$1"]],"0",0,0,0,0,0,[0,["1(?:(?:1888[689]|4400|8(?:47|8[27])[0-4])\\d{4}|9\\d{7,8})|1(?:0(?:[23568]\\d|4[0-6]|7[016-9]|9[0-8])|1(?:[1-5]\\d\\d|6(?:0[5-9]|[1-9]\\d)|7(?:[0-4]\\d|5[0-79]|6[02-4]|8[02-5]))|(?:[26]\\d|[37][1-9]|4[235-9])\\d|5(?:31|9\\d\\d)|8(?:1[23]|[23
16]\\d|4[06]|5(?:46|[7-9])|7[016-9]|8[01]|9[0-8]))\\d{5}",[9,10]]]],MZ:["258","00","(?:2|8\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2|8[2-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]],0,0,0,0,0,0,[0,["8[2-9]\\d{7}",[9]]]],NA:["264","00","[68]\\d{7,8}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["87"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0",0,0,0,0,0,[0,["(?:60|8[1245])\\d{7}",[9]]]],NC:["687","00","(?:050|[2-57-9]\\d\\d)\\d{3}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1.$2.$3",["[02-57-9]"]]],0,0,0,0,0,0,[0,["(?:[579]\\d|8[0-79])\\d{4}"]]],NE:["227","00","[027-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["08"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[089]|2[013]|7[0467]"]]],0,0,0,0,0,0,[0,["(?:23|7[0467]|[89]\\d)\\d{6}"]]],NF:["672","00","[13]\\d{5}",[6],[["(\\d{2})(\\d{4})","$1 $2",["1[0-3]"]],["(\\d)(\\d{5})","$1 $2",["[13]"]]],0,0,"([0-258]\\d{4})$","3$1",0,0,[0,["(?:14|3[58])\\d{4}"]]],NG:["234","009","(?:20|9\\d)\\d{8}|[78]\\d{9,13}",[10,11,12,13,14],[["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["20[129]"],"0$1"],["(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]"],"0$1"],["(\\d{3})(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:702[0-24-9]|819[01])\\d{6}|(?:7(?:0[13-9]|[12]\\d)|8(?:0[1-9]|1[0-8])|9(?:0[1-9]|1[1-6]))\\d{7}",[10]]]],NI:["505","00","(?:1800|[25-8]\\d{3})\\d{4}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[125-8]"]]],0,0,0,0,0,0,[0,["(?:5(?:5[0-7]|[78]\\d)|6(?:20|3[035]|4[045]|5[05]|77|8[1-9]|9[059])|(?:7[5-8]|8\\d)\\d)\\d{5}"]]],NL:["31","00","(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}",[5,6,7,8,9,10,11],[["(\\d{3})(\\d{4,7})","$1 $2",["[89]0"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["66"],"0$1"],["(\\d)(\\d{8})","$1 $2",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-578]|91"],"0$1"],["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3",["9"],"0$1"]],"0",0,0,0,0,0,[0,["(?:6[1-58]|970\\d)\\d{7}",[9,11]]]],NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]",[0,["45(?:[0-24-9]\\d|3[0-57-9])\\d{4}|(?:4[016-8]|9\\d)\\d{6}",[8]]]],NP:["977","00","(?:1\\d|9)\\d{9}|[1-9]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],["(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-59]|[67][2-6])"],"0$1"],["(\\d{3})(\\d{7})","$1-$2",["9"]]],"0",0,0,0,0,0,[0,["9(?:00|6[0-3]|7[0-24-6]|8[0-24-68])\\d{7}",[10]]]],NR:["674","00","(?:222|444|(?:55|8\\d)\\d|666|777|999)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[24-9]"]]],0,0,0,0,0,0,[0,["(?:222|55[3-9]|666|777|8\\d\\d|999)\\d{4}"]]],NU:["683","00","(?:[4-7]|888\\d)\\d{3}",[4,7],[["(\\d{3})(\\d{4})","$1 $2",["8"]]],0,0,0,0,0,0,[0,["(?:[56]|888[1-9])\\d{3}"]]],NZ:["64","0(?:0|161)","[1289]\\d{9}|50\\d{5}(?:\\d{2,3})?|[27-9]\\d{7,8}|(?:[34]\\d|6[0-35-9])\\d{6}|8\\d{4,6}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,8})","$1 $2",["8[1-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["50[036-8]|8|90","50(?:[0367]|88)|8|90"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["24|[346]|7[2-57-9]|9[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:10|74)|[589]"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["1|2[028]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,5})","$1 $2 $3",["2(?:[169]|7[0-35-9])|7"],"0$1"]],"0",0,0,0,0,0,[0,["2(?:[0-27-9]\\d|6)\\d{6,7}|2(?:1\\d|75)\\d{5}",[8,9,10]]],"00"],OM:["968","00","(?:1505|[279]\\d{3}|500)\\d{4}|800\\d{5,6}",[7,8,9],[["(\\d{3})(\\d{4,6})","$1 $2",["[58]"]],["(\\d{2})(\\d{6})","$1 $2",["2"]],["(\\d{4})(\\d{4})","$1 $2",["[179]"]]],0,0,0,0,0,0,[0,["(?:1505|90[1-9]\\d)\\d{4}|(?:7[124-9]|9[1-9])\\d{6}",[8]]]],PA:["507","00","(?:00800|8\\d{3})\\d{6}|[68]\\d{7}|[1-57-9]\\d{6}",[7,8,10,11],[["(\\d{3})(\\d{4})","$1-$2",["[1-57-9]"]],["(\\d{4})(\\d{4})","$1-$2",["[68]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]],0,0,0,0,0,0,[0,["(?:1[16]1|21[89]|6\\d{3}|8(?:1[01]|7[23]))\\d{4}",[7,8]]]],PE:["51","00|19(?:1[124]|77|90)00","(?:[14-8]|9\\d)\\d{7}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["80"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["1"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[4-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"]]],"0",0,0,0,0,0,[0,["9\\d{8}",[9]]],"00"," Anexo "],PF:["689","00","4\\d{5}
1(?:\\d{2})?|8\\d{7,8}",[6,8,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["44"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4|8[7-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]],0,0,0,0,0,0,[0,["8[7-9]\\d{6}",[8]]]],PG:["675","00|140[1-3]","(?:180|[78]\\d{3})\\d{4}|(?:[2-589]\\d|64)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["18|[2-69]|85[02-46-9]"]],["(\\d{4})(\\d{4})","$1 $2",["[78]"]]],0,0,0,0,0,0,[0,["(?:7\\d|8[1-58])\\d{6}",[8]]],"00"],PH:["63","00","(?:[2-7]|9\\d)\\d{8}|2\\d{5}|(?:1800|8)\\d{7,9}",[6,8,9,10,11,12,13],[["(\\d)(\\d{5})","$1 $2",["2"],"(0$1)"],["(\\d{4})(\\d{4,6})","$1 $2",["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|544|88[245]|(?:52|64|86)2","3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"],"(0$1)"],["(\\d{5})(\\d{4})","$1 $2",["346|4(?:27|9[35])|883","3469|4(?:279|9(?:30|56))|8834"],"(0$1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|8[2-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{4})(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1"]]],"0",0,0,0,0,0,[0,["(?:8(?:1[37]|9[5-8])|9(?:0[5-9]|1[0-24-9]|[235-7]\\d|4[2-9]|8[135-9]|9[1-9]))\\d{7}",[10]]]],PK:["92","00","122\\d{6}|[24-8]\\d{10,11}|9(?:[013-9]\\d{8,10}|2(?:[01]\\d\\d|2(?:[06-8]\\d|1[01]))\\d{7})|(?:[2-8]\\d{3}|92(?:[0-7]\\d|8[1-9]))\\d{6}|[24-9]\\d{8}|[89]\\d{7}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,7})","$1 $2 $3",["[89]0"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["1"]],["(\\d{3})(\\d{6,7})","$1 $2",["2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8])","9(?:2[3-8]|98)|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:22|3[27-9]|4[2-6]|6[3569]|9[25-7]))[2-9]"],"(0$1)"],["(\\d{2})(\\d{7,8})","$1 $2",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"],"(0$1)"],["(\\d{5})(\\d{5})","$1 $2",["58"],"(0$1)"],["(\\d{3})(\\d{7})","$1 $2",["3"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[24-9]"],"(0$1)"]],"0",0,0,0,0,0,[0,["3(?:[0-247]\\d|3[0-79]|55|64)\\d{7}",[10]]]],PL:["48","00","(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}",[6,7,8,9,10],[["(\\d{5})","$1",["19"]],["(\\d{3})(\\d{3})","$1 $2",["11|20|64"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["30|(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])1","30|(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])19"]],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["64"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["21|39|45|5[0137]|6[0469]|7[02389]|8(?:0[14]|8)"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[2-8]|[2-7]|8[1-79]|9[145]"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["8"]]],0,0,0,0,0,0,[0,["21(?:1[013-5]|2\\d|3[1-9])\\d{5}|(?:45|5[0137]|6[069]|7[2389]|88)\\d{7}",[9]]]],PM:["508","00","[78]\\d{8}|[2-9]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[0,["708(?:4[0-5]|5[0-6])\\d{4}|(?:[236-9]\\d|4[02-489]|5[02-9])\\d{4}"]]],PR:["1","011","(?:[589]\\d\\d|787)\\d{7}",[10],0,"1",0,0,0,0,"787|939",[0,["(?:787|939)[2-9]\\d{6}"]]],PS:["970","00","[2489]2\\d{6}|(?:1\\d|5)\\d{8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2489]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["5"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0",0,0,0,0,0,[0,["5[69]\\d{7}",[9]]]],PT:["351","00","1693\\d{5}|(?:[26-9]\\d|30)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["2[12]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["16|[236-9]"]]],0,0,0,0,0,0,[0,["6(?:[06]92(?:30|9\\d)|[35]92(?:[049]\\d|3[034]))\\d{3}|(?:(?:16|6[0356])93|9(?:[1-36]\\d\\d|480))\\d{5}"]]],PW:["680","01[12]","(?:[24-8]\\d\\d|345|900)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]],0,0,0,0,0,0,[0,["(?:(?:46|83)[0-5]|(?:6[2-4689]|78)0)\\d{4}|(?:45|77|88)\\d{5}"]]],PY:["595","00","[36-8]\\d{5,8}|4\\d{6,8}|59\\d{6}|9\\d{5,10}|(?:2\\d|5[0-8])\\d{6,7}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3,6})","$1 $2",["[2-9]0"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["3[289]|4[246-8]|61|7[1-3]|8[1-36]"],"(0$1)"],["(\\d{3})(\\d{4,5})","$1 $2",["2[279]|3[13-5]|4[359]|5|6(?:[34]|7[1-46-8])|7[46-8]|85"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2[14-68]|3[26-9]|4[1246-8]|6(?:1|75)|7[1-35]|8[1-36]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["87"]],["(\\d{3})(\\d{6})","$1 $2",["9(?:[5-79]|8[1-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["9"]]],"0",0,0,0,0,0,[0,["9(?:51|6[129]|7[1-6]|8[1-7]|9[1-5])\\d{6}",[9]]]],QA:["974","00","800\\d{4}|(?:2|800)\\d{6}|(?:0080|[3-7])\\d{7}",[7,8,9,11],[["(\\d{3})(\\d{4})","$1 $2",["2[136]|8"]],["(\\d{4})(\\d{4})","$1 $2",["[3-7]"]]],0,0,0,0,0,0,[0,["[35-7]\\d{7}",[8]]]],RE:["262","00","709\\d{6}|(?:26|[689]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:69(?:2\\d\\d|3(?:[06][0-6]|1[0-3]|2[0-2]|3[0-39]|4\\d|5[0-5]|7[0-37]|8[0-8]|9[0-479]))|7092[0-3])\\d{4}"]]],RO:["40","00","(?:[236-8]\\d|90)\\d{7}|[23]\\d{5}",[6,9],[["(\\d{3})(\\d{3})","$1 $2",["2[3-6]","2[3-6]\\d9"],"0$1"],["(\\d{2})(\\d{4})","$1 $2",["219|31"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23]1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[236-9]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:630|702)0\\d{5}|(?:6(?:00|2\\d)|7(?:0[013-9]|1[0-3]|[2-7]\\d|8[03-8]|9[0-39]))\\d{6}",[9]]],0," int "],RS:["381","00","38[02-9]\\d{6,9}|6\\d{7,9}|90\\d{4,8}|38\\d{5,6}|(?:7\\d\\d|800)\\d{3,9}|(?:[12]\\d|3[0-79])\\d{5,10}",[6,7,8,9,10,11,12],[["(\\d{3})(\\d{3,9})","$1 $2",["(?:2[389]|39)0|[7-9]"],"0$1"],["(\\d{2})(\\d{5,10})","$1 $2",["[1-36]"],"0$1"]],"0",0,0,0,0,0,[0,["6(?:[0-689]|7\\d)\\d{6,7}",[8,9,10]]]],RU:["7","810","8\\d{13}|[347-9]\\d{9}",[10,14],[["(\\d{4})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-8]|2[1-9])","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:1[23]|[2-9]2))","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:13[03-69]|62[013-9]))|72[1-57-9]2"],"8 ($1)",1],["(\\d{5})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-68]|2[1-9])","7(?:1(?:[06][3-6]|[18]|2[35]|[3-5][3-5])|2(?:[13][3-5]|[24-689]|7[457]))","7(?:1(?:0(?:[356]|4[023])|[18]|2(?:3[013-9]|5)|3[45]|43[013-79]|5(?:3[1-8]|4[1-7]|5)|6(?:3[0-35-9]|[4-6]))|2(?:1(?:3[178]|[45])|[24-689]|3[35]|7[457]))|7(?:14|23)4[0-8]|71(?:33|45)[1-79]"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[349]|8(?:[02-7]|1[1-8])"],"8 ($1)",1],["(\\d{4})(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3 $4",["8"],"8 ($1)"]],"8",0,0,0,0,"[3489]",[0,["9\\d{9}",[10]]],"8~10"],RW:["250","00","(?:06|[27]\\d\\d|[89]00)\\d{6}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"]],"0",0,0,0,0,0,[0,["7[237-9]\\d{7}",[9]]]],SA:["966","00","(?:[15]\\d|800|92)\\d{7}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["9"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]],"0",0,0,0,0,0,[0,["579[0-8]\\d{5}|5(?:[013-689]\\d|7[0-8])\\d{6}",[9]]]],SB:["677","0[01]","[6-9]\\d{6}|[1-6]\\d{4}",[5,7],[["(\\d{2})(\\d{5})","$1 $2",["6[89]|7|8[4-9]|9(?:[1-8]|9[0-8])"]]],0,0,0,0,0,0,[0,["48\\d{3}|(?:(?:6[89]|7[1-9]|8[4-9])\\d|9(?:1[2-9]|2[013-9]|3[0-2]|[46]\\d|5[0-46-9]|7[0-689]|8[0-79]|9[0-8]))\\d{4}"]]],SC:["248","010|0[0-2]","(?:[2489]\\d|64)\\d{5}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[246]|9[57]"]]],0,0,0,0,0,0,[0,["2[125-8]\\d{5}"]],"00"],SD:["249","00","[19]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[19]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:1[0-2]|9[0-3569])\\d{7}"]]],SE:["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10,12],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0",0,0,0,0,0,[0,["7[023689]\\d{7}",[9]]]],SG:["65","0[0-3]\\d","(?:(?:1\\d|8)\\d\\d|7000)\\d{7}|[3689]\\d{7}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["[369]|8(?:0[1-9]|[1-9])"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]],["(\\d{4})(\\d{4})(\\d{3})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]],0,0,0,0,0,0,[0,["80[1-9]\\d{5}|(?:8[1-9]|9[0-8])\\d{6}",[8]]]],SH:["290","00","(?:[256]\\d|8)\\d{3}",[4,5],0,0,0,0,0,0,"[256]",[0,["[56]\\d{4}",[5]]]],SI:["386","00|10(?:22|66|88|99)","[1-7]\\d{7}|8\\d{4,7}|90\\d{4,6}",[5,6,7,8],[["(\\d{2})(\\d{3,6})","$1 $2",["8[09]|9"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["59|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37][01]|4[013]|51|6"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-57]"],"(0$1)"]],"0",0,0,0,0,0,[0,["65(?:[178]\\d|5[56]|6[01])\\d{4}|(?:[37][01]|4[013]|51|6[489])\\d{6}",[8]]],"00"],SJ:["47","00","0\\d{4}|(?:[489]\\d|79)\\d{6}",[5,8],0,0,0,0,0,0,"79",[0,["45(?:[0-24-9]\\d|3[0-57-9])\\d{4}|(?:4[016-8]|9\\d)\\d{6}",[8]]]],SK:["421","00","[2-689]\\d{8}|[2-59]\\d{6}|[2-5]\\d{5}",[6,7,9],[["(\\d)(\\d{2})(\\d{3,4})","$1 $2 $3",["21"],"0$1"],["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["[3-5][1-8]1","[3-5][1-8]1[67]"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[689]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[3-5]"],"0$1"]],"0",0,0,0,0,0,[0,["909[1-9]\\d{5}|9(?:0[1-8]|1[0-24-9]|4[03-57-9]|5\\d)\\d{6}",[9]]]],SL:["232","00","(?:[237-9]\\d|66)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[236-9]"],"(0$1)"]],"0",0,0,0,0,0,[0,["(?:25|3[0-5]|66|7\\d|8[08]|9[09])\\d{6}"]]],SM:["378","00","(?:0549|[5-7]\\d)\\d{6}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"]],["(\\d{4})(\\d{6})","$1 $2",["0"]]],0,0,"([89]\\d{5})$","0549$1",0,0,[0,["6[16]\\d{6}",[8]]]],SN:["221","00","(?:[378]\\d|93)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2}
1)","$1 $2 $3 $4",["[379]"]]],0,0,0,0,0,0,[0,["7(?:[015-8]\\d|21|90)\\d{6}"]]],SO:["252","00","[346-9]\\d{8}|[12679]\\d{7}|[1-5]\\d{6}|[1348]\\d{5}",[6,7,8,9],[["(\\d{2})(\\d{4})","$1 $2",["8[125]"]],["(\\d{6})","$1",["[134]"]],["(\\d)(\\d{6})","$1 $2",["[15]|2[0-79]|3[0-46-8]|4[0-7]"]],["(\\d{2})(\\d{5,7})","$1 $2",["1|28|9[2-9]"]],["(\\d)(\\d{7})","$1 $2",["[267]|904"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[346-9]"]]],"0",0,0,0,0,0,[0,["(?:(?:15|(?:3[59]|4[89]|6\\d|7[0-35-9]|8[08])\\d|9(?:0\\d|[2-9]))\\d|2(?:4\\d|8))\\d{5}|(?:[67]\\d\\d|904)\\d{5}",[7,8,9]]]],SR:["597","00","(?:[2-5]|[6-9]\\d)\\d{5}",[6,7],[["(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3",["56"]],["(\\d{3})(\\d{3})","$1-$2",["[2-5]"]],["(\\d{3})(\\d{4})","$1-$2",["[6-9]"]]],0,0,0,0,0,0,[0,["(?:6[08]|7[1-7]|8[1-9])\\d{5}",[7]]]],SS:["211","00","[19]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[19]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:12|9[1257-9])\\d{7}"]]],ST:["239","00","(?:22|9\\d)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[29]"]]],0,0,0,0,0,0,[0,["900[5-9]\\d{3}|9(?:0[1-9]|[89]\\d)\\d{4}"]]],SV:["503","00","[25-7]\\d{7}|(?:80\\d|900)\\d{4}(?:\\d{4})?",[7,8,11],[["(\\d{3})(\\d{4})","$1 $2",["[89]"]],["(\\d{4})(\\d{4})","$1 $2",["[25-7]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,[0,["[5-7]\\d{7}",[8]]]],SX:["1","011","7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"(5\\d{6})$|1","721$1",0,"721",[0,["7215(?:1[02]|2\\d|5[034679]|8[0-24-8])\\d{4}"]]],SY:["963","00","[1-359]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-4]|5[1-3]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[59]"],"0$1",1]],"0",0,0,0,0,0,[0,["(?:50|9[03-689])\\d{7}",[9]]]],SZ:["268","00","0800\\d{4}|(?:[237]\\d|900)\\d{6}",[8,9],[["(\\d{4})(\\d{4})","$1 $2",["[0237]"]],["(\\d{5})(\\d{4})","$1 $2",["9"]]],0,0,0,0,0,0,[0,["7[5-9]\\d{6}",[8]]]],TA:["290","00","8\\d{3}",[4],0,0,0,0,0,0,"8"],TC:["1","011","(?:[58]\\d\\d|649|900)\\d{7}",[10],0,"1",0,"([2-479]\\d{6})$|1","649$1",0,"649",[0,["649(?:2(?:3[129]|4[1-79])|3\\d\\d|4[34][1-3])\\d{4}"]]],TD:["235","00|16","(?:22|[3689]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[236-9]"]]],0,0,0,0,0,0,[0,["(?:3[01]|[69]\\d|77|8[5-7])\\d{6}"]],"00"],TG:["228","00","[279]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[279]"]]],0,0,0,0,0,0,[0,["(?:7[0-389]|9[0-36-9])\\d{6}"]]],TH:["66","00[1-9]","(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}",[8,9,10,13],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0",0,0,0,0,0,[0,["(?:(?:14|[89]\\d)\\d\\d|6(?:[1-6]\\d\\d|7(?:1[0-8]|2[4-7]|3[1-6])))\\d{5}",[9]]]],TJ:["992","810","(?:[0-57-9]\\d|66)\\d{7}",[9],[["(\\d{6})(\\d)(\\d{2})","$1 $2 $3",["331","3317"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["44[02-479]|[34]7"]],["(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["3(?:[1245]|3[12])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["\\d"]]],0,0,0,0,0,0,[0,["(?:33[03-9]|4(?:1[18]|4[02-479])|81[1-9])\\d{6}|(?:[09]\\d|1[0-27-9]|2[0-27]|3[08]|40|5[05]|66|7[0157-9]|8[07-9])\\d{7}"]],"8~10"],TK:["690","00","[2-47]\\d{3,6}",[4,5,6,7],0,0,0,0,0,0,0,[0,["7[2-4]\\d{2,5}"]]],TL:["670","00","7\\d{7}|(?:[2-47]\\d|[89]0)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[2-489]|70"]],["(\\d{4})(\\d{4})","$1 $2",["7"]]],0,0,0,0,0,0,[0,["7[2-8]\\d{6}",[8]]]],TM:["993","810","[1-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["12"],"(8 $1)"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-5]"],"(8 $1)"],["(\\d{2})(\\d{6})","$1 $2",["[67]"],"8 $1"]],"8",0,0,0,0,0,[0,["(?:6\\d|7[12])\\d{6}"]],"8~10"],TN:["216","00","[2-57-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-57-9]"]]],0,0,0,0,0,0,[0,["3(?:001|[12]40)\\d{4}|(?:(?:[259]\\d|4[0-8])\\d|3(?:1[1-35]|6[0-4]|91))\\d{5}"]]],TO:["676","00","(?:0800|(?:[5-8]\\d\\d|999)\\d)\\d{3}|[2-8]\\d{4}",[5,7],[["(\\d{2})(\\d{3})","$1-$2",["[2-4]|50|6[09]|7[0-24-69]|8[05]"]],["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[5-9]"]]],0,0,0,0,0,0,[0,["(?:5(?:4[0-5]|5[4-6])|6(?:[09]\\d|3[02]|8[15-9])|(?:7\\d|8[46-9])\\d|999)\\d{4}",[7]]]],TR:["90","00","4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",[7,10,12,13],[["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["512|8[01589]|90"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24][1-8]|3[1-9]"],"(0$1)",1],["(\\d{3})(\\d{3})(\\d{6,7})","$1 $2 $3",["80"],"0$1",1]],"0",0,0,0,0,0,[0,["5(?:61(?:011|61\\d)|82[2-4]\\d\\d)\\d{4}|5(?:[03-5]\\d|1[06]|24|6[24]|7[245]|9[46])\\d{7}",[10]]]],TT:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-46-8]\\d{6})$|1","868$1",0,"868",[0,["868(?:(?:2[5-9]|3\\d)\\d|4(?:3[0-6]|[6-9]\\d)|6(?:20|78|8\\d)|7(?:0[1-9]|1[02-9]|[2-9]\\d))\\d{4}"]]],TV:["688","00","(?:2|7\\d\\d|90)\\d{4}",[5,6,7],[["(\\d{2})(\\d{3})","$1 $2",["2"]],["(\\d{2})(\\d{4})","$1 $2",["90"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]],0,0,0,0,0,0,[0,["(?:7[01]\\d|90)\\d{4}",[6,7]]]],TW:["886","0(?:0[25-79]|19)","[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}",[7,8,9,10,11],[["(\\d{2})(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["826"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["83"],"0$1"],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["82"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[25]0|37|49|8[09]"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-478])|7[1-9]","[23568]|4(?:0[2-48]|[1-478])|(?:400|7)[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,5})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,[0,["(?:40001[0-2]|9[0-8]\\d{4})\\d{3}",[9]]],0,"#"],TZ:["255","00[056]","(?:[25-8]\\d|41|90)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["5"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:6[0-35-9]|7\\d)\\d{7}"]]],UA:["380","00","[89]\\d{9}|[3-9]\\d{8}",[9,10],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]","6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6[0135689]|7[4-6])|6(?:[12][3-7]|[459])","3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6(?:[015689]|3[02389])|7[4-6])|6(?:[12][3-7]|[459])"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|89|9[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,[0,["790\\d{6}|(?:39|50|6[36-8]|7[1-357]|9[1-9])\\d{7}",[9]]],"0~0"],UG:["256","00[057]","800\\d{6}|(?:[29]0|[347]\\d)\\d{7}",[9],[["(\\d{4})(\\d{5})","$1 $2",["202","2024","20240"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["20[0-35-7]|4(?:6[45]|[7-9])|[7-9]","20(?:[0135-7]|2[5-9])|4(?:6[45]|[7-9])|[7-9]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[2-4]"],"0$1"]],"0",0,0,0,0,0,[0,["7(?:28|34)0\\d{5}|7(?:[014-8]\\d|2[01467]|3[0167]|9[0-589])\\d{6}"]]],US:["1","011","[2-9]\\d{9}|3\\d{6}",[10],[["(\\d{3})(\\d{4})","$1-$2",["310"],0,1],["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],0,1,"$1-$2-$3"]],"1",0,0,0,0,0,[0,["(?:472[2-47-9]|983[2-57-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[02469]|8[13])|3(?:0[1-57-9]|1[02-9]|2[013-79]|3[0-24679]|4[167]|5[0-3]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-269])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-2478]|4[0378]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-3589]|8[04-69]))[2-9]\\d{6}"]]],UY:["598","0(?:0|1[3-9]\\d)","0004\\d{2,9}|[1249]\\d{7}|2\\d{3,4}|(?:[49]\\d|80)\\d{5}",[4,5,6,7,8,9,10,11,12,13],[["(\\d{4,5})","$1",["21"]],["(\\d{3})(\\d{3,4})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[49]0|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[124]"]],["(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3 $4",["0"]]],"0",0,0,0,0,0,[0,["9[1-9]\\d{6}",[8]]],"00"," int. "],UZ:["998","00","(?:20|33|[5-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-9]"]]],0,0,0,0,0,0,[0,["(?:(?:[25]0|33|8[078]|9[0-57-9])\\d{3}
1|6(?:1(?:2(?:2[01]|98)|35[0-4]|50\\d|61[23]|7(?:[01][017]|4\\d|55|9[5-9]))|2(?:(?:11|7\\d)\\d|2(?:[12]1|9[01379])|5(?:[126]\\d|3[0-4]))|5(?:19[01]|2(?:27|9[26])|(?:30|59|7\\d)\\d)|6(?:2(?:1[5-9]|2[0367]|38|41|52|60)|(?:3[79]|9[0-3])\\d|4(?:56|83)|7(?:[07]\\d|1[017]|3[07]|4[047]|5[057]|67|8[0178]|9[79]))|7(?:2(?:24|3[237]|4[5-9]|7[15-8])|5(?:7[12]|8[0589])|7(?:0\\d|[39][07])|9(?:0\\d|7[079])))|7(?:[07]\\d{3}|2(?:2(?:2[79]|95)|3(?:2[5-9]|6[0-6])|57\\d|7(?:0\\d|1[17]|2[27]|3[37]|44|5[057]|66|88))|3(?:2(?:1[0-6]|21|3[469]|7[159])|(?:33|9[4-6])\\d|5(?:0[0-4]|5[579]|9\\d)|7(?:[0-3579]\\d|4[0467]|6[67]|8[078]))|4(?:2(?:29|5[0257]|6[0-7]|7[1-57])|5(?:1[0-4]|8\\d|9[5-9])|7(?:0\\d|1[024589]|2[0-27]|3[0137]|[46][07]|5[01]|7[5-9]|9[079])|9(?:7[015-9]|[89]\\d))|5(?:112|2(?:0\\d|2[29]|[49]4)|3[1568]\\d|52[6-9]|7(?:0[01578]|1[017]|[23]7|4[047]|[5-7]\\d|8[78]|9[079]))|9(?:22[128]|3(?:2[0-4]|7\\d)|57[02569]|7(?:2[05-9]|3[37]|4\\d|60|7[2579]|87|9[07]))))\\d{4}"]]],VA:["39","00","0\\d{5,10}|3[0-8]\\d{7,10}|55\\d{8}|8\\d{5}(?:\\d{2,4})?|(?:1\\d|39)\\d{7,8}",[6,7,8,9,10,11,12],0,0,0,0,0,0,"06698",[0,["3[1-9]\\d{8}|3[2-9]\\d{7}",[9,10]]]],VC:["1","011","(?:[58]\\d\\d|784|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","784$1",0,"784",[0,["784(?:4(?:3[0-5]|5[45]|89|9[0-8])|5(?:2[6-9]|3[0-4])|720)\\d{4}"]]],VE:["58","00","[68]00\\d{7}|(?:[24]\\d|[59]0)\\d{8}",[10],[["(\\d{3})(\\d{7})","$1-$2",["[24-689]"],"0$1"]],"0",0,0,0,0,0,[0,["4(?:1[24-8]|2[246])\\d{7}"]]],VG:["1","011","(?:284|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-578]\\d{6})$|1","284$1",0,"284",[0,["284(?:245|3(?:0[0-3]|4[0-7]|68|9[34])|4(?:4[0-6]|68|9[69])|5(?:4[0-7]|68|9[69]))\\d{4}"]]],VI:["1","011","[58]\\d{9}|(?:34|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","340$1",0,"340",[0,["340(?:2(?:0\\d|10|2[06-8]|4[49]|77)|3(?:32|44)|4(?:2[23]|44|7[34]|89)|5(?:1[34]|55)|6(?:2[56]|4[23]|77|9[023])|7(?:1[2-57-9]|2[57]|7\\d)|884|998)\\d{4}"]]],VN:["84","00","[12]\\d{9}|[135-9]\\d{8}|[16]\\d{6,7}|7\\d{6}",[7,8,9,10],[["(\\d{4})(\\d{4,6})","$1 $2",["1(?:2[02]|[89])"],0,1],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[26]|6"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[357-9]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["2[48]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["2"],"0$1",1]],"0",0,0,0,0,0,[0,["121[0-3]\\d{5}|(?:160|(?:3\\d|7[06-9])\\d|5(?:[1689]\\d|2[238]|59)|8(?:[1-8]\\d|9[6-9])|9(?:[0-8]\\d|9[013-9]))\\d{6}",[9]]]],VU:["678","00","[57-9]\\d{6}|(?:[238]\\d|48)\\d{3}",[5,7],[["(\\d{3})(\\d{4})","$1 $2",["[57-9]"]]],0,0,0,0,0,0,[0,["(?:[58]\\d|7[0-7])\\d{5}",[7]]]],WF:["681","00","(?:40|72|8\\d{4})\\d{4}|[89]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[47-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]],0,0,0,0,0,0,[0,["(?:72|8[23])\\d{4}",[6]]]],WS:["685","0","(?:[2-6]|8\\d{5})\\d{4}|[78]\\d{6}|[68]\\d{5}",[5,6,7,10],[["(\\d{5})","$1",["[2-5]|6[1-9]"]],["(\\d{3})(\\d{3,7})","$1 $2",["[68]"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]],0,0,0,0,0,0,[0,["(?:7[1-35-8]|8(?:[3-7]|9\\d{3}))\\d{5}",[7,10]]]],XK:["383","00","2\\d{7,8}|3\\d{7,11}|(?:4\\d\\d|[89]00)\\d{5}",[8,9,10,11,12],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2|39"],"0$1"],["(\\d{2})(\\d{7,10})","$1 $2",["3"],"0$1"]],"0",0,0,0,0,0,[0,["4[3-9]\\d{6}",[8]]]],YE:["967","00","(?:1|7\\d)\\d{7}|[1-7]\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-6]|7(?:[24-6]|8[0-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,[0,["7[01378]\\d{7}",[9]]]],YT:["262","00","(?:639\\d|7093)\\d{5}|(?:26|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[0,["(?:639(?:0[0-79]|1[019]|[267]\\d|3[09]|40|5[05-9]|9[04-79])|7093[5-7])\\d{4}"]]],ZA:["27","00","[1-79]\\d{8}|8\\d{4,9}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,4})","$1 $2",["8[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["8[1-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["860"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0",0,0,0,0,0,[0,["(?:1(?:3492[0-25]|4495[0235]|549(?:20|5[01]))|4[34]492[01])\\d{3}|8[1-4]\\d{3,7}|(?:2[27]|47|54)4950\\d{3}|(?:1(?:049[2-4]|9[12]\\d\\d)|(?:50[0-2]|[67]\\d\\d)\\d\\d|8(?:5\\d{3}|7(?:08[67]|158|28[5-9]|310)))\\d{4}|(?:1[6-8]|28|3[2-69]|4[025689]|5[36-8])4920\\d{3}|(?:12|[2-5]1)492\\d{4}",[5,6,7,8,9]]]],ZM:["260","00","800\\d{6}|(?:21|[579]\\d|63)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[28]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[579]"],"0$1"]],"0",0,0,0,0,0,[0,["(?:[59][5-8]|7[5-9])\\d{7}"]]],ZW:["263","00","(?:13|8\\d{4})\\d{5}|[235-8]\\d{8}|[2-689]\\d{6}",[7,9,10],[["(\\d{2})(\\d{3,5})","$1 $2",["1|2(?:0[0-36-9]|29|58)|67[0-46-9]|(?:55|68)[0-69]"],"0$1"],["(\\d{3})(\\d{3,5})","$1 $2",["2(?:0[45]|[27]|48)|37|675|(?:55|68)[78]"],"0$1"],["(\\d)(\\d{3})(\\d{2,4})","$1 $2 $3",["[49]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["80"],"0$1"],["(\\d{4})(\\d{3,5})","$1 $2",["548"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["29[013-9]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[256]|39|8[13-59]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["3"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["8"],"0$1"]],"0",0,0,0,0,0,[0,["7(?:[1278]\\d|3[1-9]|9[01])\\d{6}",[9]]]]},nonGeographic:{800:["800",0,"(?:00|[1-9]\\d)\\d{6}",[8],[["(\\d{4})(\\d{4})","$1 $2",["\\d"]]],0,0,0,0,0,0,[0,0,["(?:00|[1-9]\\d)\\d{6}"]]],808:["808",0,"[1-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[1-9]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,0,["[1-9]\\d{7}"]]],870:["870",0,"7\\d{11}|[235-7]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-7]"]]],0,0,0,0,0,0,[0,["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"],0,0,0,0,0,0,["2\\d{8}",[9]]]],878:["878",0,"10\\d{10}",[12],[["(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3",["1"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["10\\d{10}"]]],881:["881",0,"6\\d{9}|[0-36-9]\\d{8}",[9,10],[["(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[0-37-9]"]],["(\\d)(\\d{3})(\\d{5,6})","$1 $2 $3",["6"]]],0,0,0,0,0,0,[0,["6\\d{9}|[0-36-9]\\d{8}"]]],882:["882",0,"[13]\\d{6}(?:\\d{2,5})?|[19]\\d{7}|(?:[25]\\d\\d|4)\\d{7}(?:\\d{2})?",[7,8,9,10,11,12],[["(\\d{2})(\\d{5})","$1 $2",["16|342"]],["(\\d{2})(\\d{6})","$1 $2",["49"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["1[36]|9"]],["(\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["3[23]"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["16"]],["(\\d{2})(\\d{4})(\\d{4}
1)","$1 $2 $3",["10|23|3(?:[15]|4[57])|4|5[12]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["34"]],["(\\d{2})(\\d{4,5})(\\d{5})","$1 $2 $3",["[1-35]"]]],0,0,0,0,0,0,[0,["342\\d{4}|(?:337|49)\\d{6}|(?:3(?:2|47|7\\d{3})|5(?:0\\d{3}|2[0-2]))\\d{7}",[7,8,9,10,12]],0,0,0,["348[57]\\d{7}",[11]],0,0,["1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15-8]|9[0689])\\d{4}|6\\d{5,10})|(?:345\\d|9[89])\\d{6}|(?:10|2(?:3|85\\d)|3(?:[15]|[69]\\d\\d)|4[15-8]|51)\\d{8}"]]],883:["883",0,"(?:[1-4]\\d|51)\\d{6,10}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,8})","$1 $2 $3",["[14]|2[24-689]|3[02-689]|51[24-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["510"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["21"]],["(\\d{4})(\\d{4})(\\d{4})","$1 $2 $3",["51[13]"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[235]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["(?:2(?:00\\d\\d|10)|(?:370[1-9]|51\\d0)\\d)\\d{7}|51(?:00\\d{5}|[24-9]0\\d{4,7})|(?:1[0-79]|2[24-689]|3[02-689]|4[0-4])0\\d{5,9}"]]],888:["888",0,"\\d{11}",[11],[["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3"]],0,0,0,0,0,0,[0,0,0,0,0,0,["\\d{11}"]]],979:["979",0,"[1359]\\d{8}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[1359]"]]],0,0,0,0,0,0,[0,0,0,["[1359]\\d{8}"]]]}};var a=r(62626);function s(e,t){var r=Array.prototype.slice.call(t);return r.push(n),e.apply(this,r)}(0,r(36116).Z)(n);function o(){return s(a.A,arguments)}var c=r(99856),d=r(45919),l=r(26730),u=r(98379),h=r(32475),f=r(11242),m=r(58646),p=r(57623),g=r(2063),y=r(89348),b=r(74954),w=r(25808),v=r(14202);const k=(0,g.O3)()({name:"smsOtpForm",enableReinitialize:!0,schemaFactory:new g.DF(()=>c.Ik({verificationCode:(0,w.mw)()}))})(function SendSMSOTPForm(e){const[t,r]=(0,i.useState)(30),n=(0,i.useRef)(null),a=(0,i.useRef)(null),s=((0,b.tz)(),(0,i.useCallback)(()=>{r(30),n.current=window.setInterval(()=>{r(e=>e<=0?(n.current&&clearInterval(n.current),0):e-1)},1e3)},[])),o=(0,i.useCallback)(()=>{n.current&&clearInterval(n.current)},[]);return(0,i.useEffect)(()=>(a.current?.focus(),s(),()=>{o()}),[]),(0,v.jsxs)(m.A,{onSubmit:e.handleSubmit,display:"flex",flexDirection:"column",gap:4,children:[(0,v.jsx)(g.D0,{name:"verificationCode",label:"Enter the verification code sent to your phone number",component:f.ks,componentProps:{ref:a,inputMode:"numeric"},required:!0}),e.error?(0,y.c)(e.error)?(0,v.jsx)(p.A,{error:"The verification code is incorrect or expired"}):(0,v.jsx)(p.A,{error:e.error}):null,(0,v.jsxs)(u.A,{gap:1,children:[(0,v.jsx)(d.A.Submit,{isLoading:e.submitting,flexBasis:100,flexGrow:1,tracking:{id:"submit_button"},children:"Submit"}),e.canSkip&&(0,v.jsx)(d.A.Button,{onClick:()=>e.onSkip(),flexBasis:100,flexGrow:1,children:"Skip"})]}),(0,v.jsx)(h.A,{negativeMarginY:1}),(0,v.jsx)(l.A,{onClick:()=>e.resendOtp().then(s),buttonStyle:"link",isDisabled:t>
10,alignSelf:"center",paddingTop:0,reactToError:!0,children:(0,v.jsx)(b.sA,{id:"sms_ot.form.resend_code",defaultMessage:"Didn't receive the code? Click here to resend it {resendCountdown, plural, =0 {} other {({resendCountdown}s)} }",values:{resendCountdown:t}})})]})});var T=r(55279),x=r(73442),S=r(58222),C=r(86490),P=r(45756),A=r(24082),E=r(50194),I=r(49075);function $(){const e=(0,x.A)(),t=(0,T.A)(),r=(0,P.A)(),n=(0,C.A)(A.Ke),{showModal:a}=(0,S.A)(),s=(0,i.useCallback)(e=>r.dispatch((0,E.EK)({consumerId:n.id,phoneNumber:e})),[r,n.id]);return{collectSmsOtpToken:(0,i.useCallback)(async(r,i)=>(s(r),a({title:(0,v.jsx)(b.sA,{id:"shared.sms_helpers.otp_modal.title",defaultMessage:"{showPhoneNumber, select,\n true {Verify {phoneNumber}}\n false {Verify your phone number}\n}",values:{showPhoneNumber:Boolean(i?.showPhoneNumber),phoneNumber:o(r)?.formatNational()}}),closeable:i?.closeable,content:(n,a)=>(0,v.jsx)(k,{onSubmit:async i=>{const a=await e.post(t.generate("api.public.phone_number.verify_otp"),{data:{phoneNumber:r,verificationCode:i.verificationCode}});n(a.phoneNumberVerificationToken)},onSkip:()=>a(new I.A),resendOtp:()=>s(r),canSkip:i?.canSkip}),bodyProps:{padding:4}})),[e,s,a,t])}}},50194(e,t,r){"use strict";r.d(t,{vf:()=>a,gS:()=>n,Gv:()=>o,g:()=>s,EK:()=>c});var i=r(821);const n=(0,i.Iy)({type:"public/consumerProfile/settings/CHANGE_CONSUMER_LOCATION",commandName:"Pr.Domain.Roles.Consumer.Commands.ChangeConsumerLocation"}),a=(0,i.Iy)({type:"public/consumerProfile/settings/CHANGE_CONSUMER_EMAIL_NOTIFICATION_SETTINGS",commandName:"Pr.Domain.Roles.Consumer.Commands.ChangeConsumerEmailNotificationSettings"}),s=(0,i.Iy)({type:"public/consumerProfile/settings/COMPLETE_CONSUMER_REGISTRATION",commandName:"Pr.Domain.Roles.Consumer.Commands.CompleteConsumerRegistration"}),o=(0,i.Iy)({type:"public/consumerProfile/settings/CHANGE_CONSUMER_PHONE_NUMBER",commandName:"Pr.Domain.Roles.Consumer.Commands.ChangeConsumerPhoneNumber"}),c=(0,i.Iy)({type:"public/consumerProfile/settings/SEND_CONSUMER_PHONE_NUMBER_VERIFICATION_CODE",commandName:"Pr.Domain.Roles.Consumer.Commands.SendConsumerPhoneNumberVerificationCode"})},27638(e,t,r){"use strict";r.d(t,{T2:()=>s,VF:()=>a,dF:()=>n,X3:()=>m,ME:()=>c,Td:()=>f,bC:()=>h,lY:()=>o,G9:()=>p,Ll:()=>d,ZG:()=>l,_p:()=>u});var i=r(821);const n=(0,i.Iy)({type:"shared/user/CHANGE_USER_EMAIL_ADDRESS_WITH_TOKEN",commandName:"Pr.Domain.User.Commands.ChangeUserEmailAddressWithToken"}),a=(0,i.Iy)({type:"shared/user/CHANGE_USER_DISPLAY_NAME",commandName:"Pr.Domain.User.Commands.ChangeUserDisplayName"}),s=(0,i.Iy)({type:"public/user/CHANGE_USER_AVATAR",commandName:"Pr.Domain.User.Commands.ChangeUserAvatar"}),o=(0,i.Iy)({type:"public/user/REQUEST_USER_EMAIL_ADDRESS_CHANGE",commandName:"Pr.Domain.User.Commands.RequestUserEmailAddressChange"}),c=(0,i.Iy)({type:"public/user/LINK_FROM_GOOGLE",commandName:"Pr.Domain.User.Commands.LinkUserGoogleAccount"}),d=(0,i.Iy)({type:"public/user/UNLINK_FROM_GOOGLE",commandName:"Pr.Domain.User.Commands.UnlinkUserGoogleAccount"}),l=(0,i.Iy)({type:"public/user/USE_FACEBOOK_AVATAR",commandName:"Pr.Domain.User.Commands.UseFacebookUserAvatar"}),u=(0,i.Iy)({type:"public/user/USE_GOOGLE_AVATAR",commandName:"Pr.Domain.User.Commands.UseGoogleUserAvatar"}),h=(0,i.Iy)({type:"public/user/REGISTER_WITH_EMAIL_ONLY",commandName:"Pr.Domain.User.Commands.RegisterUserWithEmailOnly"}),f=(0,i.Iy)({type:"public/user/LOGIN_USER_WITH_EMAIL_ONLY",commandName:"Pr.Domain.User.Commands.LoginUserWithEmailOnly"}),m=(0,i.Iy)({type:"public/user/LINK_FROM_FACEBOOK",commandName:"Pr.Domain.User.Commands.LinkUserFacebookAccount"}),p=(0,i.Iy)({type:"public/user/UNLINK_FROM_FACEBOOK",commandName:"Pr.Domain.User.Commands.UnlinkUserFacebookAccount"})},82176(e,t,r){"use strict";r.d(t,{A:()=>i});class i{iterate(e,t,r=[]){"group"!==e.type?"facet_reference"!==e.type?t(e,r):e.facet&&e.facet.fields.forEach((e,i)=>{this.iterate(e,t,r.concat(["facet","fields",i]))}):e.fields.forEach((e,i)=>{this.iterate(e,t,r.concat(["fields",i]))})}visitFields(e,t){e.fields.forEach((e,r)=>{this.iterate(e,t,[r])})}}},78115(e,t,r){"use strict";r.d(t,{A:()=>FormattedValueView});var i=r(85906),n=r(80579),a=r(35447),s=r(74954),o=r(14202);function TruncateTextIfTooLong(e){const[t,r]=(0,i.useState)(!1);return"string"==typeof e.value?!t&&e.value.length>60?(0,o.jsx)(a.A,{breakWord:!0,onClick:()=>r(!0),cursor:"pointer",position:"relative",children:(n={text:e.value.slice(0,60).trim(),expand:(0,o.jsx)(a.A,{textStyle:"link",stretchedLink:!0,textDecorationHover:"underline",children:"Expand"})},(0,o.jsxs)(o.Fragment,{children:[n.text,"... ",n.expand]}))}):(0,o.jsx)(a.A,{breakWord:!0,children:e.value}):e.value;var n}function FormattedValueView(e){let t="review"===e.context&&"text"===e.field?.type?(0,o.jsx)(TruncateTextIfTooLong,{value:e.value}):e.value;if(e.field&&["number","number_range","text"].includes(e.field.type)){const{properties:r,type:a}=e.field;if(r)return"number"!==a&&"number_range"!==a||(t=r.currency?(0,o.jsx)(n.A,{amount:e.value,currency:r.currency,isInCents:r.isInCents,hideCentsIfWhole:!0}):(0,o.jsx)(s.Gr,{value:e.value,options:{minimumFractionDigits:r.numberOfDecimals,maximumFractionDigits:r.numberOfDecimals}})),(0,o.jsxs)(i.Fragment,{children:[r.prefix&&!e.hidePrefix&&r.prefix,t,r.suffix&&!e.hideSuffix&&r.suffix]})}return t}},87384(e,t,r){"use strict";r.d(t,{MY:()=>AddressView,i5:()=>BooleanView,bJ:()=>f,MH:()=>m,DX:()=>EnumView,rJ:()=>c.A,YH:()=>ListMultiChoiceView,pO:()=>MarkdownView,IM:()=>MultilineTextView,L:()=>p,wD:()=>g,jm:()=>y,bt:()=>RatingView,l2:()=>b,Dx:()=>w});var i=r(34084);function AddressView(e){return e.value.label}
1var n=r(74954),a=r(14202);function BooleanView(e){const{positive:t="Yes",negative:r="No"}=e.field.properties?.labels||{};return(0,a.jsx)(n.sA,{id:"specifications.boolean_view",defaultMessage:"{value, select,\n true {{trueLabel}}\n false {{falseLabel}}\n}",values:{value:String(e.value),trueLabel:t,falseLabel:r}})}var s=r(87855),o=r(12765);function EnumView(e){if("unique_choice"===e.field.type||"string"==typeof e.value){const t=e.field.properties.options.find(t=>t.value===e.value);return t?t.label:null}if("multi_choice"===e.field.type&&Array.isArray(e.value)){const t=[];return e.value.forEach(r=>{const i=e.field.properties.options.find(e=>e.value===r);i&&t.push(i.label)}),(0,a.jsx)(s.A.Consumer,{children:e=>(0,a.jsx)(o.A,{truncateAfter:1/0,items:t.sort((t,r)=>e.compare(t,r))})})}return null}var c=r(78115),d=r(70009),l=r(66307);function ListMultiChoiceView(e){const t=(0,d.A)(),r=[];return e.value.forEach(t=>{const i=e.field.properties.options.find(e=>e.value===t);i&&r.push(i.label)}),0===r.length?null:(0,a.jsx)(l.A,{paddingLeft:0,style:{listStylePosition:"inside",listStyleType:"disc"},children:r.sort((e,r)=>t.compare(e,r)).map((e,t)=>(0,a.jsx)(l.A.Item,{children:e},t))})}var u=r(49329);function MarkdownView(e){return(0,a.jsx)(u.A,{source:e.value,initialParser:"review"===e.context?"inline":e.initialParser,renderCompactLists:!0})}var h=r(14901);function MultilineTextView(e){return(0,a.jsx)(h.A,{marginBottom:4,style:{whiteSpace:"pre-line"},children:e.value})}function RatingView(e){const{max:t,numberOfDecimals:r,prefix:i,suffix:s}=e.field.properties||{};return o={rating:(0,a.jsx)(n.Gr,{value:e.value,options:{minimumFractionDigits:r,maximumFractionDigits:r}}),maximumRating:(0,a.jsx)(n.Gr,{value:t||5,options:{minimumFractionDigits:r,maximumFractionDigits:r}}),prefix:!e.hidePrefix&&i,suffix:!e.hideSuffix&&s},(0,a.jsxs)(a.Fragment,{children:[o.prefix,o.rating,"/",o.maximumRating,o.suffix]});var o}const f=(0,i.Ay)({resolved:{},chunkName:()=>"DateTimeView",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("DateTimeView").then(()=>r(50115)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>50115}),m=(0,i.Ay)({resolved:{},chunkName:()=>"DateView",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("DateView").then(()=>r(39708)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>39708}),p=(0,i.Ay)({resolved:{},chunkName:()=>"NumericalRefinementFilterViewLabel",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("NumericalRefinementFilterViewLabel").then(()=>r(35193)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>35193}),g=(0,i.Ay)({resolved:{},chunkName:()=>"NumericalRefinementItemViewLabel",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("NumericalRefinementItemViewLabel").then(()=>r(20720)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>20720}),y=(0,i.Ay)({resolved:{},chunkName:()=>"RangeView",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("RangeView").then(()=>r(92771)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>92771}),b=(0,i.Ay)({resolved:{},chunkName:()=>"SliderView",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("SliderView").then(()=>r(82835)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>82835}),w=(0,i.Ay)({resolved:{},chunkName:()=>"TimeView",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e("TimeView").then(()=>r(19239)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>19239})},70725(e,t,r){"use strict";r.d(t,{T:()=>n});var i=r(82176);function n(e){const t={};return(new i.A).visitFields(e,e=>{t[e.id]=e}),t}},51753(e,t,r){"use strict";r.d(t,{Ay:()=>n});var i=r(90910);function n(e,t="non_aggregated"){return"aggregated"===t?function(e){return!(!e||!e.type)&&(e.type===i.D.MIN_MAX?void 0!==e.min&&void 0!==e.max:e.type===i.D.TERMS?e.counts.length>0:e.type===i.D.BOOLEAN?e.sumOfCounts>0:e.type===i.D.UNIQUE?e.values.length>0:e.type===i.D.STATS?e.count>0:e.type===i.D.RATINGS||e.type===i.D.NUMERIC_OPTIONS?e.sumOfCounts>0:(console.warn(`isAggregatedValueDefined(value): unknown value.type "${e.type}"`),!0))}(e):"aggregated_filter"===t?!(!(r=e)||!r.type)&&(r.type===i.D.STATS?r.count>0&&r.min!==r.max:r.type===i.D.RATINGS?r.sumOfCounts>0:r.type===i.D.CUMULATIVE_RATINGS?r.ranges.reduce((e,t)=>
1e+t.count,0)>0:r.type===i.D.TERMS||r.type===i.D.FILTERS?r.counts.length>0:r.type===i.D.BOOLEAN?r.countsMap.true>0&&r.countsMap.false>0:r.type===i.D.RANGE||r.type===i.D.NESTED_TERMS||r.type===i.D.NUMERIC_OPTIONS?r.sumOfCounts>0:r.type===i.D.UNIQUE?r.values.length>0:r.type===i.D.MIN_MAX&&r.min!==r.max):function(e){return Array.isArray(e)?e.length>0:""!==e&&null!=e}(e);var r}},23795(e,t,r){"use strict";function i(e){if(e)return e[0]}r.d(t,{A:()=>i})},9891(e,t,r){"use strict";function i(e,t){const r=[];for(const i in e){const n=e[i];r.push(t(n,i))}return r}r.d(t,{A:()=>i})},62279(e,t,r){"use strict";r.d(t,{A:()=>a});var i=r(88151),n=r(33803);function a(e){const t=(0,n.A)(e,e=>"string"==typeof e?e.trim():e);return(0,i.A)(t,e=>""!==e&&void 0!==e)}},26357(e,t,r){"use strict";function DEFAULT_GET_IDENTIFIER(e){return e.id}const i=function(e=DEFAULT_GET_IDENTIFIER){return function t(r,i){if(!i)return;if(e(i)===r)return i;const n=i.children||[];for(const e of n){const i=t(r,e);if(i)return i}}};r.d(t,["A",0,i])},78569(e,t,r){"use strict";r.d(t,{A:()=>n});var i=r(31362);function n(e,t){if(!e||0===e.length)return[];const r=e.find(e=>e.id===t);if(r)return[r.id];for(const r of e){const e=n(r.children,t);if(!(0,i.A)(e))return e.unshift(r.id),e}return[]}},65461(e,t,r){"use strict";function i(e){const t=typeof e;return null!==e&&("object"===t||"function"===t)}r.d(t,{A:()=>i})},46370(e,t,r){"use strict";var i=r(729);const n={compareWithCollator:function(e,t,r,n){if(r.isOther)return 1;if(r.isDiscontinued&&!n.isDiscontinued)return 1;if(!r.isDiscontinued&&n.isDiscontinued)return-1;if(t&&(0,i.A)(t)&&r.marketAvailability?.startDate&&n.marketAvailability?.startDate){const e=new Date(r.marketAvailability.startDate),t=new Date(r.marketAvailability.startDate);if(e>t)return-1;if(e<t)return 1}return e.compare(r.fullName,n.fullName)}};r.d(t,["A",0,n])},37743(e,t,r){"use strict";r.d(t,{A:()=>c});var i=r(81866),n=r(23819),a=r(31362),s=r(23051),o=r(65461);function c(e,t,r,c){const d={...e,commandId:(0,i.A)(),metadata:{...(0,n.A)(),...r}};return function(e){if((0,o.A)(e)){const t=(0,s.A)(e);return!(0,a.A)(t)}return null!=e&&""!==e}(t)&&(d.commandContext=t),c&&(d.preCommand=c),d}},92839(e,t,r){"use strict";function i(e,t){const r={};if(!e)return r;for(const i in e){const n=e[i];t(n,i)||(r[i]=n)}return r}r.d(t,{A:()=>i})},73909(e,t,r){"use strict";r.d(t,{A:()=>n});var i=r(16940);function n(e){if(e.type===i.PQ.ARCHIVED_ENTRY)throw new Error("resolveCatalogIdFromSubject(subject): cannot get catalogId from an unknown subject");return e.type===i.PQ.KNOWN_INTERNAL_ENTRY?e.entry.catalogId:e.type===i.PQ.KNOWN_EXTERNAL_ENTRY?e.externalEntry.catalogId:e.type===i.PQ.UNKNOWN_INTERNAL_ENTRY?e.unknownEntry.catalogId:e.unknownExternalEntry.catalogId}},49583(e,t,r){"use strict";function i(e){return e&&e[0].toUpperCase()+e.slice(1)}r.d(t,{A:()=>i})},673(e,t,r){"use strict";r.d(t,{A:()=>a});var i=r(99856),n=r(2063);function a(e,t){return i.Yj().superRefine((0,n.bB)(e,t,{type:"UniquePhoneNumber"}))}},32928(e,t,r){"use strict";var i=r(99856);const n=(0,r(74954).YK)({atLeastThreeLetters:{id:"form.errors.display_name.at_least_three_letters",defaultMessage:"Display name must contain at least three letters"},hasValidCharacters:{id:"form.errors.display_name.has_valid_characters",defaultMessage:"Only letters, numbers, _, -, ', . and spaces are allowed"}}),a=i.Yj().max(24).regex(/[A-Za-z]{3,}/,{message:n.atLeastThreeLetters.defaultMessage}).regex(/^[A-Za-zÃ-ÿ0-9'\-\s._]+$/i,{message:n.hasValidCharacters.defaultMessage});r.d(t,["A",0,a])},50020(e,t,r){"use strict";function i(e){if(e.length<3)return!1;const[t,r,...i]=e.split("@");return!(!t||!r||i.length>0)&&(!!/^[\w-](?:[\w.\-+]*[\w-])?$/.test(t)&&(!r.includes("..")&&!!/^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(r)))}r.d(t,{A:()=>i})},25808(e,t,r){"use strict";r.d(t,{nl:()=>d,Nx:()=>p,zo:()=>h,Rp:()=>f,Zk:()=>m,vy:()=>l,mw:()=>u});var i=r(99856),n=r(63936);var a=r(90849),s=r(74954);var o=r(50020),c=r(47905);const d=(0,s.YK)({required:{id:"form.errors.required",defaultMessage:"Required"},invalidEmail:{id:"form.errors.is_email",defaultMessage:"Please provide a valid email address"},invalidNumber:{id:"form.errors.is_number",defaultMessage:"Value must be a number"},invalidURL:{id:"form.errors.is_url",defaultMessage:"Please provide a valid URL"},invalidFullURL:{id:"form.errors.is_full_url",defaultMessage:"Please provide a valid URL (including http/https)"},invalidMinWords:{id:"form.errors.min_words_count",defaultMessage:"Text must have at least {minWords, plural, =1 {# word} other {# words}}"},invalidISBN:{id:"form.errors.is_isbn",defaultMessage:"Value should be a valid ISBN code"},invalidYouTubeURL:{id:"form.errors.is_valid_youtube_url",defaultMessage:"Must be a valid YouTube URL"},invalidUniqueArray:{id:"form.errors.is_string_list_of_uuid",defaultMessage:"List must contain unique values"},invalidHook:{id:"form.errors.is_hook",defaultMessage:"Hook should only contain lowercase letters, numbers and hyphens (no spaces)"},invalidHexColor:{id:"form.errors.is_hex_color",defaultMessage:"Invalid color. Please a use a hexadecimal value (for ex: #000000)"}
1,invalidDateRangeBetween:{id:"form.errors.is_date_range_between",defaultMessage:"Should be between {0, date, long} and {1, date, long} (inclusive)"},minDate:{id:"form.errors.min_date",defaultMessage:"Should be at least {minDate, date, medium}"},flatArrayError:{id:"form.errors.flat_array_error",defaultMessage:"{message} (position {position})"}});function l(e){return i.vk(e=>null===e||"string"==typeof e&&""===e.trim()?void 0:e,e.optional())}function u(e){const t={abort:!0,message:d.required.defaultMessage};return!e||e instanceof i.ND?i.L5().refine(e=>null!=e&&("string"!=typeof e||e.trim().length>0),t).pipe(e||i.Yj()):e instanceof i.n?i.L5().refine(e=>null!=e&&(!Array.isArray(e)||e.length>0),t).pipe(e):e instanceof i.rS?i.L5().refine(e=>null!=e&&("number"!=typeof e||!Number.isNaN(e)),t).pipe(e):e instanceof i.WF?i.L5().refine(e=>null!=e,t).pipe(e):e instanceof i.bv?i.L5().refine(e=>null!=e&&("object"!=typeof e||Object.keys(e).length>0),t).pipe(e):i.L5().refine(e=>null!=e&&("number"==typeof e?!Number.isNaN(e):"boolean"==typeof e||("string"==typeof e?e.trim().length>0:Array.isArray(e)?e.length>0:"object"!=typeof e||Object.keys(e).length>0)),t).pipe(e)}function h(e){const t=i.vk(e=>{if("string"==typeof e){const t=e.trim();if(""===t)return;return function(e){const t=e.includes(","),r=e.includes(".");if(t&&r)return e.lastIndexOf(",")>e.lastIndexOf(".")?e.replace(/\./g,"").replace(",","."):e.replace(/,/g,"");return t?/,\d{3}$/.test(e)&&!/,\d{1,2}$/.test(e)?e.replace(/,/g,""):e.replace(",","."):e}(t)}return e},i.Yj().or(i.ai()).pipe((r={message:d.invalidNumber.defaultMessage},n.qG(i.rS,r))));var r;return e?t.pipe(e):t}const f=i.Yj().refine(o.A,{message:d.invalidEmail.defaultMessage}),m=(i.Yj().refine(e=>(0,c.A)(e),{message:d.invalidURL.defaultMessage}),i.Yj().refine(function(e){return(0,c.A)(e,{requireProtocol:!0})},{message:d.invalidFullURL.defaultMessage}));function p(e){return i.Yj().refine(t=>(0,a.A)(t)>=e,{message:d.invalidMinWords.defaultMessage,params:{minWords:e}})}i.Yj().refine(e=>function(e){const t=e.replace(/[^\dX]/g,"");return/^[\d-X]+$/.test(e.trim())&&t.length>=10&&t.length<=13}(e),{message:d.invalidISBN.defaultMessage}),i.Yj().regex(/^(?:https?:\/\/)?(?:m\.|www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/i,{message:d.invalidYouTubeURL.defaultMessage});i.Yj().regex(/^[a-z0-9][-a-z0-9]*$/,{message:d.invalidHook.defaultMessage}),i.Yj().regex(/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i,{message:d.invalidHexColor.defaultMessage})},3423(e,t,r){"use strict";r.r(t),r.d(t,{default:()=>GlobalWriteReviewForm});var i=r(41398),n=r(55156),a=r(16940),s=r(98806),o=r(14202);function GlobalWriteReviewForm(){const e=(0,n.fL)();return(0,o.jsx)(i.A,{simplified:!0,namespace:"write_review",hideFooter:!0,children:(0,o.jsx)(s.A,{subjectContext:{type:a.PQ.UNKNOWN_INTERNAL_ENTRY},queryParams:e})})}},98806(e,t,r){"use strict";r.d(t,{A:()=>WriteReviewForm});var i=r(99009),n=r(28e3),a=r(99737),s=r(98379),o=r(45919),c=r(85906),d=r(59955),l=r(10014),u=r(89348),h=r(55279),f=r(73442),m=r(69275),p=r(86490),g=r(45756),y=r(47806),b=r(74954),w=r(63197),v=r(94874),k=r(24082),T=r(23766),x=r(76015),S=r(55156),C=r(27638),P=r(16940);function A(e){return{commandName:"Pr.Domain.ConsumerPlatform.Review.Commands.SubmitNewReview",payload:e}}var E=r(24716),I=r(37743),$=r(42673),_=r(47326),N=r(28610),R=r(88151),O=r(92839),F=r(33803),B=r(49583);const D=[{code:"AUD",symbols:["$","AUD"],decimalSeparator:".",thousandsSeparator:",",locale:"en-AU"}],M=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),j=e=>{for(const t of D)if(t.symbols.some(t=>e===t.toUpperCase())||e===t.code.toUpperCase())return t.code};function L(e,t="AUD"){if(!e?.trim())return;const r=e.trim().toUpperCase().replace(/\s+/g,""),i=(()=>{const e=D.flatMap(e=>[...e.symbols.map(e=>e.toUpperCase()),e.code.toUpperCase()]).sort((e,t)=>t.length-e.length).map(M).join("|");return new RegExp(`^(?:(${e})?)([\\d,\\.]+)(?:(${e}))?$`)})(),n=r.match(i);if(!n)return;const[,a,s,o]=n;if((a&&j(a)||o&&j(o)||t)!==t)return;const c=(d=t,D.find(e=>e.code===d));var d;if(!c)return void console.error("Currency config not found",{currency:t});const{decimalSeparator:l,thousandsSeparator:u}=c,h=s.lastIndexOf(l),f=s.indexOf(u);if(-1!==h&&-1!==f&&f>h)return;if(!((e,t,r)=>{const i=e.split(t);if(i.length<=1)return!0;
1if(i[0].length>3)return!1;for(let e=1;e<i.length;e++){const t=i[e];if(t.includes(r)){const[e]=t.split(r);if(3!==e.length)return!1}else if(3!==t.length)return!1}return!0})(s,u,l))return;const m=s.replace(new RegExp(M(u),"g"),"").replace(new RegExp(M(l),"g"),".");if(!/^\d+(\.\d+)?$/.test(m))return;const p=parseFloat(m);return Number.isNaN(p)||!Number.isFinite(p)?void 0:p}var U=r(28402),z=r(82176),W=r(97431),V=r(26357),q=r(54380);var H=r(32928),G=r(50020);const K=(0,V.A)(),Y=new z.A;function X(e,t,r){const i=(0,F.A)((0,R.A)(function(e,t){let r;return r=t,r}(0,r),e=>(0,q.A)(e)),e=>function(e){return e.replace(/[\u0250-\ue007]/g,"")}(e).trim());i.displayName&&(i.displayName=i.displayName.replace(e.writeReviewInvitationLink.placeholderDisplayName,""),i.displayName===i.displayName.toUpperCase()&&(i.displayName=i.displayName.toLowerCase().split(" ").map(e=>(0,B.A)(e)).join(" "))),i.emailAddress&&(i.emailAddress=i.emailAddress.replace(e.writeReviewInvitationLink.placeholderEmailAddress,"").replace(/ /g,"+").toLowerCase()),i.c&&(i.encodedJourneyCustomisation=i.c,delete i.c);const n=(a=i,(0,O.A)(a,(e,t)=>"emailAddress"===t&&!(0,G.A)(e)||("displayName"===t?!H.A.safeParse(e).success:"rating"===t&&(!Number.isInteger(Number(e))||e<1||e>5))));var a;return n.rating&&(n.rating=Number(n.rating)),n}var Q=r(85992),J=r(14202);function WriteReviewForm(e){const{logger:t}=(0,c.useContext)(w.A),r=(0,b.tz)(),R=(0,y.A)(),O=(0,S.zy)(),F=(0,S.Zp)(),B=(0,h.A)(),D=(0,p.A)(x.wz),M=e.subjectContext.listing?e.subjectContext.listing.tree?e.subjectContext.listing.tree.id:e.subjectContext.listing.id:e.subjectContext.type!==P.PQ.KNOWN_EXTERNAL_ENTRY&&e.subjectContext.type!==P.PQ.UNKNOWN_EXTERNAL_ENTRY||!e.subjectContext.externalEntry?void 0:e.subjectContext.externalEntry.externalId,j=(0,m.A)(),z=(0,f.A)(),V=(0,p.A)(x.eP),q=(0,g.A)(),H=(0,p.A)(k.Jj),G=H.context.role!==P.Xh.GUEST&&H.context.role!==P.Xh.CONSUMER,[Z,ee]=(0,c.useState)(void 0),[te,re]=(0,c.useState)(void 0),ie=(0,c.useMemo)(()=>function(e,t,r,i,n={}){const a=X(t,0,n);if(r.listing?.specifications&&Y.visitFields(r.listing.specifications,t=>{if(t.userFriendlyQueryParameterName&&t.userFriendlyQueryParameterName in a){const r=a[t.userFriendlyQueryParameterName],i=(()=>{if("text"===t.type)return r;if("resource_reference"===t.type)return(0,U.A)(r)?{type:"reference",value:r,label:r}:{type:"resource",value:r,label:r};if("number"===t.type)return t.properties?.currency?L(r,t.properties.currency):Number.isNaN(Number(r))?void e.error("Failed to parse number from query parameter",{metadata:{info:{field:t,queryValue:r}}}):Number(r);if("boolean"===t.type)return"true"===r||"1"===r||"yes"===r;if("date"===t.type||"datetime"===t.type){const i=new Date(r);return Number.isNaN(i.getTime())?void e.error("Failed to parse date from query parameter",{metadata:{info:{field:t,queryValue:r}}}):i}e.error("Unsupported specification value from query parameter",{metadata:{info:{field:t,queryValue:r}}})})();void 0!==i&&(a[`specificationValues.${t.id}`]=i),delete a[t.userFriendlyQueryParameterName]}}),r.type===P.PQ.KNOWN_INTERNAL_ENTRY&&r.listing){const e={type:P.PQ.KNOWN_INTERNAL_ENTRY,catalogId:r.listing.catalogId,entryId:r.listing.id};if(r.listing.isLeaf)return{...a,subject:e};const t=K(r.listing.id,r.listing?.tree);if(t&&(!t.children||0===t.children.length))return{...a,subject:e}}if(r.type===P.PQ.UNKNOWN_INTERNAL_ENTRY){const{term:e,entryType:t,entryName:r,categoryName:n,brandName:s,model:o,locationName:c,webLink:d,...l}=a;return{...l,subject:{type:P.PQ.UNKNOWN_INTERNAL_ENTRY,catalogId:(0,W.rR)(i.hostname,i.pathname),entryType:t,entryName:r||e,categoryName:n,brandName:s,model:o,locationName:c,webLink:d}}}return r.type===P.PQ.KNOWN_EXTERNAL_ENTRY&&r.externalEntry&&r.externalEntry.externalCatalog?r.externalEntry.id?{...a,subject:{type:P.PQ.KNOWN_EXTERNAL_ENTRY,catalogId:r.externalEntry.externalCatalog.catalogId,externalCatalogId:r.externalEntry.externalCatalog.id,externalEntryId:r.externalEntry.id,externalId:r.externalEntry.externalId,externalEntryName:r.externalEntry.name,url:r.externalEntry.url,pictureUrl:r.externalEntry.pictureUrl}}:{...a,subject:{type:P.PQ.OPTIMISTIC_KNOWN_EXTERNAL_ENTRY,catalogId:r.externalEntry.externalCatalog.catalogId,externalCatalogId:r.externalEntry.externalCatalog.id,externalId:r.externalEntry.externalId,externalEntryName:r.externalEntry.name,url:r.externalEntry.url,pictureUrl:r.externalEntry.pictureUrl}}:(r.type===P.PQ.UNKNOWN_EXTERNAL_ENTRY&&(0,v.A)(`Unexpected WriteReviewForm subject type ${r.type}`,{metadata:{config:t,subjectContext:r,location:i,queryParams:n}}),a)}(t,j,e.subjectContext,O,e.queryParams),[e.subjectContext]);(0,c.useEffect)(()=>{void 0===Z&&H.context.role!==P.Xh.STAFF&&ee(G)},[G]);const ne=e.subjectContext.listing?.hideProofOfPurchaseField?"hidden":e.reviewFormProps?.proofOfPurchaseFieldState?e.reviewFormProps.proofOfPurchaseFieldState:e.subjectContext.listing?.requiresProofOfPurchase?"required":"optional";return(0,J.jsxs)(i.A,{globalGaContext:(0,N.A)(e.subjectContext.listing),children:[(0,J.jsx)(d.A,{title:r.formatMessage({id:"public.write_review.form.page_title",defaultMessage:"{hasSubject, select,\n true {Write a review on {listingName}}\n false {Write a review}\n}"},{hasSubject:Boolean(e.subjectContext.listing),listingName:e.subjectContext.listing?.fullName??""})}),Z&&(0,J.jsx)(l.A,{title:"User not allowed to write reviews",content:()=>(0,J.jsx)(b.sA,{id:"public.write_review.form.prohibited_actor_modal.content",defaultMessage:"You are currently signed in as {actorRole, select,\n company_representative {a company representative}\n staff {an administrator}\n other {a {actorRole}}\n} and thus cannot write a review. You can still try out the form but cannot submit it. If you actually wish to
1submit a review, sign in as a different user.",values:{actorRole:H.context.role}}),footer:e=>(0,J.jsxs)(s.A,{flexDirection:{xs:"column",sm:"row"},flexGrow:1,gap:1,justifyContent:"between",margin:0,children:[(0,J.jsx)(o.A.Button,{onClick:()=>q.dispatch((0,T.ri)()),buttonStyle:"danger",flexBasis:100,flexGrow:1,children:"Sign out"}),(0,J.jsx)(o.A.Button,{onClick:e,buttonStyle:"primary",flexBasis:100,flexGrow:1,children:"Play with the form"})]}),bodyProps:{padding:4},reject:()=>ee(!1),resolve:()=>ee(!1)}),(0,J.jsx)(a.A,{singleCenteredContainer:!0,children:(0,J.jsx)(n.A,{persistentId:M,initialValues:ie,subjectContext:e.subjectContext,onSubmitReview:async(t,r,i)=>{const n=e=>{if((0,u.c)(e)&&400121===e.response.data?.code)throw re(!0),e;throw(0,v.A)(e,{context:"SubmitReviewFailed",metadata:{review:t,credentials:i}}),e};try{const a={...t,reviewId:r,collectionMethod:e.collectionMethod,invitationId:e.invitation?.invitationId,invitationIdHash:e.invitation?.invitationIdHash};if(a.subject.type===P.PQ.UNKNOWN_INTERNAL_ENTRY&&("product"===a.subject.entryType?delete a.subject.locationName:(delete a.subject.brandName,delete a.subject.model)),V)return q.dispatch(_.L(a)).then(()=>{Q.IU(),e.onSuccess?.(),F(B.generate("www.public.write_review_thank_you",{reviewId:a.reviewId}))},n);if(!i)throw new Error("Authentication credentials are required for guest review submission");const s=await z.post("/api/validators/UniqueEmail",{data:{value:i.emailAddress}}).then(e=>"NON_UNIQUE_EMAIL"===e.error?.id);let o;if(s){const t=i.isRegistered&&i.phoneNumberVerification?{commandName:"Pr.Domain.Roles.Consumer.Commands.ChangeConsumerPhoneNumber",payload:{consumerId:null,phoneNumber:i.phoneNumberVerification.phoneNumber,phoneNumberVerificationToken:i.phoneNumberVerification.phoneNumberVerificationToken,actor:{id:null,context:{role:P.Xh.CONSUMER}}}}:void 0;o=q.dispatch(C.Td({emailAddress:i.emailAddress,deferredCommand:(0,I.A)(A(a),void 0,void 0,t),redirectTo:B.generate("www.public.write_review_thank_you",{reviewId:a.reviewId,...e.queryParams})}))}else{if(!i.roleIntention)throw new Error("Role intention is required for unregistered users");o=q.dispatch(C.bC({userId:R(),displayName:i.displayName,roleIntention:i.roleIntention,emailAddress:i.emailAddress,deferredCommand:(0,I.A)(A(a)),redirectTo:B.generate("www.public.write_review_thank_you",{reviewId:a.reviewId,...e.queryParams})}))}return o.then(()=>{Q.IU(),e.onSuccess?.(),e.invitation?.invitationIdHash?(0,E.A)(B.generate("www.public.write_review_thank_you",{reviewId:a.reviewId,authToken:e.invitation?.invitationIdHash})):F(B.generate("www.public.write_review_confirm_email",{emailAddress:i.emailAddress,isRegistered:s?"1":null}))},n)}catch(e){n(e)}},requiresPhoneNumber:te??(!D.consumerData?.phoneNumberDetails?.phoneNumberE164&&e.subjectContext.listing?.requiresPhoneNumber),...(0,$.A)(e.reviewFormProps,{onceFormIsDirty:()=>{e.subjectContext.type===P.PQ.KNOWN_INTERNAL_ENTRY&&e.subjectContext.listing&&Q.M_(e.subjectContext.listing)}}),proofOfPurchaseFieldState:ne},M)})]})}},47326(e,t,r){"use strict";r.d(t,{Z:()=>a,L:()=>n});var i=r(821);const n=(0,i.Iy)({type:"public/writeReview/SUBMIT_REVIEW",commandName:"Pr.Domain.ConsumerPlatform.Review.Commands.SubmitNewReview"}),a=(0,i.Iy)({type:"public/writeReview/SUBMIT_EDIT_REVIEW",commandName:"Pr.Domain.ConsumerPlatform.Review.Commands.EditReview"})},4515(e,t,r){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let i=0,n=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(i++,"%c"===e&&(n=i))}),t.splice(n,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;
1if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(37854)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},37854(e,t,r){e.exports=function(e){function t(e){let r,n,a,s=null;function o(...e){if(!o.enabled)return;const i=o,n=Number(new Date),a=n-(r||n);i.diff=a,i.prev=r,i.curr=n,r=n,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,n)=>{if("%%"===r)return"%";s++;const a=t.formatters[n];if("function"==typeof a){const t=e[s];r=a.call(i,t),e.splice(s,1),s--}return r}),t.formatArgs.call(i,e);(i.log||t.log).apply(i,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=i,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(n!==t.namespaces&&(n=t.namespaces,a=t.enabled(e)),a),set:e=>{s=e}}),"function"==typeof t.init&&t.init(o),o}function i(e,r){const i=t(this.namespace+(void 0===r?":":r)+e);return i.log=this.log,i}function n(e,t){let r=0,i=0,n=-1,a=0;for(;r<e.length;)if(i<t.length&&(t[i]===e[r]||"*"===t[i]))"*"===t[i]?(n=i,a=r,i++):(r++,i++);else{if(-1===n)return!1;i=n+1,a++,r=a}for(;i<t.length&&"*"===t[i];)i++;return i===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=r(36207),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(r=>{t[r]=e[r]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},15333(e){function t(e){return Promise.resolve().then(()=>{const t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t})}t.keys=()=>[],t.resolve=t,t.id=15333,e.exports=t},53712(e){e.exports=function(){"use strict";var e=/^(b|B)$/,t={iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},r={iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]},i={floor:Math.floor,ceil:Math.ceil};function n(n){var a,s,o,c,d,l,u,h,f,m,p,g,y,b,w,v,k,T,x,S,C,P=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},A=[],E=0;if(isNaN(n))throw new TypeError("Invalid number");if(o=!0===P.bits,w=!0===P.unix,g=!0===P.pad,s=P.base||10,y=void 0!==P.round?P.round:w?1:2,u=void 0!==P.locale?P.locale:"",h=P.localeOptions||{},v=void 0!==P.separator?P.separator:"",k=void 0!==P.spacer?P.spacer:w?"":" ",x=P.symbols||{},T=2===s?P.standard||"iec":"jedec",p=P.output||"string",d=!0===P.fullform,l=P.fullforms instanceof Array?P.fullforms:[],a=void 0!==P.exponent?P.exponent:-1,S=i[P.roundingMethod]||Math.round,f=(m=Number(n))<0,c=s>2?1e3:1024,C=!1===isNaN(P.precision)?parseInt(P.precision,10):0,f&&(m=-m),(-1===a||isNaN(a))&&(a=Math.floor(Math.log(m)/Math.log(c)))<0&&(a=0),a>8&&(C>0&&(C+=8-a),a=8),"exponent"===p)return a;
1if(0===m)A[0]=0,b=A[1]=w?"":t[T][o?"bits":"bytes"][a];else{E=m/(2===s?Math.pow(2,10*a):Math.pow(1e3,a)),o&&(E*=8)>=c&&a<8&&(E/=c,a++);var I=Math.pow(10,a>0?y:0);A[0]=S(E*I)/I,A[0]===c&&a<8&&void 0===P.exponent&&(A[0]=1,a++),b=A[1]=10===s&&1===a?o?"kbit":"kB":t[T][o?"bits":"bytes"][a],w&&(A[1]=A[1].charAt(0),e.test(A[1])&&(A[0]=Math.floor(A[0]),A[1]=""))}if(f&&(A[0]=-A[0]),C>0&&(A[0]=A[0].toPrecision(C)),A[1]=x[A[1]]||A[1],!0===u?A[0]=A[0].toLocaleString():u.length>0?A[0]=A[0].toLocaleString(u,h):v.length>0&&(A[0]=A[0].toString().replace(".",v)),g&&!1===Number.isInteger(A[0])&&y>0){var $=v||".",_=A[0].toString().split($),N=_[1]||"",R=N.length,O=y-R;A[0]="".concat(_[0]).concat($).concat(N.padEnd(R+O,"0"))}return d&&(A[1]=l[a]?l[a]:r[T][a]+(o?"bit":"byte")+(1===A[0]?"":"s")),"array"===p?A:"object"===p?{value:A[0],symbol:A[1],exponent:a,unit:b}:A.join(k)}return n.partial=function(e){return function(t){return n(t,e)}},n}()},48821(e,t){},45451(e,t,r){var i=r(40631).Symbol;e.exports=i},95513(e,t,r){var i=r(36024);e.exports=function(e,t,r){for(var n=-1,a=e.length;++n<a;){var s=e[n],o=t(s);if(null!=o&&(void 0===c?o==o&&!i(o):r(o,c)))var c=o,d=s}return d}},38742(e,t,r){var i=r(45451),n=r(25085),a=r(75624),s=i?i.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?n(e):a(e)}},5889(e){e.exports=function(e,t){return e>t}},9918(e){e.exports=function(e,t){return e<t}},26210(e,t,r){var i="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g;e.exports=i},25085(e,t,r){var i=r(45451),n=Object.prototype,a=n.hasOwnProperty,s=n.toString,o=i?i.toStringTag:void 0;e.exports=function(e){var t=a.call(e,o),r=e[o];try{e[o]=void 0;var i=!0}catch(e){}var n=s.call(e);return i&&(t?e[o]=r:delete e[o]),n}},75624(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},40631(e,t,r){var i=r(26210),n="object"==typeof self&&self&&self.Object===Object&&self,a=i||n||Function("return this")();e.exports=a},78106(e){e.exports=function(e){return e}},68384(e){e.exports=function(e){return null!=e&&"object"==typeof e}},36024(e,t,r){var i=r(38742),n=r(68384);e.exports=function(e){return"symbol"==typeof e||n(e)&&"[object Symbol]"==i(e)}},51308(e,t,r){var i=r(95513),n=r(5889),a=r(78106);e.exports=function(e){return e&&e.length?i(e,a,n):void 0}},62082(e,t,r){var i=r(95513),n=r(9918),a=r(78106);e.exports=function(e){return e&&e.length?i(e,a,n):void 0}},53774(e,t,r){"use strict";r.d(t,["A",0,{"record-button":"o2ey_a",fadeInOutPulse:"snFujO","real-time-video-container":"b6NtKk","camera-icon":"p3AKX7",countdown:"eYke9K","preview-video-container":"FI_JU5","trim-timeline":"hwCHJC","trim-filmstrip":"NShxqt","trim-selection":"L7ggHt","trim-handle":"PgSlIL","volume-indicator":"P5CgRQ","volume-indicator-fill":"pW1ifo","video-input":"JhumjN"}])},36207(e){var t=1e3,r=60*t,i=60*r,n=24*i,a=7*n,s=365.25*n;function o(e,t,r,i){var n=t>=1.5*r;return Math.round(e/r)+" "+i+(n?"s":"")}e.exports=function(e,c){c=c||{};var d=typeof e;if("string"===d&&e.length>0)return function(e){if((e=String(e)).length>100)return;var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!o)return;var c=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*a;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*i;case"minutes":case"minute":case"mins":case"min":case"m":return c*r;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===d&&isFinite(e))return c.long?function(e){var a=Math.abs(e);if(a>=n)return o(e,a,n,"day");if(a>=i)return o(e,a,i,"hour");if(a>=r)return o(e,a,r,"minute");if(a>=t)return o(e,a,t,"second");return e+" ms"}(e):function(e){var a=Math.abs(e);if(a>=n)return Math.round(e/n)+"d";if(a>=i)return Math.round(e/i)+"h";if(a>=r)return Math.round(e/r)+"m";if(a>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},76851(){},44835(e,t,r){"use strict";r.d(t,{A:()=>S});var i=r(1456),n=r(32058),a=r(36524),s=r(22186);var o=/^[A-Z]{2}$/;function c(e,t){var r,n,a,s=new i.Ay(t);return a=e,o.test(a)?(r=e,s.selectNumberingPlan(r),n=s.countryCallingCode()):n=e,{country:r,callingCode:n}}function d(e,t,r){var n=new i.Ay(r).getCountryCodesForCallingCode(e);return n?n.filter(function(e){return function(e,t,r){var n=new i.Ay(r);return n.selectNumberingPlan(t),n.numberingPlan.possibleLengths().indexOf(e.length)>=0}(t,e,r)}):[]}var l=r(86453),u=r(39408),h=r(53148),f=/^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;var m={formatExtension:function(e,t,r){return"".concat(e).concat(r.ext()).concat(t)}};function p(e,t,r,n){r=r?function(){for(var e=1,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];for(;e<r.length;){if(r[e])for(var n in r[e])r[0][n]=r[e][n];e++}return r[0]}({},m,r):m;var a=new i.Ay(n);if(e.country&&"001"!==e.country){if(!a.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));a.selectNumberingPlan(e.country)}else{if(!e.countryCallingCode)return e.phone||"";a.selectNumberingPlan(e.countryCallingCode)}var s,o=a.countryCallingCode(),c=r.v2?e.nationalNumber:e.phone;switch(t){case"NATIONAL":return c?y(s=g(c,e.carrierCode,"NATIONAL",a,r),e.ext,a,r.formatExtension):"";case"INTERNATIONAL":return c?(s=g(c,null,"INTERNATIONAL",a,r),y(s="+".concat(o," ").concat(s),e.ext,a,r.formatExtension)):"+".concat(o);case"E.164":return"+".concat(o).concat(c);case"RFC3966":return function(e){var t=e.number,r=e.ext;if(!t)return"";if("+"!==t[0])throw new Error('"formatRFC3966()" expects "number" to be in E.164 format.');return"tel:".concat(t).concat(r?";ext="+r:"")}({number:"+".concat(o).concat(c),ext:e.ext});case"IDD":if(!r.fromCountry)return;var d=function(e,t,r,n,a){var s=(0,i.Ko)(n,a.metadata);if(s===r){var o=g(e,t,"NATIONAL",a);return"1"===r?r+" "+o:o}var c=function(e,t,r){var n=new i.Ay(r);return n.selectNumberingPlan(e||t),n.defaultIDDPrefix()?n.defaultIDDPrefix():f.test(n.IDDPrefix())?n.IDDPrefix():void 0}(n,void 0,a.metadata);if(c)return"".concat(c," ").concat(r," ").concat(g(e,null,"INTERNATIONAL",a))}(c,e.carrierCode,o,r.fromCountry,a);if(!d)return;return y(d,e.ext,a,r.formatExtension);default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(t,'"'))}}function g(e,t,r,i,n){var s,o,c=(s=i.formats(),o=e,function(e,t){for(var r=0;r<e.length;){if(t(e[r]))return e[r];r++}}(s,function(e){if(e.leadingDigitsPatterns().length>0){var t=e.leadingDigitsPatterns()[e.leadingDigitsPatterns().length-1];if(0!==o.search(t))return!1}return(0,a.A)(o,e.pattern())}));return c?(0,h.A)(e,c,{useInternationalFormat:"INTERNATIONAL"===r,withNationalPrefix:!c.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||!n||!1!==n.nationalPrefix,carrierCode:t,metadata:i}):e}function y(e,t,r,i){return t?i(e,t,r):e}function b(e){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(e)}function w(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function v(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?w(Object(r),!0).forEach(function(t){k(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function k(e,t,r){return(t=x(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function T(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,x(i.key),i)}}function x(e){var t=function(e,t){if("object"!=b(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=b(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==b(t)?t:t+""}var S=function(){return e=function PhoneNumber(e,t,r){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,PhoneNumber),!e)throw new TypeError("First argument is required");if("string"!=typeof e)throw new TypeError("First argument must be a string");if("+"===e[0]&&!t)throw new TypeError("`metadata` argument not passed");if((0,u.A)(t)&&(0,u.A)(t.countries)){r=t;var n=e;if(!C.test(n))throw new Error('Invalid `number` argument passed: must consist of a "+" followed by digits');var a=(0,l.A)(n,void 0,void 0,void 0,r);if(e=a.countryCallingCode,!(t=a.number))throw new Error("Invalid `number` argument passed: too short")}if(!t)throw new TypeError("`nationalNumber` argument is required");if("string"!=typeof t)throw new TypeError("`nationalNumber` argument must be a string");(0,i.aR)(r);var s=c(e,r),o=s.country,d=s.callingCode;this.country=o,this.countryCallingCode=d,this.nationalNumber=t,this.number="+"+this.countryCallingCode+this.nationalNumber,this.getMetadata=function(){return r}},(t=[{key:"setExt",value:function(e){this.ext=e}},{key:"getPossibleCountries",value:function(){return this.country?[this.country]:d(this.countryCallingCode,this.nationalNumber,this.getMetadata())}},{key:"isPossible",value:function(){return(0,n.A)(this,{v2:!0},this.getMetadata())}},{key:"isValid",value:function(){return function(e,t,r){t=t||{};var n=new i.Ay(r);if(n.selectNumberingPlan(e.country||e.countryCallingCode),n.hasTypes())return void 0!==(0,s.A)(e,t,n.metadata);var o=t.v2?e.nationalNumber:e.phone;return(0,a.A)(o,n.nationalNumberPattern())}(this,{v2:!0},this.getMetadata())}},{key:"isNonGeographic",value:function(){return new i.Ay(this.getMetadata()).isNonGeographicCallingCode(this.countryCallingCode)}},{key:"isEqual",value:function(e){return this.number===e.number&&this.ext===e.ext}},{key:"getType",value:function(){return(0,s.A)(this,{v2:!0},this.getMetadata())}},{key:"format",value:function(e,t){return p(this,e,t?v(v({},t),{},{v2:!0}):{v2:!0},this.getMetadata())}},{key:"formatNational",value:function(e){return this.format("NATIONAL",e)}},{key:"formatInternational",value:function(e){return this.format("INTERNATIONAL",e)}},{key:"getURI",value:function(e){return this.format("RFC3966",e)}}])&&T(e.prototype,t),r&&T(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}(),C=/^\+\d+$/},73820(e,t,r){"use strict";r.d(t,{Cb:()=>n,Jq:()=>a,OA:()=>s,c7:()=>i,tz:()=>c,uD:()=>o});var i=2,n=17,a=3,s="0-9ï¼-ï¼Ù -Ù©Û°-Û¹",o="".concat("-â-ââã¼ï¼").concat("ï¼/").concat("ï¼.").concat("  Âââ ã").concat("()ï¼ï¼ï¼»ï¼½\\[\\]").concat("~ââ¼ï½"),c="+ï¼"},15171(e,t,r){"use strict";r.d(t,{A:()=>n});var i=r(73820);function n(e){return e.replace(new RegExp("[".concat(i.uD,"]+"),"g")," ").trim()}},88502(e,t,r){"use strict";r.d(t,{A:()=>s});var i=r(1456);function n(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return a(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function s(e,t,r){return o(e,void 0,t,r)}function o(e,t,r,a){r&&(a=new i.Ay(a.metadata)).selectNumberingPlan(r);var s=a.type(t),c=s&&s.possibleLengths()||a.possibleLengths();if(!c)return"IS_POSSIBLE";if("FIXED_LINE_OR_MOBILE"===t){if(!a.type("FIXED_LINE"))return o(e,"MOBILE",r,a);var d=a.type("MOBILE");d&&(c=function(e,t){for(var r,i=e.slice(),a=n(t);!(r=a()).done;){var s=r.value;e.indexOf(s)<0&&i.push(s)}return i.sort(function(e,t){return e-t})}(c,d.possibleLengths()))}else if(t&&!s)return"INVALID_LENGTH";var l=e.length,u=c[0];return u===l?"IS_POSSIBLE":u>l?"TOO_SHORT":c[c.length-1]<l?"TOO_LONG":c.indexOf(l,1)>=0?"IS_POSSIBLE":"INVALID_LENGTH"}},86453(e,t,r){"use strict";r.d(t,{A:()=>
1o});var i=r(15854),n=r(24351),a=r(1456),s=r(73820);function o(e,t,r,o,c){if(!e)return{};var d;if("+"!==e[0]){var l=(0,i.A)(e,t||r,o,c);if(!l||l===e){if(t||r||o){var u=(0,n.A)(e,t,r,o,c),h=u.countryCallingCode,f=u.number;if(h)return{countryCallingCodeSource:"FROM_NUMBER_WITHOUT_PLUS_SIGN",countryCallingCode:h,number:f}}return{number:e}}d=!0,e="+"+l}if("0"===e[1])return{};for(var m=new a.Ay(c),p=2;p-1<=s.Jq&&p<=e.length;){var g=e.slice(1,p);if(m.hasCallingCode(g))return m.selectNumberingPlan(g),{countryCallingCodeSource:d?"FROM_NUMBER_WITH_IDD":"FROM_NUMBER_WITH_PLUS_SIGN",countryCallingCode:g,number:e.slice(p)};p++}return{}}},24351(e,t,r){"use strict";r.d(t,{A:()=>o});var i=r(1456),n=r(36524),a=r(30929),s=r(88502);function o(e,t,r,o,c){if(!(t||r||o))return{number:e};var d=t||r?(0,i.Ko)(t||r,c):o;if(0===e.indexOf(d)){var l=new i.Ay(c);l.selectNumberingPlan(t||r||o);var u=e.slice(d.length),h=(0,a.A)(u,void 0,l).nationalNumber,f=(0,a.A)(e,void 0,l).nationalNumber;if(!(0,n.A)(f,l.nationalNumberPattern())&&(0,n.A)(h,l.nationalNumberPattern())||"TOO_LONG"===(0,s.A)(f,void 0,l))return{countryCallingCode:d,number:u}}return{number:e}}},30929(e,t,r){"use strict";r.d(t,{A:()=>o});var i=r(49175),n=r(36524),a=r(88502),s=r(14843);function o(e,t,r){var o=(0,i.A)(e,r),c=o.carrierCode,d=o.nationalNumber;if(d!==e){if(!function(e,t,r){if((0,n.A)(e,r.nationalNumberPattern())&&!(0,n.A)(t,r.nationalNumberPattern()))return!1;return!0}(e,d,r))return{nationalNumber:e};if(r.numberingPlan.possibleLengths()&&(t||(t=(0,s.A)(r.numberingPlan.callingCode(),{nationalNumber:d,metadata:r})),!function(e,t,r){switch((0,a.A)(e,t,r)){case"TOO_SHORT":case"INVALID_LENGTH":return!1;default:return!0}}(d,t,r)))return{nationalNumber:e}}return{nationalNumber:d,carrierCode:c}}},49175(e,t,r){"use strict";function i(e,t){if(e&&t.numberingPlan.nationalPrefixForParsing()){var r=new RegExp("^(?:"+t.numberingPlan.nationalPrefixForParsing()+")"),i=r.exec(e);if(i){var n,a,s,o=i.length-1,c=o>0&&i[o];if(t.nationalPrefixTransformRule()&&c)n=e.replace(r,t.nationalPrefixTransformRule()),o>1&&(a=i[1]);else{var d=i[0];n=e.slice(d.length),c&&(a=i[1])}if(c){var l=e.indexOf(i[1]);e.slice(0,l)===t.numberingPlan.nationalPrefix()&&(s=t.numberingPlan.nationalPrefix())}else s=i[0];return{nationalNumber:n,nationalPrefix:s,carrierCode:a}}}return{nationalNumber:e}}r.d(t,{A:()=>i})},53148(e,t,r){"use strict";r.d(t,{A:()=>a,_:()=>n});var i=r(15171),n=/(\$\d)/;function a(e,t,r){var a=r.useInternationalFormat,s=r.withNationalPrefix,o=(r.carrierCode,r.metadata,e.replace(new RegExp(t.pattern()),a?t.internationalFormat():s&&t.nationalPrefixFormattingRule()?t.format().replace(n,t.nationalPrefixFormattingRule()):t.format()));return a?(0,i.A)(o):o}},14843(e,t,r){"use strict";r.d(t,{A:()=>n});var i=r(81419);function n(e,t){var r=t.nationalNumber,n=t.metadata;var a=n.getCountryCodesForCallingCode(e);if(a)return 1===a.length?a[0]:(0,i.A)(r,a,n.metadata)}},81419(e,t,r){"use strict";r.d(t,{A:()=>o});var i=r(1456),n=r(22186);function a(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return s(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function o(e,t,r){for(var s,o=new i.Ay(r),c=a(t);!(s=c()).done;){var d=s.value;if(o.selectNumberingPlan(d),o.leadingDigits()){if(e&&0===e.search(o.leadingDigits()))return d}else if((0,n.A)({phone:e,country:d},void 0,o.metadata))return d}}},22186(e,t,r){"use strict";r.d(t,{A:()=>c});var i=r(1456),n=r(36524);function a(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return s(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}var o=["MOBILE","PREMIUM_RATE","TOLL_FREE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL"];function c(e,t,r){if(t=t||{},e.country||e.countryCallingCode){var s=new i.Ay(r);s.selectNumberingPlan(e.country||e.countryCallingCode);var c=t.v2?e.nationalNumber:e.phone;if((0,n.A)(c,s.nationalNumberPattern())){if(d(c,"FIXED_LINE",s))return s.type("MOBILE")&&""===s.type("MOBILE").pattern()?"FIXED_LINE_OR_MOBILE":s.type("MOBILE")?d(c,"MOBILE",s)?"FIXED_LINE_OR_MOBILE":"FIXED_LINE":"FIXED_LINE_OR_MOBILE";
1for(var l,u=a(o);!(l=u()).done;){var h=l.value;if(d(c,h,s))return h}}}}function d(e,t,r){var i=r.type(t);return!(!i||!i.pattern())&&(!(i.possibleLengths()&&i.possibleLengths().indexOf(e.length)<0)&&(0,n.A)(e,i.pattern()))}},39408(e,t,r){"use strict";r.d(t,{A:()=>n});var i={}.constructor;function n(e){return null!=e&&e.constructor===i}},36524(e,t,r){"use strict";function i(e,t){return e=e||"",new RegExp("^(?:"+t+")$").test(e)}r.d(t,{A:()=>i})},71102(e,t,r){"use strict";function i(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}r.d(t,{Ay:()=>o,ZW:()=>s});var a={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","ï¼":"0","ï¼":"1","ï¼":"2","ï¼":"3","ï¼":"4","ï¼":"5","ï¼":"6","ï¼":"7","ï¼":"8","ï¼":"9","Ù ":"0","Ù¡":"1","Ù¢":"2","Ù£":"3","Ù¤":"4","Ù¥":"5","Ù¦":"6","Ù§":"7","Ù¨":"8","Ù©":"9","Û°":"0","Û±":"1","Û²":"2","Û³":"3","Û´":"4","Ûµ":"5","Û¶":"6","Û·":"7","Û¸":"8","Û¹":"9"};function s(e){return a[e]}function o(e){for(var t,r="",n=i(e.split(""));!(t=n()).done;){var a=s(t.value);a&&(r+=a)}return r}},15854(e,t,r){"use strict";r.d(t,{A:()=>s});var i=r(1456),n=r(73820),a=new RegExp("(["+n.OA+"])");function s(e,t,r,n){if(t){var s=new i.Ay(n);s.selectNumberingPlan(t||r);var o=new RegExp(s.IDDPrefix());if(0===e.search(o)){var c=(e=e.slice(e.match(o)[0].length)).match(a);if(!(c&&null!=c[1]&&c[1].length>0&&"0"===c[1]))return e}}}},32058(e,t,r){"use strict";r.d(t,{A:()=>a,x:()=>s});var i=r(1456),n=r(88502);function a(e,t,r){void 0===t&&(t={});var n=new i.Ay(r);if(t.v2){if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");n.selectNumberingPlan(e.country||e.countryCallingCode)}else{if(!e.phone)return!1;if(e.country){if(!n.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));n.selectNumberingPlan(e.country)}else{if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");n.selectNumberingPlan(e.countryCallingCode)}}if(n.possibleLengths())return s(e.phone||e.nationalNumber,n);if(e.countryCallingCode&&n.isNonGeographicCallingCode(e.countryCallingCode))return!0;throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.')}function s(e,t){return"IS_POSSIBLE"===(0,n.A)(e,void 0,t)}},1456(e,t,r){"use strict";function i(e,t){e=e.split("-"),t=t.split("-");for(var r=e[0].split("."),i=t[0].split("."),n=0;n<3;n++){var a=Number(r[n]),s=Number(i[n]);if(a>s)return 1;if(s>a)return-1;if(!isNaN(a)&&isNaN(s))return 1;if(isNaN(a)&&!isNaN(s))return-1}return e[1]&&t[1]?e[1]>t[1]?1:e[1]<t[1]?-1:0:!e[1]&&t[1]?1:e[1]&&!t[1]?-1:0}r.d(t,{Ay:()=>h,Ko:()=>v,J_:()=>k,aR:()=>b}),r.dn(i);var n=r(39408),a=/^\d+$/;function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,l(i.key),i)}}function d(e,t,r){return t&&c(e.prototype,t),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e){var t=function(e,t){if("object"!=s(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=s(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==s(t)?t:t+""}var u=" ext. ",h=function(){return d(function Metadata(e){o(this,Metadata),b(e),this.metadata=e,T.call(this,e)},[{key:"getCountries",value:function(){return Object.keys(this.metadata.countries).filter(function(e){return"001"!==e})}},{key:"getCountryMetadata",value:function(e){return this.metadata.countries[e]}},{key:"nonGeographic",value:function(){if(!(this.v1||this.v2||this.v3))return this.metadata.nonGeographic||this.metadata.nonGeographical}},{key:"hasCountry",value:function(e){return void 0!==this.getCountryMetadata(e)}},{key:"hasCallingCode",value:function(e){if(this.getCountryCodesForCallingCode(e))return!0;
vendor: 6,495 bytes, line 1
1if(this.nonGeographic()){if(this.nonGeographic()[e])return!0}else{var t=this.countryCallingCodes()[e];if(t&&1===t.length&&"001"===t[0])return!0}}},{key:"isNonGeographicCallingCode",value:function(e){return this.nonGeographic()?!!this.nonGeographic()[e]:!this.getCountryCodesForCallingCode(e)}},{key:"country",value:function(e){return this.selectNumberingPlan(e)}},{key:"selectNumberingPlan",value:function(e,t){var r,i,n;if(e&&(n=e,a.test(n)?i=e:r=e),t&&(i=t),r&&"001"!==r){var s=this.getCountryMetadata(r);if(!s)throw new Error("Unknown country: ".concat(r));this.numberingPlan=new f(s,this)}else if(i){if(!this.hasCallingCode(i))throw new Error("Unknown calling code: ".concat(i));this.numberingPlan=new f(this.getNumberingPlanMetadata(i),this)}else this.numberingPlan=void 0;return this}},{key:"getCountryCodesForCallingCode",value:function(e){var t=this.countryCallingCodes()[e];if(t){if(1===t.length&&3===t[0].length)return;return t}}},{key:"getCountryCodeForCallingCode",value:function(e){var t=this.getCountryCodesForCallingCode(e);if(t)return t[0]}},{key:"getNumberingPlanMetadata",value:function(e){var t=this.getCountryCodeForCallingCode(e);if(t)return this.getCountryMetadata(t);if(this.nonGeographic()){var r=this.nonGeographic()[e];if(r)return r}else{var i=this.countryCallingCodes()[e];if(i&&1===i.length&&"001"===i[0])return this.metadata.countries["001"]}}},{key:"countryCallingCode",value:function(){return this.numberingPlan.callingCode()}},{key:"IDDPrefix",value:function IDDPrefix(){return this.numberingPlan.IDDPrefix()}},{key:"defaultIDDPrefix",value:function(){return this.numberingPlan.defaultIDDPrefix()}},{key:"nationalNumberPattern",value:function(){return this.numberingPlan.nationalNumberPattern()}},{key:"possibleLengths",value:function(){return this.numberingPlan.possibleLengths()}},{key:"formats",value:function(){return this.numberingPlan.formats()}},{key:"nationalPrefixForParsing",value:function(){return this.numberingPlan.nationalPrefixForParsing()}},{key:"nationalPrefixTransformRule",value:function(){return this.numberingPlan.nationalPrefixTransformRule()}},{key:"leadingDigits",value:function(){return this.numberingPlan.leadingDigits()}},{key:"hasTypes",value:function(){return this.numberingPlan.hasTypes()}},{key:"type",value:function(e){return this.numberingPlan.type(e)}},{key:"ext",value:function(){return this.numberingPlan.ext()}},{key:"countryCallingCodes",value:function(){return this.v1?this.metadata.country_phone_code_to_countries:this.metadata.country_calling_codes}},{key:"chooseCountryByCountryCallingCode",value:function(e){return this.selectNumberingPlan(e)}},{key:"hasSelectedNumberingPlan",value:function(){return void 0!==this.numberingPlan}}])}(),f=function(){return d(function NumberingPlan(e,t){o(this,NumberingPlan),this.globalMetadataObject=t,this.metadata=e,T.call(this,t.metadata)},[{key:"callingCode",value:function(){return this.metadata[0]}},{key:"_getDefaultCountryMetadataForThisCallingCode",value:function(){return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode())}},{key:"getDefaultCountryMetadataForRegion",value:function(){return this._getDefaultCountryMetadataForThisCallingCode()}},{key:"IDDPrefix",value:function IDDPrefix(){if(!this.v1&&!this.v2)return this.metadata[1]}},{key:"defaultIDDPrefix",value:function(){if(!this.v1&&!this.v2)return this.metadata[12]}},{key:"nationalNumberPattern",value:function(){return this.v1||this.v2?this.metadata[1]:this.metadata[2]}},{key:"possibleLengths",value:function(){if(!this.v1)return this.metadata[this.v2?2:3]}},{key:"_getFormats",value:function(e){return e[this.v1?2:this.v2?3:4]}},{key:"formats",value:function(){var e=this,t=this._getFormats(this.metadata)||this._getFormats(this._getDefaultCountryMetadataForThisCallingCode())||[];return t.map(function(t){return new m(t,e)})}},{key:"nationalPrefix",value:function(){return this.metadata[this.v1?3:this.v2?4:5]}},{key:"_getNationalPrefixFormattingRule",value:function(e){return e[this.v1?4:this.v2?5:6]}},{key:"nationalPrefixFormattingRule",value:function(){return this._getNationalPrefixFormattingRule(this.metadata)||this._getNationalPrefixFormattingRule(this._getDefaultCountryMetadataForThisCallingCode())}},{key:"_nationalPrefixForParsing",value:function(){return this.metadata[this.v1?5:this.v2?6:7]}},{key:"nationalPrefixForParsing",value:function(){return this._nationalPrefixForParsing()||this.nationalPrefix()}},{key:"nationalPrefixTransformRule",value:function(){return this.metadata[this.v1?6:this.v2?7:8]}},{key:"_getNationalPrefixIsOptionalWhenFormatting",value:function(){return!!this.metadata[this.v1?7:this.v2?8:9]}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata)||this._getNationalPrefixIsOptionalWhenFormatting(this._getDefaultCountryMetadataForThisCallingCode())}},{key:"leadingDigits",value:function(){return this.metadata[this.v1?8:this.v2?9:10]}},{key:"types",value:function(){return this.metadata[this.v1?9:this.v2?10:11]}},{key:"hasTypes",value:function(){return(!this.types()||0!==this.types().length)&&!!this.types()}},{key:"type",value:function(e){if(this.hasTypes()&&y(this.types(),e))return new g(y(this.types(),e),this)}},{key:"ext",value:function(){return this.v1||this.v2?u:this.metadata[13]||u}}])}(),m=function(){return d(function Format(e,t){o(this,Format),this._format=e,this.metadata=t},[{key:"pattern",value:function(){return this._format[0]}},{key:"format",value:function(){return this._format[1]}},{key:"leadingDigitsPatterns",value:function(){return this._format[2]||[]}},{key:"nationalPrefixFormattingRule",value:function(){return this._format[3]||this.metadata.nationalPrefixFormattingRule()}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return!!this._format[4]||this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"nationalPrefixIsMandatoryWhenFormattingInNationalFormat",value:function(){return this.usesNationalPrefix()&&!this.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"usesNationalPrefix",value:function(){return!(!this.nationalPrefixFormattingRule()||p.test(this.nationalPrefixFormattingRule()))}},{key:"internationalFormat",value:function(){return this._format[5]||this.format()}}])}(),p=/^\(?\$1\)?$/,g=function(){return d(function Type(e,t){o(this,Type),this.type=e,this.metadata=t},[{key:"pattern",value:function(){return this.metadata.v1?this.type:this.t
1ype[0]}},{key:"possibleLengths",value:function(){if(!this.metadata.v1)return this.type[1]||this.metadata.possibleLengths()}}])}();function y(e,t){switch(t){case"FIXED_LINE":return e[0];case"MOBILE":return e[1];case"TOLL_FREE":return e[2];case"PREMIUM_RATE":return e[3];case"PERSONAL_NUMBER":return e[4];case"VOICEMAIL":return e[5];case"UAN":return e[6];case"PAGER":return e[7];case"VOIP":return e[8];case"SHARED_COST":return e[9]}}function b(e){if(!e)throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");if(!(0,n.A)(e)||!(0,n.A)(e.countries))throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat((0,n.A)(e)?"an object of shape: { "+Object.keys(e).join(", ")+" }":"a "+w(e)+": "+e,"."))}var w=function(e){return s(e)};function v(e,t){var r=new h(t);if(r.hasCountry(e))return r.selectNumberingPlan(e).countryCallingCode();throw new Error("Unknown country: ".concat(e))}function k(e,t){return t.countries.hasOwnProperty(e)}function T(e){var t=e.version;"number"==typeof t?(this.v1=1===t,this.v2=2===t,this.v3=3===t,this.v4=4===t):t?-1===i(t,"1.2.0")?this.v2=!0:-1===i(t,"1.7.35")?this.v3=!0:this.v4=!0:this.v1=!0}},61853(e,t,r){"use strict";r.d(t,{A:()=>s,G:()=>o});var i=r(71102);function n(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return a(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function s(e){for(var t,r="",i=n(e.split(""));!(t=i()).done;){r+=o(t.value,r)||""}return r}function o(e,t,r){return"+"===e?t?void("function"==typeof r&&r("end")):"+":(0,i.ZW)(e)}},62626(e,t,r){"use strict";r.d(t,{A:()=>ee});var i=r(39408);function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function s(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,a,s,o=[],c=!0,d=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(i=a.call(r)).done)&&(o.push(i.value),o.length!==t);c=!0);}catch(e){d=!0,n=e}finally{try{if(!c&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(d)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function d(e){var t,r,n,c=o(Array.prototype.slice.call(e),4),d=c[0],l=c[1],u=c[2],h=c[3];if("string"!=typeof d)throw new TypeError("A text for parsing must be a string.");if(t=d,l&&"string"!=typeof l){if(!(0,i.A)(l))throw new Error("Invalid second argument: ".concat(l));u?(r=l,n=u):n=l}else h?(r=u,n=h):(r=void 0,n=u),l&&(r=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?a(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({defaultCountry:l},r));return{text:t,options:r,metadata:n}}var l=r(73820);function ParseError_typeof(e){return ParseError_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ParseError_typeof(e)}function u(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,ParseError_toPropertyKey(i.key),i)}}function ParseError_toPropertyKey(e){var t=function ParseError_toPrimitive(e,t){if("object"!=ParseError_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=ParseError_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ParseError_typeof(t)?t:t+""}function h(e,t,r){return t=g(t),function(e,t){if(t&&("object"==ParseError_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,m()?Reflect.construct(t,r||[],g(e).constructor):t.apply(e,r))}function f(e){var t="function"==typeof Map?new Map:void 0;return f=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,Wrapper)}function Wrapper(){return function(e,t,r){if(m())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,t);var n=new(e.bind.apply(e,i));return r&&p(n,r.prototype),n}(e,arguments,g(this).constructor)}return Wrapper.prototype=Object.create(e.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),p(Wrapper,e)},f(e)}function m(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(m=function(){return!!e})()}function p(e,t){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},p(e,t)}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}var y=function(e){function ParseError(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,ParseError),t=h(this,ParseError,[e]),Object.setPrototypeOf(t,ParseError.prototype),t.name=t.constructor.name,t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(ParseError,e),t=ParseError,r&&u(t.prototype,r),i&&u(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,i}(f(Error)),b=r(1456),w=function(e){return"([".concat(l.OA,"]{1,").concat(e,"})")};function v(e){var t="[  \\t,]*",r="[:\\.ï¼]?[  \\t,-]*",i="#?",n="[  \\t]*";return";ext="+w("20")+"|"+(t+"(?:e?xt(?:ensi(?:oÌ?|ó))?n?|ï½
?ï½ï½ï½?|доб|anexo)"+r+w("20")+i)+"|"+(t+"(?:[xï½#ï¼~ï½]|int|ï½ï½ï½)"+r+w("9")+i)+"|"+("[- ]+"+w("6")+"#")+"|"+(n+"(?:,{2}|;)"+r+w("15")+i)+"|"+(n+"(?:,)+"+r+w("9")+i)}var k="["+l.OA+"]{"+l.c7+"}",T="["+l.tz+"]{0,1}(?:["+l.uD+"]*["+l.OA+"]){3,}["+l.uD+l.OA+"]*",x=new RegExp("^["+l.tz+"]{0,1}(?:["+l.uD+"]*["+l.OA+"]){1,2}$","i"),S=T+"(?:"+v()+")?",C=new RegExp("^"+k+"$|^"+S+"$","i");var P=new RegExp("(?:"+v()+")$","i");var A=r(61853),E=r(32058),I=r(44835),$=r(36524),_=r(86453),N=r(30929),R=r(14843),O="(["+l.OA+"]|[\\-\\.\\(\\)]?)",F="^\\+"+O+"*["+l.OA+"]"+O+"*$",B=new RegExp(F,"g"),D=l.OA,M=new RegExp("^("+("["+D+"]+((\\-)*["+D+"])*")+"\\.)*"+("[a-zA-Z]+((\\-)*["+D+"])*")+"\\.?$","g"),j="tel:",L=";
1phone-context=";function U(e,t){var r,i=t.extractFormattedPhoneNumber,n=function(e){var t=e.indexOf(L);if(t<0)return null;var r=t+15;if(r>=e.length)return"";var i=e.indexOf(";",r);return i>=0?e.substring(r,i):e.substring(r)}(e);if(!function(e){return null===e||0!==e.length&&(B.test(e)||M.test(e))}(n))throw new y("NOT_A_NUMBER");if(null===n)r=i(e)||"";else{r="","+"===n.charAt(0)&&(r+=n);var a,s=e.indexOf(j);a=s>=0?s+4:0;var o=e.indexOf(L);r+=e.substring(a,o)}var c=r.indexOf(";isub=");if(c>0&&(r=r.substring(0,c)),""!==r)return r}var z=new RegExp("["+l.tz+l.OA+"]"),W=new RegExp("[^"+l.OA+"#]+$");function V(e,t,r){t=t||{};var i=new b.Ay(r);if(t.defaultCountry&&!i.hasCountry(t.defaultCountry)){if(t.v2)throw new y("INVALID_COUNTRY");throw new Error("Unknown country: ".concat(t.defaultCountry))}var n=function(e,t,r){var i=U(e,{extractFormattedPhoneNumber:function(e){return function(e,t,r){if(!e)return;if(e.length>250){if(r)throw new y("TOO_LONG");return}if(!1===t)return e;var i=e.search(z);if(i<0)return;return e.slice(i).replace(W,"")}(e,r,t)}});if(!i)return{};if(!function(e){return e.length>=l.c7&&C.test(e)}(i))return function(e){return x.test(e)}(i)?{error:"TOO_SHORT"}:{};var n=function(e){var t=e.search(P);if(t<0)return{};for(var r=e.slice(0,t),i=e.match(P),n=1;n<i.length;){if(i[n])return{number:r,ext:i[n]};n++}}(i);if(n.ext)return n;return{number:i}}(e,t.v2,t.extract),a=n.number,s=n.ext,o=n.error;if(!a){if(t.v2){if("TOO_SHORT"===o)throw new y("TOO_SHORT");throw new y("NOT_A_NUMBER")}return{}}var c=function(e,t,r,i){var n,a=(0,_.A)((0,A.A)(e),void 0,t,r,i.metadata),s=a.countryCallingCodeSource,o=a.countryCallingCode,c=a.number;if(o)i.selectNumberingPlan(o);else{if(!c||!t&&!r)return{};t?(n=t,i.selectNumberingPlan(t),o=i.numberingPlan.callingCode()):(i.selectNumberingPlan(r),o=r)}if(!c)return{countryCallingCodeSource:s,countryCallingCode:o};var d=(0,N.A)((0,A.A)(c),void 0,i),l=d.nationalNumber,u=d.carrierCode,h=(0,R.A)(o,{nationalNumber:l,metadata:i});h&&(n=h,"001"===h||i.selectNumberingPlan(n));return{country:n,countryCallingCode:o,countryCallingCodeSource:s,nationalNumber:l,carrierCode:u}}(a,t.defaultCountry,t.defaultCallingCode,i),d=c.country,u=c.nationalNumber,h=c.countryCallingCode,f=c.countryCallingCodeSource,m=c.carrierCode;if(!i.hasSelectedNumberingPlan()){if(t.v2)throw new y("INVALID_COUNTRY");return{}}if(!u||u.length<l.c7){if(t.v2)throw new y("TOO_SHORT");return{}}if(u.length>l.Cb){if(t.v2)throw new y("TOO_LONG");return{}}if(t.v2){var p=new I.A(h,u,i.metadata);return d&&(p.country=d),m&&(p.carrierCode=m),s&&(p.ext=s),p.__countryCallingCodeSource=f,p}var g=!!(t.extended?i.hasSelectedNumberingPlan():d)&&(0,$.A)(u,i.nationalNumberPattern());return t.extended?{country:d,countryCallingCode:h,carrierCode:m,valid:g,possible:!!g||!(!0!==t.extended||!i.possibleLengths()||!(0,E.x)(u,i)),phone:u,ext:s}:g?function(e,t,r){var i={country:e,phone:t};r&&(i.ext=r);return i}(d,u,s):{}}function q(e){return q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},q(e)}function H(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function G(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?H(Object(r),!0).forEach(function(t){K(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function K(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=q(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=q(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==q(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Y(e){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Y(e)}function X(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function Q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?X(Object(r),!0).forEach(function(t){J(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):X(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function J(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=Y(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=Y(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Y(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Z(e,t,r){t&&t.defaultCountry&&!(0,b.J_)(t.defaultCountry,r)&&(t=Q(Q({},t),{},{defaultCountry:void 0}));try{return function(e,t,r){return V(e,G(G({},t),{},{v2:!0}),r)}(e,t,r)}catch(e){if(!(e instanceof y))throw e}}function ee(){var e=d(arguments);return Z(e.text,e.options,e.metadata)}},64659(e,t,r){"use strict";r.d(t,{Ay:()=>V,VB:()=>H});const i=new Map([["avif","image/avif"],["bmp","image/bmp"],["css","text/css"],["csv","text/csv"],["doc","application/msword"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["gif","image/gif"],["gz","application/gzip"],["htm","text/html"],["html","text/html"],["ico","image/x-icon"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["js","application/javascript"],["json","application/json"],["md","text/markdown"],["mjs","application/javascript"],["mp3","audio/mpeg"],["mp4","video/mp4"],["ogg","audio/ogg"],["pdf","application/pdf"],["png","image/png"],["ppt","application/powerpoint"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["svg","image/svg+xml"],["tif","image/tiff"],["tiff","image/tiff"],["txt","text/plain"],["wasm","application/wasm"],["wav","audio/x-wav"],["weba","audio/webm"],["webm","video/webm"],["webp","image/webp"],["xls","application/vnd.ms-excel"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xml","application/xml"],["zip","application/zip"]]);var n=class extends Error{constructor(e){super("DataTransferItem is not a file"),this.item=e,this.name="UnexpectedObjectError"}};function a(e,t,r){const i=e,{webkitRelativePath:n}=e,a="string"==typeof t?t:"string"==typeof n&&n.length>0?n:`./${e.name}`;return"string"!=typeof i.path&&s(i,"path",a),void 0!==r&&Object.defineProperty(i,"handle",{value:r,writable:!1,configurable:!1,enumerable:!0}),s(i,"relativePath",a),i}function s(e,t,r){Object.defineProperty(e,t,{value:r,writable:!1,configurable:!1,enumerable:!0})}const o=[".DS_Store","Thumbs.db"];async function c(e,{mimeTypes:t=i}={}){return(await async function(e){if(l(e)&&d(e.dataTransfer))return async function(e,t){const r=h(e.items).filter(e=>"file"===e.kind);return"drop"!==t?r:u(m(await Promise.all(r.map(f))))}(e.dataTransfer,e.type);if(l(t=e)&&d(t.clipboardData))return function(e){const t=h(e.items).filter(e=>"file"===e.kind).map(e=>e.getAsFile()).filter(e=>null!==e);return u((t.length>0?t:h(e.files)).map(e=>a(e)))}(e.clipboardData);if(function(e){return l(e)&&l(e.target)}(e))return function(e){return h(e.target.files).map(e=>a(e))}(e);if(Array.isArray(e)&&e.every(e=>"getFile"in e&&"function"==typeof e.getFile))return async function(e){return(await Promise.all(e.map(e=>e.getFile()))).map(e=>a(e))}(e);var t;return[]}(e)).map(e=>e instanceof File?function(e,t=i){const{name:r}=e;if(r&&-1!==r.lastIndexOf(".")&&!e.type){const i=r.split(".").pop().toLowerCase(),n=t.get(i);n&&Object.defineProperty(e,"type",{value:n,writable:!1,configurable:!1,enumerable:!0})}return e}(e,t):e)}function d(e){return l(e)}function l(e){return"object"==typeof e&&null!==e}function u(e){return e.filter(e=>-1===o.indexOf(e.name))}function h(e){return null===e?[]:Array.from(e)}async function f(e){if("function"!=typeof e.webkitGetAsEntry)return p(e);const t=e.webkitGetAsEntry();if(t?.isDirectory){const r=await g(e);return"directory"===r?.kind?y(r,`/${r.name}`):w(t)}return p(e,t)}function m(e){const t=[];for(const r of e)Array.isArray(r)?t.push(...m(r)):t.push(r);return t}async function p(e,t){const r=e.getAsFile(),i=await g(e);if(null!=i){const e=r??await i.getFile();return e.handle=i,a(e)}if(!r)throw new n(e);return a(r,t?.fullPath??void 0)}async function g(e){if(globalThis.isSecureContext&&"function"==typeof e.getAsFileSystemHandle)return e.getAsFileSystemHandle()}async function y(e,t){const r=[];for await(const i of e.values()){const e=`${t}/${i.name}`;if("directory"===i.kind)r.push(...await y(i,e));else{const t=await i.getFile();r.push(a(t,e,i))}}return r}async function b(e){return e.isDirectory?w(e):async function(e){return new Promise((t,r)=>{e.file(r=>{t(a(r,e.fullPath))},e=>{r(e)})})}(e)}function w(e){const t=e.createReader();return new Promise((e,r)=>{const i=[];!function n(){t.readEntries(async t=>{if(t.length){const e=Promise.all(t.map(b));i.push(e),n()}else try{e(await Promise.all(i))}catch(e){r(e)}},e=>{r(e)})}()})}var v=r(85906);function k(e,t){if(e&&t){const r=Array.isArray(t)?t:t.split(",");if(0===r.length)return!0;const i=e.name||"",n=(e.type||"").toLowerCase(),a=n.replace(/\/.*$/,"");return r.some(e=>{const t=e.trim().toLowerCase();return"."===t.charAt(0)?i.toLowerCase().endsWith(t):t.endsWith("/*")?a===t.replace(/\/.*$/,""):n===t})}return!0}var T=r(14202);const x=k;function S(e=""){const t=e.split(",");return{code:"file-invalid-type",message:`File type must be ${t.length>1?`one of ${t.join(", ")}`:t[0]}`}}const C=["KB","MB","GB","TB","PB"];function P(e){if(e<1024)return`${e} ${1===e?"byte":"bytes"}`;let t=e/1024,r=0;for(;t>=1024&&r<C.length-1;)t/=1024,r++;return`${Number(t.toFixed(2))} ${C[r]}`}function A(e){return{code:"file-too-large",message:`File is larger than ${P(e)}`}}function E(e){return{code:"file-too-small",message:`File is smaller than ${P(e)}`}}const I={code:"too-many-files",message:"Too many files"};function $(e,t){const r="application/x-moz-file"===e.type||x(e,t??"")||function(e){return""===e.type&&"function"==typeof e.getAsFile}(e);return[r,r?null:S(t)]}function _(e,t,r){if(N(e.size))if(N(t)&&N(r)){if(e.size>r)return[!1,A(r)];if(e.size<t)return[!1,E(t)]}else{if(N(t)&&e.size<t)return[!1,E(t)];if(N(r)&&e.size>r)return[!1,A(r)]}return[!0,null]}function N(e){return null!=e}function R(e){return"function"==typeof e.isPropagationStopped?e.isPropagationStopped():void 0!==e.cancelBubble&&e.cancelBubble}function O(e){const t=e.dataTransfer??e.clipboardData;return t?Array.prototype.some.call(t.types,e=>"Files"===e||"application/x-moz-file"===e)||Array.prototype.some.call(t.items??[],F):!!e.target&&!!e.target.files}function F(e){return"object"==typeof e&&null!==e&&"file"===e.kind}function B(e){e.preventDefault()}function D(...e){return(t,...r)=>e.some(e=>(!R(t)&&e&&e(t,...r),R(t)))}function M(e){return Array.isArray(e)?e:"string"==typeof e?[e]:[]}function j(e){if(N(e))return Array.isArray(e)?e.filter(e=>N(e)&&N(e.accept)):[{accept:e}]}function L(e){const t=[],r=Object.keys(e);for(const r of Object.values(e))for(const e of M(r))t.includes(e)||t.push(e);return t.length>0?t.join(", "):r.length>0?r.join(", "):"Files"}function U(e,{omitWildcardMimeTypesWithExtensions:t=!1}={}){if(N(e))return Object.entries(e).reduce((e,[r,i])=>{const n=M(i);return t&&r.endsWith("/*")&&n.some(W)?e.push(...n):e.push(r,...n),e},[]).filter(e=>z(e)||W(e)).join(",")}function z(e){return"audio/*"===e||"video/*"===e||"image/*"===e||"text/*"===e||"application/*"===e||/\w+\/[-+.\w]+/g.test(e)}function W(e){return/^.*\.[\w]+$/.test(e)}const V=(0,v.forwardRef)(({children:e,...t},r)=>{const{open:i,...n}=H(t);return(0,v.useImperativeHandle)(r,()=>({open:i}),[i]),(0,T.jsx)(T.Fragment,{children:e?.({...n,open:i})})});V.displayName="Dropzone";const q={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragUnknown:!1,isDragGlobal:!1,isProcessing:!1,acceptedFiles:[],fileRejections:[],dragFileRejections:[]};function H(e={}){const{accept:t,disabled:r=!1,getFilesFromEvent:i=c,maxSize:n=Number.POSITIVE_INFINITY,minSize:a=0,multiple:s=!0,maxFiles:o=0,onDragEnter:d,onDragLeave:l,onDragOver:u,onDrop:h,onDropAccepted:f,onDropRejected:m,onFileDialogCancel:p,onFileDialogOpen:g,useFsAccessApi:y=!1,autoFocus:b=!1,preventDropOnDocument:w=!0,noClick:k=!1,noKeyboard:T=!1,noDrag:x=!1,noDragEventsBubbling:S=!1,noPaste:C=!1,onError:P,validator:A,getErrorMessage:E}=e,F=(0,v.useMemo)(()=>function(e){const t=j(e);if(!N(t))return;const r={};for(const e of t)for(const[t,i]of Object.entries(e.accept)){const e=r[t]??(r[t]=[]);for(const t of M(i))e.includes(t)||e.push(t)}return r}(t),[t]),V=(0,v.useMemo)(()=>U(F),[F]),H=(0,v.useMemo)(()=>U(F,{omitWildcardMimeTypesWithExtensions:!0}),[F]),Y=(0,v.useMemo)(()=>function(e){const t=j(e);if(!N(t))return;const r=t.map(e=>{const t=Object.entries(e.accept).filter(([e,t])=>{let r=!0;return z(e)||(console.warn(`Skipped "${e}" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.`),r=!1),(Array.isArray(t)||"string"==typeof t)&&M(t).every(W)||(console.warn(`Skipped "${e}
1" because an invalid file extension was provided.`),r=!1),r}).reduce((e,[t,r])=>(e[t]=M(r),e),{});return{description:N(e.description)&&""!==e.description?e.description:L(t),accept:t}}).filter(e=>Object.keys(e.accept).length>0);return r.length>0?r:void 0}(t),[t]),X=(0,v.useMemo)(()=>"function"==typeof g?g:K,[g]),Q=(0,v.useMemo)(()=>"function"==typeof p?p:K,[p]),J=(0,v.useRef)(null),Z=(0,v.useRef)(null),[ee,te]=(0,v.useReducer)(G,q),{isFocused:re,isFileDialogActive:ie}=ee,ne=(0,v.useRef)(ie);ne.current=ie;const ae=(0,v.useRef)(null),se=(0,v.useCallback)(()=>{ae.current?.abort();const e=new AbortController;return ae.current=e,te({type:"setProcessing",isProcessing:!0}),e.signal},[]),oe=(0,v.useCallback)(e=>{e.aborted||te({type:"setProcessing",isProcessing:!1})},[]),ce=(0,v.useRef)("undefined"!=typeof window&&window.isSecureContext&&y&&"showOpenFilePicker"in window),de=()=>{!ce.current&&ie&&setTimeout(()=>{if(Z.current){const{files:e}=Z.current;e?.length||(te({type:"closeDialog"}),Q())}},300)};(0,v.useEffect)(()=>(window.addEventListener("focus",de,!1),()=>{window.removeEventListener("focus",de,!1)}),[Z,ie,Q,ce]);const le=(0,v.useRef)([]),ue=(0,v.useRef)([]),he=e=>{J.current&&e.target&&J.current.contains(e.target)&&e.defaultPrevented||(e.preventDefault(),le.current=[])};(0,v.useEffect)(()=>(w&&(document.addEventListener("dragover",B,!1),document.addEventListener("drop",he,!1)),()=>{w&&(document.removeEventListener("dragover",B),document.removeEventListener("drop",he))}),[J,w]),(0,v.useEffect)(()=>{const e=e=>{e.target&&(ue.current=[...ue.current,e.target]),O(e)&&te({isDragGlobal:!0,type:"setDragGlobal"})},t=e=>{ue.current=ue.current.filter(t=>t!==e.target&&null!==t),ue.current.length>0||te({isDragGlobal:!1,type:"setDragGlobal"})},r=()=>{ue.current=[],te({isDragGlobal:!1,type:"setDragGlobal"})},i=()=>{ue.current=[],te({isDragGlobal:!1,type:"setDragGlobal"})};return document.addEventListener("dragenter",e,!1),document.addEventListener("dragleave",t,!1),document.addEventListener("dragend",r,!1),document.addEventListener("drop",i,!1),()=>{document.removeEventListener("dragenter",e),document.removeEventListener("dragleave",t),document.removeEventListener("dragend",r),document.removeEventListener("drop",i)}},[J]),(0,v.useEffect)(()=>(!r&&b&&J.current&&J.current.focus(),()=>{}),[J,b,r]);const fe=(0,v.useCallback)(e=>{P?P(e):console.error(e)},[P]),me=(0,v.useCallback)(e=>{e.preventDefault(),e.persist?.(),Ee(e),ne.current||(le.current=[...le.current,e.target],O(e)&&Promise.resolve(i(e)).then(t=>{if(R(e)&&!S)return;const r=t.length>0?function({files:e,accept:t,minSize:r,maxSize:i,multiple:n,maxFiles:a=0,validator:s,getErrorMessage:o}){const c=[],d=[],l=(e,t)=>o&&"undefined"!=typeof File&&t instanceof File?{...e,message:o(e,t)}:e;e.forEach(e=>{const[n,a]=$(e,t),[s,o]=_(e,r,i);
1n&&s?c.push(e):d.push({file:e,errors:[a,o].filter(e=>null!=e).map(t=>l(t,e))})});const u=n?a>=1?a:Number.POSITIVE_INFINITY:1;return c.length>u&&c.slice(u).forEach(e=>{d.push({file:e,errors:[l(I,e)]})}),d.length>0?{verdict:"reject",rejections:d}:{verdict:s?"unknown":"accept",rejections:d}}({files:t,accept:V,minSize:a,maxSize:n,multiple:s,maxFiles:o,validator:A,getErrorMessage:E}):null;te({isDragAccept:"accept"===r?.verdict,isDragReject:"reject"===r?.verdict,isDragUnknown:"unknown"===r?.verdict,isDragActive:!0,dragFileRejections:r?.rejections??[],type:"setDraggedFiles"}),d&&d(e)}).catch(e=>fe(e)))},[i,d,fe,S,V,a,n,s,o,A,E]),pe=(0,v.useCallback)(e=>{if(e.preventDefault(),e.persist?.(),Ee(e),ne.current)return!1;const t=O(e);if(t&&e.dataTransfer)try{e.dataTransfer.dropEffect="copy"}catch{}return t&&u&&u(e),!1},[u,S]),ge=(0,v.useCallback)(e=>{e.preventDefault(),e.persist?.(),Ee(e);const t=le.current.filter(e=>J.current?.contains(e)),r=t.indexOf(e.target);-1!==r&&t.splice(r,1),le.current=t,t.length>0||(te({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragUnknown:!1,dragFileRejections:[]}),O(e)&&l&&l(e))},[J,l,S]),ye=(0,v.useCallback)(async(e,t,r)=>{const i=(e,t)=>E?{...e,message:E(e,t)}:e,c=e=>{const r=[],n=[];e.forEach(({file:e,accepted:t,acceptError:a,sizeMatch:s,sizeError:o,customErrors:c})=>{if(t&&s&&!c)r.push(e);else{let t=[a,o];c&&(t=t.concat(c)),n.push({file:e,errors:t.filter(e=>null!=e).map(t=>i(t,e))})}});const a=s?o>=1?o:Number.POSITIVE_INFINITY:1;r.length>a&&r.splice(a).forEach(e=>{n.push({file:e,errors:[i(I,e)]})}),te({acceptedFiles:r,fileRejections:n,type:"setFiles"}),h&&h(r,n,t),n.length>0&&m&&m(n,t),r.length>0&&f&&f(r,t)},d=e.map(e=>{const[t,r]=$(e,H),[i,s]=_(e,a,n);return{file:e,accepted:t,acceptError:r,sizeMatch:i,sizeError:s,customErrors:A?A(e):null}});if(!d.some(({customErrors:e})=>{return null!=(t=e)&&"function"==typeof t.then;var t}))return void c(d);let l;try{l=await Promise.all(d.map(async({customErrors:e,...t})=>({...t,customErrors:await e})))}catch(e){return void(r.aborted||(oe(r),fe(e)))}r.aborted||c(l)},[te,s,H,a,n,o,h,f,m,A,E,fe,oe]),be=(0,v.useCallback)(e=>{if(e.preventDefault(),e.persist?.(),Ee(e),le.current=[],(!ne.current||!e.dataTransfer)&&(te({type:"reset"}),O(e))){const t=se();Promise.resolve(i(e)).then(r=>{if(!t.aborted){if(!R(e)||S)return ye(r,e,t);oe(t)}}).catch(e=>{t.aborted||(oe(t),fe(e))})}},[i,ye,fe,S,se,oe]),we=(0,v.useCallback)(e=>{if(!O(e))return;e.preventDefault(),e.persist?.(),Ee(e);const t=se();Promise.resolve(i(e)).then(r=>{if(!t.aborted){if(!R(e)||S)return ye(r,e,t);oe(t)}}).catch(e=>{t.aborted||(oe(t),fe(e))})},[i,ye,fe,S,se,oe]),ve=(0,v.useCallback)(()=>{if(ce.current){te({type:"openDialog"}),X();const e={multiple:s,types:Y};let t;return void window.showOpenFilePicker(e).then(e=>(t=se(),i(e))).then(e=>{if(te({type:"closeDialog"}),!t.aborted)return ye(e,null,t)}).catch(e=>{var r;t&&oe(t),(r=e)instanceof DOMException&&("AbortError"===r.name||r.code===r.ABORT_ERR)?(Q(e),te({type:"closeDialog"})):function(e){return e instanceof DOMException&&("SecurityError"===e.name||e.code===e.SECURITY_ERR)}(e)||function(e){return e instanceof DOMException&&"NotAllowedError"===e.name}(e)?(ce.current=!1,Z.current?(Z.current.value="",Z.current.click()):fe(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):fe(e)})}Z.current&&(te({type:"openDialog"}),X(),Z.current.value="",Z.current.click())},[te,X,Q,y,ye,fe,Y,s,se,oe]),ke=(0,v.useCallback)(e=>{J.current?.isEqualNode(e.target)&&(" "!==e.key&&"Enter"!==e.key&&32!==e.keyCode&&13!==e.keyCode||(e.preventDefault(),ve()))},[J,ve]),Te=(0,v.useCallback)(()=>{te({type:"focus"})},[]),xe=(0,v.useCallback)(()=>{te({type:"blur"})},[]),Se=(0,v.useCallback)(()=>{k||(!function(e=window.navigator.userAgent){return function(e){return-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/")}(e)||function(e){return-1!==e.indexOf("Edge/")}(e)}()?ve():setTimeout(ve,0))},[k,ve]),Ce=e=>r?null:e,Pe=e=>T?null:Ce(e),Ae=e=>x?null:Ce(e),Ee=e=>{S&&e.stopPropagation()},Ie=(0,v.useMemo)(()=>({refKey:e="ref",role:t,onKeyDown:i,onFocus:n,onBlur:a,onClick:s,onDragEnter:o,onDragOver:c,onDragLeave:d,onDrop:l,onPaste:u,...h}={})=>{return{onKeyDown:Pe(D(i,ke)),onFocus:Pe(D(n,Te)),onBlur:Pe(D(a,xe)),onClick:Ce(D(s,Se)),onDragEnter:Ae(D(o,me)),onDragOver:Ae(D(c,pe)),onDragLeave:Ae(D(d,ge)),onDrop:Ae(D(l,be)),onPaste:(f=D(u,we),C?null:Ce(f)),role:"string"==typeof t&&""!==t?t:"presentation",[e]:J,...r||T?{}:{tabIndex:0},...r?{"aria-disabled":!0}:{},...h};var f},[J,ke,Te,xe,Se,me,pe,ge,be,we,T,x,C,r]),$e=(0,v.useCallback)(e=>{e.stopPropagation()},[]),_e=(0,v.useMemo)(()=>({refKey:e="ref",onChange:t,onClick:r,...i}={})=>({accept:H,multiple:s,type:"file","aria-label":"file upload",style:{border:0,display:"block",height:0,margin:0,opacity:0,overflow:"hidden",padding:0,width:0},onChange:Ce(D(t,be)),onClick:Ce(D(r,$e)),tabIndex:-1,[e]:Z,...i}),[Z,t,s,be,r]);
1return{...ee,isFocused:re&&!r,getRootProps:Ie,getInputProps:_e,rootRef:J,inputRef:Z,open:Ce(ve)}}function G(e,t){switch(t.type){case"focus":return{...e,isFocused:!0};case"blur":return{...e,isFocused:!1};case"openDialog":return{...q,isFileDialogActive:!0};case"closeDialog":return{...e,isFileDialogActive:!1};case"setDraggedFiles":return{...e,isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject,isDragUnknown:t.isDragUnknown,dragFileRejections:t.dragFileRejections};case"setProcessing":return{...e,isProcessing:t.isProcessing};case"setFiles":return{...e,acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,dragFileRejections:[],isProcessing:!1,isDragReject:!1,isDragUnknown:!1};case"setDragGlobal":return{...e,isDragGlobal:t.isDragGlobal};case"reset":return{...q};default:return e}}function K(){}},36116(e,t,r){"use strict";r.d(t,{Z:()=>At});var i=r(85906);const n={ext:"ext.",country:"Phone number country",phone:"Phone",AC:"Ascension Island",AD:"Andorra",AE:"United Arab Emirates",AF:"Afghanistan",AG:"Antigua and Barbuda",AI:"Anguilla",AL:"Albania",AM:"Armenia",AO:"Angola",AQ:"Antarctica",AR:"Argentina",AS:"American Samoa",AT:"Austria",AU:"Australia",AW:"Aruba",AX:"Ã
land Islands",AZ:"Azerbaijan",BA:"Bosnia and Herzegovina",BB:"Barbados",BD:"Bangladesh",BE:"Belgium",BF:"Burkina Faso",BG:"Bulgaria",BH:"Bahrain",BI:"Burundi",BJ:"Benin",BL:"Saint Barthélemy",BM:"Bermuda",BN:"Brunei Darussalam",BO:"Bolivia",BQ:"Bonaire, Sint Eustatius and Saba",BR:"Brazil",BS:"Bahamas",BT:"Bhutan",BV:"Bouvet Island",BW:"Botswana",BY:"Belarus",BZ:"Belize",CA:"Canada",CC:"Cocos (Keeling) Islands",CD:"Congo, Democratic Republic of the",CF:"Central African Republic",CG:"Congo",CH:"Switzerland",CI:"Cote d'Ivoire",CK:"Cook Islands",CL:"Chile",CM:"Cameroon",CN:"China",CO:"Colombia",CR:"Costa Rica",CU:"Cuba",CV:"Cape Verde",CW:"Curaçao",CX:"Christmas Island",CY:"Cyprus",CZ:"Czech Republic",DE:"Germany",DJ:"Djibouti",DK:"Denmark",DM:"Dominica",DO:"Dominican Republic",DZ:"Algeria",EC:"Ecuador",EE:"Estonia",EG:"Egypt",EH:"Western Sahara",ER:"Eritrea",ES:"Spain",ET:"Ethiopia",FI:"Finland",FJ:"Fiji",FK:"Falkland Islands",FM:"Federated States of Micronesia",FO:"Faroe Islands",FR:"France",GA:"Gabon",GB:"United Kingdom",GD:"Grenada",GE:"Georgia",GF:"French Guiana",GG:"Guernsey",GH:"Ghana",GI:"Gibraltar",GL:"Greenland",GM:"Gambia",GN:"Guinea",GP:"Guadeloupe",GQ:"Equatorial Guinea",GR:"Greece",GS:"South Georgia and the South Sandwich Islands",GT:"Guatemala",GU:"Guam",GW:"Guinea-Bissau",GY:"Guyana",HK:"Hong Kong",HM:"Heard Island and McDonald Islands",HN:"Honduras",HR:"Croatia",HT:"Haiti",HU:"Hungary",ID:"Indonesia",IE:"Ireland",IL:"Israel",IM:"Isle of Man",IN:"India",IO:"British Indian Ocean Territory",IQ:"Iraq",IR:"Iran",IS:"Iceland",IT:"Italy",JE:"Jersey",JM:"Jamaica",JO:"Jordan",JP:"Japan",KE:"Kenya",KG:"Kyrgyzstan",KH:"Cambodia",KI:"Kiribati",KM:"Comoros",KN:"Saint Kitts and Nevis",KP:"North Korea",KR:"South Korea",KW:"Kuwait",KY:"Cayman Islands",KZ:"Kazakhstan",LA:"Laos",LB:"Lebanon",LC:"Saint Lucia",LI:"Liechtenstein",LK:"Sri Lanka",LR:"Liberia",LS:"Lesotho",LT:"Lithuania",LU:"Luxembourg",LV:"Latvia",LY:"Libya",MA:"Morocco",MC:"Monaco",MD:"Moldova",ME:"Montenegro",MF:"Saint Martin (French Part)",MG:"Madagascar",MH:"Marshall Islands",MK:"North Macedonia",ML:"Mali",MM:"Myanmar",MN:"Mongolia",MO:"Macao",MP:"Northern Mariana Islands",MQ:"Martinique",MR:"Mauritania",MS:"Montserrat",MT:"Malta",MU:"Mauritius",MV:"Maldives",MW:"Malawi",MX:"Mexico",MY:"Malaysia",MZ:"Mozambique",NA:"Namibia",NC:"New Caledonia",NE:"Niger",NF:"Norfolk Island",NG:"Nigeria",NI:"Nicaragua",NL:"Netherlands",NO:"Norway",NP:"Nepal",NR:"Nauru",NU:"Niue",NZ:"New Zealand",OM:"Oman",PA:"Panama",PE:"Peru",PF:"French Polynesia",PG:"Papua New Guinea",PH:"Philippines",PK:"Pakistan",PL:"Poland",PM:"Saint Pierre and Miquelon",PN:"Pitcairn",PR:"Puerto Rico",PS:"Palestine",PT:"Portugal",PW:"Palau",PY:"Paraguay",QA:"Qatar",RE:"Reunion",RO:"Romania",RS:"Serbia",RU:"Russia",RW:"Rwanda",SA:"Saudi Arabia",SB:"Solomon Islands",SC:"Seychelles",SD:"Sudan",SE:"Sweden",SG:"Singapore",SH:"Saint Helena",SI:"Slovenia",SJ:"Svalbard and Jan Mayen",SK:"Slovakia",SL:"Sierra Leone",SM:"San Marino",SN:"Senegal",SO:"Somalia",SR:"Suriname",SS:"South Sudan",ST:"Sao Tome and Principe",SV:"El Salvador",SX:"Sint Maarten",SY:"Syria",SZ:"Swaziland",TA:"Tristan da Cunha",TC:"Turks and Caicos Islands",TD:"Chad",TF:"French Southern Territories",TG:"Togo",TH:"Thailand",TJ:"Tajikistan",TK:"Tokelau",TL:"Timor-Leste",TM:"Turkmenistan",TN:"Tunisia",TO:"Tonga",TR:"Turkey",TT:"Trinidad and Tobago",TV:"Tuvalu",TW:"Taiwan",TZ:"Tanzania",UA:"Ukraine",UG:"Uganda",UM:"United States Minor Outlying Islands",US:"United States",UY:"Uruguay",UZ:"Uzbekistan",VA:"Holy See (Vatican City State)",VC:"Saint Vincent and the Grenadines",VE:"Venezuela",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",VN:"Vietnam",VU:"Vanuatu",WF:"Wallis and Futuna",WS:"Samoa",XA:"Abkhazia",XK:"Kosovo",XO:"South Ossetia",YE:"Yemen",YT:"Mayotte",ZA:"South Africa",ZM:"Zambia",ZW:"Zimbabwe",ZZ:"International"};var a=r(65794),s=a.shape({country_calling_codes:a.object.isRequired,countries:a.object.isRequired}),o=a.objectOf(a.string),c=r(79400);function d(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return l(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return l(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function u(e,t){for(var r,i=0,n=d(t.split(""));!(r=n()).done;){r.value===e&&i++}return i}function h(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function m(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"x",r=arguments.length>2?arguments[2]:void 0;if(!e)return function(e){return{text:e}};var i=u(t,e);return function(n){if(!n)return{text:"",template:e};for(var a,s=0,o="",c=h(e.split(""));!(a=c()).done;){var d=a.value;if(d===t){if(o+=n[s],++s===n.length&&n.length<i)break}else o+=d}return r&&(o=function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"x",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:" ",n=e.length,a=u("(",e)-u(")",e);a>0&&n<t.length;)e+=t[n].replace(r,i),")"===t[n]&&a--,n++;return e}(o,e)),{text:o,template:e}}}r.dn(m);var p=8,g=46;function y(e,t){void 0!==t&&(!function(){if("undefined"!=typeof navigator)return b.test(navigator.userAgent)}()?e.setSelectionRange(t,t):setTimeout(function(){return e.setSelectionRange(t,t)},0))}var b=/Android/i;function w(e,t,r,i,n){if(!t.hasAttribute("readonly")){var a=function(e){switch(e.keyCode){case p:return"Backspace";case g:return"Delete"}}(e);switch(a){case"Delete":case"Backspace":e.preventDefault();var s=function(e){if(e.selectionStart!==e.selectionEnd)return{start:e.selectionStart,end:e.selectionEnd}}(t);return s?(v(t,s),k(t,r,i,void 0,n)):k(t,r,i,a,n)}}}function v(e,t){var r=e.value;
1r=r.slice(0,t.start)+r.slice(t.end),e.value=r,y(e,t.start)}function k(e,t,r,i,n){var a=function(e,t,r){for(var i={},n="",a=0,s=0;s<e.length;){var o=r(e[s],n,i);void 0!==o&&(n+=o,void 0!==t&&(t===s?a=n.length-1:t>s&&(a=n.length))),s++}return void 0===t&&(a=n.length),{value:n,caret:a}}(e.value,e.selectionStart,t),s=a.value,o=a.caret;if(i){var c=function(e,t,r){switch(r){case"Backspace":t>0&&(e=e.slice(0,t-1)+e.slice(t),t--);break;case"Delete":e=e.slice(0,t)+e.slice(t+1)}return{value:e,caret:t}}(s,o,i);s=c.value,o=c.caret}var d=function(e,t,r){"string"==typeof r&&(r=m(r));var i=r(e)||{},n=i.text,a=i.template;if(void 0===n&&(n=e),a)if(void 0===t)t=n.length;else{for(var s=0,o=!1,c=-1;s<n.length&&s<a.length;){if(n[s]!==a[s]){if(0===t){o=!0,t=s;break}c=s,t--}s++}o||(t=c+1)}return{text:n,caret:t}}(s,o,r),l=d.text;o=d.caret,e.value=l,y(e,o),n&&n(s)}var T=["ref","parse","format","value","defaultValue","controlled","onChange","onKeyDown"];function x(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?x(Object(r),!0).forEach(function(t){C(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function C(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function P(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r,i,n={},a=Object.keys(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function A(e){var t=e.ref,r=e.parse,n=e.format,a=e.value,s=e.defaultValue,o=e.controlled,c=void 0===o||o,d=e.onChange,l=e.onKeyDown,u=P(e,T),h=(0,i.useRef)(),f=(0,i.useCallback)(function(e){h.current=e,t&&("function"==typeof t?t(e):t.current=e)},[t]),m=(0,i.useCallback)(function(e){k(h.current,r,n,void 0,d)},[h,r,n,d]),p=(0,i.useCallback)(function(e){if(l&&l(e),!e.defaultPrevented)return w(e,h.current,r,n,d)},[h,r,n,d,l]),g=S(S({},u),{},{ref:f,onChange:m,onKeyDown:p});return S(S({},g),{},c?{value:n(E(a)?"":a).text}:{defaultValue:n(E(s)?"":s).text})}function E(e){return null==e}var I=["inputComponent","parse","format","value","defaultValue","onChange","controlled","onKeyDown","type"];function Input_ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function Input_defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Input_objectWithoutProperties(e,t){if(null==e)return{};var r,i,n=function Input_objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,i,n={},a=Object.keys(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Input(e,t){var r=e.inputComponent,n=void 0===r?"input":r,a=e.parse,s=e.format,o=e.value,c=e.defaultValue,d=e.onChange,l=e.controlled,u=e.onKeyDown,h=e.type,f=A(function Input_objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Input_ownKeys(Object(r),!0).forEach(function(t){Input_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Input_ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({ref:t,parse:a,format:s,value:o,defaultValue:c,onChange:d,controlled:l,onKeyDown:u,type:void 0===h?"text":h},Input_objectWithoutProperties(e,I)));return i.createElement(n,f)}
1(Input=i.forwardRef(Input)).propTypes={parse:a.func.isRequired,format:a.func.isRequired,inputComponent:a.elementType,type:a.string,value:a.string,defaultValue:a.string,onChange:a.func,controlled:a.bool,onKeyDown:a.func,onCut:a.func,onPaste:a.func};const $=Input;var _=r(1456),N=r(44835),R=r(88502);function O(e){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},O(e)}function F(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,B(i.key),i)}}function B(e){var t=function(e,t){if("object"!=O(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=O(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==O(t)?t:t+""}var D=function(){return e=function AsYouTypeState(e){var t=e.onCountryChange,r=e.onCallingCodeChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,AsYouTypeState),this.onCountryChange=t,this.onCallingCodeChange=r},(t=[{key:"reset",value:function(e){var t=e.country,r=e.callingCode;this.international=!1,this.missingPlus=!1,this.IDDPrefix=void 0,this.callingCode=void 0,this.digits="",this.resetNationalSignificantNumber(),this.initCountryAndCallingCode(t,r)}},{key:"resetNationalSignificantNumber",value:function(){this.nationalSignificantNumber=this.getNationalDigits(),this.nationalSignificantNumberIsModified=!1,this.nationalPrefix=void 0,this.carrierCode=void 0,this.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix=void 0}},{key:"update",value:function(e){for(var t=0,r=Object.keys(e);t<r.length;t++){var i=r[t];this[i]=e[i]}}},{key:"initCountryAndCallingCode",value:function(e,t){this.setCountry(e),this.setCallingCode(t)}},{key:"setCountry",value:function(e){this.country=e,this.onCountryChange(e)}},{key:"setCallingCode",value:function(e){this.callingCode=e,this.onCallingCodeChange(e,this.country)}},{key:"startInternationalNumber",value:function(e,t){this.international=!0,this.initCountryAndCallingCode(e,t)}},{key:"appendDigits",value:function(e){this.digits+=e}},{key:"appendNationalSignificantNumberDigits",value:function(e){this.nationalSignificantNumber+=e}},{key:"getNationalDigits",value:function(){return this.international?this.digits.slice((this.IDDPrefix?this.IDDPrefix.length:0)+(this.callingCode?this.callingCode.length:0)):this.digits}},{key:"getDigitsWithoutInternationalPrefix",value:function(){return this.international&&this.IDDPrefix?this.digits.slice(this.IDDPrefix.length):this.digits}}])&&F(e.prototype,t),r&&F(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();function AsYouTypeFormatter_util_createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function AsYouTypeFormatter_util_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return AsYouTypeFormatter_util_arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?AsYouTypeFormatter_util_arrayLikeToArray(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function AsYouTypeFormatter_util_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}var M="x",j=new RegExp(M);function L(e,t){if(t<1)return"";for(var r="";t>1;)1&t&&(r+=e),t>>=1,e+=e;return r+e}function U(e,t){return")"===e[t]&&t++,function(e){var t=[],r=0;for(;r<e.length;)"("===e[r]?t.push(r):")"===e[r]&&t.pop(),r++;var i=0,n="";t.push(e.length);for(var a=0,s=t;a<s.length;a++){var o=s[a];n+=e.slice(i,o),i=o+1}return n}(e.slice(0,t))}var z=r(71102),W=r(53148);function V(e,t,r){var i=r.metadata,n=r.shouldTryNationalPrefixFormattingRule,a=r.getSeparatorAfterNationalPrefix;if(new RegExp("^(?:".concat(t.pattern(),")$")).test(e.nationalSignificantNumber))return function(e,t,r){var i=r.metadata,n=r.shouldTryNationalPrefixFormattingRule,a=r.getSeparatorAfterNationalPrefix;e.nationalSignificantNumber,e.international,e.nationalPrefix,e.carrierCode;if(n(t)){var s=q(e,t,{useNationalPrefixFormattingRule:!0,getSeparatorAfterNationalPrefix:a,metadata:i});if(s)return s}return q(e,t,{useNationalPrefixFormattingRule:!1,getSeparatorAfterNationalPrefix:a,metadata:i})}(e,t,{metadata:i,shouldTryNationalPrefixFormattingRule:n,getSeparatorAfterNationalPrefix:a})}function q(e,t,r){var i=r.metadata,n=r.useNationalPrefixFormattingRule,a=r.getSeparatorAfterNationalPrefix,s=(0,W.A)(e.nationalSignificantNumber,t,{carrierCode:e.carrierCode,useInternationalFormat:e.international,withNationalPrefix:n,metadata:i});if(n||(e.nationalPrefix?s=e.nationalPrefix+a(t)+s:e.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix&&(s=e.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix+" "+s)),function(e,t){return(0,z.Ay)(e)===t.getNationalDigits()}(s,e))return s}function AsYouTypeFormatter_PatternParser_typeof(e){return AsYouTypeFormatter_PatternParser_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},AsYouTypeFormatter_PatternParser_typeof(e)}function AsYouTypeFormatter_PatternParser_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];
vendor: 5,189 bytes, line 1
1i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,AsYouTypeFormatter_PatternParser_toPropertyKey(i.key),i)}}function AsYouTypeFormatter_PatternParser_toPropertyKey(e){var t=function AsYouTypeFormatter_PatternParser_toPrimitive(e,t){if("object"!=AsYouTypeFormatter_PatternParser_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=AsYouTypeFormatter_PatternParser_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==AsYouTypeFormatter_PatternParser_typeof(t)?t:t+""}var H=function(){return function AsYouTypeFormatter_PatternParser_createClass(e,t,r){return t&&AsYouTypeFormatter_PatternParser_defineProperties(e.prototype,t),r&&AsYouTypeFormatter_PatternParser_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}(function PatternParser(){!function AsYouTypeFormatter_PatternParser_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,PatternParser)},[{key:"parse",value:function(e){if(this.context=[{or:!0,instructions:[]}],this.parsePattern(e),1!==this.context.length)throw new Error("Non-finalized contexts left when pattern parse ended");var t=this.context[0],r=t.branches,i=t.instructions;if(r)return{op:"|",args:r.concat([X(i)])};if(0===i.length)throw new Error("Pattern is required");return 1===i.length?i[0]:i}},{key:"startContext",value:function(e){this.context.push(e)}},{key:"endContext",value:function(){this.context.pop()}},{key:"getContext",value:function(){return this.context[this.context.length-1]}},{key:"parsePattern",value:function(e){if(!e)throw new Error("Pattern is required");var t=e.match(Y);if(t){var r=t[1],i=e.slice(0,t.index),n=e.slice(t.index+r.length);switch(r){case"(?:":i&&this.parsePattern(i),this.startContext({or:!0,instructions:[],branches:[]});break;case")":if(!this.getContext().or)throw new Error('")" operator must be preceded by "(?:" operator');if(i&&this.parsePattern(i),0===this.getContext().instructions.length)throw new Error('No instructions found after "|" operator in an "or" group');var a=this.getContext().branches;a.push(X(this.getContext().instructions)),this.endContext(),this.getContext().instructions.push({op:"|",args:a});break;case"|":if(!this.getContext().or)throw new Error('"|" operator can only be used inside "or" groups');if(i&&this.parsePattern(i),!this.getContext().branches){if(1!==this.context.length)throw new Error('"branches" not found in an "or" group context');this.getContext().branches=[]}this.getContext().branches.push(X(this.getContext().instructions)),this.getContext().instructions=[];break;case"[":i&&this.parsePattern(i),this.startContext({oneOfSet:!0});break;case"]":if(!this.getContext().oneOfSet)throw new Error('"]" operator must be preceded by "[" operator');this.endContext(),this.getContext().instructions.push({op:"[]",args:G(i)});break;default:throw new Error("Unknown operator: ".concat(r))}n&&this.parsePattern(n)}else{if(K.test(e))throw new Error("Illegal characters found in a pattern: ".concat(e));this.getContext().instructions=this.getContext().instructions.concat(e.split(""))}}}])}();function G(e){for(var t=[],r=0;r<e.length;){if("-"===e[r]){if(0===r||r===e.length-1)throw new Error("Couldn't parse a one-of set pattern: ".concat(e));for(var i=e[r-1].charCodeAt(0)+1,n=e[r+1].charCodeAt(0)-1,a=i;a<=n;)t.push(String.fromCharCode(a)),a++}else t.push(e[r]);r++}return t}var K=/[\(\)\[\]\?\:\|]/,Y=new RegExp("(\\||\\(\\?\\:|\\)|\\[|\\])");function X(e){return 1===e.length?e[0]:e}function AsYouTypeFormatter_PatternMatcher_createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function AsYouTypeFormatter_PatternMatcher_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return AsYouTypeFormatter_PatternMatcher_arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?AsYouTypeFormatter_PatternMatcher_arrayLikeToArray(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function AsYouTypeFormatter_PatternMatcher_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function AsYouTypeFormatter_PatternMatcher_typeof(e){return AsYouTypeFormatter_PatternMatcher_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},AsYouTypeFormatter_PatternMatcher_typeof(e)}function AsYouTypeFormatter_PatternMatcher_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];
1i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,AsYouTypeFormatter_PatternMatcher_toPropertyKey(i.key),i)}}function AsYouTypeFormatter_PatternMatcher_toPropertyKey(e){var t=function AsYouTypeFormatter_PatternMatcher_toPrimitive(e,t){if("object"!=AsYouTypeFormatter_PatternMatcher_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=AsYouTypeFormatter_PatternMatcher_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==AsYouTypeFormatter_PatternMatcher_typeof(t)?t:t+""}var Q=function(){return function AsYouTypeFormatter_PatternMatcher_createClass(e,t,r){return t&&AsYouTypeFormatter_PatternMatcher_defineProperties(e.prototype,t),r&&AsYouTypeFormatter_PatternMatcher_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}(function PatternMatcher(e){!function AsYouTypeFormatter_PatternMatcher_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,PatternMatcher),this.matchTree=(new H).parse(e)},[{key:"match",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).allowOverflow;if(!e)throw new Error("String is required");var r=J(e.split(""),this.matchTree,!0);if(r&&r.match&&delete r.matchedChars,!r||!r.overflow||t)return r}}])}();function J(e,t,r){if("string"==typeof t){var i=e.join("");return 0===t.indexOf(i)?e.length===t.length?{match:!0,matchedChars:e}:{partialMatch:!0}:0===i.indexOf(t)?r&&e.length>t.length?{overflow:!0}:{match:!0,matchedChars:e.slice(0,t.length)}:void 0}if(Array.isArray(t)){for(var n=e.slice(),a=0;a<t.length;){var s=J(n,t[a],r&&a===t.length-1);if(!s)return;if(s.overflow)return s;if(!s.match){if(s.partialMatch)return{partialMatch:!0};throw new Error("Unsupported match result:\n".concat(JSON.stringify(s,null,2)))}if(0===(n=n.slice(s.matchedChars.length)).length)return a===t.length-1?{match:!0,matchedChars:e}:{partialMatch:!0};a++}return r?{overflow:!0}:{match:!0,matchedChars:e.slice(0,e.length-n.length)}}switch(t.op){case"|":for(var o,c,d=AsYouTypeFormatter_PatternMatcher_createForOfIteratorHelperLoose(t.args);!(c=d()).done;){var l=J(e,c.value,r);if(l){if(l.overflow)return l;if(l.match)return{match:!0,matchedChars:l.matchedChars};if(!l.partialMatch)throw new Error("Unsupported match result:\n".concat(JSON.stringify(l,null,2)));o=!0}}return o?{partialMatch:!0}:void 0;case"[]":for(var u,h=AsYouTypeFormatter_PatternMatcher_createForOfIteratorHelperLoose(t.args);!(u=h()).done;){var f=u.value;if(e[0]===f)return 1===e.length?{match:!0,matchedChars:e}:r?{overflow:!0}:{match:!0,matchedChars:[f]}}return;default:throw new Error("Unsupported instruction tree: ".concat(t))}}var Z=r(73820),ee=r(15171);function AsYouTypeFormatter_typeof(e){return AsYouTypeFormatter_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},AsYouTypeFormatter_typeof(e)}function AsYouTypeFormatter_createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function AsYouTypeFormatter_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return AsYouTypeFormatter_arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?AsYouTypeFormatter_arrayLikeToArray(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function AsYouTypeFormatter_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function AsYouTypeFormatter_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];
vendor: 5,666 bytes, line 1
1i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,AsYouTypeFormatter_toPropertyKey(i.key),i)}}function AsYouTypeFormatter_toPropertyKey(e){var t=function AsYouTypeFormatter_toPrimitive(e,t){if("object"!=AsYouTypeFormatter_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=AsYouTypeFormatter_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==AsYouTypeFormatter_typeof(t)?t:t+""}var te=L("9",15),re=/[- ]/,CREATE_CHARACTER_CLASS_PATTERN=function(){return/\[([^\[\]])*\]/g},CREATE_STANDALONE_DIGIT_PATTERN=function(){return/\d(?=[^,}][^,}])/g},ie=new RegExp("["+Z.uD+"]*\\$1["+Z.uD+"]*(\\$\\d["+Z.uD+"]*)*$"),ne=function(){return function AsYouTypeFormatter_createClass(e,t,r){return t&&AsYouTypeFormatter_defineProperties(e.prototype,t),r&&AsYouTypeFormatter_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}(function AsYouTypeFormatter(e){e.state;var t=e.metadata;!function AsYouTypeFormatter_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,AsYouTypeFormatter),this.metadata=t,this.resetFormat()},[{key:"resetFormat",value:function(){this.chosenFormat=void 0,this.template=void 0,this.nationalNumberTemplate=void 0,this.populatedNationalNumberTemplate=void 0,this.populatedNationalNumberTemplatePosition=-1}},{key:"reset",value:function(e,t){this.resetFormat(),e?(this.isNANP="1"===e.callingCode(),this.matchingFormats=e.formats(),t.nationalSignificantNumber&&this.narrowDownMatchingFormats(t)):(this.isNANP=void 0,this.matchingFormats=[])}},{key:"format",value:function(e,t){var r=this;if(function(e,t){return"IS_POSSIBLE"===(0,R.A)(e,void 0,t)}(t.nationalSignificantNumber,this.metadata))for(var i,n=AsYouTypeFormatter_createForOfIteratorHelperLoose(this.matchingFormats);!(i=n()).done;){var a=i.value,s=V(t,a,{metadata:this.metadata,shouldTryNationalPrefixFormattingRule:function(e){return r.shouldTryNationalPrefixFormattingRule(e,{international:t.international,nationalPrefix:t.nationalPrefix})},getSeparatorAfterNationalPrefix:function(e){return r.getSeparatorAfterNationalPrefix(e)}});if(s)return this.resetFormat(),this.chosenFormat=a,this.setNationalNumberTemplate(s.replace(/\d/g,M),t),this.populatedNationalNumberTemplate=s,this.populatedNationalNumberTemplatePosition=this.template.lastIndexOf(M),s}return this.formatNationalNumberWithNextDigits(e,t)}},{key:"formatNationalNumberWithNextDigits",value:function(e,t){var r=this.chosenFormat,i=this.chooseFormat(t);if(i)return i===r?this.formatNextNationalNumberDigits(e):this.formatNextNationalNumberDigits(t.getNationalDigits())}},{key:"narrowDownMatchingFormats",value:function(e){var t=this,r=e.nationalSignificantNumber,i=e.nationalPrefix,n=e.international,a=r,s=a.length-3;s<0&&(s=0),this.matchingFormats=this.matchingFormats.filter(function(e){return t.formatSuits(e,n,i)&&t.formatMatches(e,a,s)}),this.chosenFormat&&-1===this.matchingFormats.indexOf(this.chosenFormat)&&this.resetFormat()}},{key:"formatSuits",value:function(e,t,r){return!(r&&!e.usesNationalPrefix()&&!e.nationalPrefixIsOptionalWhenFormattingInNationalFormat())&&!(!t&&!r&&e.nationalPrefixIsMandatoryWhenFormattingInNationalFormat())}},{key:"formatMatches",value:function(e,t,r){var i=e.leadingDigitsPatterns().length;if(0===i)return!0;r=Math.min(r,i-1);var n=e.leadingDigitsPatterns()[r];if(t.length<3)try{return void 0!==new Q(n).match(t,{allowOverflow:!0})}catch(e){return console.error(e),!0}return new RegExp("^(".concat(n,")")).test(t)}},{key:"getFormatFormat",value:function(e,t){return t?e.internationalFormat():e.format()}},{key:"chooseFormat",value:function(e){for(var t,r=this,i=function(){var i=t.value;return r.chosenFormat===i?0:ie.test(r.getFormatFormat(i,e.international))?r.createTemplateForFormat(i,e)?(r.chosenFormat=i,0):(r.matchingFormats=r.matchingFormats.filter(function(e){return e!==i}),1):1},n=AsYouTypeFormatter_createForOfIteratorHelperLoose(this.matchingFormats.slice());!(t=n()).done&&0!==i(););return this.chosenFormat||this.resetFormat(),this.chosenFormat}},{key:"createTemplateForFormat",value:function(e,t){if(!(e.pattern().indexOf("|")>=0)){var r=this.getTemplateForFormat(e,t);return r?(this.setNationalNumberTemplate(r,t),!0):void 0}}},{key:"getSeparatorAfterNationalPrefix",value:function(e){return this.isNANP||e&&e.nationalPrefixFormattingRule()&&re.test(e.nationalPrefixFormattingRule())?" ":""}},{key:"getInternationalPrefixBeforeCountryCallingCode",value:function(e,t){var r=e.IDDPrefix,i=e.missingPlus;return r?t&&!1===t.spacing?r:r+" ":i?"":"+"}},{key:"getTemplate",value:function(e){if(this.template){for(var t=-1,r=0,i=e.international?this.getInternationalPrefixBeforeCountryCallingCode(e,{spacing:!1}):"";r<i.length+e.getDigitsWithoutInternationalPrefix().length;)t=this.template.indexOf(M,t+1),r++;return U(this.template,t+1)}}},{key:"setNationalNumberTemplate",value:function(e,t){this.nationalNumberTemplate=e,this.populatedNationalNumberTemplate=e,this.populatedNationalNumberTemplatePosition=-1,t.international?this.template=this.getInternationalPrefixBeforeCountryCallingCode(t).replace(/[\d\+]/g,M)+L(M,t.callingCode.length)+" "+e:this.template=e}},{key:"getTemplateForFormat",value:function(e,t){var r=t.nationalSignificantNumber,i=t.international,n=t.nationalPrefix,a=t.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix,s=e.pattern();s=s.replace(CREATE_CHARACTER_CLASS_PATTERN(),"\\d").replace(CREATE_STANDALONE_DIGIT_PATTERN(),"\\d");var o=te.match(s)[0];if(!(r.length>
1o.length)){var c=new RegExp("^"+s+"$"),d=r.replace(/\d/g,"9");c.test(d)&&(o=d);var l,u=this.getFormatFormat(e,i);if(this.shouldTryNationalPrefixFormattingRule(e,{international:i,nationalPrefix:n})){var h=u.replace(W._,e.nationalPrefixFormattingRule());if((0,z.Ay)(e.nationalPrefixFormattingRule())===(n||"")+(0,z.Ay)("$1")&&(u=h,l=!0,n))for(var f=n.length;f>0;)u=u.replace(/\d/,M),f--}var m=o.replace(new RegExp(s),u).replace(new RegExp("9","g"),M);return l||(a?m=L(M,a.length)+" "+m:n&&(m=L(M,n.length)+this.getSeparatorAfterNationalPrefix(e)+m)),i&&(m=(0,ee.A)(m)),m}}},{key:"formatNextNationalNumberDigits",value:function(e){var t=function(e,t,r){for(var i,n=AsYouTypeFormatter_util_createForOfIteratorHelperLoose(r.split(""));!(i=n()).done;){var a=i.value;if(e.slice(t+1).search(j)<0)return;t=e.search(j),e=e.replace(j,a)}return[e,t]}(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition,e);if(t)return this.populatedNationalNumberTemplate=t[0],this.populatedNationalNumberTemplatePosition=t[1],U(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition+1);this.resetFormat()}},{key:"shouldTryNationalPrefixFormattingRule",value:function(e,t){var r=t.international,i=t.nationalPrefix;if(e.nationalPrefixFormattingRule()){var n=e.usesNationalPrefix();if(n&&i||!n&&!r)return!0}}}])}(),ae=r(86453),se=r(24351),oe=r(49175),ce=r(15854);function AsYouTypeParser_typeof(e){return AsYouTypeParser_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},AsYouTypeParser_typeof(e)}function de(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,a,s,o=[],c=!0,d=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(i=a.call(r)).done)&&(o.push(i.value),o.length!==t);c=!0);}catch(e){d=!0,n=e}finally{try{if(!c&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(d)throw n}}return o}}(e,t)||function AsYouTypeParser_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return AsYouTypeParser_arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?AsYouTypeParser_arrayLikeToArray(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function AsYouTypeParser_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function AsYouTypeParser_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,AsYouTypeParser_toPropertyKey(i.key),i)}}function AsYouTypeParser_toPropertyKey(e){var t=function AsYouTypeParser_toPrimitive(e,t){if("object"!=AsYouTypeParser_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=AsYouTypeParser_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==AsYouTypeParser_typeof(t)?t:t+""}var le="["+Z.uD+Z.OA+"]+",ue=new RegExp("^"+le+"$","i"),he="(?:["+Z.tz+"]["+Z.uD+Z.OA+"]*|["+Z.uD+Z.OA+"]+)",fe=new RegExp("[^"+Z.uD+Z.OA+"]+.*$"),me=/[^\d\[\]]/,pe=function(){return function AsYouTypeParser_createClass(e,t,r){return t&&AsYouTypeParser_defineProperties(e.prototype,t),r&&AsYouTypeParser_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}(function AsYouTypeParser(e){var t=e.defaultCountry,r=e.defaultCallingCode,i=e.metadata,n=e.onNationalSignificantNumberChange;!function AsYouTypeParser_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,AsYouTypeParser),this.defaultCountry=t,this.defaultCallingCode=r,this.metadata=i,this.onNationalSignificantNumberChange=n},[{key:"input",value:function(e,t){var r,i=function(e){var t=function(e){var t=function(e){var t,r=e.search(he);
1if(r<0)return;e=e.slice(r),"+"===e[0]&&(t=!0,e=e.slice(1));e=e.replace(fe,""),t&&(e="+"+e);return e}(e)||"";if("+"===t[0])return[t.slice(1),!0];return[t]}(e),r=de(t,2),i=r[0],n=r[1];ue.test(i)||(i="");return[i,n]}(e),n=de(i,2),a=n[0],s=n[1],o=(0,z.Ay)(a);return s&&(t.digits||(t.startInternationalNumber(void 0,void 0),o||(r=!0))),o&&this.inputDigits(o,t),{digits:o,justLeadingPlus:r}}},{key:"inputDigits",value:function(e,t){var r=t.digits,i=r.length<3&&r.length+e.length>=3;if(t.appendDigits(e),i&&this.extractIddPrefix(t),this.isWaitingForCountryCallingCode(t)){if(!this.extractCountryCallingCode(t))return}else t.appendNationalSignificantNumberDigits(e);t.international||this.hasExtractedNationalSignificantNumber||this.extractNationalSignificantNumber(t.getNationalDigits(),function(e){return t.update(e)})}},{key:"isWaitingForCountryCallingCode",value:function(e){var t=e.international,r=e.callingCode;return t&&!r}},{key:"extractCountryCallingCode",value:function(e){var t=(0,ae.A)("+"+e.getDigitsWithoutInternationalPrefix(),e.country,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),r=t.countryCallingCode,i=t.number;if(r)return e.setCallingCode(r),e.update({nationalSignificantNumber:i}),!0}},{key:"reset",value:function(e){if(e){this.hasSelectedNumberingPlan=!0;var t=e._nationalPrefixForParsing();this.couldPossiblyExtractAnotherNationalSignificantNumber=t&&me.test(t)}else this.hasSelectedNumberingPlan=void 0,this.couldPossiblyExtractAnotherNationalSignificantNumber=void 0}},{key:"extractNationalSignificantNumber",value:function(e,t){if(this.hasSelectedNumberingPlan){var r=(0,oe.A)(e,this.metadata),i=r.nationalPrefix,n=r.nationalNumber,a=r.carrierCode;if(n!==e)return this.onExtractedNationalNumber(i,a,n,e,t),!0}}},{key:"extractAnotherNationalSignificantNumber",value:function(e,t,r){if(!this.hasExtractedNationalSignificantNumber)return this.extractNationalSignificantNumber(e,r);if(this.couldPossiblyExtractAnotherNationalSignificantNumber){var i=(0,oe.A)(e,this.metadata),n=i.nationalPrefix,a=i.nationalNumber,s=i.carrierCode;if(a!==t)return this.onExtractedNationalNumber(n,s,a,e,r),!0}}},{key:"onExtractedNationalNumber",value:function(e,t,r,i,n){var a,s=!1,o=i.lastIndexOf(r);if(o<0||o!==i.length-r.length)s=!0;else{var c=i.slice(0,o);c&&c!==e&&(a=c)}n({nationalPrefix:e,carrierCode:t,nationalSignificantNumber:r,nationalSignificantNumberIsModified:s,prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix:a}),this.hasExtractedNationalSignificantNumber=!0,this.onNationalSignificantNumberChange()}},{key:"reExtractNationalSignificantNumber",value:function(e){return!!this.extractAnotherNationalSignificantNumber(e.getNationalDigits(),e.nationalSignificantNumber,function(t){return e.update(t)})||(this.extractIddPrefix(e)||this.fixMissingPlus(e)?(this.extractCallingCodeAndNationalSignificantNumber(e),!0):void 0)}},{key:"extractIddPrefix",value:function(e){var t=e.international,r=e.IDDPrefix,i=e.digits;e.nationalSignificantNumber;if(!t&&!r){var n=(0,ce.A)(i,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata);return void 0!==n&&n!==i?(e.update({IDDPrefix:i.slice(0,i.length-n.length)}),this.startInternationalNumber(e,{country:void 0,callingCode:void 0}),!0):void 0}}},{key:"fixMissingPlus",value:function(e){if(!e.international){var t=(0,se.A)(e.digits,e.country,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata).countryCallingCode;if(t)return e.update({missingPlus:!0}),this.startInternationalNumber(e,{country:e.country,callingCode:t}),!0}}},{key:"startInternationalNumber",value:function(e,t){var r=t.country,i=t.callingCode;e.startInternationalNumber(r,i),e.nationalSignificantNumber&&(e.resetNationalSignificantNumber(),this.onNationalSignificantNumberChange(),this.hasExtractedNationalSignificantNumber=void 0)}},{key:"extractCallingCodeAndNationalSignificantNumber",value:function(e){this.extractCountryCallingCode(e)&&this.extractNationalSignificantNumber(e.getNationalDigits(),function(t){return e.update(t)})}}])}();var ge=r(14843),ye=r(81419),be=r(39408);function AsYouType_typeof(e){return AsYouType_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},AsYouType_typeof(e)}function AsYouType_slicedToArray(e,t){return function AsYouType_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function AsYouType_iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,a,s,o=[],c=!0,d=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(i=a.call(r)).done)&&(o.push(i.value),o.length!==t);c=!0);}catch(e){d=!0,n=e}
1finally{try{if(!c&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(d)throw n}}return o}}(e,t)||function AsYouType_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return AsYouType_arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?AsYouType_arrayLikeToArray(e,t):void 0}}(e,t)||function AsYouType_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function AsYouType_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function AsYouType_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,AsYouType_toPropertyKey(i.key),i)}}function AsYouType_toPropertyKey(e){var t=function AsYouType_toPrimitive(e,t){if("object"!=AsYouType_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=AsYouType_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==AsYouType_typeof(t)?t:t+""}var we=function(){return function AsYouType_createClass(e,t,r){return t&&AsYouType_defineProperties(e.prototype,t),r&&AsYouType_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}(function AsYouType(e,t){!function AsYouType_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,AsYouType),this.metadata=new _.Ay(t);var r=AsYouType_slicedToArray(this.getCountryAndCallingCode(e),2),i=r[0],n=r[1];this.defaultCountry=i,this.defaultCallingCode=n,this.reset()},[{key:"getCountryAndCallingCode",value:function(e){var t,r;return e&&((0,be.A)(e)?(t=e.defaultCountry,r=e.defaultCallingCode):t=e),t&&!this.metadata.hasCountry(t)&&(t=void 0),[t,r]}},{key:"input",value:function(e){var t=this.parser.input(e,this.state),r=t.digits;if(t.justLeadingPlus)this.formattedOutput="+";else if(r){var i;if(this.determineTheCountryIfNeeded(),this.state.nationalSignificantNumber&&this.formatter.narrowDownMatchingFormats(this.state),this.metadata.hasSelectedNumberingPlan()&&(i=this.formatter.format(r,this.state)),void 0===i&&this.parser.reExtractNationalSignificantNumber(this.state)){this.determineTheCountryIfNeeded();var n=this.state.getNationalDigits();n&&(i=this.formatter.format(n,this.state))}this.formattedOutput=i?this.getFullNumber(i):this.getNonFormattedNumber()}return this.formattedOutput}},{key:"reset",value:function(){var e=this;return this.state=new D({onCountryChange:function(t){e.country=t},onCallingCodeChange:function(t,r){e.metadata.selectNumberingPlan(r||t),e.formatter.reset(e.metadata.numberingPlan,e.state),e.parser.reset(e.metadata.numberingPlan)}}),this.formatter=new ne({state:this.state,metadata:this.metadata}),this.parser=new pe({defaultCountry:this.defaultCountry,defaultCallingCode:this.defaultCallingCode,metadata:this.metadata,state:this.state,onNationalSignificantNumberChange:function(){e.determineTheCountryIfNeeded(),e.formatter.reset(e.metadata.numberingPlan,e.state)}}),this.state.reset({country:this.defaultCountry,callingCode:this.defaultCallingCode}),this.formattedOutput="",this}},{key:"isInternational",value:function(){return this.state.international}},{key:"getCallingCode",value:function(){if(this.isInternational())return this.state.callingCode}},{key:"getCountryCallingCode",value:function(){return this.getCallingCode()}},{key:"getCountry",value:function(){if(this.state.digits)return this._getCountry()}},{key:"_getCountry",value:function(){var e=this.state.country;return e}},{key:"determineTheCountryIfNeeded",value:function(){this.state.country&&!this.isCountryCallingCodeAmbiguous()||this.determineTheCountry()}},{key:"getFullNumber",value:function(e){var t=this;if(this.isInternational()){var r=function(e){return t.formatter.getInternationalPrefixBeforeCountryCallingCode(t.state,{spacing:!!e})+e},i=this.state.callingCode;return r(i?e?"".concat(i," ").concat(e):i:"".concat(this.state.getDigitsWithoutInternationalPrefix()))}return e}},{key:"getNonFormattedNationalNumberWithPrefix",value:function(){var e=this.state,t=e.nationalSignificantNumber,r=e.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix,i=e.nationalPrefix,n=t,a=r||i;return a&&(n=a+n),n}},{key:"getNonFormattedNumber",value:function(){var e=this.state.nationalSignificantNumberIsModified;return this.getFullNumber(e?this.state.getNationalDigits():this.getNon
1FormattedNationalNumberWithPrefix())}},{key:"getNonFormattedTemplate",value:function(){var e=this.getNonFormattedNumber();if(e)return e.replace(/[\+\d]/g,M)}},{key:"isCountryCallingCodeAmbiguous",value:function(){var e=this.state.callingCode,t=this.metadata.getCountryCodesForCallingCode(e);return t&&t.length>1}},{key:"determineTheCountry",value:function(){var e=(0,ge.A)(this.isInternational()?this.state.callingCode:this.defaultCallingCode,{nationalNumber:this.state.nationalSignificantNumber,metadata:this.metadata});e!==this.state.country&&(this.state.setCountry(e),e&&this.metadata.selectNumberingPlan(e))}},{key:"getNumberValue",value:function(){var e=this.state,t=e.digits,r=e.callingCode,i=e.country,n=e.nationalSignificantNumber;if(t)return this.isInternational()?r?"+"+r+n:"+"+t:i||r?"+"+(i?this.metadata.countryCallingCode():r)+n:void 0}},{key:"getNumber",value:function(){var e=this.state,t=e.nationalSignificantNumber,r=e.carrierCode,i=e.callingCode;if(t){var n=this._getCountry();if(n||i){if(n&&n===this.defaultCountry){var a=function(e,t,r){var i=r.getCountryCodesForCallingCode(e);if(i.length>1)return(0,ye.A)(t,i,r.metadata)}(this.metadata.numberingPlan.callingCode(),t,this.metadata);a&&(n=a)}var s=new N.A(n||i,t,this.metadata.metadata);return r&&(s.carrierCode=r),s}}}},{key:"isPossible",value:function(){var e=this.getNumber();return!!e&&e.isPossible()}},{key:"isValid",value:function(){var e=this.getNumber();return!!e&&e.isValid()}},{key:"validateLength",value:function(){var e=this.state,t=e.digits,r=e.nationalSignificantNumber;if(!t)return"NOT_A_NUMBER";if(!this.metadata.numberingPlan)return"INVALID_COUNTRY";if(!r)return"TOO_SHORT";var i=(0,R.A)(r,void 0,this.metadata);return"IS_POSSIBLE"!==i?i:void 0}},{key:"getNationalNumber",value:function(){return this.state.nationalSignificantNumber}},{key:"getChars",value:function(){return(this.state.international?"+":"")+this.state.digits}},{key:"getTemplate",value:function(){return this.formatter.getTemplate(this.state)||this.getNonFormattedTemplate()||""}}])}();function ve(e){var t=e.inputFormat,r=e.country,i=e.metadata;return"NATIONAL_PART_OF_INTERNATIONAL"===t?"+".concat((0,_.Ko)(r,i)):""}function ke(e,t){return t&&" "===(e=e.slice(t.length))[0]&&(e=e.slice(1)),e}var Te=r(61853);function xe(e,t,r){if(!r||!r.ignoreRest){return(0,Te.G)(e,t,function(e){if(r&&"end"===e)r.ignoreRest=!0})}}function Se(e){var t=e.onKeyDown,r=e.inputFormat;return(0,i.useCallback)(function(e){e.keyCode===Ce&&"INTERNATIONAL"===r&&e.target instanceof HTMLInputElement&&e.target.selectionStart===Pe.length?e.preventDefault():t&&t(e)},[t,r])}var Ce=8,Pe="+",Ae=["onKeyDown","country","inputFormat","metadata","international","withCountryCallingCode"];function Ee(){return Ee=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Ee.apply(this,arguments)}function InputSmart_objectWithoutProperties(e,t){if(null==e)return{};var r,i,n=function InputSmart_objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,i,n={},a=Object.keys(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const Ie=function(e){function InputSmart(t,r){var n=t.onKeyDown,a=t.country,s=t.inputFormat,o=t.metadata,c=void 0===o?e:o,d=(t.international,t.withCountryCallingCode,InputSmart_objectWithoutProperties(t,Ae)),l=(0,i.useCallback)(function(e){var t=new we(a,c),r=ve({inputFormat:s,country:a,metadata:c}),i=t.input(r+e),n=t.getTemplate();return r&&(i=ke(i,r),n&&(n=ke(n,r))),{text:i,template:n}},[a,c]),u=Se({onKeyDown:n,inputFormat:s});return i.createElement($,Ee({},d,{ref:r,parse:xe,format:l,onKeyDown:u}))}return(InputSmart=i.forwardRef(InputSmart)).propTypes={value:a.string.isRequired,onChange:a.func.isRequired,onKeyDown:a.func,country:a.string,inputFormat:a.oneOf(["INTERNATIONAL","NATIONAL_PART_OF_INTERNATIONAL","NATIONAL","INTERNATIONAL_OR_NATIONAL"]).isRequired,metadata:a.object},InputSmart}();var $e=["value","onChange","onKeyDown","country","inputFormat","metadata","inputComponent","international","withCountryCallingCode"];function InputBasic_extends(){return InputBasic_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},InputBasic_extends.apply(this,arguments)}function InputBasic_objectWithoutProperties(e,t){if(null==e)return{};var r,i,n=function InputBasic_objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,i,n={},a=Object.keys(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const _e=function InputBasic_createInput(e){function InputBasic(t,r){var n=t.value,a=t.onChange,s=t.onKeyDown,o=t.country,c=t.inputFormat,d=t.metadata,l=void 0===d?e:d,u=t.inputComponent,h=void 0===u?"input":u,f=(t.international,t.withCountryCallingCode,InputBasic_objectWithoutProperties(t,$e)),m=ve({inputFormat:c,country:o,metadata:l}),p=(0,i.useCallback)(function(e){var t=(0,Te.A)(e.target.value);t===n&&(0===InputBasic_format(m,t,o,l).indexOf(e.target.value)&&(t=t.
1slice(0,-1)));a(t)},[m,n,a,o,l]),g=Se({onKeyDown:s,inputFormat:c});return i.createElement(h,InputBasic_extends({},f,{ref:r,value:InputBasic_format(m,n,o,l),onChange:p,onKeyDown:g}))}return(InputBasic=i.forwardRef(InputBasic)).propTypes={value:a.string.isRequired,onChange:a.func.isRequired,onKeyDown:a.func,country:a.string,inputFormat:a.oneOf(["INTERNATIONAL","NATIONAL_PART_OF_INTERNATIONAL","NATIONAL","INTERNATIONAL_OR_NATIONAL"]).isRequired,metadata:a.object,inputComponent:a.elementType},InputBasic}();function InputBasic_format(e,t,r,i){return ke(function(e,t,r){return r||(r=t,t=void 0),new we(t,r).input(e)}(e+t,r,i),e)}function Ne(e){return String.fromCodePoint(127397+e.toUpperCase().charCodeAt(0))}var Re=["value","onChange","options","disabled","readOnly"],Oe=["value","options","className","iconComponent","getIconAspectRatio","arrowComponent","unicodeFlags"];function CountrySelect_createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function CountrySelect_unsupportedIterableToArray(e,t){if(!e)return;if("string"==typeof e)return CountrySelect_arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return CountrySelect_arrayLikeToArray(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function CountrySelect_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function CountrySelect_extends(){return CountrySelect_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},CountrySelect_extends.apply(this,arguments)}function CountrySelect_objectWithoutProperties(e,t){if(null==e)return{};var r,i,n=function CountrySelect_objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,i,n={},a=Object.keys(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function CountrySelect(e){var t=e.value,r=e.onChange,n=e.options,a=e.disabled,s=e.readOnly,o=CountrySelect_objectWithoutProperties(e,Re),c=(0,i.useCallback)(function(e){var t=e.target.value;r("ZZ"===t?void 0:t)},[r]);(0,i.useMemo)(function(){return Be(n,t)},[n,t]);return i.createElement("select",CountrySelect_extends({},o,{disabled:a||s,readOnly:s,value:t||"ZZ",onChange:c}),n.map(function(e){var t=e.value,r=e.label,n=e.divider;return i.createElement("option",{key:n?"|":t||"ZZ",value:n?"|":t||"ZZ",disabled:!!n,style:n?Fe:void 0},r)}))}CountrySelect.propTypes={value:a.string,onChange:a.func.isRequired,options:a.arrayOf(a.shape({value:a.string,label:a.string,divider:a.bool})).isRequired,disabled:a.bool,readOnly:a.bool};var Fe={fontSize:"1px",backgroundColor:"currentColor",color:"inherit"};function CountrySelectWithIcon(e){var t,r=e.value,n=e.options,a=e.className,s=e.iconComponent,o=(e.getIconAspectRatio,e.arrowComponent),d=void 0===o?DefaultArrowComponent:o,l=e.unicodeFlags,u=CountrySelect_objectWithoutProperties(e,Oe),h=(0,i.useMemo)(function(){return Be(n,r)},[n,r]);return i.createElement("div",{className:"PhoneInputCountry"},i.createElement(CountrySelect,CountrySelect_extends({},u,{value:r,options:n,className:c("PhoneInputCountrySelect",a)})),h&&(l&&r?i.createElement("div",{className:"PhoneInputCountryIconUnicode"},Ne((t=r)[0])+Ne(t[1])):i.createElement(s,{"aria-hidden":!0,country:r,label:h.label,aspectRatio:l?1:void 0})),i.createElement(d,null))}function DefaultArrowComponent(){return i.createElement("div",{className:"PhoneInputCountrySelectArrow"})}function Be(e,t){for(var r,i=CountrySelect_createForOfIteratorHelperLoose(e);!(r=i()).done;){var n=r.value;if(!n.divider&&De(n.value,t))return n}}function De(e,t){return null==e?null==t:e===t}CountrySelectWithIcon.propTypes={iconComponent:a.elementType,arrowComponent:a.elementType,unicodeFlags:a.bool};var Me=["country","countryName","flags","flagUrl"];function Flag_extends(){return Flag_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Flag_extends.apply(this,arguments)}function Flag_objectWithoutProperties(e,t){if(null==e)return{};var r,i,n=function Flag_objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,i,n={},a=Object.keys(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}
1function FlagComponent(e){var t=e.country,r=e.countryName,n=e.flags,a=e.flagUrl,s=Flag_objectWithoutProperties(e,Me);return n&&n[t]?n[t]({title:r}):i.createElement("img",Flag_extends({},s,{alt:r,role:r?void 0:"presentation",src:a.replace("{XX}",t).replace("{xx}",t.toLowerCase())}))}FlagComponent.propTypes={country:a.string.isRequired,countryName:a.string.isRequired,flags:a.objectOf(a.elementType),flagUrl:a.string.isRequired};var je=["aspectRatio"],Le=["title"],Ue=["title"];function InternationalIcon_extends(){return InternationalIcon_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},InternationalIcon_extends.apply(this,arguments)}function InternationalIcon_objectWithoutProperties(e,t){if(null==e)return{};var r,i,n=function InternationalIcon_objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,i,n={},a=Object.keys(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function InternationalIcon_InternationalIcon(e){var t=e.aspectRatio,r=InternationalIcon_objectWithoutProperties(e,je);return 1===t?i.createElement(InternationalIcon1x1,r):i.createElement(InternationalIcon3x2,r)}function InternationalIcon3x2(e){var t=e.title,r=InternationalIcon_objectWithoutProperties(e,Le);return i.createElement("svg",InternationalIcon_extends({},r,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 75 50"}),i.createElement("title",null,t),i.createElement("g",{className:"PhoneInputInternationalIconGlobe",stroke:"currentColor",fill:"none",strokeWidth:"2",strokeMiterlimit:"10"},i.createElement("path",{strokeLinecap:"round",d:"M47.2,36.1C48.1,36,49,36,50,36c7.4,0,14,1.7,18.5,4.3"}),i.createElement("path",{d:"M68.6,9.6C64.2,12.3,57.5,14,50,14c-7.4,0-14-1.7-18.5-4.3"}),i.createElement("line",{x1:"26",y1:"25",x2:"74",y2:"25"}),i.createElement("line",{x1:"50",y1:"1",x2:"50",y2:"49"}),i.createElement("path",{strokeLinecap:"round",d:"M46.3,48.7c1.2,0.2,2.5,0.3,3.7,0.3c13.3,0,24-10.7,24-24S63.3,1,50,1S26,11.7,26,25c0,2,0.3,3.9,0.7,5.8"}),i.createElement("path",{strokeLinecap:"round",d:"M46.8,48.2c1,0.6,2.1,0.8,3.2,0.8c6.6,0,12-10.7,12-24S56.6,1,50,1S38,11.7,38,25c0,1.4,0.1,2.7,0.2,4c0,0.1,0,0.2,0,0.2"})),i.createElement("path",{className:"PhoneInputInternationalIconPhone",stroke:"none",fill:"currentColor",d:"M12.4,17.9c2.9-2.9,5.4-4.8,0.3-11.2S4.1,5.2,1.3,8.1C-2,11.4,1.1,23.5,13.1,35.6s24.3,15.2,27.5,11.9c2.8-2.8,7.8-6.3,1.4-11.5s-8.3-2.6-11.2,0.3c-2,2-7.2-2.2-11.7-6.7S10.4,19.9,12.4,17.9z"}))}function InternationalIcon1x1(e){var t=e.title,r=InternationalIcon_objectWithoutProperties(e,Ue);return i.createElement("svg",InternationalIcon_extends({},r,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 50 50"}),i.createElement("title",null,t),i.createElement("g",{className:"PhoneInputInternationalIconGlobe",stroke:"currentColor",fill:"none",strokeWidth:"2",strokeLinecap:"round"},i.createElement("path",{d:"M8.45,13A21.44,21.44,0,1,1,37.08,41.56"}),i.createElement("path",{d:"M19.36,35.47a36.9,36.9,0,0,1-2.28-13.24C17.08,10.39,21.88.85,27.8.85s10.72,9.54,10.72,21.38c0,6.48-1.44,12.28-3.71,16.21"}),i.createElement("path",{d:"M17.41,33.4A39,39,0,0,1,27.8,32.06c6.62,0,12.55,1.5,16.48,3.86"}),i.createElement("path",{d:"M44.29,8.53c-3.93,2.37-9.86,3.88-16.49,3.88S15.25,10.9,11.31,8.54"}),i.createElement("line",{x1:"27.8",y1:"0.85",x2:"27.8",y2:"34.61"}),i.createElement("line",{x1:"15.2",y1:"22.23",x2:"49.15",y2:"22.23"})),i.createElement("path",{className:"PhoneInputInternationalIconPhone",stroke:"transparent",fill:"currentColor",d:"M9.42,26.64c2.22-2.22,4.15-3.59.22-8.49S3.08,17,.93,19.17c-2.49,2.48-.13,11.74,9,20.89s18.41,11.5,20.89,9c2.15-2.15,5.91-4.77,1-8.71s-6.27-2-8.49.22c-1.55,1.55-5.48-1.69-8.86-5.08S7.87,28.19,9.42,26.64Z"}))}function ze(e){(function(e){if(e.length<2)return!1;if("+"!==e[0])return!1;for(var t=1;t<e.length;){var r=e.charCodeAt(t);if(!(r>=48&&r<=57))return!1;t++}return!0})(e)||console.error("[react-phone-number-input] Expected the initial `value` to be a E.164 phone number. Got",e)}function We(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return Ve(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ve(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ve(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function qe(e,t){return!!(0,_.J_)(e,t)||(console.error("Country not found: ".concat(e)),!1)}function He(e,t){return e&&0===(e=e.filter(function(e){return qe(e,t)})).length&&(e=void 0),e}function Ge(e){return new _.Ay(e).getCountries()}InternationalIcon_InternationalIcon.propTypes={title:a.string.isRequired,aspectRatio:a.number},InternationalIcon3x2.propTypes={title:a.string.isRequired},InternationalIcon1x1.propTypes={title:a.string.isRequired};
1var Ke=["country","label","aspectRatio"];function CountryIcon_extends(){return CountryIcon_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},CountryIcon_extends.apply(this,arguments)}function CountryIcon_objectWithoutProperties(e,t){if(null==e)return{};var r,i,n=function CountryIcon_objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,i,n={},a=Object.keys(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Ye(e){var t=e.flags,r=e.flagUrl,n=e.flagComponent,s=e.internationalIcon;function CountryIcon(e){var a=e.country,o=e.label,d=e.aspectRatio,l=CountryIcon_objectWithoutProperties(e,Ke),u=s===InternationalIcon_InternationalIcon?d:void 0;return i.createElement("div",CountryIcon_extends({},l,{className:c("PhoneInputCountryIcon",{"PhoneInputCountryIcon--square":1===u,"PhoneInputCountryIcon--border":a})}),a?i.createElement(n,{country:a,countryName:o,flags:t,flagUrl:r,className:"PhoneInputCountryIconImg"}):i.createElement(s,{title:o,aspectRatio:u,className:"PhoneInputCountryIconImg"}))}return CountryIcon.propTypes={country:a.string,label:a.string.isRequired,aspectRatio:a.number},CountryIcon}Ye({flagUrl:"https://purecatamphetamine.github.io/country-flag-icons/3x2/{XX}.svg",flagComponent:FlagComponent,internationalIcon:InternationalIcon_InternationalIcon});function Xe(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return Qe(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Qe(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Qe(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function Je(e,t){for(var r,i=Xe(e);!(r=i()).done;){var n=r.value;n&&Ze(n,t)}}function Ze(e,t){"function"==typeof e?e(t):e.current=t}var et=r(62626);function tt(e,t){return"+"+(0,_.Ko)(e,t)}function rt(e,t){return(0,et.A)(e||"",t)}function it(e,t){var r=t.prevCountry,i=t.newCountry,n=t.metadata,a=t.useNationalFormat;if(r===i)return e;if(!e)return a?"":i?tt(i,n):"";if(i){if("+"===e[0]){if(a)return 0===e.indexOf("+"+(0,_.Ko)(i,n))?function(e,t,r){if(t){var i="+"+(0,_.Ko)(t,r);if(e.length<i.length){if(0===i.indexOf(e))return""}else if(0===e.indexOf(i))return e.slice(i.length)}for(var n=0,a=Object.keys(r.country_calling_codes);n<a.length;n++){var s=a[n];if(1===e.indexOf(s))return e.slice(1+s.length)}return""}(e,i,n):"";if(r){var s=tt(i,n);return 0===e.indexOf(s)?e:s}var o=tt(i,n);return 0===e.indexOf(o)?e:o}}else if("+"!==e[0])return nt(e,r,n)||"";return e}function nt(e,t,r){if(e){if("+"===e[0]){if("+"===e)return;var i=new we(t,r);return i.input(e),i.getNumberValue()}if(t){var n=dt(e,t,r);return"+".concat((0,_.Ko)(t,r)).concat(n||"")}}}function at(e,t,r){var i=dt(e,t,r);if(i){var n=i.length-function(e,t){return t=new _.Ay(t),t.selectNumberingPlan(e),t.numberingPlan.possibleLengths()[t.numberingPlan.possibleLengths().length-1]}(t,r);if(n>0)return e.slice(0,e.length-n)}return e}function st(e,t){var r=t.country,i=t.countries,n=t.defaultCountry,a=t.latestCountrySelectedByUser,s=t.required,o=t.metadata;if("+"===e)return r;var c=function(e,t){var r=new we(null,t);return r.input(e),r.getCountry()}(e,o);if(c)return!i||i.indexOf(c)>=0?c:void 0;if(r)if(lt(e,r,o)){if(a&<(e,a,o))return a;if(n&<(e,n,o))return n;if(!s)return}else if(!s)return;return r}function ot(e,t,r){if(0===e.indexOf(tt(t,r))){var i=new we(t,r);i.input(e);var n=i.getNumber();return n?n.formatNational().replace(/\D/g,""):""}return e.replace(/\D/g,"")}function ct(e,t,r){return String.prototype.localeCompare?e.localeCompare(t,r):e<t?-1:e>t?1:0}function dt(e,t,r){var i=new we(t,r);i.input(e);var n=i.getNumber();return n&&n.nationalNumber}function lt(e,t,r){for(var i=tt(t,r),n=0;n<e.length&&n<i.length;){if(e[n]!==i[n])return!1;n++}return!0}function ut(e){var t=e.value,r=e.phoneNumber,i=e.defaultCountry,n=e.international,a=e.useNationalFormat,s=e.metadata;return(!1===n||a)&&r&&r.country?function(e){return e.formatNational().replace(/\D/g,"")}(r):!t&&n&&i?tt(i,s):t}function ht(e){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ht(e)}function ft(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function mt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?ft(Object(r),!0).forEach(function(t){pt(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ft(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function pt(e,t,r){var i;return i=function(e,t){if("object"!=ht(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=ht(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==ht(i)?i:i+"")in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function gt(e,t){return null===e&&(e=void 0),null===t&&(t=void 0),e===t}var yt=["name","disabled","readOnly","autoComplete","style","className","inputRef","inputComponent","numberInputProps","smartCaret","countrySelectComponent","countrySelectProps","containerComponent","containerComponentProps","defaultCountry","countries","countryOptionsOrder","labels","flags","flagComponent","flagUrl","addInternationalOption","internationalIcon","displayInitialValueAsLocalNumber","initialValueFormat","onCountryChange","limitMaxLength","countryCallingCodeEditable","focusInputOnCountrySelection","reset","metadata","international","locales"];function PhoneInputWithCountry_typeof(e){return PhoneInputWithCountry_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},PhoneInputWithCountry_typeof(e)}function PhoneInputWithCountry_ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function PhoneInputWithCountry_objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?PhoneInputWithCountry_ownKeys(Object(r),!0).forEach(function(t){PhoneInputWithCountry_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):PhoneInputWithCountry_ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function PhoneInputWithCountry_extends(){return PhoneInputWithCountry_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},PhoneInputWithCountry_extends.apply(this,arguments)}function PhoneInputWithCountry_objectWithoutProperties(e,t){if(null==e)return{};var r,i,n=function PhoneInputWithCountry_objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,i,n={},a=Object.keys(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function PhoneInputWithCountry_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,PhoneInputWithCountry_toPropertyKey(i.key),i)}}function bt(e,t,r){return t=vt(t),function(e,t){if(t&&("object"===PhoneInputWithCountry_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,wt()?Reflect.construct(t,r||[],vt(e).constructor):t.apply(e,r))}function wt(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(wt=function(){return!!e})()}function vt(e){return vt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},vt(e)}function kt(e,t){return kt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},kt(e,t)}function PhoneInputWithCountry_defineProperty(e,t,r){return(t=PhoneInputWithCountry_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function PhoneInputWithCountry_toPropertyKey(e){var t=function PhoneInputWithCountry_toPrimitive(e,t){if("object"!=PhoneInputWithCountry_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=PhoneInputWithCountry_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==PhoneInputWithCountry_typeof(t)?t:t+""}var Tt=function(e){function PhoneNumberInput_(e){var t;!function PhoneInputWithCountry_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,PhoneNumberInput_),PhoneInputWithCountry_defineProperty(t=bt(this,PhoneNumberInput_,[e]),"setInputRef",function(e){Je([t.props.inputRef,t.inputRef],e)}),PhoneInputWithCountry_defineProperty(t,"isCountrySupportedWithError",function(e){return qe(e,t.props.metadata)}),PhoneInputWithCountry_defineProperty(t,"onCountryChange",function(e){var r=t.props,i=r.international,n=r.metadata,a=r.onChange,s=r.focusInputOnCountrySelection,o=t.state,c=it(o.phoneDigits,{prevCountry:o.country,newCountry:e,metadata:n,useNationalFormat:!i}),d=nt(c,e,n);s&&t.inputRef.current.focus(),t.setState({country:e,latestCountrySelectedByUser:e,hasUserSelectedACountry:!0,phoneDigits:c,value:d},function(){a(d)})}),PhoneInputWithCountry_defineProperty(t,"onChange",function(e){var r=t.props,i=r.defaultCountry,n=r.onChange,a=r.addInternationalOption,s=r.international,o=r.limitMaxLength,c=r.countryCallingCodeEditable,d=r.metadata,l=t.state,u=l.countries,h=l.phoneDigits,f=l.country,m=l.latestCountrySelectedByUser,p=function(e,t){var r,i=t.prevPhoneDigits,n=t.country,a=t.defaultCountry,s=t.latestCountrySelectedByUser,o=t.countryRequired,c=t.getAnyCountry,d=t.countries,l=t.international,u=t.limitMaxLength,h=t.countryCallingCodeEditable,f=t.metadata;if(l&&!1===h&&n){var m,p=tt(n,f);if(0!==e.indexOf(p))return e&&"+"!==e[0]?m=nt(e=p+e,n,f):e=p,{phoneDigits:e,value:m,country:n}}return!1===l&&n&&e&&"+"===e[0]&&(e=ot(e,n,f)),e&&n&&u&&(e=at(e,n,f)),!e||"+"===e[0]||n&&!l||(e="+"+e),!e&&i&&"+"===i[0]&&(n=l?void 0:a),"+"===e&&i&&"+"===i[0]&&i.length>1&&(n=void 0),e&&(r="+"===e[0]&&("+"===e||n&&0===tt(n,f).indexOf(e))?void 0:nt(e,n,f)),r&&(n=st(r,{country:n,countries:d,defaultCountry:a,latestCountrySelectedByUser:s,required:!1,metadata:f}),!1===l&&n&&e&&"+"===e[0]&&(r=nt(e=ot(e,n,f),n,f))),!n&&o&&(n=a||c()),{phoneDigits:e,country:n,value:r}}(e,{prevPhoneDigits:h,country:f,countryRequired:!a,defaultCountry:i,latestCountrySelectedByUser:m,getAnyCountry:function(){return t.getFirstSupportedCountry({countries:u})},countries:u,international:s,limitMaxLength:o,countryCallingCodeEditable:c,metadata:d}),g=p.phoneDigits,y=p.country,b=p.value,w={phoneDigits:g,value:b,country:y};m&&b&&!lt(b,m,d)&&(w.latestCountrySelectedByUser=void 0),!1===c&&(b||g!==t.state.phoneDigits||(w.forceRerender={})),t.setState(w,function(){return n(b)})}),PhoneInputWithCountry_defineProperty(t,"_onFocus",function(){return t.setState({isFocused:!0})}),PhoneInputWithCountry_defineProperty(t,"_onBlur",function(){return t.setState({isFocused:!1})}),PhoneInputWithCountry_defineProperty(t,"onFocus",function(e){t._onFocus();var r=t.props.onFocus;r&&r(e)}),PhoneInputWithCountry_defineProperty(t,"onBlur",function(e){var r=t.props.onBlur;t._onBlur(),r&&r(e)}),PhoneInputWithCountry_defineProperty(t,"onCountryFocus",function(e){t._onFocus();var r=t.props.countrySelectProps;if(r){var i=r.onFocus;i&&i(e)}}),PhoneInputWithCountry_defineProperty(t,"onCountryBlur",function(e){t._onBlur();var r=t.props.countrySelectProps;if(r){var i=r.onBlur;i&&i(e)}}),t.inputRef=i.createRef();var r=t.props,n=r.value,a=(r.labels,r.international),s=r.addInternationalOption,o=r.displayInitialValueAsLocalNumber,c=r.initialValueFormat,d=r.metadata,l=t.props,u=l.defaultCountry,h=l.countries;u&&(t.isCountrySupportedWithError(u)||(u=void 0)),n&&ze(n),h=He(h,d);var f=rt(n,d);t.CountryIcon=Ye(t.props);var m=function(e){var t,r=e.value,i=e.phoneNumber,n=e.defaultCountry,a=e.getAnyCountry,s=e.countries,o=e.required,
1c=e.metadata;return i&&i.country?t=i.country:n&&(r&&!lt(r,n,c)||(t=n)),s&&s.indexOf(t)<0&&(t=void 0),!t&&o&&s&&s.length>0&&(t=a()),t}({value:n,phoneNumber:f,defaultCountry:u,required:!s,countries:h||Ge(d),getAnyCountry:function(){return t.getFirstSupportedCountry({countries:h})},metadata:d});return t.state={props:t.props,country:m,countries:h,phoneDigits:ut({value:n,phoneNumber:f,defaultCountry:u,international:a,useNationalFormat:o||"national"===c,metadata:d}),value:n},t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&kt(e,t)}(PhoneNumberInput_,e),function PhoneInputWithCountry_createClass(e,t,r){return t&&PhoneInputWithCountry_defineProperties(e.prototype,t),r&&PhoneInputWithCountry_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}(PhoneNumberInput_,[{key:"componentDidMount",value:function(){var e=this.props.onCountryChange,t=this.props.defaultCountry,r=this.state.country;e&&(t&&(this.isCountrySupportedWithError(t)||(t=void 0)),r!==t&&e(r))}},{key:"componentDidUpdate",value:function(e,t){var r=this.props.onCountryChange,i=this.state.country;r&&i!==t.country&&r(i)}},{key:"getCountrySelectOptions",value:function(e){var t=e.countries,r=this.props,i=r.international,n=r.countryCallingCodeEditable,a=r.countryOptionsOrder,s=r.addInternationalOption,o=r.labels,c=r.locales,d=r.metadata;return this.useMemoCountrySelectOptions(function(){return function(e,t){if(!t)return e;for(var r,i=[],n=[],a=i,s=function(){var t=r.value;if("|"===t)a.push({divider:!0});else if("..."===t||"â¦"===t)a=n;else{var i;i="ð"===t?void 0:t;var s=e.indexOf(e.filter(function(e){return e.value===i})[0]),o=e[s];e.splice(s,1),a.push(o)}},o=We(t);!(r=o()).done;)s();return i.concat(e).concat(n)}(function(e){var t=e.countries,r=e.countryNames,i=e.addInternationalOption,n=e.compareStringsLocales,a=e.compareStrings;a||(a=ct);var s=t.map(function(e){return{value:e,label:r[e]||e}});return s.sort(function(e,t){return a(e.label,t.label,n)}),i&&s.unshift({label:r.ZZ}),s}({countries:t||Ge(d),countryNames:o,addInternationalOption:(!i||!1!==n)&&s,compareStringsLocales:c}),function(e,t){if(e&&(e=e.filter(function(e){switch(e){case"ð":case"|":case"...":case"â¦":return!0;default:return qe(e,t)}})).length>0)return e}(a,d))},[t,a,s,o,d])}},{key:"useMemoCountrySelectOptions",value:function(e,t){return this.countrySelectOptionsMemoDependencies&&function(e,t){if(e.length!==t.length)return!1;var r=0;for(;r<e.length;){if(e[r]!==t[r])return!1;r++}return!0}(t,this.countrySelectOptionsMemoDependencies)||(this.countrySelectOptionsMemo=e(),this.countrySelectOptionsMemoDependencies=t),this.countrySelectOptionsMemo}},{key:"getFirstSupportedCountry",value:function(e){var t=e.countries;return this.getCountrySelectOptions({countries:t})[0].value}},{key:"render",value:function(){var e=this.props,t=e.name,r=e.disabled,n=e.readOnly,a=e.autoComplete,s=e.style,o=e.className,d=(e.inputRef,e.inputComponent),l=e.numberInputProps,u=e.smartCaret,h=e.countrySelectComponent,f=e.countrySelectProps,m=e.containerComponent,p=e.containerComponentProps,g=(e.defaultCountry,e.countries,e.countryOptionsOrder,e.labels),y=(e.flags,e.flagComponent,e.flagUrl,e.addInternationalOption,e.internationalIcon,e.displayInitialValueAsLocalNumber,e.initialValueFormat,e.onCountryChange,e.limitMaxLength,e.countryCallingCodeEditable,e.focusInputOnCountrySelection,e.reset,e.metadata),b=e.international,w=(e.locales,PhoneInputWithCountry_objectWithoutProperties(e,yt)),v=this.state,k=v.country,T=v.countries,x=v.phoneDigits,S=v.isFocused,C=u?Ie:_e,P=this.getCountrySelectOptions({countries:T});return i.createElement(m,PhoneInputWithCountry_extends({style:s,className:c(o,"PhoneInput",{"PhoneInput--focus":S,"PhoneInput--disabled":r,"PhoneInput--readOnly":n})},p),i.createElement(h,PhoneInputWithCountry_extends({name:t?"".concat(t,"Country"):void 0,"aria-label":g.country},f,{value:k,options:P,onChange:this.onCountryChange,onFocus:this.onCountryFocus,onBlur:this.onCountryBlur,disabled:r||f&&f.disabled,readOnly:n||f&&f.readOnly,iconComponent:this.CountryIcon})),i.createElement(C,PhoneInputWithCountry_extends({ref:this.setInputRef,type:"tel",autoComplete:a},l,w,{inputFormat:!0===b?"INTERNATIONAL":!1===b?"NATIONAL":"INTERNATIONAL_OR_NATIONAL",international:!!b||void 0,withCountryCallingCode:!!b||void 0,name:t,metadata:y,country:k,value:x||"",onChange:this.onChange,onFocus:this.onFocus,onBlur:this.onBlur,disabled:r,readOnly:n,inputComponent:d,className:c("PhoneInputInput",l&&l.className,w.className)})))}}],[{key:"getDerivedStateFromProps",value:function(e,t){return PhoneInputWithCountry_objectSpread({props:e},function(e,t,r){var i=e.metadata,n=e.countries,a=e.defaultCountry,s=e.value,o=e.reset,c=e.international,d=e.displayInitialValueAsLocalNumber,l=e.initialValueFormat,u=t.defaultCountry,h=t.value,f=t.reset,m=(r.country,r.value),p=r.hasUserSelectedACountry,g=r.latestCountrySelectedByUser,y=function(e){return ut(mt(mt({},e),{},{international:c,useNationalFormat:d||"national"===l,metadata:i}))};if(o!==f)return{phoneDigits:y({value:void 0,defaultCountry:a}),value:void 0,country:a,latestCountrySelectedByUser:void 0,hasUserSelectedACountry:void 0};if(a!==u){var b=!a||qe(a,i),w=!m||c&&m===y({value:void 0,defaultCountry:u});if(!p&&b&&!s&&w)return{country:a,phoneDigits:y({value:void 0,defaultCountry:a}),value:void 0}}if(!gt(s,h)&&!gt(s,m)){var v,k,T;if(s){s&&ze(s),v=rt(s,i);var x=He(n,i);v&&v.country?(!x||x.indexOf(v.country)>=0)&&(k=v.country):(k=st(s,{country:void 0,countries:x,metadata:i}
1))||a&&0===s.indexOf(tt(a,i))&&(k=a)}return s?g&&((k?g===k:lt(s,g,i))?k||(k=g):T={latestCountrySelectedByUser:void 0}):T={latestCountrySelectedByUser:void 0,hasUserSelectedACountry:void 0},mt(mt({},T),{},{phoneDigits:y({phoneNumber:v,value:s,defaultCountry:a}),value:s,country:s?k:a})}}(e,t.props,t))}}])}(i.PureComponent),xt=i.forwardRef(function(e,t){return i.createElement(Tt,PhoneInputWithCountry_extends({},function(e){for(var t in e=PhoneInputWithCountry_objectSpread({},e),St)void 0===e[t]&&(e[t]=St[t]);return e}(e),{inputRef:t}))});xt.propTypes={value:a.string,onChange:a.func.isRequired,onFocus:a.func,onBlur:a.func,disabled:a.bool,readOnly:a.bool,autoComplete:a.string,initialValueFormat:a.oneOf(["national"]),displayInitialValueAsLocalNumber:a.bool,defaultCountry:a.string,countries:a.arrayOf(a.string),labels:o,locales:a.oneOfType([a.string,a.arrayOf(a.string)]),flagUrl:a.string,flags:a.objectOf(a.elementType),flagComponent:a.elementType,addInternationalOption:a.bool,internationalIcon:a.elementType,countryOptionsOrder:a.arrayOf(a.string),style:a.object,className:a.string,countrySelectComponent:a.elementType,countrySelectProps:a.object,inputComponent:a.elementType,numberInputProps:a.object,containerComponent:a.elementType,containerComponentProps:a.object,smartCaret:a.bool,international:a.bool,limitMaxLength:a.bool,countryCallingCodeEditable:a.bool,metadata:s,onCountryChange:a.func,focusInputOnCountrySelection:a.bool};var St={autoComplete:"tel",countrySelectComponent:CountrySelectWithIcon,flagComponent:FlagComponent,flagUrl:"https://purecatamphetamine.github.io/country-flag-icons/3x2/{XX}.svg",internationalIcon:InternationalIcon_InternationalIcon,inputComponent:"input",containerComponent:"div",reset:a.any,smartCaret:!0,addInternationalOption:!0,countryCallingCodeEditable:!0,focusInputOnCountrySelection:!0};const Ct=xt;var Pt=["metadata","labels"];function PhoneInputWithCountryDefault_extends(){return PhoneInputWithCountryDefault_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},PhoneInputWithCountryDefault_extends.apply(this,arguments)}function PhoneInputWithCountryDefault_objectWithoutProperties(e,t){if(null==e)return{};var r,i,n=function PhoneInputWithCountryDefault_objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,i,n={},a=Object.keys(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function At(e){var t=i.forwardRef(function(t,r){var a=t.metadata,s=void 0===a?e:a,o=t.labels,c=void 0===o?n:o,d=PhoneInputWithCountryDefault_objectWithoutProperties(t,Pt);return i.createElement(Ct,PhoneInputWithCountryDefault_extends({},d,{ref:r,metadata:s,labels:c}))});return t.propTypes={metadata:s,labels:o},t}At()}}]); 2//# sourceMappingURL=public-containers-WriteReview-components-GlobalWriteReviewForm_a23bb929.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.