UNPKG

@nutrient-sdk/viewer

Version:

View and annotate PDF files in your web app. Full support for mobile and desktop. Runs in the browser using WASM.

13 lines 60.6 kB
/*! * Nutrient Web SDK 1.15.1 (https://www.nutrient.io/sdk/web) * * Copyright (c) 2016-2026 PSPDFKit GmbH. All rights reserved. * * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. * This notice may not be removed from this file. * * PSPDFKit uses several open source third-party components: https://www.nutrient.io/legal/acknowledgements/web-acknowledgements/ */ "use strict";(globalThis.webpackChunkNutrientViewer=globalThis.webpackChunkNutrientViewer||[]).push([[750],{99282(e,t,r){r.r(t),r.d(t,{default:()=>Z});var n=r(34724),s=r(57191),o=r(89339),i=r(71530),a=r(84008),l=r(93688),c=r(86177),u=r(70274),h=r(79065),d=r(62389),p=r(29655),m=r(52041),f=r(27013),E=r(43775),g=r(9855);class w extends(s.mS({authPayload:null,serverUrl:null,hostedBaseUrl:null,documentId:null,layerName:null,sourcePdfSha256:null,backendPermissions:null,documentURL:null,imageToken:null,instantSettings:null,token:null,features:(0,s.B8)(),signatureFeatureAvailability:g.g.NONE,isFormsEnabled:!0,minSearchQueryLength:1,documentHandle:null,isDocumentHandleOutdated:!1,digitalSignatures:null,defaultGroup:void 0,hasCollaborationPermissions:!1,forceLegacySignaturesFeature:!1,disableWebAssemblyStreaming:!1,overrideMemoryLimit:null,baseCoreUrl:null,useDeprecatedRestProvider:!1,canvasRendering:!1})){}var y=r(41417),R=r(21428),v=r(92182),$=r(63620),I=r(23264),S=r(4689),A=r(66531);const b="The image can not be rendered because of an unknown error.";class P{constructor(e){let{identifier:t,url:r,authModule:s,payload:o,doNotRequestWebP:i=!1}=e;(0,n.A)(this,"_abortController",null),(0,n.A)(this,"aborted",!1),this.identifier=t,this.url=r,this.authModule=s,this.payload=o,this.doNotRequestWebP=i}abort(){this.aborted=!0,this._abortController?.abort(),this.httpRequest?.abort()}request(){var e=this;this.aborted=!1;const t=async function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const n=await(0,R.k)(e.authModule.getAuthState(),t=>{e._abortController=t});if(e.aborted)throw new DOMException("Aborted","AbortError");const s=n.imageToken;return new Promise((n,i)=>{const a=new XMLHttpRequest;e.httpRequest=a,a.open(e.payload?"POST":"GET",e.url,!0),a.setRequestHeader("X-PSPDFKit-Image-Token",s),a.setRequestHeader("PSPDFKit-Platform","web"),a.setRequestHeader("PSPDFKit-Version",(0,I._q)()),v.xd&&!e.doNotRequestWebP&&a.setRequestHeader("Accept","image/webp,*/*"),a.responseType="blob",a.onreadystatechange=(async()=>{if(4!==a.readyState)return;if(a.response&&a.response.type.startsWith("application/json")){const s=new FileReader;return s.onload=async s=>{const l=s.target?.result,c=JSON.parse(l);if(0!==r||(0,y.Nk)(a.status)||!A.r.isAuthFailure(a.status,l))c.attachments_not_found?n({attachmentsNotFound:c.attachments_not_found}):c.error?"initialization_error"===c.error?n(null):i(new o.uE(`The server could not render the requested image (${c.error})`)):i(new o.uE(b));else try{if(await e.authModule.refresh(),e.aborted)return void i(new DOMException("Aborted","AbortError"));const r=await t(1);n(r)}catch(e){i(e)}},s.onerror=()=>i(new o.uE(b)),void s.readAsText(a.response)}if(!(0,y.Nk)(a.status)){const s=a.response;let l="";if(s)try{l="function"==typeof s.text?await s.text():""}catch{l=""}return void(0===r&&A.r.isAuthFailure(a.status,l)?e.authModule.refresh().then(()=>{if(e.aborted)throw new DOMException("Aborted","AbortError");return t(1)}).then(n).catch(i):i(new o.uE(b)))}const s=a.response,l=URL.createObjectURL(s),c=new Image;c.onerror=()=>i(new o.uE(b)),c.src=l;const u=c.decode();try{await u}catch(e){if(!S.H8)throw new o.uE(`The image could not be decoded: ${e.message}`);await new Promise(e=>setTimeout(e,200))}n(new $.A(c,()=>URL.revokeObjectURL(l)))}).bind(e),a.send(e.payload)})};return t()}}var _=r(53379),N=r(45252),L=r(22019),T=r(90939),O=r(53276);var F=r(61493),C=r(2090),D=r(70402),x=r(99802),U=r(67880),M=r(5386),j=r(77112),k=r(90037),G=r(98046),V=r(99819),B=r(74129),H=r(80874),X=r(61469),q=r(28805),z=r(600),W=r(39515),J=r(82725),K=r(19896);const Y=["ERR_HTTP2_PROTOCOL_ERROR","ERR_CONTENT_LENGTH_MISMATCH","NS_ERROR_NET_INTERRUPT","NS_ERROR_NET_RESET","NS_BINDING_ABORTED","Load failed","NetworkError"];function Q(e){const t=e instanceof Error?e.message:String(e);return Y.some(e=>t.includes(e))}class Z extends M.K{constructor(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window;super(),t=this,(0,n.A)(this,"_password",null),(0,n.A)(this,"_authModule",null),(0,n.A)(this,"type","SERVER"),(0,n.A)(this,"_requestRenderAnnotation",(e,r,n,s,i,l,c)=>{const u=`${this._state.documentURL}/render_annotation`,h=`render-annotation-${l?(0,a.Z0)():e.id}`,d=JSON.stringify({data:(0,m.eq)(e),width:s,height:i,detached:l||void 0,formFieldValue:r?(0,m.cA)(r):void 0,render_form_highlight:void 0===c||c});let p=!1,f=[];const E=(0,K.yl)();let g;if((0,N.cu)(e)){if(g=(0,N.sS)(e),this.isVisuallyIdenticalAnnotationCached({annotation:e,providedVisualAnnotationIndex:g,width:s,height:i}))return this.cachedRenderedAnnotationDiscardablePromise(g,E);this._addCachedRenderedAnnotation(g,{width:s,height:i,noZoom:e.noZoom,APStreamPromise:E.promise})}const w=function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const a=new FormData;a.append("render",d),r.length>0&&"imageAttachmentId"in e&&e.imageAttachmentId&&n&&a.append(e.imageAttachmentId,n),r.length>0&&"widgetAttachmentId"in e&&e.widgetAttachmentId&&n&&a.append(e.widgetAttachmentId,n),(0,o.V1)(t._authModule,"AuthModule must be initialized before renderAnnotation");const l=new P({identifier:h,url:u,authModule:t._authModule,payload:a,doNotRequestWebP:s>_.HI||i>_.HI}),c=t._requestQueue.enqueue(l,!1);c.promise.then(r=>{if(p)return;if(r&&"object"==typeof r&&"attachmentsNotFound"in r&&Array.isArray(r.attachmentsNotFound))return void w(r.attachmentsNotFound);const n=r;return(0,N.cu)(e)&&t._makeEnqueuedRelease(n??null,g),E.resolve(n??void 0),n}).catch(e=>{const r=t._cachedRenderedAnnotations.get(g);r?.timeout&&clearTimeout(r.timeout),t._cachedRenderedAnnotations.delete(g),p?E.resolve(void 0):E.reject(e)}),f.push(c)};return w(),{promise:E.promise,cancel:()=>{p=!0,f.forEach(e=>{e.cancel()})}}}),(0,n.A)(this,"_requestRenderAnnotations",(e,t,r,n,s)=>{const o=`${this._state.documentURL}/render_annotations`,i=JSON.stringify({annotations:t.map((t,s)=>({pageIndex:e,pdfObjectId:t,width:r[s],height:n[s]})),formFieldValues:s});let a,l,c=!1;const u=new Promise((e,t)=>{a=e,l=t});return this._fetch(o,{method:"post",body:i,credentials:"include",useImageToken:!0,headers:{"Content-Type":"application/json",Accept:"multipart/form-data"}}).then(e=>e.formData()).then(e=>{c||a(Array.from(e.values()))}).catch(e=>{c||l(e)}),{promise:u,cancel:()=>{c=!0}}}),(0,n.A)(this,"handleDocumentHandleConflict",()=>{this._state=this._state.set("isDocumentHandleOutdated",!0),this.cancelRequests(),this._destroyProvider()});let s=null;if("session"in e){if("string"!=typeof e.session)throw new o.uE("The supplied session token is invalid. Must be a string.");s={jwt:e.session},e.instant=!("instant"in e)||"boolean"!=typeof e.instant&&!(0,o.Qd)(e.instant)||e.instant}else"authPayload"in e&&e.authPayload&&(s=e.authPayload);if("object"!=typeof s)throw new o.uE("authPayload must be an object that contains the `jwt`. For example: `authPayload: { jwt: 'xxx.xxx.xxx'}`");const l=s?.accessToken;let c=null,u=null,h="documentId"in e?e.documentId:null,d=null;if(l)d=e.hostedBaseUrl||"https://api.pspdfkit.com/",(0,y.Me)(d),(0,f.P1)(l);else{if(!s||"object"!=typeof s||!("jwt"in s)||"string"!=typeof s.jwt)throw new o.uE("authPayload must be an object that contains the `jwt`. For example: `authPayload: { jwt: 'xxx.xxx.xxx'}`");const{serverUrl:t,documentId:n}=(0,f.Gm)(s.jwt);if(c=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window;const n=e.serverUrl||t||(0,I.$_)(r.document);if("/"!==n.substr(-1))throw new o.uE("`serverUrl` must have a slash at the end (e.g. `https://pspdfkit.example.com/`).");if(!e.serverUrl&&n===(0,y.ln)(r.location.origin))throw new o.uE('NutrientViewer automatically infers the URL of Nutrient Document Engine from the current `<script>` tag.\nIn the current case, this URL is set to the same as the current browser\'s location.\nThis can happen when you bundle nutrient-viewer.js with your custom JavaScript for example.\n\nTo make sure everything works as expected, please set the `serverUrl` to the URL of Nutrient Document Engine:\n\nNutrientViewer.load({\n serverUrl: "https://pspdfkit-server.example.com/",\n ...,\n});');return n}(e,t,r),h=h||n,"string"!=typeof h)throw new o.uE("`documentId` must be of type string.");u=`${c}i/d/${h}`}!function(e){let t="";if("boolean"!=typeof e&&((0,o.Qd)(e)?(e.hasOwnProperty("clientsPresenceEnabled")&&"boolean"!=typeof e.clientsPresenceEnabled&&(t+="`clientsPresenceEnabled` in instance settings is not valid. Must be `true` or `false`.\n"),e.hasOwnProperty("listenToServerChangesEnabled")&&"boolean"!=typeof e.listenToServerChangesEnabled&&(t+="`listenToServerChangesEnabled` in instance settings is not valid. Must be `true` or `false`.\n")):t="`instant` flag must either be set to `true` or `false`\n",t))throw new o.uE(`${t}\nFor more information about Nutrient Instant please visit:\nwww.nutrient.io/guides/web/instant/overview/`)}(e.instant);let p=null;if(e.instant)if((0,o.Qd)(e.instant)){const t=e.instant;p={clientsPresenceEnabled:!1!==t.clientsPresenceEnabled,listenToServerChangesEnabled:!1!==t.listenToServerChangesEnabled}}else p=D.S;this._requestQueue=new i.L(_.LB),this._onAuthFailed=e.onAuthFailed;const E=!!e.electronicSignatures&&Boolean(e.electronicSignatures.forceLegacySignaturesFeature),g=e.baseUrl||(0,I.$_)(window.document),R=e.baseCoreUrl||g;this._state=new w({serverUrl:c,hostedBaseUrl:d,documentId:h,instantSettings:p,documentURL:u,authPayload:s,isFormsEnabled:!e.disableForms,forceLegacySignaturesFeature:E,disableWebAssemblyStreaming:e.disableWebAssemblyStreaming,overrideMemoryLimit:e.overrideMemoryLimit,baseCoreUrl:R,useDeprecatedRestProvider:e.useDeprecatedRestProvider,canvasRendering:e.canvasRendering??!1}),e.useDeprecatedRestProvider&&(0,o.R8)("Token refresh (setSession, onAuthFailed) is not supported when using the deprecated REST provider. Use the default Instant provider for token refresh."),"trustedCAsCallback"in e&&e.trustedCAsCallback&&(0,o.R8)("NutrientViewer.Configuration#trustedCAsCallback is only used on Standalone deployments. On a Server-Backed deployment, please follow the instructions at https://www.nutrient.io/guides/web")}isUsingInstantProvider(){return!this._state.useDeprecatedRestProvider}setSession(e){this._authModule&&this._authModule.setSession(e)}hasClientsPresence(){const e=this._state.instantSettings;return null!=e&&!1!==e.clientsPresenceEnabled}async load(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};await this.tryAuthenticateHostedViewer();const t=await(0,F.Q)(`${this._state.serverUrl}i/d/${this._state.documentId}`,this._state.authPayload,e.password,e.signal);this._authModule=new A.r({serverUrl:this._state.serverUrl,documentId:this._state.documentId,authPayload:this._state.authPayload,password:e.password,onAuthFailed:this._onAuthFailed,onAuthStateUpdated:e=>{this._state=this._state.set("authPayload",e.authPayload);const t=this._state.documentHandle;e.layerHandle===t?this._state=this._state.set("documentURL",e.documentURL).set("documentHandle",e.layerHandle):this.handleDocumentHandleConflict()}}),this._authModule.initializeWithAuthResponse(t);const{imageToken:r,token:n,permissions:i,features:a,signatureFeatureAvailability:h,hasPassword:d,minSearchQueryLength:p,layerHandle:f,allowedTileScales:E,digitalSignatures:w,defaultGroup:y,collaborationPermissions:R,creatorName:v,documentEngineVersion:$,layerName:S,sourcePdfSha256:b}=t;this._password=e.password;const P=(0,l.valid)((0,l.coerce)($));if(this.documentEngineVersion=P,!this.satisfiesDocumentEngineVersion(">=1.5.6"))throw new o.uE(`Document Engine version ${$} does not meet minimum required version requirement >=1.5.6.`);if(this._state.instantSettings&&!a.includes(V.Y.INSTANT))throw new o.uE("Instant feature is not enabled on this server. Please set `instant` to `false`.\n\nFor more information about Nutrient Instant please visit:\nwww.nutrient.io/guides/web/instant/overview/");if(this._state.useDeprecatedRestProvider&&this._state.instantSettings)throw new o.uE("Instant feature can't be enabled together with using deprecated REST provider. Please set either `instant` or `useDeprecatedRestProvider` to `false`.\n\nFor more information about Nutrient Instant please visit:\nwww.nutrient.io/guides/web/instant/overview/");const _=!a.includes(V.Y.INSTANT)&&!this.satisfiesDocumentEngineVersion(">=1.7.0"),N=h===g.g.ELECTRONIC_SIGNATURES&&(0,q.UX)(a)&&this._state.forceLegacySignaturesFeature?g.g.LEGACY_SIGNATURES:h;this._state=this._state.withMutations(e=>e.set("imageToken",r).set("token",n).set("features",(0,s.B8)(a)).set("signatureFeatureAvailability",N).set("backendPermissions",new O.A({readOnly:-1===i.indexOf("write"),downloadingAllowed:i.indexOf("download")>=0})).set("documentURL",`${this._state.serverUrl}i/d/${this._state.documentId}/h/${f}`).set("documentHandle",f).set("isDocumentHandleOutdated",!1).set("digitalSignatures",(0,m.N5)(w)).set("layerName",S).set("sourcePdfSha256",b).set("useDeprecatedRestProvider",_||e.useDeprecatedRestProvider));(0,o.V1)(this._authModule,"AuthModule must be initialized before CorePDFDocument");const L=this._authModule;if(this.corePDFDocument=new J.N({corePDFAccessGetter:async()=>{const t=B.mG.checkOut().object,r=(0,I.f)(null),n=await(0,F.Q)(`${this._state.serverUrl}i/d/${this._state.documentId}`,this._state.authPayload,e.password);(0,o.V1)(n.wasmToken,"No wasmToken was returned from the server."),(0,o.V1)(this._state.baseCoreUrl),await t.loadNativeModule(this._state.baseCoreUrl,{mainThreadOrigin:r,disableWebAssemblyStreaming:this._state.disableWebAssemblyStreaming,enableAutomaticLinkExtraction:!1,overrideMemoryLimit:this._state.overrideMemoryLimit,workerSpawnerFn:()=>c.pj(!0)}).then(async()=>{t.load("",n.wasmToken,{mainThreadOrigin:r,productId:null})}),(0,o.V1)(t.workerSpawner,"Core workerSpawner is not initialized.");const s=t.workerSpawner.getWorker();return(0,o.V1)(s,"Core worker is not initialized."),u.LV(s)},canvasRendering:this._state.canvasRendering},{type:"serverDocument",documentId:this._state.documentId,authProvider:L,satifiesVersion:e=>this.satisfiesDocumentEngineVersion(e)}),R&&!this._state.instantSettings)throw new o.uE("Collaboration Permissions is not supported when `instant` is disabled. Please make sure `configuration#instant` is set to `true`.");this._state=this._state.withMutations(e=>{e.defaultGroup=y,e.hasCollaborationPermissions=Boolean(R)}),this.provider&&this.provider.destroy(),this.provider=await this._initProvider();const T=this.mapAuthResponseToClientInfo(t);return{features:this._state.features,signatureFeatureAvailability:this._state.signatureFeatureAvailability,hasPassword:d,password:this._password,minSearchQueryLength:p,allowedTileScales:E,creatorName:v,defaultGroup:y,clientInfo:T}}mapAuthResponseToClientInfo(e){const t=(0,H.o)();if(null===t)return null;if(!e.licenseEnvironment&&!e.licenseId&&!e.demoKeyId)return null;if("production"===e.licenseEnvironment&&!e.licenseId)return null;let r,n=X.n.EVALUATION;if(e.licenseEnvironment)switch(e.licenseEnvironment){case"production":n=X.n.PRODUCTION;break;case"development":n=X.n.DEVELOPMENT;break;case"demo":n=X.n.DEMO;break;default:n=X.n.EVALUATION}if(e.demoKeyId){const t=Number.parseInt(e.demoKeyId,10);Number.isNaN(t)||(r=t)}return{environment:n,productId:t,productVersion:"1.15.1",licenseId:e.licenseId,demoKeyId:r}}satisfiesDocumentEngineVersion(e){return!!this.documentEngineVersion&&(0,l.satisfies)(this.documentEngineVersion,e)}async tryAuthenticateHostedViewer(){if("accessToken"in this._state.authPayload){const{hostedBaseUrl:e}=this._state,t=this._state.authPayload.accessToken,{serverUrl:r,serverId:n,jwt:s}=await async function(e,t){const r=await fetch(`${e}i/documents/auth`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","PSPDFKit-Platform":"web","PSPDFKit-Version":"cloud-protocol=1, server-protocol=5, client=1.15.1, client-git=c0609e0ed9"},body:JSON.stringify({accessToken:t})});if(r.ok)return r.json();throw new Error(`An error occurred while connecting to PSPDFKit API: ${await r.text()}`)}(e,t);this._state=this._state.withMutations(e=>{e.set("serverUrl",r).set("documentId",n).set("documentURL",`${r}i/d/${n}`).set("authPayload",{jwt:s})})}}async _initProvider(){if(this._state.useDeprecatedRestProvider){const e=this._state.isFormsEnabled&&this._state.features.includes(V.Y.FORMS),{RESTProvider:t}=await r.e(269).then(r.bind(r,45889));return new t(this._state.documentURL,{token:this._state.token},{isFormsEnabled:e,features:this._state.features})}{const{InstantProvider:e}=await r.e(534).then(r.bind(r,53946));(0,o.V1)(this._authModule,"AuthModule must be initialized before InstantProvider");const t=new e(this._authModule,this._state.instantSettings||D.z);return t.setDocumentHandleConflictCallback(this.handleDocumentHandleConflict),t}}destroy(){this.corePDFDocument?.cancelRequests(),this._authModule?.destroy(),this._authModule=null,this._destroyProvider(),this._requestQueue?.destroy()}documentInfo(){return this._fetch(`${this._state.documentURL}/document.json`).then(e=>e.json()).then(e=>e.data)}getFormJSON(){return this._fetch(`${this._state.documentURL}/form.json`).then(e=>403===e.status?{v:1,type:"pspdfkit/form",annotations:[],fields:[]}:e.json().then(e=>e.data))}async evalFormValuesActions(){throw new Error("not implemented")}async evalScript(){throw new Error("not implemented")}async setFormJSONUpdateBatchMode(){throw new Error("not implemented")}compareDocuments(){throw new Error("not implemented")}updateButtonIcon(){throw new Error("not implemented")}permissions(){return Promise.resolve(this._state.backendPermissions)}getDefaultGroup(){return this._state.defaultGroup}isCollaborationPermissionsEnabled(){return this._state.hasCollaborationPermissions}textForPageIndex(e){return this.corePDFDocument.getTextLines(e)}async getSuggestedLineHeightFactor(){return 1}async getAnnotationsByScale(){return[]}getAvailableFontFaces(){throw new o.uE("Custom fonts need to be mounted on the server in Server-Backed deployments.")}getContentTreeForPageIndex(e){return this.corePDFDocument.getContentTree(e)}getTextFromRects(e,t){const r=encodeURIComponent(JSON.stringify(t.map(p.w).toArray()));return this._fetch(`${this._state.documentURL}/page-${e}-highlighted?rects=${r}`).then(e=>e.json()).then(e=>e.text)}_getJSONRequestHandler(){return E.A}renderAnnotation(e,t,r,n,s,o,i){return this._requestRenderAnnotation(e,t,r,n,s,!1,i)}async renderPageAnnotations(e,t,r){const n=this.provider,s=t.some(e=>e instanceof T.sb);s&&await n._setReadStateCallbacksPromise;const i=[],a=[],l=new globalThis.Map,c=t.filter(e=>{const t=s?n._readStateCallbacks.getAnnotationWithFormField(e.id):null,r=t?.formField,o=(0,N.lG)(e,r);if(o&&r&&"number"==typeof e.pdfObjectId){i.find(e=>e.name===r.name)||(i.push((0,m.cA)((0,G.Af)(r))),a.push(r),l.set(r.name,n._readStateCallbacks?.getFormFieldRevision?.(r.name)??0))}return o&&"number"==typeof e.pdfObjectId});if(0===c.size&&0===i.length)return Promise.resolve();const u=new Promise((t,n)=>{const s=c.filter(e=>0!==Math.floor(e.boundingBox.width*r)&&0!==Math.floor(e.boundingBox.height*r)),{promise:u,cancel:h}=this._requestRenderAnnotations(e,s.map(e=>e.pdfObjectId).toArray(),s.map(e=>Math.floor(e.boundingBox.width*r)).toArray(),s.map(e=>Math.floor(e.boundingBox.height*r)).toArray(),i);u.then(e=>{const r=e.map((e,t)=>{const r=s.get(t);return(0,o.V1)(r),this.isWidgetPageRenderFresh(r,a,l)?e&&(0,k.BJ)(e)||Promise.resolve(null):Promise.resolve(void 0)});r.forEach(async(e,t)=>{const r=await e,n=s.get(t);if(n){const e=this.annotationAPStreamPromises.get(n.id),t=this.isWidgetPageRenderFresh(n,a,l);!t&&r&&r.release(),e&&(this.annotationAPStreamPromises=this.annotationAPStreamPromises.delete(n.id),e(t?r:void 0)),r&&t&&this.cacheAPStream(r,n)}}),Promise.all(r).then(()=>t())}).catch(e=>{this.resolvePendingAnnotationAPStreams(s.map(e=>e.id).toArray()),h(),n(e)})});return this.pageAPStreamsPromises=this.pageAPStreamsPromises.set(e,u),u}renderDetachedAnnotation(e,t,r,n){return this._requestRenderAnnotation(e,null,t,r,n,!0)}async getAttachment(e){try{const t=await this._fetch(`${this._state.documentURL}/attachments/${e}`);switch(t.status){case 404:throw new o.uE("Attachment not Found.");case 200:return await t.blob();default:throw new o.uE("Bad Request.")}}catch(e){throw new o.uE(`Could not fetch attachment from Nutrient Document Engine. ${e}`)}}async search(e,t,r,n){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4],i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:U.n.TEXT;const a=`q=${i===U.n.PRESET?e.replace(/_/g,"-"):encodeURIComponent(e)}&start=${t}&limit=${r}&type=${i}&include_annotations=${s.toString()}&case_sensitive=${n.toString()}`,l=`${this._state.documentURL}/search?${a}`;(0,o.V1)(this._authModule,"AuthModule must be initialized before search");const c=await new E.A(this._authModule,l).request();return(0,d.g)(c.data)}async getMeasurementSnappingPoints(e){}async searchAndRedact(e,t){const{searchType:r,annotationPreset:n,searchInAnnotations:o,caseSensitive:i,startPageIndex:a,pageRange:l}=t,{color:c,fillColor:u,outlineColor:h,...d}=n,p=await this._fetch(`${this._state.documentURL}/redactions`,{method:"post",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({strategy:r,strategyOptions:{[r]:r===U.n.PRESET?e.replace(/_/g,"-"):e,includeAnnotations:o,caseSensitive:i,...void 0!==a&&{start:a},...void 0!==l&&{limit:l}},content:{...d,color:c&&c.toHex(),fillColor:u&&u.toHex(),outlineColor:h&&h.toHex()}})}),{data:m}=await p.json(),f=(0,s.B8)(m.annotations?.filter(e=>!!e.content).map(e=>x.A.fromJSON(e.id,e.content))||[]);if(f.size){const e=this._state.instantSettings;!this.isUsingInstantProvider()||e&&e.listenToServerChangesEnabled||await this.syncChanges()}return f}async exportPDF(){let{flatten:e=!1,includeComments:t=!0,excludeAnnotations:r=!1,outputFormat:n=!1,optimize:s=!1,flattenElectronicSignatures:i=e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e&&!1===i)throw new o.uE("Cannot set `flattenElectronicSignatures` to `false` when `flatten` is set to `true`.");(0,o.V1)(this._authModule,"AuthModule must be initialized before exportPDF");const a=`${this._state.documentURL}/pdf`,l={comments:String(t),render_ap_streams:String(!e),remove_annotations:String(r)};if(e?l.flatten=String(e):l.keep_signatures=String(!i),s){const e={documentFormat:"pdf",grayscaleText:!1,grayscaleGraphics:!1,grayscaleFormFields:!1,grayscaleAnnotations:!1,grayscaleImages:!1,disableImages:!1,mrcCompression:!1,imageOptimizationQuality:2,linearize:!1};let t;if("boolean"!=typeof s){t={...e,...s}}else t=e;const{documentFormat:r,grayscaleText:n,grayscaleGraphics:o,grayscaleFormFields:i,grayscaleAnnotations:c,grayscaleImages:u,disableImages:h,mrcCompression:d,imageOptimizationQuality:p,linearize:m}=t;return this._fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:[{document:{id:"#self"}}],output:{type:r,grayscaleText:n,grayscaleGraphics:o,grayscaleFormFields:i,grayscaleAnnotations:c,grayscaleImages:u,disableImages:h,mrcCompression:d,imageOptimizationQuality:p,linearize:m}}),credentials:"include"},l).then(e=>e.arrayBuffer())}if(n){const e={conformance:z.o.PDFA_2B,vectorization:!0,rasterization:!0};let t;if("boolean"!=typeof n){t={...e,...n}}else t=e;const{conformance:r,vectorization:s,rasterization:o}=t;return this._fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:[{document:{id:"#self"}}],output:{type:"pdfa",conformance:r,vectorization:s,rasterization:o}}),credentials:"include"},l).then(e=>e.arrayBuffer())}return this._fetch(a,{method:"GET",credentials:"include"},l).then(e=>e.arrayBuffer())}exportOffice(e){let{format:t}=e;const r=`${this._state.documentURL}/build`;return this._fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:[{document:{id:"#self"}}],output:{type:t.toLowerCase()}}),credentials:"include"}).then(e=>e.arrayBuffer()).catch(e=>{throw new o.uE(`Exporting to Office failed: ${e.message}`)})}exportXFDF(e){let t={};return null!=e&&(t={ignorePageRotation:e.toString()}),this._fetch(`${this._state.documentURL}/document.xfdf`,{},t).then(e=>e.text())}exportInstantJSON(e){return this._fetch(`${this._state.documentURL}/instant.json${"number"==typeof e?`?version=${e}`:""}`).then(e=>e.json())}getPDFURL(){let{includeComments:e=!0,excludeAnnotations:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,o.V1)(this._authModule,"AuthModule must be initialized before getPDFURL"),{promise:this._authModule.getAuthState().then(r=>`${r.documentURL}/pdf?token=${r.token}&flatten=true&comments=${String(e)}&remove_annotations=${String(t)}`),revoke:()=>{}}}generatePDFObjectURL(){let e,{includeComments:t=!0,excludeAnnotations:r=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=!1;return{promise:new Promise(s=>{this.exportPDF({flatten:!0,includeComments:t,excludeAnnotations:r}).then(t=>{if(n)return;const r=new Blob([t],{type:"application/pdf"});e=window.URL.createObjectURL(r),s(e)})}),revoke:()=>{e&&window.URL.revokeObjectURL(e),n=!0}}}async getDocumentOutline(){let e;try{e=(await this._fetch(`${this._state.documentURL}/outline.json`).then(e=>e.json())).data}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)throw t;const r=t?.status,n=t?.body;if("number"==typeof r&&"string"==typeof n&&A.r.isAuthFailure(r,n))throw t;if(t instanceof Error&&t.message.startsWith("Auth "))throw t;e={}}const t=Array.isArray(e.outline)?e.outline:[];return(0,s.B8)(t.map(L.r))}async setDocumentOutline(){throw new o.uE("Not implemented in Server backend.")}async getPageGlyphs(){throw new o.uE("Not implemented in Server backend.")}onKeystrokeEvent(){throw new Error("not implemented")}async getMeasurementScales(){let e;try{return e=(await this._fetch(`${this._state.documentURL}/measurement_content_formats`).then(e=>e.json())).data,e}catch(e){throw new o.uE(`Fetching measurement scales failed: ${e}`)}}async getSecondaryMeasurementUnit(){let e;try{return e=(await this._fetch(`${this._state.documentURL}/secondary_measurement_unit`).then(e=>e.json())).data,e}catch(e){throw new o.uE(`Fetching secondary measurement unit failed: ${e}`)}}async setSecondaryMeasurementUnit(e){try{const t=JSON.stringify({unitTo:e?e.unitTo:null,precision:e?e.precision:null});await this._fetch(`${this._state.documentURL}/secondary_measurement_unit`,{method:"post",body:t,credentials:"include",headers:{"Content-Type":"application/json"}})}catch(e){throw new o.uE(`Setting secondary measurement unit failed: ${e}`)}}async addMeasurementScale(e){try{const t=JSON.stringify((0,h.U)(e));await this._fetch(`${this._state.documentURL}/measurement_content_formats`,{method:"post",body:t,credentials:"include",headers:{"Content-Type":"application/json"}})}catch(e){throw new o.uE(`Adding a new measurement scale failed: ${e}`)}}async removeMeasurementScale(e){try{const t=JSON.stringify((0,h.U)(e));await this._fetch(`${this._state.documentURL}/measurement_content_formats/delete`,{method:"post",body:t,credentials:"include",headers:{"Content-Type":"application/json"}})}catch(e){throw new o.uE(`Removing scale failed: ${e}`)}}async applyOperationsAndReload(e){try{const t=await ee(e);this._destroyProvider(),await this._fetch(`${this._state.documentURL}/apply-operations`,{method:"post",body:t,credentials:"include"})}catch(e){throw new o.uE(`Applying operations failed: ${e}`)}return this.reloadDocument()}async applyRedactionsAndReload(){try{return this._destroyProvider(),await this._fetch(`${this._state.documentURL}/redact`,{method:"post",credentials:"include"}),this.reloadDocument()}catch(e){throw this.provider.load(),new o.uE(`Applying redactions failed: ${e}`)}}async reloadDocument(){this.clearRenderedAnnotationsCache();try{return await this.load({password:this._password})}catch(e){throw new o.uE(`Reloading the document failed: ${e}`)}}async exportPDFWithOperations(e){try{const t=await ee(e);return await async function(e){let t=1;for(;;){const r=await e();try{return await r.arrayBuffer()}catch(e){if(3===t||!Q(e))throw e;(0,o.R8)(`Retrying /pdf-with-operations export after a truncated response from an older Document Engine deployment (${t}/3): ${e}`),t+=1,await new Promise(e=>setTimeout(e,200))}}}(()=>this._fetch(`${this._state.documentURL}/pdf-with-operations`,{method:"post",body:t,credentials:"include"}))}catch(e){throw new o.uE(`Exporting PDF with operations failed: ${e}`)}}async setSignaturesLTV(e){throw new Error("not implemented")}async getSignaturesInfo(){return this._refreshSignaturesInfoPromise&&await this._refreshSignaturesInfoPromise,this._state.digitalSignatures}refreshSignaturesInfo(){return this._refreshSignaturesInfoPromise||(this._refreshSignaturesInfoPromise=new Promise((e,t)=>{this._fetch(`${this._state.documentURL}/signatures`,{method:"get",credentials:"include"}).then(e=>e.json()).then(t=>{let{data:r}=t;this._state=this._state.set("digitalSignatures",(0,m.N5)(r)),this._refreshSignaturesInfoPromise=null,e()}).catch(e=>{this._state=this._state.set("digitalSignatures",null),this._refreshSignaturesInfoPromise=null,t(e)})})),this._refreshSignaturesInfoPromise}async signDocumentAndReload(e,t){(0,o.V1)(void 0===t||"object"==typeof t,"Signing service data must be an object if specified.");try{if(void 0!==t&&"object"!=typeof t)throw new o.uE("Signing service data must be an object if specified.");(0,W.r6)(e);const r=e?{..."placeholderSize"in e?{estimatedSize:e.placeholderSize}:null,..."flatten"in e?{flatten:e.flatten}:null,...e?.signatureMetadata?{signatureMetadata:(0,m.sZ)(e.signatureMetadata)}:null,..."position"in e?{position:(0,m.qN)(e.position)}:null,..."appearance"in e?{appearance:await(0,m.z8)(e.appearance)}:null,..."formFieldName"in e?{formFieldName:e.formFieldName}:null,...void 0!==e?.signingData&&"signatureContainer"in e.signingData?{signatureContainer:e.signingData.signatureContainer}:null,...void 0!==e?.signingData&&"signatureType"in e.signingData?{signatureType:m.xz[e.signingData.signatureType]}:null}:null,n=e?.appearance?.watermarkImage||null,s=e?.appearance?.graphicImage||null,i={...t?{signingToken:t.signingToken}:null,...r},a=new FormData;if(a.append("data",JSON.stringify(i)),n&&a.append("image",n),s&&a.append("graphicImage",s),this._destroyProvider(),await this._fetch(`${this._state.documentURL}/sign`,{method:"post",body:a,credentials:"include"}),await this.reloadDocument(),e?.formFieldName)return e.formFieldName}catch(e){throw this.provider.load(),new o.uE(`Adding digital signature failed: ${e.message||e}`)}}async setFontSubstitutions(e){try{const t=`${this._state.documentURL}/font-substitutions`;await this._fetch(t,{method:"put",body:JSON.stringify({fontSubstitutions:e}),credentials:"include",headers:{"Content-Type":"application/json"}})}catch(e){throw new o.uE(`Error setting font substitution: ${e.message}`)}}getDocumentHandle(){return this._state.documentHandle}async getEmbeddedFiles(){const e=await this._fetch(`${this._state.documentURL}/embedded-files`,{method:"get",credentials:"include"}),{data:t}=await e.json();return(0,s.B8)(t?.embeddedFiles?.map(e=>{let{id:t,content:r}=e;return(0,j.r)(t,r)})||[])}cancelRequests(){this.corePDFDocument?.cancelRequests(),this._requestQueue.cancelAll()}_destroyProvider(){this.provider&&(this.provider._clients?.disconnect(),this.provider.destroy())}async _fetch(e,t,r){var n=this;const s=t?.useImageToken??!1,{useImageToken:i,...a}=t??{},l=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;(0,o.V1)(n._authModule,"AuthModule must be initialized before _fetch");const i=await function(e,t){if(!t)return e.getAuthState();if(t.aborted)return Promise.reject(new DOMException("Aborted","AbortError"));let r=null;const n=new Promise((e,n)=>{r=()=>n(new DOMException("Aborted","AbortError")),t.addEventListener("abort",r,{once:!0})});return Promise.race([e.getAuthState(),n]).finally(()=>{r&&(t.removeEventListener("abort",r),r=null)})}(n._authModule,a.signal),c=s?"X-PSPDFKit-Image-Token":"X-PSPDFKit-Token",u=s?i.imageToken:i.token,h=new URLSearchParams(r||{}),d=h.toString()?`${e}${e.includes("?")?"&":"?"}${h.toString()}`:e,p={};a.headers instanceof Headers?a.headers.forEach((e,t)=>{p[t]=e}):Array.isArray(a.headers)?a.headers.forEach(e=>{let[t,r]=e;p[t]=r}):"object"==typeof a.headers&&null!==a.headers&&Object.assign(p,a.headers),Object.keys(p).forEach(e=>{const t=e.toLowerCase();t!==c.toLowerCase()&&"pspdfkit-platform"!==t&&"pspdfkit-version"!==t||delete p[e]});const m={...p,[c]:u,"PSPDFKit-Platform":"web","PSPDFKit-Version":(0,I._q)()},f=await fetch(d,{...a,headers:m});if(!f.ok){const e=await function(e){if("function"==typeof e.clone){const t=e.clone();return t.json().catch(()=>t.text())}return("function"==typeof e.text?e.text():Promise.resolve("")).then(e=>{try{return JSON.parse(e)}catch{return e}})}(f),r="object"==typeof e&&null!=e&&"reason"in e?e.reason:"string"==typeof e?e:null,s=(null!=r&&""!==r?String(r):null)||`${f.status??""} ${f.statusText??""}`.trim()||"Unknown error",i="object"==typeof e&&null!=e?JSON.stringify(e):"string"==typeof e?e:"";if(n._authModule&&A.r.isAuthFailure(f.status,i)&&0===t){try{await n._authModule.refresh()}catch(e){const t=e instanceof Error?e.message:String(e);throw new o.uE(`Auth refresh failed: ${t}`)}return l(1)}throw Object.assign(new o.uE(s),{status:f.status,body:i})}return f};return l()}syncChanges(){return this.provider.syncChanges()}async clearAPStreamCache(){}async runPDFFormattingScripts(){return[]}async runPDFFormattingScriptsFromWidgets(){return this.runPDFFormattingScripts()}async lazyLoadPages(){}async contentEditorReload(){return this._destroyProvider(),this.reloadDocument()}getOCGs(){throw new Error("not implemented")}getOCGVisibilityState(){throw new Error("not implemented")}setOCGVisibilityState(){throw new Error("not implemented")}async timestampData(e,t){throw new Error("not implemented")}async waitUntilFullyLoaded(e){throw new Error("not implemented")}}async function ee(e){const t={},r=new WeakMap,n=await Promise.all(e.map(async(e,n)=>{if("importDocument"===e.type){const s=e.document;return(0,o.V1)(s instanceof File||s instanceof Blob,"Wrong `importDocument` operation `document` value: it must be a File or a Blob"),(0,C.g)(r,t,s,e,n,"document")}if("applyInstantJson"===e.type){const s=e.instantJson;(0,o.V1)("object"==typeof s&&null!==s,"Wrong `applyInstantJson` operation `instantJson` value: it must be an object");const i=JSON.stringify(s),a=new Blob([i],{type:"application/json"});return(0,C.g)(r,t,a,e,n,"dataFilePath")}if("applyXfdf"===e.type){const s=e.xfdf;(0,o.V1)("string"==typeof s,"Wrong `applyXfdf` operation `xfdf` value: it must be a string");const i=new Blob([s],{type:"application/vnd.adobe.xfdf"});return(0,C.g)(r,t,i,e,n,"dataFilePath")}return e})),s=new FormData;s.append("operations",JSON.stringify({operations:n}));for(const e in t)s.append(e,t[e]);return s}},70402(e,t,r){r.d(t,{S:()=>n,z:()=>s});const n={clientsPresenceEnabled:!0,listenToServerChangesEnabled:!0},s={clientsPresenceEnabled:!1,listenToServerChangesEnabled:!1}},76595(e,t,r){const n=Symbol("SemVer ANY");class s{static get ANY(){return n}constructor(e,t){if(t=o(t),e instanceof s){if(e.loose===!!t.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),c("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===n?this.value="":this.value=this.operator+this.semver.version,c("comp",this)}parse(e){const t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw new TypeError(`Invalid comparator: ${e}`);this.operator=void 0!==r[1]?r[1]:"","="===this.operator&&(this.operator=""),r[2]?this.semver=new u(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(c("Comparator.test",e,this.options.loose),this.semver===n||e===n)return!0;if("string"==typeof e)try{e=new u(e,this.options)}catch(e){return!1}return l(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof s))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new h(e.value,t).test(this.value):""===e.operator?""===e.value||new h(this.value,t).test(e.semver):(!(t=o(t)).includePrerelease||"<0.0.0-0"!==this.value&&"<0.0.0-0"!==e.value)&&(!(!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0")))&&(!(!this.operator.startsWith(">")||!e.operator.startsWith(">"))||(!(!this.operator.startsWith("<")||!e.operator.startsWith("<"))||(!(this.semver.version!==e.semver.version||!this.operator.includes("=")||!e.operator.includes("="))||(!!(l(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))||!!(l(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))))))}}e.exports=s;const o=r(14948),{safeRe:i,t:a}=r(86431),l=r(90870),c=r(76887),u=r(75403),h=r(69854)},69854(e,t,r){const n=/\s+/g;class s{constructor(e,t){if(t=i(t),e instanceof s)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new s(e.raw,t);if(e instanceof a)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(n," "),this.set=this.raw.split("||").map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter(e=>!g(e[0])),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&w(e[0])){this.set=[e];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");const t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=" "),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){const t=((this.options.includePrerelease&&f)|(this.options.loose&&E))+":"+e,r=o.get(t);if(r)return r;const n=this.options.loose,s=n?u[h.HYPHENRANGELOOSE]:u[h.HYPHENRANGE];e=e.replace(s,L(this.options.includePrerelease)),l("hyphen replace",e),e=e.replace(u[h.COMPARATORTRIM],d),l("comparator trim",e),e=e.replace(u[h.TILDETRIM],p),l("tilde trim",e),e=e.replace(u[h.CARETTRIM],m),l("caret trim",e);let i=e.split(" ").map(e=>R(e,this.options)).join(" ").split(/\s+/).map(e=>N(e,this.options));n&&(i=i.filter(e=>(l("loose invalid filter",e,this.options),!!e.match(u[h.COMPARATORLOOSE])))),l("range list",i);const c=new Map,w=i.map(e=>new a(e,this.options));for(const e of w){if(g(e))return[e];c.set(e.value,e)}c.size>1&&c.has("")&&c.delete("");const y=[...c.values()];return o.set(t,y),y}intersects(e,t){if(!(e instanceof s))throw new TypeError("a Range is required");return this.set.some(r=>y(r,t)&&e.set.some(e=>y(e,t)&&r.every(r=>e.every(e=>r.intersects(e,t)))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new c(e,this.options)}catch(e){return!1}for(let t=0;t<this.set.length;t++)if(T(this.set[t],e,this.options))return!0;return!1}}e.exports=s;const o=new(r(70295)),i=r(14948),a=r(76595),l=r(76887),c=r(75403),{safeRe:u,t:h,comparatorTrimReplace:d,tildeTrimReplace:p,caretTrimReplace:m}=r(86431),{FLAG_INCLUDE_PRERELEASE:f,FLAG_LOOSE:E}=r(79549),g=e=>"<0.0.0-0"===e.value,w=e=>""===e.value,y=(e,t)=>{let r=!0;const n=e.slice();let s=n.pop();for(;r&&n.length;)r=n.every(e=>s.intersects(e,t)),s=n.pop();return r},R=(e,t)=>(e=e.replace(u[h.BUILD],""),l("comp",e,t),e=S(e,t),l("caret",e),e=$(e,t),l("tildes",e),e=b(e,t),l("xrange",e),e=_(e,t),l("stars",e),e),v=e=>!e||"x"===e.toLowerCase()||"*"===e,$=(e,t)=>e.trim().split(/\s+/).map(e=>I(e,t)).join(" "),I=(e,t)=>{const r=t.loose?u[h.TILDELOOSE]:u[h.TILDE];return e.replace(r,(t,r,n,s,o)=>{let i;return l("tilde",e,t,r,n,s,o),v(r)?i="":v(n)?i=`>=${r}.0.0 <${+r+1}.0.0-0`:v(s)?i=`>=${r}.${n}.0 <${r}.${+n+1}.0-0`:o?(l("replaceTilde pr",o),i=`>=${r}.${n}.${s}-${o} <${r}.${+n+1}.0-0`):i=`>=${r}.${n}.${s} <${r}.${+n+1}.0-0`,l("tilde return",i),i})},S=(e,t)=>e.trim().split(/\s+/).map(e=>A(e,t)).join(" "),A=(e,t)=>{l("caret",e,t);const r=t.loose?u[h.CARETLOOSE]:u[h.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,(t,r,s,o,i)=>{let a;return l("caret",e,t,r,s,o,i),v(r)?a="":v(s)?a=`>=${r}.0.0${n} <${+r+1}.0.0-0`:v(o)?a="0"===r?`>=${r}.${s}.0${n} <${r}.${+s+1}.0-0`:`>=${r}.${s}.0${n} <${+r+1}.0.0-0`:i?(l("replaceCaret pr",i),a="0"===r?"0"===s?`>=${r}.${s}.${o}-${i} <${r}.${s}.${+o+1}-0`:`>=${r}.${s}.${o}-${i} <${r}.${+s+1}.0-0`:`>=${r}.${s}.${o}-${i} <${+r+1}.0.0-0`):(l("no pr"),a="0"===r?"0"===s?`>=${r}.${s}.${o}${n} <${r}.${s}.${+o+1}-0`:`>=${r}.${s}.${o}${n} <${r}.${+s+1}.0-0`:`>=${r}.${s}.${o} <${+r+1}.0.0-0`),l("caret return",a),a})},b=(e,t)=>(l("replaceXRanges",e,t),e.split(/\s+/).map(e=>P(e,t)).join(" ")),P=(e,t)=>{e=e.trim();const r=t.loose?u[h.XRANGELOOSE]:u[h.XRANGE];return e.replace(r,(r,n,s,o,i,a)=>{l("xRange",e,r,n,s,o,i,a);const c=v(s),u=c||v(o),h=u||v(i),d=h;return"="===n&&d&&(n=""),a=t.includePrerelease?"-0":"",c?r=">"===n||"<"===n?"<0.0.0-0":"*":n&&d?(u&&(o=0),i=0,">"===n?(n=">=",u?(s=+s+1,o=0,i=0):(o=+o+1,i=0)):"<="===n&&(n="<",u?s=+s+1:o=+o+1),"<"===n&&(a="-0"),r=`${n+s}.${o}.${i}${a}`):u?r=`>=${s}.0.0${a} <${+s+1}.0.0-0`:h&&(r=`>=${s}.${o}.0${a} <${s}.${+o+1}.0-0`),l("xRange return",r),r})},_=(e,t)=>(l("replaceStars",e,t),e.trim().replace(u[h.STAR],"")),N=(e,t)=>(l("replaceGTE0",e,t),e.trim().replace(u[t.includePrerelease?h.GTE0PRE:h.GTE0],"")),L=e=>(t,r,n,s,o,i,a,l,c,u,h,d)=>`${r=v(n)?"":v(s)?`>=${n}.0.0${e?"-0":""}`:v(o)?`>=${n}.${s}.0${e?"-0":""}`:i?`>=${r}`:`>=${r}${e?"-0":""}`} ${l=v(c)?"":v(u)?`<${+c+1}.0.0-0`:v(h)?`<${c}.${+u+1}.0-0`:d?`<=${c}.${u}.${h}-${d}`:e?`<${c}.${u}.${+h+1}-0`:`<=${l}`}`.trim(),T=(e,t,r)=>{for(let r=0;r<e.length;r++)if(!e[r].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let r=0;r<e.length;r++)if(l(e[r].semver),e[r].semver!==a.ANY&&e[r].semver.prerelease.length>0){const n=e[r].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0}},75403(e,t,r){const n=r(76887),{MAX_LENGTH:s,MAX_SAFE_INTEGER:o}=r(79549),{safeRe:i,t:a}=r(86431),l=r(14948),{compareIdentifiers:c}=r(28628);class u{constructor(e,t){if(t=l(t),e instanceof u){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>s)throw new TypeError(`version is longer than ${s} characters`);n("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const r=e.trim().match(t.loose?i[a.LOOSE]:i[a.FULL]);if(!r)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>o||this.major<0)throw new TypeError("Invalid major version");if(this.minor>o||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>o||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<o)return t}return e}):this.prerelease=[],this.build=r[5]?r[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(n("SemVer.compare",this.version,this.options,e),!(e instanceof u)){if("string"==typeof e&&e===this.version)return 0;e=new u(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof u||(e=new u(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(e){if(e instanceof u||(e=new u(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{const r=this.prerelease[t],s=e.prerelease[t];if(n("prerelease compare",t,r,s),void 0===r&&void 0===s)return 0;if(void 0===s)return 1;if(void 0===r)return-1;if(r!==s)return c(r,s)}while(++t)}compareBuild(e){e instanceof u||(e=new u(e,this.options));let t=0;do{const r=this.build[t],s=e.build[t];if(n("build compare",t,r,s),void 0===r&&void 0===s)return 0;if(void 0===s)return 1;if(void 0===r)return-1;if(r!==s)return c(r,s)}while(++t)}inc(e,t,r){if(e.startsWith("pre")){if(!t&&!1===r)throw new Error("invalid increment argument: identifier is empty");if(t){const e=`-${t}`.match(this.options.loose?i[a.PRERELEASELOOSE]:i[a.PRERELEASE]);if(!e||e[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,r),this.inc("pre",t,r);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,r),this.inc("pre",t,r);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(r)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let n=this.prerelease.length;for(;--n>=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(t===this.prerelease.join(".")&&!1===r)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let n=[t,e];!1===r&&(n=[t]),0===c(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=n):this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}e.exports=u},89719(e,t,r){const n=r(13425);e.exports=(e,t)=>{const r=n(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null}},90870(e,t,r){const n=r(75162),s=r(26494),o=r(38023),i=r(47332),a=r(67568),l=r(28669);e.exports=(e,t,r,c)=>{switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e===r;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e!==r;case"":case"=":case"==":return n(e,r,c);case"!=":return s(e,r,c);case">":return o(e,r,c);case">=":return i(e,r,c);case"<":return a(e,r,c);case"<=":return l(e,r,c);default:throw new TypeError(`Invalid operator: ${t}`)}}},40681(e,t,r){const n=r(75403),s=r(13425),{safeRe:o,t:i}=r(86431);e.exports=(e,t)=>{if(e instanceof n)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let r=null;if((t=t||{}).rtl){const n=t.includePrerelease?o[i.COERCERTLFULL]:o[i.COERCERTL];let s;for(;(s=n.exec(e))&&(!r||r.index+r[0].length!==e.length);)r&&s.index+s[0].length===r.index+r[0].length||(r=s),n.lastIndex=s.index+s[1].length+s[2].length;n.lastIndex=-1}else r=e.match(t.includePrerelease?o[i.COERCEFULL]:o[i.COERCE]);if(null===r)return null;const a=r[2],l=r[3]||"0",c=r[4]||"0",u=t.includePrerelease&&r[5]?`-${r[5]}`:"",h=t.includePrerelease&&r[6]?`+${r[6]}`:"";return s(`${a}.${l}.${c}${u}${h}`,t)}},8512(e,t,r){const n=r(75403);e.exports=(e,t,r)=>{const s=new n(e,r),o=new n(t,r);return s.compare(o)||s.compareBuild(o)}},7642(e,t,r){const n=r(87509);e.exports=(e,t)=>n(e,t,!0)},87509(e,t,r){const n=r(75403);e.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))},18823(e,t,r){const n=r(13425);e.exports=(e,t)=>{const r=n(e,null,!0),s=n(t,null,!0),o=r.compare(s);if(0===o)return null;const i=o>0,a=i?r:s,l=i?s:r,c=!!a.prerelease.length;if(!!l.prerelease.length&&!c){if(!l.patch&&!l.minor)return"major";if(0===l.compareMain(a))return l.minor&&!l.patch?"minor":"patch"}const u=c?"pre":"";return r.major!==s.major?u+"major":r.minor!==s.minor?u+"minor":r.patch!==s.patch?u+"patch":"prerelease"}},75162(e,t,r){const n=r(87509);e.exports=(e,t,r)=>0===n(e,t,r)},38023(e,t,r){const n=r(87509);e.exports=(e,t,r)=>n(e,t,r)>0},47332(e,t,r){const n=r(87509);e.exports=(e,t,r)=>n(e,t,r)>=0},5234(e,t,r){const n=r(75403);e.exports=(e,t,r,s,o)=>{"string"==typeof r&&(o=s,s=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,s,o).version}catch(e){return null}}},67568(e,t,r){const n=r(87509);e.exports=(e,t,r)=>n(e,t,r)<0},28669(e,t,r){const n=r(87509);e.exports=(e,t,r)=>n(e,t,r)<=0},90703(e,t,r){const n=r(75403);e.exports=(e,t)=>new n(e,t).major},86923(e,t,r){const n=r(75403);e.exports=(e,t)=>new n(e,t).minor},26494(e,t,r){const n=r(87509);e.exports=(e,t,r)=>0!==n(e,t,r)},13425(e,t,r){const n=r(75403);e.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}},45700(e,t,r){const n=r(75403);e.exports=(e,t)=>new n(e,t).patch},69970(e,t,r){const n=r(13425);e.exports=(e,t)=>{const r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}},73629(e,t,r){const n=r(87509);e.exports=(e,t,r)=>n(t,e,r)},48392(e,t,r){const n=r(8512);e.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))},61211(e,t,r){const n=r(69854);e.exports=(e,t,r)=>{try{t=new n