@rhc-office/sdk 6.6.266 → 6.6.268
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/document-viewer.js +1 -1
- package/dist/browser/document-viewer.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +666 -523
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/dist/tools/AnnotationToolImpl.d.ts +47 -0
- package/dist/tools/AnnotationToolImpl.d.ts.map +1 -0
- package/dist/tools/CryptoToolImpl.d.ts +9 -0
- package/dist/tools/CryptoToolImpl.d.ts.map +1 -0
- package/dist/tools/DigitalSignToolImpl.d.ts +27 -0
- package/dist/tools/DigitalSignToolImpl.d.ts.map +1 -0
- package/dist/tools/DocumentToolImpl.d.ts +1 -0
- package/dist/tools/DocumentToolImpl.d.ts.map +1 -1
- package/dist/tools/SignServerToolImpl.d.ts +19 -0
- package/dist/tools/SignServerToolImpl.d.ts.map +1 -0
- package/dist/tools/SymbologyToolImpl.d.ts +8 -0
- package/dist/tools/SymbologyToolImpl.d.ts.map +1 -0
- package/dist/tools/TemplateSignToolImpl.d.ts +13 -0
- package/dist/tools/TemplateSignToolImpl.d.ts.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/viewer/DocumentSDK.d.ts +0 -1
- package/dist/viewer/DocumentSDK.d.ts.map +1 -1
- package/dist/viewer/SdkCallbackRegistry.d.ts +3 -0
- package/dist/viewer/SdkCallbackRegistry.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/tools/AnnotationToolImpl.ts +263 -0
- package/src/tools/CryptoToolImpl.ts +27 -0
- package/src/tools/DigitalSignToolImpl.ts +155 -0
- package/src/tools/DocumentToolImpl.ts +24 -2
- package/src/tools/SignServerToolImpl.ts +92 -0
- package/src/tools/SymbologyToolImpl.ts +34 -0
- package/src/tools/TemplateSignToolImpl.ts +51 -0
- package/src/tools/index.ts +6 -0
- package/src/viewer/DocumentSDK.ts +13 -114
- package/src/viewer/SdkCallbackRegistry.ts +9 -0
package/dist/index.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(l,h){typeof exports=="object"&&typeof module<"u"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(l=typeof globalThis<"u"?globalThis:l||self,h(l.RHCOfficeSDK={}))})(this,function(l){"use strict";var h=(n=>(n.DEFAULT="default",n.COMPACT="compact",n.HIDE="none",n))(h||{});const P="RIGHT_CENTER",C="REGULAR_ESM",A="auto",T="__RHC_OFFICE_DIGITAL_SIGN_ENVIRONMENT__",D={defaults:{bjca:{pin:""},deviceType:"client",edgePosition:P,kol:{appId:"",appName:"",pin:"",serviceUrl:"",token:""},plugin:{pin:"",usbKeyType:14},rsaMode:A,signatureType:C},signServer:{authSource:"Password",defaultLogin:"",defaultPassword:"",defaultServer:"",kol:{appId:"",appName:"",serviceUrl:"",token:""},macAddress:"",token:"",usbKey:{checkCertificateBinding:!1,usbKeyType:14}}},M=n=>({bjca:{pin:n.bjca.pin},deviceType:n.deviceType,edgePosition:n.edgePosition,kol:{appId:n.kol.appId,appName:n.kol.appName,pin:n.kol.pin,serviceUrl:n.kol.serviceUrl,token:n.kol.token},plugin:{pin:n.plugin.pin,usbKeyType:n.plugin.usbKeyType},rsaMode:n.rsaMode,signatureType:n.signatureType}),I=n=>({authSource:n.authSource,defaultLogin:n.defaultLogin,defaultPassword:n.defaultPassword,defaultServer:n.defaultServer,kol:{appId:n.kol.appId,appName:n.kol.appName,serviceUrl:n.kol.serviceUrl,token:n.kol.token},macAddress:n.macAddress,token:n.token,usbKey:{checkCertificateBinding:n.usbKey.checkCertificateBinding,usbKeyType:n.usbKey.usbKeyType}}),m=n=>({defaults:M(n.defaults),signServer:I(n.signServer)}),w=n=>({defaults:n.defaults?{...n.defaults,bjca:n.defaults.bjca?{...n.defaults.bjca}:void 0,kol:n.defaults.kol?{...n.defaults.kol}:void 0,plugin:n.defaults.plugin?{...n.defaults.plugin}:void 0}:void 0,signServer:n.signServer?{...n.signServer,kol:n.signServer.kol?{...n.signServer.kol}:void 0,usbKey:n.signServer.usbKey?{...n.signServer.usbKey}:void 0}:void 0}),q=(n,t)=>t?{bjca:{pin:t.bjca?.pin??n.bjca.pin},deviceType:t.deviceType??n.deviceType,edgePosition:t.edgePosition??n.edgePosition,kol:{appId:t.kol?.appId??n.kol.appId,appName:t.kol?.appName??n.kol.appName,pin:t.kol?.pin??n.kol.pin,serviceUrl:t.kol?.serviceUrl??n.kol.serviceUrl,token:t.kol?.token??n.kol.token},plugin:{pin:t.plugin?.pin??n.plugin.pin,usbKeyType:t.plugin?.usbKeyType??n.plugin.usbKeyType},rsaMode:t.rsaMode??n.rsaMode,signatureType:t.signatureType??n.signatureType}:M(n),Q=(n,t)=>t?{authSource:t.authSource??n.authSource,defaultLogin:t.defaultLogin??n.defaultLogin,defaultPassword:t.defaultPassword??n.defaultPassword,defaultServer:t.defaultServer??n.defaultServer,kol:{appId:t.kol?.appId??n.kol.appId,appName:t.kol?.appName??n.kol.appName,serviceUrl:t.kol?.serviceUrl??n.kol.serviceUrl,token:t.kol?.token??n.kol.token},macAddress:t.macAddress??n.macAddress,token:t.token??n.token,usbKey:{checkCertificateBinding:t.usbKey?.checkCertificateBinding??n.usbKey.checkCertificateBinding,usbKeyType:t.usbKey?.usbKeyType??n.usbKey.usbKeyType}}:I(n),_=(n,t)=>({defaults:q(n.defaults,t.defaults),signServer:Q(n.signServer,t.signServer)}),z=(n,t)=>({defaults:n.defaults||t.defaults?{...n.defaults,...t.defaults,bjca:{...n.defaults?.bjca??{},...t.defaults?.bjca??{}},kol:{...n.defaults?.kol??{},...t.defaults?.kol??{}},plugin:{...n.defaults?.plugin??{},...t.defaults?.plugin??{}}}:void 0,signServer:n.signServer||t.signServer?{...n.signServer,...t.signServer,kol:{...n.signServer?.kol??{},...t.signServer?.kol??{}},usbKey:{...n.signServer?.usbKey??{},...t.signServer?.usbKey??{}}}:void 0}),W=()=>globalThis,g=()=>{const n=W();return n[T]||(n[T]={current:m(D),defaults:m(D),overrides:{}}),n[T]},$=()=>g().current,j=n=>{const t=g();return t.defaults=m(n),t.current=_(t.defaults,t.overrides),t.current},Y=n=>{const t=g();return t.current=m(n),t.overrides=w(n),t.current},X=n=>{const t=g();return t.overrides=z(t.overrides,w(n)),t.current=_(t.current,n),t.current},J=n=>{const t=g();return n&&(t.defaults=m(n)),t.overrides={},t.current=m(t.defaults),t.current},Z={EDGE_POSITION:P,RSA_MODE:A,SIGNATURE_TYPE:C},E=n=>{if(n.length!==0)return n.length===1?n[0]:n},u=(n,t,e)=>new Proxy({},{get:(i,r)=>{if(r==="then")return;if(typeof r=="symbol")return r===Symbol.toStringTag?n:void 0;const a=t[r];return a?(...o)=>{if(a.kind==="callbackRegister"){a.callback?.(e.callbacks,o);return}if(a.kind==="stateGetter")return a.state?.(e.state.snapshot(),o);const s=a.adapterMethod??r;if(a.kind==="query")return e.bridge.request(n,s,E(o));if(a.kind==="callbackQuery"){const c=o.find(d=>typeof d=="function"),b=o.filter(d=>typeof d!="function");e.bridge.request(n,s,E(b)).then(d=>{const S=a.mapCallbackResult?.(d)??[d];c?.(...S)}).catch(e.onAsyncError);return}e.bridge.request(n,s,E(o)).catch(e.onAsyncError)}:(...o)=>{const s=new Error(`${n}.${r} is not implemented by the SDK adapter.`);e.onAsyncError(s)}}}),k=(n,t)=>new Proxy({},{get:(e,i)=>{if(i!=="then"&&typeof i!="symbol")return(...r)=>{const a=`${n}.${i} is not implemented by the SDK adapter.`;t.onAsyncError(new Error(a))}}}),ee={addDocumentOpenedCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.documentOpened.push(e)}},addDocumentSavedCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.documentSaved.push(e)}},addDocumentClosedCallback:{kind:"callbackRegister",callback:(n,t)=>{const e=t[0];typeof e=="function"&&n.documentClosed.push(e)}},openPDFDocument:{kind:"callbackQuery",adapterMethod:"open"},openPdfDocument:{kind:"callbackQuery",adapterMethod:"open"},openOFDDocument:{kind:"callbackQuery",adapterMethod:"open"},openOfdDocument:{kind:"callbackQuery",adapterMethod:"open"},openOfficeDocument:{kind:"callbackQuery",adapterMethod:"open"},openImageDocument:{kind:"callbackQuery",adapterMethod:"open"},openTextDocument:{kind:"callbackQuery",adapterMethod:"open"},openFromLocalStorage:{kind:"command"},setUploadUrl:{kind:"command"},save:{kind:"callbackQuery"},saveAs:{kind:"query"},getDocumentContent:{kind:"callbackQuery",mapCallbackResult:n=>{const t=n;return[t?.fileCacheId,t?.fileBuffer]}},closeDocument:{kind:"callbackQuery"},isDocumentOpened:{kind:"stateGetter",state:n=>n.documentOpened},isDocumentModified:{kind:"stateGetter",state:n=>n.documentModified},print:{kind:"command"},createPreview:{kind:"command"}};class te{constructor(t){this.addDocumentOpenedCallback=e=>this.adapter.addDocumentOpenedCallback(e),this.addDocumentSavedCallback=e=>this.adapter.addDocumentSavedCallback(e),this.addDocumentClosedCallback=e=>this.adapter.addDocumentClosedCallback(e),this.openPDFDocument=(e,i)=>this.adapter.openPDFDocument(e,i),this.openPdfDocument=(e,i)=>this.adapter.openPdfDocument(e,i),this.openOFDDocument=(e,i)=>this.adapter.openOFDDocument(e,i),this.openOfdDocument=(e,i)=>this.adapter.openOfdDocument(e,i),this.openOfficeDocument=(e,i)=>this.adapter.openOfficeDocument(e,i),this.openImageDocument=(e,i)=>this.adapter.openImageDocument(e,i),this.openTextDocument=(e,i)=>this.adapter.openTextDocument(e,i),this.openFromLocalStorage=()=>this.adapter.openFromLocalStorage(),this.setUploadUrl=e=>this.adapter.setUploadUrl(e),this.save=(e,i,r)=>this.adapter.save(e,i,r),this.saveAs=e=>this.adapter.saveAs(e),this.getDocumentContent=e=>this.adapter.getDocumentContent(e),this.closeDocument=(e,i,r)=>this.adapter.closeDocument(e,i,r),this.isDocumentOpened=()=>this.adapter.isDocumentOpened(),this.isDocumentModified=()=>this.adapter.isDocumentModified(),this.print=()=>this.adapter.print(),this.createPreview=(e,i)=>this.adapter.createPreview(e,i),this.adapter=u("document",ee,t)}}const ne={clearFind:{kind:"command"},findNext:{kind:"command"},findPrevious:{kind:"command"}};class ie{constructor(t){this.clearFind=()=>this.adapter.clearFind(),this.findNext=e=>this.adapter.findNext(e),this.findPrevious=e=>this.adapter.findPrevious(e),this.adapter=u("find",ne,t)}}const re={configFileUpload:{kind:"command"},setHttpHeaders:{kind:"command"},setHttpFormFields:{kind:"command"}};class ae{constructor(t){this.configFileUpload=e=>this.adapter.configFileUpload(e),this.setHttpHeaders=e=>this.adapter.setHttpHeaders(e),this.setHttpFormFields=e=>this.adapter.setHttpFormFields(e),this.adapter=u("networking",re,t)}}const oe=n=>({addPageChangeCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.pageChange.push(i)}},addPageModeChangeCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.pageModeChange.push(i)}},getPageCount:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&i(n.state.snapshot().pageCount)}},getPageIndex:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&i(n.state.snapshot().pageIndex)}},setSinglePageViewMode:{kind:"command"},setTwoPagesViewMode:{kind:"command"},setPageScrollVertical:{kind:"command"},setPageScrollHorizontal:{kind:"command"},setPageCursorPanDrag:{kind:"command"},setPageCursorTextSelect:{kind:"command"},rotateCW:{kind:"command"},rotateCCW:{kind:"command"},autoFitPage:{kind:"command"},fitPageSize:{kind:"command"},fitPageWidth:{kind:"command"},fitPageHeight:{kind:"command"},increasePageScale:{kind:"command"},decreasePageScale:{kind:"command"},setPageScale:{kind:"command"},setPageBlendColor:{kind:"command"},gotoPage:{kind:"command"},gotoNextPage:{kind:"command"},gotoPreviousPage:{kind:"command"},rotatePage:{kind:"command"}});class se{constructor(t){this.addPageChangeCallback=e=>this.adapter.addPageChangeCallback(e),this.addPageModeChangeCallback=e=>this.adapter.addPageModeChangeCallback(e),this.getPageCount=e=>this.adapter.getPageCount(e),this.getPageIndex=e=>this.adapter.getPageIndex(e),this.setSinglePageViewMode=()=>this.adapter.setSinglePageViewMode(),this.setTwoPagesViewMode=()=>this.adapter.setTwoPagesViewMode(),this.setPageScrollVertical=()=>this.adapter.setPageScrollVertical(),this.setPageScrollHorizontal=()=>this.adapter.setPageScrollHorizontal(),this.setPageCursorPanDrag=()=>this.adapter.setPageCursorPanDrag(),this.setPageCursorTextSelect=()=>this.adapter.setPageCursorTextSelect(),this.rotateCW=()=>this.adapter.rotateCW(),this.rotateCCW=()=>this.adapter.rotateCCW(),this.autoFitPage=()=>this.adapter.autoFitPage(),this.fitPageSize=()=>this.adapter.fitPageSize(),this.fitPageWidth=()=>this.adapter.fitPageWidth(),this.fitPageHeight=()=>this.adapter.fitPageHeight(),this.increasePageScale=()=>this.adapter.increasePageScale(),this.decreasePageScale=()=>this.adapter.decreasePageScale(),this.setPageScale=e=>this.adapter.setPageScale(e),this.setPageBlendColor=(e,i,r,a)=>this.adapter.setPageBlendColor(e,i,r,a),this.gotoPage=(e,i,r)=>this.adapter.gotoPage(e,i,r),this.gotoNextPage=()=>this.adapter.gotoNextPage(),this.gotoPreviousPage=()=>this.adapter.gotoPreviousPage(),this.rotatePage=e=>this.adapter.rotatePage(e),this.adapter=u("page",oe(t),t)}}const de={open:{kind:"command"},setFormFieldValue:{kind:"command"},setFormFieldReadonly:{kind:"command"},commit:{kind:"callbackQuery",mapCallbackResult:()=>[]},clear:{kind:"callbackQuery",mapCallbackResult:()=>[]},toKeyValue:{kind:"callbackQuery",mapCallbackResult:n=>[Array.isArray(n)?n:[]]}};class le{constructor(t){this.open=()=>this.adapter.open(),this.setFormFieldValue=(e,i)=>this.adapter.setFormFieldValue(e,i),this.setFormFieldReadonly=(e,i)=>this.adapter.setFormFieldReadonly(e,i),this.commit=e=>this.adapter.commit(e),this.clear=e=>this.adapter.clear(e),this.toKeyValue=e=>this.adapter.toKeyValue(e),this.adapter=u("pdfFormFiller",de,t)}}const ce=/\s*,\s*/,ue=/\s*-\s*/,R=n=>{const t=Number.parseInt(n.trim(),10);return!Number.isFinite(t)||t<=0?null:t},he=n=>{const t=n.split(ue);if(t.length===1){const r=R(t[0]??"");return r?[r]:[]}const e=R(t[0]??""),i=R(t[1]??"");return!e||!i||i<e?[]:Array.from({length:i-e+1},(r,a)=>e+a)},me=n=>n?n.split(ce).flatMap(e=>he(e)).filter((e,i,r)=>r.indexOf(e)===i):[];class pe{constructor(t,e,i){this.setFieldName=r=>{this.key=r},this.setFieldValue=r=>{this.value=r},this.setDescription=r=>{this.description=r},this.key=t,this.value=e,this.description=i}}class ge{constructor(){this.fields=[],this.keywordTextFixedPositions=void 0,this.keywordOffsetX=0,this.keywordOffsetY=0,this.bookmarkOffsetX=0,this.bookmarkOffsetY=0,this.printMargin=0,this.grayscaleSealImage=!1,this.signType=0,this.sealPosition=0,this.getSignType=()=>this.signType,this.setSignType=t=>{this.signType=t},this.isCrossPageSideSign=()=>this.signType===2||this.signType===3,this.getSealPosition=()=>this.sealPosition,this.setSignOnPageSides=t=>{t>=0&&t<=3&&(this.signType=t)},this.setSignPositionOnPageSides=t=>{this.sealPosition=t},this.setPageRange=t=>{this.pageRange=t},this.getPageRange=()=>this.pageRange,this.getPageRanges=()=>me(this.pageRange),this.setSignUserData=t=>{this.signUserData=t},this.setPrintMargin=t=>{this.printMargin=t},this.getPrintMargin=()=>this.printMargin??0,this.setSignReason=t=>{this.signReason=t},this.getSignReason=()=>this.signReason,this.setSignLocation=t=>{this.signLocation=t},this.getSignLocation=()=>this.signLocation,this.setDefaultStampPassword=t=>{this.defaultStampPassword=t}}}const ke=new Set([2,5]),fe=n=>({showToolbarMenu:{kind:"command"},hideToolbarMenu:{kind:"command"},setupToolbarMenu:{kind:"command"},showToolbarMenuItem:{kind:"command"},hideToolbarMenuItem:{kind:"command"},setupRibbonMenu:{kind:"command"},setupRibbonMenuItem:{kind:"command"},setupRibbonTitleBar:{kind:"command"},showRibbonMenu:{kind:"command"},hideRibbonMenu:{kind:"command"},showRibbonMenuItem:{kind:"command"},hideRibbonMenuItem:{kind:"command"},showRibbonTitleBar:{kind:"command"},hideRibbonTitleBar:{kind:"command"},selectRibbonMenu:{kind:"command"},setRibbonMenuButtonStyle:{kind:"command"},setWatermark:{kind:"command"},setCompactMode:{kind:"command"},enterBookViewMode:{kind:"callbackQuery",mapCallbackResult:()=>[]},exitBookViewMode:{kind:"command"},isBookViewActivated:{kind:"stateGetter",state:()=>ke.has(n.state.snapshot().pageMode)},requestFullScreen:{kind:"command"},exitFullScreen:{kind:"command"},invalidateView:{kind:"command"}});class be{constructor(t){this.showToolbarMenu=()=>this.adapter.showToolbarMenu(),this.hideToolbarMenu=()=>this.adapter.hideToolbarMenu(),this.setupToolbarMenu=e=>this.adapter.setupToolbarMenu(e),this.showToolbarMenuItem=e=>this.adapter.showToolbarMenuItem(e),this.hideToolbarMenuItem=e=>this.adapter.hideToolbarMenuItem(e),this.setupRibbonMenu=e=>this.adapter.setupRibbonMenu(e),this.setupRibbonMenuItem=(e,i,r)=>this.adapter.setupRibbonMenuItem(e,i,r),this.setupRibbonTitleBar=e=>this.adapter.setupRibbonTitleBar(e),this.showRibbonMenu=()=>this.adapter.showRibbonMenu(),this.hideRibbonMenu=()=>this.adapter.hideRibbonMenu(),this.showRibbonMenuItem=(e,i)=>this.adapter.showRibbonMenuItem(e,i),this.hideRibbonMenuItem=(e,i)=>this.adapter.hideRibbonMenuItem(e,i),this.showRibbonTitleBar=()=>this.adapter.showRibbonTitleBar(),this.hideRibbonTitleBar=()=>this.adapter.hideRibbonTitleBar(),this.selectRibbonMenu=e=>this.adapter.selectRibbonMenu(e),this.setRibbonMenuButtonStyle=(e,i)=>this.adapter.setRibbonMenuButtonStyle(e,i),this.setWatermark=e=>this.adapter.setWatermark(e),this.setCompactMode=e=>this.adapter.setCompactMode(e),this.enterBookViewMode=e=>this.adapter.enterBookViewMode(e),this.exitBookViewMode=()=>this.adapter.exitBookViewMode(),this.isBookViewActivated=()=>this.adapter.isBookViewActivated(),this.requestFullScreen=()=>this.adapter.requestFullScreen(),this.exitFullScreen=()=>this.adapter.exitFullScreen(),this.invalidateView=()=>this.adapter.invalidateView(),this.adapter=u("ui",fe(t),t)}}const Te=n=>{if(!n)return;const t=n.trim().toLowerCase();if(t==="application")return"auto";if(t==="light"||t==="dark"||t==="high-contrast"||t==="auto")return t},F=n=>{const t=new URL(n,globalThis.location?.href??"http://localhost/");return t.hash="",t.pathname.endsWith("/")||(t.pathname=`${t.pathname}/`),t.toString()},Ee=n=>new URL("editors.bootstrap.js",n).toString(),Re=(n,t)=>{const e=F(n);return{...t,appUrl:e,scrollIntoView:t.scrollIntoView??!0,theme:Te(t.theme)}},p="rhc-office-editor",v="__RHC_OFFICE_SDK_READER_LOADER__",O=()=>{const n=globalThis;return n[v]||(n[v]={activeAppUrl:null,loadPromises:new Map}),n[v]},ve=n=>Array.from(document.querySelectorAll("script")).find(t=>t.src===n)??null;class L extends Error{constructor(t){super(`Failed to load reader bootstrap script: ${t}`),this.name="ReaderScriptLoadError"}}class ye extends Error{constructor(t,e){super(`Reader Web Component "${p}" is already bound to ${t} and cannot be reloaded from ${e}.`),this.name="ReaderSourceConflictError"}}const U=n=>{const t=O();if(t.activeAppUrl&&t.activeAppUrl!==n)throw new ye(t.activeAppUrl,n)},Se=n=>{const t=O();U(n);const e=t.loadPromises.get(n);if(e)return e;if(globalThis.customElements?.get(p)){t.activeAppUrl=n;const o=Promise.resolve();return t.loadPromises.set(n,o),o}const i=Ee(n),r=ve(i);t.activeAppUrl=n;const a=new Promise((o,s)=>{const c=S=>{S?.remove(),s(new L(i))},b=()=>{globalThis.customElements.whenDefined(p).then(()=>{o()}).catch(s)};if(r){if(globalThis.customElements?.get(p)){o();return}r.addEventListener("error",()=>s(new L(i)),{once:!0}),b();return}const d=document.createElement("script");d.src=i,d.async=!0,d.dataset.rhcOfficeSdkReader=n,d.addEventListener("load",b,{once:!0}),d.addEventListener("error",()=>c(d),{once:!0}),document.head.appendChild(d)}).catch(o=>{throw t.loadPromises.delete(n),!globalThis.customElements?.get(p)&&t.activeAppUrl===n&&(t.activeAppUrl=null),o});return t.loadPromises.set(n,a),a},Pe="rhc-office.editor-adapter",Ce=1,Ae="__RHC_OFFICE_EDITOR_ADAPTER__",N="rhcOfficeAdapterReady",V="rhcOfficeAdapterEvent",De="data-rhc-office-reader-id",Me=5e3,Ie=5e3,we=()=>{const n=globalThis.crypto;return typeof n?.randomUUID=="function"?n.randomUUID():`adapter-${Date.now()}-${Math.random().toString(36).slice(2)}`},f=()=>globalThis[Ae];class _e extends Error{constructor(t,e,i){super(e),this.name="ReaderBridgeError",this.code=t,this.details=i}}class Fe{constructor(t){this.readerId=null,this.readyTimeoutMs=t?.readyTimeoutMs??Ie,this.requestTimeoutMs=t?.requestTimeoutMs??Me}configureTimeouts(t){this.readyTimeoutMs=t?.readyTimeoutMs??this.readyTimeoutMs,this.requestTimeoutMs=t?.requestTimeoutMs??this.requestTimeoutMs}setReaderId(t){this.readerId=t}getReaderId(){return this.readerId}async request(t,e,i,r){const a=await this.requestRaw(t,e,i,r);if(a.ok)return a.result;throw new _e(a.error.code,a.error.message,a.error.details)}async requestRaw(t,e,i,r){if(!this.readerId)return{ok:!1,requestId:"",error:{code:"READER_NOT_READY",message:"Reader is not mounted."}};const a=await this.waitForAdapter(this.readerId,r?.timeoutMs);if(!a)return{ok:!1,requestId:"",error:{code:"ADAPTER_UNAVAILABLE",message:"Editor adapter is not available."}};const o={protocol:Pe,version:Ce,requestId:we(),readerId:this.readerId,tool:t,method:e,params:i};return this.withTimeout(a.request(o),o.requestId,r?.timeoutMs??this.requestTimeoutMs)}getCapabilities(){return this.readerId?f()?.getCapabilities(this.readerId)??null:null}async waitForAdapter(t,e=this.readyTimeoutMs){const i=f();return i?.getCapabilities(t)?i:new Promise(r=>{let a;const o=()=>{a&&clearTimeout(a),globalThis.removeEventListener(N,s)},s=c=>{if((c instanceof CustomEvent?c.detail:void 0)?.readerId!==t)return;const d=f();o(),r(d??null)};globalThis.addEventListener(N,s),a=setTimeout(()=>{o(),r(f()?.getCapabilities(t)?f():null)},e)})}async withTimeout(t,e,i){return new Promise(r=>{const a=setTimeout(()=>{r({ok:!1,requestId:e,error:{code:"TIMEOUT",message:`Editor adapter request timed out after ${i}ms.`}})},i);t.then(o=>r(o)).catch(o=>{r({ok:!1,requestId:e,error:{code:"EXECUTION_FAILED",message:o instanceof Error?o.message:String(o)}})}).finally(()=>{clearTimeout(a)})})}}const B={annotationEnabled:!1,documentModified:!1,documentOpened:!1,pageCount:0,pageIndex:1,pageMode:0,zoomLevel:100};class Oe{constructor(){this.state={...B}}reset(){this.state={...B}}update(t){t&&(this.state={...this.state,...t})}setDocumentOpened(t){this.state={...this.state,documentOpened:t}}snapshot(){return{...this.state}}}class Le{constructor(){this.annotationEvents=[],this.annotationPersist=[],this.annotationRetrieve=[],this.digitalAnnotationRetrieve=[],this.digitalSignatureParse=[],this.digitalSignatureRetrieve=[],this.documentClosed=[],this.documentOpened=[],this.documentSaved=[],this.pageChange=[],this.pageModeChange=[]}emit(t,e){switch(t){case"documentOpened":case"documentLoaded":this.documentOpened.forEach(i=>i("ok",""));return;case"documentSaved":this.documentSaved.forEach(i=>i(e));return;case"documentClosed":this.documentClosed.forEach(i=>i(e));return;case"pageChange":{const i=e;this.pageChange.forEach(r=>r(i.pageIndex??1,i.pageCount??0));return}case"pageModeChange":{const i=e;this.pageModeChange.forEach(r=>r(i.pageMode??0));return}case"annotationEvent":{const i=e;this.annotationEvents.forEach(r=>r(i.event??"annotationEvent",i.payload));return}case"annotationPersist":this.annotationPersist.forEach(i=>i(e));return;case"annotationRetrieve":this.annotationRetrieve.forEach(i=>i(e));return;case"digitalAnnotationRetrieve":this.digitalAnnotationRetrieve.forEach(i=>i(Array.isArray(e)?e:[]));return;case"digitalSignatureRetrieve":this.digitalSignatureRetrieve.forEach(i=>i(Array.isArray(e)?e:[]));return;case"digitalSignatureParse":this.digitalSignatureParse.forEach(i=>i(Array.isArray(e)?e:[]));return;default:return}}}const Ue=["documentLoaded","documentStateChange","documentError"],Ne="readerReady",Ve="readerUnload",y="readerError",Be=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`rhc-reader-${Date.now()}-${Math.random().toString(36).slice(2)}`,K=(n,t)=>({appUrl:t?.appUrl??null,configuration:t,element:n}),Ke=n=>{if(typeof n=="string"){const t=document.getElementById(n);if(!t)throw new Error(`Reader container "${n}" was not found.`);if(!(t instanceof HTMLDivElement))throw new Error(`Reader container "${n}" must be a div element.`);return t}if(!(n instanceof HTMLDivElement))throw new Error("Reader container must be a div element.");return n},xe=()=>{const n=typeof globalThis.matchMedia=="function";return(n?globalThis.matchMedia("(prefers-contrast: more)").matches:!1)?"high-contrast":(n?globalThis.matchMedia("(prefers-color-scheme: dark)").matches:!1)?"dark":"light"},x=(n,t)=>{const e=n;if(typeof e.addEventListener=="function"){e.addEventListener("change",t);return}typeof e.addListener=="function"&&e.addListener(t)},G=(n,t)=>{const e=n;if(typeof e.removeEventListener=="function"){e.removeEventListener("change",t);return}typeof e.removeListener=="function"&&e.removeListener(t)},Ge=(n,t)=>{t.style&&(n.style.cssText=t.style),n.style.display||(n.style.display="block"),n.style.width?t.width&&(n.style.width=t.width):n.style.width=t.width??"100%",n.style.height?t.height&&(n.style.height=t.height):n.style.height=t.height??"100%"},He=(n,t)=>{const e=t.theme;if(!e)return n.removeAttribute("theme"),null;if(e!=="auto")return n.setAttribute("theme",e),null;const i=()=>{n.setAttribute("theme",xe())};if(i(),typeof globalThis.matchMedia!="function")return null;const r=globalThis.matchMedia("(prefers-color-scheme: dark)"),a=globalThis.matchMedia("(prefers-contrast: more)"),o=()=>{i()};return x(r,o),x(a,o),()=>{G(r,o),G(a,o)}};class H{constructor(t){this.bridge=new Fe,this.callbacks=new Le,this.readerState=new Oe,this.bridgeToolContext={bridge:this.bridge,callbacks:this.callbacks,debug:()=>this.debugEnabled,onAsyncError:e=>this.reportAdapterError(e),state:this.readerState},this.documentTool=new te(this.bridgeToolContext),this.uiTool=new be(this.bridgeToolContext),this.pageTool=new se(this.bridgeToolContext),this.findTool=new ie(this.bridgeToolContext),this.signServerTool=k("signServer",this.bridgeToolContext),this.digitalSignTool=k("digitalSign",this.bridgeToolContext),this.symbologyTool=k("symbology",this.bridgeToolContext),this.annotationTool=this.createAnnotationTool(),this.templateSignTool=k("templateSign",this.bridgeToolContext),this.pdfFormFiller=new le(this.bridgeToolContext),this.networkingTool=new ae(this.bridgeToolContext),this.cryptoTool=k("crypto",this.bridgeToolContext),this.readyCallbacks=[],this.unloadCallbacks=[],this.debugEnabled=!1,this.isReady=!1,this.removed=!1,this.mountToken=0,this.hostContainer=null,this.readerElement=null,this.readerId=null,this.normalizedConfiguration=null,this.nativeEventCleanupCallbacks=[],this.themeCleanup=null,this.enableDebug=e=>{this.debugEnabled=e},this.changeLanguage=()=>{},this.setLicense=(e,i)=>{this.license={license:e,feature:i}},this.setSessionUser=e=>{this.sessionUser=e},this.setSessionUserId=e=>{if(typeof this.sessionUser=="string"||!this.sessionUser){this.sessionUser={userName:typeof this.sessionUser=="string"?this.sessionUser:"",userId:e};return}this.sessionUser={...this.sessionUser,userId:e}},this.setSessionData=e=>{this.sessionData=e},this.isReaderReady=()=>this.isReady,this.isReaderDestroyed=()=>this.removed&&!this.isReady,this.addReaderReadyCallback=e=>{this.readyCallbacks.push(e)},this.addReaderUnloadCallback=e=>{this.unloadCallbacks.push(e)},this.setReaderEventListener=e=>{this.readerEventListener=e},this.embedReader=(e,i,r)=>{const a=Ke(e),o=F(i);U(o);const s=Re(o,r),c=this.mountToken+1;this.removeReader(),this.mountToken=c,this.removed=!1,this.hostContainer=a,this.normalizedConfiguration=s,this.mountReader(a,s,c)},this.removeReader=()=>{const e=!!(this.readerElement||this.hostContainer);if(this.mountToken+=1,this.cleanupNativeEventForwarders(),this.cleanupThemeBinding(),this.readerElement?.parentNode&&this.readerElement.parentNode.removeChild(this.readerElement),this.readerElement=null,this.readerId=null,this.bridge.setReaderId(null),this.readerState.reset(),this.hostContainer=null,this.normalizedConfiguration=null,this.isReady=!1,this.removed=!0,!e)return;const i=K(null,null);this.emitReaderEvent(Ve,i),this.unloadCallbacks.forEach(r=>r())},this.getDocumentTool=()=>this.documentTool,this.getUITool=()=>this.uiTool,this.getPageTool=()=>this.pageTool,this.getFindTool=()=>this.findTool,this.getSignServerTool=()=>this.signServerTool,this.getDigitalSignTool=()=>this.digitalSignTool,this.getSymbologyTool=()=>this.symbologyTool,this.getAnnotationTool=()=>this.annotationTool,this.getTemplateSignTool=()=>this.templateSignTool,this.getPdfFormFiller=()=>this.pdfFormFiller,this.getNetworkingTool=()=>this.networkingTool,this.getCryptoTool=()=>this.cryptoTool,this.createDigitalSignOptions=()=>new ge,this.createKVField=(e,i,r)=>new pe(e,i,r),this.mountReader=async(e,i,r)=>{try{if(await Se(i.appUrl),this.mountToken!==r)return;const a=document.createElement(p),o=Be();if(a.setAttribute(De,o),this.readerId=o,this.bridge.setReaderId(o),Ge(a,i),this.themeCleanup=He(a,i),this.bindNativeReaderEvents(a),e.replaceChildren(a),this.readerElement=a,await Promise.resolve(),this.mountToken!==r)return;i.scrollIntoView&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({behavior:"smooth",block:"nearest"}),this.isReady=!0;const s=K(a,i);this.emitReaderEvent(Ne,s),this.readyCallbacks.forEach(c=>c())}catch(a){if(this.mountToken!==r)return;this.reportReaderError(a)}},this.bindNativeReaderEvents=e=>{this.cleanupNativeEventForwarders();const i=r=>{const a=r instanceof CustomEvent?r.detail:null;!a||a.readerId!==this.readerId||(this.readerState.update(a.statePatch),this.callbacks.emit(a.event,a.payload),this.emitReaderEvent(a.event,a.payload))};e.addEventListener(V,i),this.nativeEventCleanupCallbacks.push(()=>{e.removeEventListener(V,i)}),Ue.forEach(r=>{const a=o=>{const s=o instanceof CustomEvent?o.detail:o;r==="documentLoaded"&&this.readerState.setDocumentOpened(!0),this.emitReaderEvent(r,s),r==="documentError"&&this.emitReaderEvent(y,s)};e.addEventListener(r,a),this.nativeEventCleanupCallbacks.push(()=>{e.removeEventListener(r,a)})})},this.cleanupNativeEventForwarders=()=>{this.nativeEventCleanupCallbacks.splice(0).forEach(e=>e())},this.cleanupThemeBinding=()=>{this.themeCleanup?.(),this.themeCleanup=null},this.emitReaderEvent=(e,i)=>{this.readerEventListener?.(e,i)},this.reportReaderError=e=>{this.isReady=!1,this.debugEnabled&&console.error("[RHC Office SDK] Reader mount failed",e),this.emitReaderEvent(y,e)},this.reportAdapterError=e=>{this.debugEnabled&&console.error("[RHC Office SDK] Adapter command failed",e),this.emitReaderEvent(y,e)},this.bridge.configureTimeouts({readyTimeoutMs:t?.adapterReadyTimeoutMs,requestTimeoutMs:t?.adapterRequestTimeoutMs})}createAnnotationTool(){return u("annotation",{addAnnotationEventCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.annotationEvents.push(i)}},addAnnotationPersistCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.annotationPersist.push(i)}},addAnnotationRetrieveCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.annotationRetrieve.push(i)}},addDigitalAnnotationRetrieveCallback:{kind:"callbackRegister",callback:(t,e)=>{const i=e[0];typeof i=="function"&&t.digitalAnnotationRetrieve.push(i)}},isInAnnotationMode:{kind:"stateGetter",state:t=>t.annotationEnabled},getAnnotations:{kind:"stateGetter",state:()=>[]},getAnnotationsCount:{kind:"stateGetter",state:()=>0},queryAnnotationsBy:{kind:"stateGetter",state:()=>[]},setToolSource:{kind:"command"},openAnnotationView:{kind:"command"},closeAnnotationView:{kind:"command"},openTextAnnotationView:{kind:"command"},setTextAnnotationFontColor:{kind:"command"},setTextAnnotationFontSize:{kind:"command"},closeTextAnnotationView:{kind:"command"},createTextAnnotation:{kind:"command"},setPersistToDocument:{kind:"command"},saveAnnotations:{kind:"callbackQuery"},saveTextAnnotations:{kind:"command"},clearAnnotations:{kind:"command"},clearTextAnnotations:{kind:"command"},undoAnnotation:{kind:"command"},redoAnnotation:{kind:"command"},selectAnnotationTool:{kind:"command"},showAnnotationColorPicker:{kind:"command"},setAnnotationPenType:{kind:"command"},appendAnnotations:{kind:"callbackQuery"},batchAppendAnnotations:{kind:"callbackQuery"},setAnnotationPenColor:{kind:"command"},setAnnotationPenWidth:{kind:"command"},setAnnotationPenThickness:{kind:"command"},enableAnnotationsInfoView:{kind:"command"},enableAnnotationsDeletion:{kind:"command"},enableAnnotationsDeletionOnlyByAuthor:{kind:"command"},listDigitalStamps:{kind:"command"},listAnnotations:{kind:"command"},deleteAnnotationsBy:{kind:"command"},deleteAnnotationsById:{kind:"command"},addDigitalAnnotation:{kind:"command"},addInkAnnotationCallback:{kind:"callbackRegister"}},this.bridgeToolContext)}}const qe=n=>new H(n);l.DIGITAL_SIGN_DEFAULTS=Z,l.DocumentSDK=H,l.WatermarkDisplay=h,l.createNewDocumentSdk=qe,l.getDigitalSignEnvironment=$,l.initializeDigitalSignEnvironment=j,l.patchDigitalSignEnvironment=X,l.resetDigitalSignEnvironment=J,l.setDigitalSignEnvironment=Y,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(o,h){typeof exports=="object"&&typeof module<"u"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(o=typeof globalThis<"u"?globalThis:o||self,h(o.RHCOfficeSDK={}))})(this,function(o){"use strict";var h=(t=>(t.DEFAULT="default",t.COMPACT="compact",t.HIDE="none",t))(h||{});const E="RIGHT_CENTER",R="REGULAR_ESM",P="auto",f="__RHC_OFFICE_DIGITAL_SIGN_ENVIRONMENT__",D={defaults:{bjca:{pin:""},deviceType:"client",edgePosition:E,kol:{appId:"",appName:"",pin:"",serviceUrl:"",token:""},plugin:{pin:"",usbKeyType:14},rsaMode:P,signatureType:R},signServer:{authSource:"Password",defaultLogin:"",defaultPassword:"",defaultServer:"",kol:{appId:"",appName:"",serviceUrl:"",token:""},macAddress:"",token:"",usbKey:{checkCertificateBinding:!1,usbKeyType:14}}},C=t=>({bjca:{pin:t.bjca.pin},deviceType:t.deviceType,edgePosition:t.edgePosition,kol:{appId:t.kol.appId,appName:t.kol.appName,pin:t.kol.pin,serviceUrl:t.kol.serviceUrl,token:t.kol.token},plugin:{pin:t.plugin.pin,usbKeyType:t.plugin.usbKeyType},rsaMode:t.rsaMode,signatureType:t.signatureType}),I=t=>({authSource:t.authSource,defaultLogin:t.defaultLogin,defaultPassword:t.defaultPassword,defaultServer:t.defaultServer,kol:{appId:t.kol.appId,appName:t.kol.appName,serviceUrl:t.kol.serviceUrl,token:t.kol.token},macAddress:t.macAddress,token:t.token,usbKey:{checkCertificateBinding:t.usbKey.checkCertificateBinding,usbKeyType:t.usbKey.usbKeyType}}),m=t=>({defaults:C(t.defaults),signServer:I(t.signServer)}),w=t=>({defaults:t.defaults?{...t.defaults,bjca:t.defaults.bjca?{...t.defaults.bjca}:void 0,kol:t.defaults.kol?{...t.defaults.kol}:void 0,plugin:t.defaults.plugin?{...t.defaults.plugin}:void 0}:void 0,signServer:t.signServer?{...t.signServer,kol:t.signServer.kol?{...t.signServer.kol}:void 0,usbKey:t.signServer.usbKey?{...t.signServer.usbKey}:void 0}:void 0}),re=(t,n)=>n?{bjca:{pin:n.bjca?.pin??t.bjca.pin},deviceType:n.deviceType??t.deviceType,edgePosition:n.edgePosition??t.edgePosition,kol:{appId:n.kol?.appId??t.kol.appId,appName:n.kol?.appName??t.kol.appName,pin:n.kol?.pin??t.kol.pin,serviceUrl:n.kol?.serviceUrl??t.kol.serviceUrl,token:n.kol?.token??t.kol.token},plugin:{pin:n.plugin?.pin??t.plugin.pin,usbKeyType:n.plugin?.usbKeyType??t.plugin.usbKeyType},rsaMode:n.rsaMode??t.rsaMode,signatureType:n.signatureType??t.signatureType}:C(t),se=(t,n)=>n?{authSource:n.authSource??t.authSource,defaultLogin:n.defaultLogin??t.defaultLogin,defaultPassword:n.defaultPassword??t.defaultPassword,defaultServer:n.defaultServer??t.defaultServer,kol:{appId:n.kol?.appId??t.kol.appId,appName:n.kol?.appName??t.kol.appName,serviceUrl:n.kol?.serviceUrl??t.kol.serviceUrl,token:n.kol?.token??t.kol.token},macAddress:n.macAddress??t.macAddress,token:n.token??t.token,usbKey:{checkCertificateBinding:n.usbKey?.checkCertificateBinding??t.usbKey.checkCertificateBinding,usbKeyType:n.usbKey?.usbKeyType??t.usbKey.usbKeyType}}:I(t),M=(t,n)=>({defaults:re(t.defaults,n.defaults),signServer:se(t.signServer,n.signServer)}),oe=(t,n)=>({defaults:t.defaults||n.defaults?{...t.defaults,...n.defaults,bjca:{...t.defaults?.bjca??{},...n.defaults?.bjca??{}},kol:{...t.defaults?.kol??{},...n.defaults?.kol??{}},plugin:{...t.defaults?.plugin??{},...n.defaults?.plugin??{}}}:void 0,signServer:t.signServer||n.signServer?{...t.signServer,...n.signServer,kol:{...t.signServer?.kol??{},...n.signServer?.kol??{}},usbKey:{...t.signServer?.usbKey??{},...n.signServer?.usbKey??{}}}:void 0}),de=()=>globalThis,p=()=>{const t=de();return t[f]||(t[f]={current:m(D),defaults:m(D),overrides:{}}),t[f]},le=()=>p().current,ce=t=>{const n=p();return n.defaults=m(t),n.current=M(n.defaults,n.overrides),n.current},ue=t=>{const n=p();return n.current=m(t),n.overrides=w(t),n.current},he=t=>{const n=p();return n.overrides=oe(n.overrides,w(t)),n.current=M(n.current,t),n.current},me=t=>{const n=p();return t&&(n.defaults=m(t)),n.overrides={},n.current=m(n.defaults),n.current},ge={EDGE_POSITION:E,RSA_MODE:P,SIGNATURE_TYPE:R},b=t=>{if(t.length!==0)return t.length===1?t[0]:t},u=(t,n,e)=>new Proxy({},{get:(i,a)=>{if(a==="then")return;if(typeof a=="symbol")return a===Symbol.toStringTag?t:void 0;const r=n[a];return r?(...s)=>{if(r.kind==="callbackRegister"){r.callback?.(e.callbacks,s);return}if(r.kind==="stateGetter")return r.state?.(e.state.snapshot(),s);const d=r.adapterMethod??a;if(r.kind==="query")return e.bridge.request(t,d,b(s));if(r.kind==="callbackQuery"){const c=s.find(l=>typeof l=="function"),S=s.filter(l=>typeof l!="function");e.bridge.request(t,d,b(S)).then(l=>{const y=r.mapCallbackResult?.(l)??[l];c?.(...y)}).catch(e.onAsyncError);return}e.bridge.request(t,d,b(s)).catch(e.onAsyncError)}:(...s)=>{const d=new Error(`${t}.${a} is not implemented by the SDK adapter.`);e.onAsyncError(d)}}}),pe={addAnnotationEventCallback:{kind:"callbackRegister",callback:(t,n)=>{const e=n[0];typeof e=="function"&&t.annotationEvents.push(e)}},addAnnotationPersistCallback:{kind:"callbackRegister",callback:(t,n)=>{const e=n[0];typeof e=="function"&&t.annotationPersist.push(e)}},addAnnotationRetrieveCallback:{kind:"callbackRegister",callback:(t,n)=>{const e=n[0];typeof e=="function"&&t.annotationRetrieve.push(e)}},addDigitalAnnotationRetrieveCallback:{kind:"callbackRegister",callback:(t,n)=>{const e=n[0];typeof e=="function"&&t.digitalAnnotationRetrieve.push(e)}},isInAnnotationMode:{kind:"stateGetter",state:t=>t.annotationEnabled},getAnnotations:{kind:"stateGetter",state:()=>[]},getAnnotationsCount:{kind:"stateGetter",state:()=>0},queryAnnotationsBy:{kind:"stateGetter",state:()=>[]},setToolSource:{kind:"command"},openAnnotationView:{kind:"command"},closeAnnotationView:{kind:"command"},openTextAnnotationView:{kind:"command"},setTextAnnotationFontColor:{kind:"command"},setTextAnnotationFontSize:{kind:"command"},closeTextAnnotationView:{kind:"command"},createTextAnnotation:{kind:"command"},setPersistToDocument:{kind:"command"},saveAnnotations:{kind:"callbackQuery"},saveTextAnnotations:{kind:"command"},clearAnnotations:{kind:"command"},clearTextAnnotations:{kind:"command"},undoAnnotation:{kind:"command"},redoAnnotation:{kind:"command"},selectAnnotationTool:{kind:"command"},showAnnotationColorPicker:{kind:"command"},setAnnotationPenType:{kind:"command"},appendAnnotations:{kind:"callbackQuery"},batchAppendAnnotations:{kind:"callbackQuery"},setAnnotationPenColor:{kind:"command"},setAnnotationPenWidth:{kind:"command"},setAnnotationPenThickness:{kind:"command"},enableAnnotationsInfoView:{kind:"command"},enableAnnotationsDeletion:{kind:"command"},enableAnnotationsDeletionOnlyByAuthor:{kind:"command"},listDigitalStamps:{kind:"command"},listAnnotations:{kind:"command"},deleteAnnotationsBy:{kind:"command"},deleteAnnotationsById:{kind:"command"},addDigitalAnnotation:{kind:"command"},addInkAnnotationCallback:{kind:"callbackRegister"}};class O{constructor(n){this.setToolSource=e=>this.adapter.setToolSource(e),this.openAnnotationView=e=>this.adapter.openAnnotationView(e),this.closeAnnotationView=e=>this.adapter.closeAnnotationView(e),this.openTextAnnotationView=()=>this.adapter.openTextAnnotationView(),this.setTextAnnotationFontColor=e=>this.adapter.setTextAnnotationFontColor(e),this.setTextAnnotationFontSize=e=>this.adapter.setTextAnnotationFontSize(e),this.closeTextAnnotationView=e=>this.adapter.closeTextAnnotationView(e),this.createTextAnnotation=e=>this.adapter.createTextAnnotation(e),this.setPersistToDocument=e=>this.adapter.setPersistToDocument(e),this.saveAnnotations=e=>this.adapter.saveAnnotations(e),this.saveTextAnnotations=()=>this.adapter.saveTextAnnotations(),this.clearAnnotations=()=>this.adapter.clearAnnotations(),this.clearTextAnnotations=()=>this.adapter.clearTextAnnotations(),this.undoAnnotation=()=>this.adapter.undoAnnotation(),this.redoAnnotation=()=>this.adapter.redoAnnotation(),this.selectAnnotationTool=e=>this.adapter.selectAnnotationTool(e),this.showAnnotationColorPicker=()=>this.adapter.showAnnotationColorPicker(),this.setAnnotationPenType=e=>this.adapter.setAnnotationPenType(e),this.appendAnnotations=(e,i)=>this.adapter.appendAnnotations(e,i),this.batchAppendAnnotations=(e,i)=>this.adapter.batchAppendAnnotations(e,i),this.setAnnotationPenColor=e=>this.adapter.setAnnotationPenColor(e),this.setAnnotationPenWidth=e=>this.adapter.setAnnotationPenWidth(e),this.setAnnotationPenThickness=e=>this.adapter.setAnnotationPenThickness(e),this.enableAnnotationsInfoView=e=>this.adapter.enableAnnotationsInfoView(e),this.enableAnnotationsDeletion=e=>this.adapter.enableAnnotationsDeletion(e),this.enableAnnotationsDeletionOnlyByAuthor=e=>this.adapter.enableAnnotationsDeletionOnlyByAuthor(e),this.listDigitalStamps=()=>this.adapter.listDigitalStamps(),this.isInAnnotationMode=()=>this.adapter.isInAnnotationMode(),this.listAnnotations=e=>this.adapter.listAnnotations(e),this.getAnnotations=()=>this.adapter.getAnnotations(),this.getAnnotationsCount=()=>this.adapter.getAnnotationsCount(),this.queryAnnotationsBy=e=>this.adapter.queryAnnotationsBy(e),this.deleteAnnotationsBy=(e,i)=>this.adapter.deleteAnnotationsBy(e,i),this.deleteAnnotationsById=(e,i)=>this.adapter.deleteAnnotationsById(e,i),this.addDigitalAnnotation=e=>this.adapter.addDigitalAnnotation(e),this.addInkAnnotationCallback=e=>this.adapter.addInkAnnotationCallback(e),this.addAnnotationEventCallback=e=>this.adapter.addAnnotationEventCallback(e),this.addAnnotationPersistCallback=e=>this.adapter.addAnnotationPersistCallback(e),this.addAnnotationRetrieveCallback=e=>this.adapter.addAnnotationRetrieveCallback(e),this.addDigitalAnnotationRetrieveCallback=e=>this.adapter.addDigitalAnnotationRetrieveCallback(e),this.adapter=u("annotation",pe,n)}}const ke={configSecurityProvider:{kind:"command"},getSecurityProviders:{kind:"query"}};class _{constructor(n){this.configSecurityProvider=e=>this.adapter.configSecurityProvider(e),this.getSecurityProviders=()=>this.adapter.getSecurityProviders(),this.adapter=u("crypto",ke,n)}}const Se={addDigitalSignatureRetrieveCallback:{kind:"callbackRegister",callback:(t,n)=>{const e=n[0];typeof e=="function"&&t.digitalSignatureRetrieve.push(e)}},addDigitalSignatureParseCallback:{kind:"callbackRegister",callback:(t,n)=>{const e=n[0];typeof e=="function"&&t.digitalSignatureParse.push(e)}},addDigitalSignCallback:{kind:"callbackRegister",callback:(t,n)=>{const e=n[0];typeof e=="function"&&t.digitalSign.push(e)}},setCryptoProvider:{kind:"command"},setSealSource:{kind:"command"},setDefaultStampPassword:{kind:"command"},setDefaultSealPassword:{kind:"command"},setDefaultKeystorePassword:{kind:"command"},setDefaultUSBKeyPassword:{kind:"command"},setupExternalSealServer:{kind:"command"},setDigitalSignOptions:{kind:"command"},setExternalDigitalSignOptions:{kind:"command"},setPDFDigitalSignCaptionOptions:{kind:"command"},addDigitalSignature:{kind:"callbackQuery"},addDigitalSignatureBySelectedSearchHighlight:{kind:"command"},listDigitalSignatures:{kind:"callbackQuery"},getDigitalSignatures:{kind:"stateGetter",state:()=>[]},getDigitalSignaturesCount:{kind:"stateGetter",state:()=>0},enableDigitalSignatureInfoView:{kind:"command"},enableDigitalSignatureRevocation:{kind:"command"}};class F{constructor(n){this.addDigitalSignatureRetrieveCallback=e=>this.adapter.addDigitalSignatureRetrieveCallback(e),this.addDigitalSignatureParseCallback=e=>this.adapter.addDigitalSignatureParseCallback(e),this.setCryptoProvider=(e,i,a)=>this.adapter.setCryptoProvider(e,i,a),this.setSealSource=e=>this.adapter.setSealSource(e),this.setDefaultStampPassword=e=>this.adapter.setDefaultStampPassword(e),this.setDefaultSealPassword=e=>this.adapter.setDefaultSealPassword(e),this.setDefaultKeystorePassword=e=>this.adapter.setDefaultKeystorePassword(e),this.setDefaultUSBKeyPassword=e=>this.adapter.setDefaultUSBKeyPassword(e),this.addDigitalSignCallback=e=>this.adapter.addDigitalSignCallback(e),this.setupExternalSealServer=e=>this.adapter.setupExternalSealServer(e),this.setDigitalSignOptions=e=>this.adapter.setDigitalSignOptions(e),this.setExternalDigitalSignOptions=e=>this.adapter.setExternalDigitalSignOptions(e),this.setPDFDigitalSignCaptionOptions=e=>this.adapter.setPDFDigitalSignCaptionOptions(e),this.addDigitalSignature=(e,i)=>this.adapter.addDigitalSignature(e,i),this.addDigitalSignatureBySelectedSearchHighlight=e=>this.adapter.addDigitalSignatureBySelectedSearchHighlight(e),this.listDigitalSignatures=e=>this.adapter.listDigitalSignatures(e),this.getDigitalSignatures=()=>this.adapter.getDigitalSignatures(),this.getDigitalSignaturesCount=()=>this.adapter.getDigitalSignaturesCount(),this.enableDigitalSignatureInfoView=e=>this.adapter.enableDigitalSignatureInfoView(e),this.enableDigitalSignatureRevocation=e=>this.adapter.enableDigitalSignatureRevocation(e),this.adapter=u("digitalSign",Se,n)}}const fe="rhc-office.editor-adapter",be=1,Te="__RHC_OFFICE_EDITOR_ADAPTER__",L="rhcOfficeAdapterReady",N="rhcOfficeAdapterEvent",U="data-rhc-office-reader-id",ve={addDocumentOpenedCallback:{kind:"callbackRegister",callback:(t,n)=>{const e=n[0];typeof e=="function"&&t.documentOpened.push(e)}},addDocumentSavedCallback:{kind:"callbackRegister",callback:(t,n)=>{const e=n[0];typeof e=="function"&&t.documentSaved.push(e)}},addDocumentClosedCallback:{kind:"callbackRegister",callback:(t,n)=>{const e=n[0];typeof e=="function"&&t.documentClosed.push(e)}},openPDFDocument:{kind:"callbackQuery",adapterMethod:"open"},openPdfDocument:{kind:"callbackQuery",adapterMethod:"open"},openOFDDocument:{kind:"callbackQuery",adapterMethod:"open"},openOfdDocument:{kind:"callbackQuery",adapterMethod:"open"},openOfficeDocument:{kind:"callbackQuery",adapterMethod:"open"},openImageDocument:{kind:"callbackQuery",adapterMethod:"open"},openTextDocument:{kind:"callbackQuery",adapterMethod:"open"},openFromLocalStorage:{kind:"command"},setUploadUrl:{kind:"command"},save:{kind:"callbackQuery"},saveAs:{kind:"query"},getDocumentContent:{kind:"callbackQuery",mapCallbackResult:t=>{const n=t;return[n?.fileCacheId,n?.fileBuffer]}},closeDocument:{kind:"callbackQuery"},isDocumentOpened:{kind:"stateGetter",state:t=>t.documentOpened},isDocumentModified:{kind:"stateGetter",state:t=>t.documentModified},print:{kind:"command"},createPreview:{kind:"command"}};class B{constructor(n){this.context=n,this.addDocumentOpenedCallback=e=>this.adapter.addDocumentOpenedCallback(e),this.addDocumentSavedCallback=e=>this.adapter.addDocumentSavedCallback(e),this.addDocumentClosedCallback=e=>this.adapter.addDocumentClosedCallback(e),this.openPDFDocument=(e,i)=>this.adapter.openPDFDocument(e,i),this.openPdfDocument=(e,i)=>this.adapter.openPdfDocument(e,i),this.openOFDDocument=(e,i)=>this.adapter.openOFDDocument(e,i),this.openOfdDocument=(e,i)=>this.adapter.openOfdDocument(e,i),this.openOfficeDocument=(e,i)=>this.adapter.openOfficeDocument(e,i),this.openImageDocument=(e,i)=>this.adapter.openImageDocument(e,i),this.openTextDocument=(e,i)=>this.adapter.openTextDocument(e,i),this.openFromLocalStorage=()=>this.adapter.openFromLocalStorage(),this.setUploadUrl=e=>this.adapter.setUploadUrl(e),this.save=(e,i,a)=>this.adapter.save(e,i,a),this.saveAs=e=>{const i=this.context.bridge.getReaderId();if(!i)return Promise.resolve({success:!1,action:"save-as",filename:e?.filename,error:"Reader is not mounted or does not expose saveAs."});const a=document.querySelector(`[${U}="${i}"]`);return typeof a?.saveAs=="function"?a.saveAs(e):this.adapter.saveAs(e)},this.getDocumentContent=e=>this.adapter.getDocumentContent(e),this.closeDocument=(e,i,a)=>this.adapter.closeDocument(e,i,a),this.isDocumentOpened=()=>this.adapter.isDocumentOpened(),this.isDocumentModified=()=>this.adapter.isDocumentModified(),this.print=()=>this.adapter.print(),this.createPreview=(e,i)=>this.adapter.createPreview(e,i),this.adapter=u("document",ve,n)}}const Ae={clearFind:{kind:"command"},findNext:{kind:"command"},findPrevious:{kind:"command"}};class V{constructor(n){this.clearFind=()=>this.adapter.clearFind(),this.findNext=e=>this.adapter.findNext(e),this.findPrevious=e=>this.adapter.findPrevious(e),this.adapter=u("find",Ae,n)}}const ye={configFileUpload:{kind:"command"},setHttpHeaders:{kind:"command"},setHttpFormFields:{kind:"command"}};class K{constructor(n){this.configFileUpload=e=>this.adapter.configFileUpload(e),this.setHttpHeaders=e=>this.adapter.setHttpHeaders(e),this.setHttpFormFields=e=>this.adapter.setHttpFormFields(e),this.adapter=u("networking",ye,n)}}const Ee=t=>({addPageChangeCallback:{kind:"callbackRegister",callback:(n,e)=>{const i=e[0];typeof i=="function"&&n.pageChange.push(i)}},addPageModeChangeCallback:{kind:"callbackRegister",callback:(n,e)=>{const i=e[0];typeof i=="function"&&n.pageModeChange.push(i)}},getPageCount:{kind:"callbackRegister",callback:(n,e)=>{const i=e[0];typeof i=="function"&&i(t.state.snapshot().pageCount)}},getPageIndex:{kind:"callbackRegister",callback:(n,e)=>{const i=e[0];typeof i=="function"&&i(t.state.snapshot().pageIndex)}},setSinglePageViewMode:{kind:"command"},setTwoPagesViewMode:{kind:"command"},setPageScrollVertical:{kind:"command"},setPageScrollHorizontal:{kind:"command"},setPageCursorPanDrag:{kind:"command"},setPageCursorTextSelect:{kind:"command"},rotateCW:{kind:"command"},rotateCCW:{kind:"command"},autoFitPage:{kind:"command"},fitPageSize:{kind:"command"},fitPageWidth:{kind:"command"},fitPageHeight:{kind:"command"},increasePageScale:{kind:"command"},decreasePageScale:{kind:"command"},setPageScale:{kind:"command"},setPageBlendColor:{kind:"command"},gotoPage:{kind:"command"},gotoNextPage:{kind:"command"},gotoPreviousPage:{kind:"command"},rotatePage:{kind:"command"}});class x{constructor(n){this.addPageChangeCallback=e=>this.adapter.addPageChangeCallback(e),this.addPageModeChangeCallback=e=>this.adapter.addPageModeChangeCallback(e),this.getPageCount=e=>this.adapter.getPageCount(e),this.getPageIndex=e=>this.adapter.getPageIndex(e),this.setSinglePageViewMode=()=>this.adapter.setSinglePageViewMode(),this.setTwoPagesViewMode=()=>this.adapter.setTwoPagesViewMode(),this.setPageScrollVertical=()=>this.adapter.setPageScrollVertical(),this.setPageScrollHorizontal=()=>this.adapter.setPageScrollHorizontal(),this.setPageCursorPanDrag=()=>this.adapter.setPageCursorPanDrag(),this.setPageCursorTextSelect=()=>this.adapter.setPageCursorTextSelect(),this.rotateCW=()=>this.adapter.rotateCW(),this.rotateCCW=()=>this.adapter.rotateCCW(),this.autoFitPage=()=>this.adapter.autoFitPage(),this.fitPageSize=()=>this.adapter.fitPageSize(),this.fitPageWidth=()=>this.adapter.fitPageWidth(),this.fitPageHeight=()=>this.adapter.fitPageHeight(),this.increasePageScale=()=>this.adapter.increasePageScale(),this.decreasePageScale=()=>this.adapter.decreasePageScale(),this.setPageScale=e=>this.adapter.setPageScale(e),this.setPageBlendColor=(e,i,a,r)=>this.adapter.setPageBlendColor(e,i,a,r),this.gotoPage=(e,i,a)=>this.adapter.gotoPage(e,i,a),this.gotoNextPage=()=>this.adapter.gotoNextPage(),this.gotoPreviousPage=()=>this.adapter.gotoPreviousPage(),this.rotatePage=e=>this.adapter.rotatePage(e),this.adapter=u("page",Ee(n),n)}}const Re={open:{kind:"command"},setFormFieldValue:{kind:"command"},setFormFieldReadonly:{kind:"command"},commit:{kind:"callbackQuery",mapCallbackResult:()=>[]},clear:{kind:"callbackQuery",mapCallbackResult:()=>[]},toKeyValue:{kind:"callbackQuery",mapCallbackResult:t=>[Array.isArray(t)?t:[]]}};class G{constructor(n){this.open=()=>this.adapter.open(),this.setFormFieldValue=(e,i)=>this.adapter.setFormFieldValue(e,i),this.setFormFieldReadonly=(e,i)=>this.adapter.setFormFieldReadonly(e,i),this.commit=e=>this.adapter.commit(e),this.clear=e=>this.adapter.clear(e),this.toKeyValue=e=>this.adapter.toKeyValue(e),this.adapter=u("pdfFormFiller",Re,n)}}class H extends Error{constructor(n,e){super(`[Phase 1] ${n}.${e} is not implemented yet.`),this.name="SDKPhase1NotImplementedError"}}const Pe=(t,n)=>()=>{throw new H(t,n)},De=t=>new Proxy({},{get:(n,e)=>{if(e!=="then")return typeof e=="symbol"?e===Symbol.toStringTag?t:void 0:Pe(t,e)}}),Ce=/\s*,\s*/,Ie=/\s*-\s*/,T=t=>{const n=Number.parseInt(t.trim(),10);return!Number.isFinite(n)||n<=0?null:n},we=t=>{const n=t.split(Ie);if(n.length===1){const a=T(n[0]??"");return a?[a]:[]}const e=T(n[0]??""),i=T(n[1]??"");return!e||!i||i<e?[]:Array.from({length:i-e+1},(a,r)=>e+r)},Me=t=>t?t.split(Ce).flatMap(e=>we(e)).filter((e,i,a)=>a.indexOf(e)===i):[];class q{constructor(n,e,i){this.setFieldName=a=>{this.key=a},this.setFieldValue=a=>{this.value=a},this.setDescription=a=>{this.description=a},this.key=n,this.value=e,this.description=i}}class Q{constructor(){this.fields=[],this.keywordTextFixedPositions=void 0,this.keywordOffsetX=0,this.keywordOffsetY=0,this.bookmarkOffsetX=0,this.bookmarkOffsetY=0,this.printMargin=0,this.grayscaleSealImage=!1,this.signType=0,this.sealPosition=0,this.getSignType=()=>this.signType,this.setSignType=n=>{this.signType=n},this.isCrossPageSideSign=()=>this.signType===2||this.signType===3,this.getSealPosition=()=>this.sealPosition,this.setSignOnPageSides=n=>{n>=0&&n<=3&&(this.signType=n)},this.setSignPositionOnPageSides=n=>{this.sealPosition=n},this.setPageRange=n=>{this.pageRange=n},this.getPageRange=()=>this.pageRange,this.getPageRanges=()=>Me(this.pageRange),this.setSignUserData=n=>{this.signUserData=n},this.setPrintMargin=n=>{this.printMargin=n},this.getPrintMargin=()=>this.printMargin??0,this.setSignReason=n=>{this.signReason=n},this.getSignReason=()=>this.signReason,this.setSignLocation=n=>{this.signLocation=n},this.getSignLocation=()=>this.signLocation,this.setDefaultStampPassword=n=>{this.defaultStampPassword=n}}}const Oe={setSignServer:{kind:"command"},addSignServerAuthCallback:{kind:"callbackRegister",callback:(t,n)=>{const e=n[0];typeof e=="function"&&t.signServerAuth.push(e)}},setSignServerDefaultLogin:{kind:"command"},setDefaultSignServerLogin:{kind:"command"},setSignServerDefaultPassword:{kind:"command"},setDefaultSignServerPassword:{kind:"command"},loginNTKOSignServer:{kind:"command"},loginSignServer:{kind:"callbackQuery"},signOutSignServer:{kind:"command"},isAuthenticatedOnSignServer:{kind:"stateGetter",state:()=>!1},setSignServerLoginFromUSBKey:{kind:"command"},setUserAuthSource:{kind:"command"}};class z{constructor(n){this.setSignServer=e=>this.adapter.setSignServer(e),this.addSignServerAuthCallback=e=>this.adapter.addSignServerAuthCallback(e),this.setSignServerDefaultLogin=e=>this.adapter.setSignServerDefaultLogin(e),this.setDefaultSignServerLogin=e=>this.adapter.setDefaultSignServerLogin(e),this.setSignServerDefaultPassword=e=>this.adapter.setSignServerDefaultPassword(e),this.setDefaultSignServerPassword=e=>this.adapter.setDefaultSignServerPassword(e),this.loginNTKOSignServer=(e,i,a)=>this.adapter.loginNTKOSignServer(e,i,a),this.loginSignServer=(e,i,a,r)=>this.adapter.loginSignServer(e,i,a,r),this.signOutSignServer=()=>this.adapter.signOutSignServer(),this.isAuthenticatedOnSignServer=()=>this.adapter.isAuthenticatedOnSignServer(),this.setSignServerLoginFromUSBKey=(e,i)=>this.adapter.setSignServerLoginFromUSBKey(e,i),this.setUserAuthSource=e=>this.adapter.setUserAuthSource(e),this.adapter=u("signServer",Oe,n)}}const _e={createPDF417Barcode:{kind:"command"}};class W{constructor(n){this.createPDF417Barcode=(e,i,a,r,s,d,c)=>this.adapter.createPDF417Barcode(e,i,a,r,s,d,c),this.adapter=u("symbology",_e,n)}}const Fe={setup:{kind:"command"},create:{kind:"command"},getMarkups:{kind:"callbackQuery"},removeMarkup:{kind:"command"},removeAllMarkups:{kind:"command"},sign:{kind:"callbackQuery"}};class ${constructor(n){this.setup=e=>this.adapter.setup(e),this.create=e=>this.adapter.create(e),this.getMarkups=e=>this.adapter.getMarkups(e),this.removeMarkup=(e,i)=>this.adapter.removeMarkup(e,i),this.removeAllMarkups=e=>this.adapter.removeAllMarkups(e),this.sign=e=>this.adapter.sign(e),this.adapter=u("templateSign",Fe,n)}}const Le=new Set([2,5]),Ne=t=>({showToolbarMenu:{kind:"command"},hideToolbarMenu:{kind:"command"},setupToolbarMenu:{kind:"command"},showToolbarMenuItem:{kind:"command"},hideToolbarMenuItem:{kind:"command"},setupRibbonMenu:{kind:"command"},setupRibbonMenuItem:{kind:"command"},setupRibbonTitleBar:{kind:"command"},showRibbonMenu:{kind:"command"},hideRibbonMenu:{kind:"command"},showRibbonMenuItem:{kind:"command"},hideRibbonMenuItem:{kind:"command"},showRibbonTitleBar:{kind:"command"},hideRibbonTitleBar:{kind:"command"},selectRibbonMenu:{kind:"command"},setRibbonMenuButtonStyle:{kind:"command"},setWatermark:{kind:"command"},setCompactMode:{kind:"command"},enterBookViewMode:{kind:"callbackQuery",mapCallbackResult:()=>[]},exitBookViewMode:{kind:"command"},isBookViewActivated:{kind:"stateGetter",state:()=>Le.has(t.state.snapshot().pageMode)},requestFullScreen:{kind:"command"},exitFullScreen:{kind:"command"},invalidateView:{kind:"command"}});class Y{constructor(n){this.showToolbarMenu=()=>this.adapter.showToolbarMenu(),this.hideToolbarMenu=()=>this.adapter.hideToolbarMenu(),this.setupToolbarMenu=e=>this.adapter.setupToolbarMenu(e),this.showToolbarMenuItem=e=>this.adapter.showToolbarMenuItem(e),this.hideToolbarMenuItem=e=>this.adapter.hideToolbarMenuItem(e),this.setupRibbonMenu=e=>this.adapter.setupRibbonMenu(e),this.setupRibbonMenuItem=(e,i,a)=>this.adapter.setupRibbonMenuItem(e,i,a),this.setupRibbonTitleBar=e=>this.adapter.setupRibbonTitleBar(e),this.showRibbonMenu=()=>this.adapter.showRibbonMenu(),this.hideRibbonMenu=()=>this.adapter.hideRibbonMenu(),this.showRibbonMenuItem=(e,i)=>this.adapter.showRibbonMenuItem(e,i),this.hideRibbonMenuItem=(e,i)=>this.adapter.hideRibbonMenuItem(e,i),this.showRibbonTitleBar=()=>this.adapter.showRibbonTitleBar(),this.hideRibbonTitleBar=()=>this.adapter.hideRibbonTitleBar(),this.selectRibbonMenu=e=>this.adapter.selectRibbonMenu(e),this.setRibbonMenuButtonStyle=(e,i)=>this.adapter.setRibbonMenuButtonStyle(e,i),this.setWatermark=e=>this.adapter.setWatermark(e),this.setCompactMode=e=>this.adapter.setCompactMode(e),this.enterBookViewMode=e=>this.adapter.enterBookViewMode(e),this.exitBookViewMode=()=>this.adapter.exitBookViewMode(),this.isBookViewActivated=()=>this.adapter.isBookViewActivated(),this.requestFullScreen=()=>this.adapter.requestFullScreen(),this.exitFullScreen=()=>this.adapter.exitFullScreen(),this.invalidateView=()=>this.adapter.invalidateView(),this.adapter=u("ui",Ne(n),n)}}const Ue=t=>{if(!t)return;const n=t.trim().toLowerCase();if(n==="application")return"auto";if(n==="light"||n==="dark"||n==="high-contrast"||n==="auto")return n},j=t=>{const n=new URL(t,globalThis.location?.href??"http://localhost/");return n.hash="",n.pathname.endsWith("/")||(n.pathname=`${n.pathname}/`),n.toString()},Be=t=>new URL("editors.bootstrap.js",t).toString(),Ve=(t,n)=>{const e=j(t);return{...n,appUrl:e,scrollIntoView:n.scrollIntoView??!0,theme:Ue(n.theme)}},g="rhc-office-editor",v="__RHC_OFFICE_SDK_READER_LOADER__",X=()=>{const t=globalThis;return t[v]||(t[v]={activeAppUrl:null,loadPromises:new Map}),t[v]},Ke=t=>Array.from(document.querySelectorAll("script")).find(n=>n.src===t)??null;class J extends Error{constructor(n){super(`Failed to load reader bootstrap script: ${n}`),this.name="ReaderScriptLoadError"}}class xe extends Error{constructor(n,e){super(`Reader Web Component "${g}" is already bound to ${n} and cannot be reloaded from ${e}.`),this.name="ReaderSourceConflictError"}}const Z=t=>{const n=X();if(n.activeAppUrl&&n.activeAppUrl!==t)throw new xe(n.activeAppUrl,t)},Ge=t=>{const n=X();Z(t);const e=n.loadPromises.get(t);if(e)return e;if(globalThis.customElements?.get(g)){n.activeAppUrl=t;const s=Promise.resolve();return n.loadPromises.set(t,s),s}const i=Be(t),a=Ke(i);n.activeAppUrl=t;const r=new Promise((s,d)=>{const c=y=>{y?.remove(),d(new J(i))},S=()=>{globalThis.customElements.whenDefined(g).then(()=>{s()}).catch(d)};if(a){if(globalThis.customElements?.get(g)){s();return}a.addEventListener("error",()=>d(new J(i)),{once:!0}),S();return}const l=document.createElement("script");l.src=i,l.async=!0,l.dataset.rhcOfficeSdkReader=t,l.addEventListener("load",S,{once:!0}),l.addEventListener("error",()=>c(l),{once:!0}),document.head.appendChild(l)}).catch(s=>{throw n.loadPromises.delete(t),!globalThis.customElements?.get(g)&&n.activeAppUrl===t&&(n.activeAppUrl=null),s});return n.loadPromises.set(t,r),r},He=5e3,qe=5e3,Qe=()=>{const t=globalThis.crypto;return typeof t?.randomUUID=="function"?t.randomUUID():`adapter-${Date.now()}-${Math.random().toString(36).slice(2)}`},k=()=>globalThis[Te];class ze extends Error{constructor(n,e,i){super(e),this.name="ReaderBridgeError",this.code=n,this.details=i}}class We{constructor(n){this.readerId=null,this.readyTimeoutMs=n?.readyTimeoutMs??qe,this.requestTimeoutMs=n?.requestTimeoutMs??He}configureTimeouts(n){this.readyTimeoutMs=n?.readyTimeoutMs??this.readyTimeoutMs,this.requestTimeoutMs=n?.requestTimeoutMs??this.requestTimeoutMs}setReaderId(n){this.readerId=n}getReaderId(){return this.readerId}async request(n,e,i,a){const r=await this.requestRaw(n,e,i,a);if(r.ok)return r.result;throw new ze(r.error.code,r.error.message,r.error.details)}async requestRaw(n,e,i,a){if(!this.readerId)return{ok:!1,requestId:"",error:{code:"READER_NOT_READY",message:"Reader is not mounted."}};const r=await this.waitForAdapter(this.readerId,a?.timeoutMs);if(!r)return{ok:!1,requestId:"",error:{code:"ADAPTER_UNAVAILABLE",message:"Editor adapter is not available."}};const s={protocol:fe,version:be,requestId:Qe(),readerId:this.readerId,tool:n,method:e,params:i};return this.withTimeout(r.request(s),s.requestId,a?.timeoutMs??this.requestTimeoutMs)}getCapabilities(){return this.readerId?k()?.getCapabilities(this.readerId)??null:null}async waitForAdapter(n,e=this.readyTimeoutMs){const i=k();return i?.getCapabilities(n)?i:new Promise(a=>{let r;const s=()=>{r&&clearTimeout(r),globalThis.removeEventListener(L,d)},d=c=>{if((c instanceof CustomEvent?c.detail:void 0)?.readerId!==n)return;const l=k();s(),a(l??null)};globalThis.addEventListener(L,d),r=setTimeout(()=>{s(),a(k()?.getCapabilities(n)?k():null)},e)})}async withTimeout(n,e,i){return new Promise(a=>{const r=setTimeout(()=>{a({ok:!1,requestId:e,error:{code:"TIMEOUT",message:`Editor adapter request timed out after ${i}ms.`}})},i);n.then(s=>a(s)).catch(s=>{a({ok:!1,requestId:e,error:{code:"EXECUTION_FAILED",message:s instanceof Error?s.message:String(s)}})}).finally(()=>{clearTimeout(r)})})}}const ee={annotationEnabled:!1,documentModified:!1,documentOpened:!1,pageCount:0,pageIndex:1,pageMode:0,zoomLevel:100};class $e{constructor(){this.state={...ee}}reset(){this.state={...ee}}update(n){n&&(this.state={...this.state,...n})}setDocumentOpened(n){this.state={...this.state,documentOpened:n}}snapshot(){return{...this.state}}}class Ye{constructor(){this.annotationEvents=[],this.annotationPersist=[],this.annotationRetrieve=[],this.digitalAnnotationRetrieve=[],this.digitalSign=[],this.digitalSignatureParse=[],this.digitalSignatureRetrieve=[],this.documentClosed=[],this.documentOpened=[],this.documentSaved=[],this.pageChange=[],this.pageModeChange=[],this.signServerAuth=[]}emit(n,e){switch(n){case"documentOpened":case"documentLoaded":this.documentOpened.forEach(i=>i("ok",""));return;case"documentSaved":this.documentSaved.forEach(i=>i(e));return;case"documentClosed":this.documentClosed.forEach(i=>i(e));return;case"pageChange":{const i=e;this.pageChange.forEach(a=>a(i.pageIndex??1,i.pageCount??0));return}case"pageModeChange":{const i=e;this.pageModeChange.forEach(a=>a(i.pageMode??0));return}case"annotationEvent":{const i=e;this.annotationEvents.forEach(a=>a(i.event??"annotationEvent",i.payload));return}case"annotationPersist":this.annotationPersist.forEach(i=>i(e));return;case"annotationRetrieve":this.annotationRetrieve.forEach(i=>i(e));return;case"digitalAnnotationRetrieve":this.digitalAnnotationRetrieve.forEach(i=>i(Array.isArray(e)?e:[]));return;case"digitalSign":this.digitalSign.forEach(i=>i(e));return;case"digitalSignatureRetrieve":this.digitalSignatureRetrieve.forEach(i=>i(Array.isArray(e)?e:[]));return;case"digitalSignatureParse":this.digitalSignatureParse.forEach(i=>i(Array.isArray(e)?e:[]));return;case"signServerAuth":this.signServerAuth.forEach(i=>i(e));return;default:return}}}const je=["documentLoaded","documentStateChange","documentError"],Xe="readerReady",Je="readerUnload",A="readerError",Ze=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`rhc-reader-${Date.now()}-${Math.random().toString(36).slice(2)}`,te=(t,n)=>({appUrl:n?.appUrl??null,configuration:n,element:t}),et=t=>{if(typeof t=="string"){const n=document.getElementById(t);if(!n)throw new Error(`Reader container "${t}" was not found.`);if(!(n instanceof HTMLDivElement))throw new Error(`Reader container "${t}" must be a div element.`);return n}if(!(t instanceof HTMLDivElement))throw new Error("Reader container must be a div element.");return t},tt=()=>{const t=typeof globalThis.matchMedia=="function";return(t?globalThis.matchMedia("(prefers-contrast: more)").matches:!1)?"high-contrast":(t?globalThis.matchMedia("(prefers-color-scheme: dark)").matches:!1)?"dark":"light"},ne=(t,n)=>{const e=t;if(typeof e.addEventListener=="function"){e.addEventListener("change",n);return}typeof e.addListener=="function"&&e.addListener(n)},ie=(t,n)=>{const e=t;if(typeof e.removeEventListener=="function"){e.removeEventListener("change",n);return}typeof e.removeListener=="function"&&e.removeListener(n)},nt=(t,n)=>{n.style&&(t.style.cssText=n.style),t.style.display||(t.style.display="block"),t.style.width?n.width&&(t.style.width=n.width):t.style.width=n.width??"100%",t.style.height?n.height&&(t.style.height=n.height):t.style.height=n.height??"100%"},it=(t,n)=>{const e=n.theme;if(!e)return t.removeAttribute("theme"),null;if(e!=="auto")return t.setAttribute("theme",e),null;const i=()=>{t.setAttribute("theme",tt())};if(i(),typeof globalThis.matchMedia!="function")return null;const a=globalThis.matchMedia("(prefers-color-scheme: dark)"),r=globalThis.matchMedia("(prefers-contrast: more)"),s=()=>{i()};return ne(a,s),ne(r,s),()=>{ie(a,s),ie(r,s)}};class ae{constructor(n){this.bridge=new We,this.callbacks=new Ye,this.readerState=new $e,this.bridgeToolContext={bridge:this.bridge,callbacks:this.callbacks,debug:()=>this.debugEnabled,onAsyncError:e=>this.reportAdapterError(e),state:this.readerState},this.documentTool=new B(this.bridgeToolContext),this.uiTool=new Y(this.bridgeToolContext),this.pageTool=new x(this.bridgeToolContext),this.findTool=new V(this.bridgeToolContext),this.signServerTool=new z(this.bridgeToolContext),this.digitalSignTool=new F(this.bridgeToolContext),this.symbologyTool=new W(this.bridgeToolContext),this.annotationTool=new O(this.bridgeToolContext),this.templateSignTool=new $(this.bridgeToolContext),this.pdfFormFiller=new G(this.bridgeToolContext),this.networkingTool=new K(this.bridgeToolContext),this.cryptoTool=new _(this.bridgeToolContext),this.readyCallbacks=[],this.unloadCallbacks=[],this.debugEnabled=!1,this.isReady=!1,this.removed=!1,this.mountToken=0,this.hostContainer=null,this.readerElement=null,this.readerId=null,this.normalizedConfiguration=null,this.nativeEventCleanupCallbacks=[],this.themeCleanup=null,this.enableDebug=e=>{this.debugEnabled=e},this.changeLanguage=()=>{},this.setLicense=(e,i)=>{this.license={license:e,feature:i}},this.setSessionUser=e=>{this.sessionUser=e},this.setSessionUserId=e=>{if(typeof this.sessionUser=="string"||!this.sessionUser){this.sessionUser={userName:typeof this.sessionUser=="string"?this.sessionUser:"",userId:e};return}this.sessionUser={...this.sessionUser,userId:e}},this.setSessionData=e=>{this.sessionData=e},this.isReaderReady=()=>this.isReady,this.isReaderDestroyed=()=>this.removed&&!this.isReady,this.addReaderReadyCallback=e=>{this.readyCallbacks.push(e)},this.addReaderUnloadCallback=e=>{this.unloadCallbacks.push(e)},this.setReaderEventListener=e=>{this.readerEventListener=e},this.embedReader=(e,i,a)=>{const r=et(e),s=j(i);Z(s);const d=Ve(s,a),c=this.mountToken+1;this.removeReader(),this.mountToken=c,this.removed=!1,this.hostContainer=r,this.normalizedConfiguration=d,this.mountReader(r,d,c)},this.removeReader=()=>{const e=!!(this.readerElement||this.hostContainer);if(this.mountToken+=1,this.cleanupNativeEventForwarders(),this.cleanupThemeBinding(),this.readerElement?.parentNode&&this.readerElement.parentNode.removeChild(this.readerElement),this.readerElement=null,this.readerId=null,this.bridge.setReaderId(null),this.readerState.reset(),this.hostContainer=null,this.normalizedConfiguration=null,this.isReady=!1,this.removed=!0,!e)return;const i=te(null,null);this.emitReaderEvent(Je,i),this.unloadCallbacks.forEach(a=>a())},this.getDocumentTool=()=>this.documentTool,this.getUITool=()=>this.uiTool,this.getPageTool=()=>this.pageTool,this.getFindTool=()=>this.findTool,this.getSignServerTool=()=>this.signServerTool,this.getDigitalSignTool=()=>this.digitalSignTool,this.getSymbologyTool=()=>this.symbologyTool,this.getAnnotationTool=()=>this.annotationTool,this.getTemplateSignTool=()=>this.templateSignTool,this.getPdfFormFiller=()=>this.pdfFormFiller,this.getNetworkingTool=()=>this.networkingTool,this.getCryptoTool=()=>this.cryptoTool,this.createDigitalSignOptions=()=>new Q,this.createKVField=(e,i,a)=>new q(e,i,a),this.mountReader=async(e,i,a)=>{try{if(await Ge(i.appUrl),this.mountToken!==a)return;const r=document.createElement(g),s=Ze();if(r.setAttribute(U,s),this.readerId=s,this.bridge.setReaderId(s),nt(r,i),this.themeCleanup=it(r,i),this.bindNativeReaderEvents(r),e.replaceChildren(r),this.readerElement=r,await Promise.resolve(),this.mountToken!==a)return;i.scrollIntoView&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({behavior:"smooth",block:"nearest"}),this.isReady=!0;const d=te(r,i);this.emitReaderEvent(Xe,d),this.readyCallbacks.forEach(c=>c())}catch(r){if(this.mountToken!==a)return;this.reportReaderError(r)}},this.bindNativeReaderEvents=e=>{this.cleanupNativeEventForwarders();const i=a=>{const r=a instanceof CustomEvent?a.detail:null;!r||r.readerId!==this.readerId||(this.readerState.update(r.statePatch),this.callbacks.emit(r.event,r.payload),this.emitReaderEvent(r.event,r.payload))};e.addEventListener(N,i),this.nativeEventCleanupCallbacks.push(()=>{e.removeEventListener(N,i)}),je.forEach(a=>{const r=s=>{const d=s instanceof CustomEvent?s.detail:s;a==="documentLoaded"&&this.readerState.setDocumentOpened(!0),this.emitReaderEvent(a,d),a==="documentError"&&this.emitReaderEvent(A,d)};e.addEventListener(a,r),this.nativeEventCleanupCallbacks.push(()=>{e.removeEventListener(a,r)})})},this.cleanupNativeEventForwarders=()=>{this.nativeEventCleanupCallbacks.splice(0).forEach(e=>e())},this.cleanupThemeBinding=()=>{this.themeCleanup?.(),this.themeCleanup=null},this.emitReaderEvent=(e,i)=>{this.readerEventListener?.(e,i)},this.reportReaderError=e=>{this.isReady=!1,this.debugEnabled&&console.error("[RHC Office SDK] Reader mount failed",e),this.emitReaderEvent(A,e)},this.reportAdapterError=e=>{this.debugEnabled&&console.error("[RHC Office SDK] Adapter command failed",e),this.emitReaderEvent(A,e)},this.bridge.configureTimeouts({readyTimeoutMs:n?.adapterReadyTimeoutMs,requestTimeoutMs:n?.adapterRequestTimeoutMs})}}const at=t=>new ae(t);o.AnnotationToolImpl=O,o.CryptoToolImpl=_,o.DIGITAL_SIGN_DEFAULTS=ge,o.DigitalSignOptions=Q,o.DigitalSignToolImpl=F,o.DocumentSDK=ae,o.DocumentToolImpl=B,o.FindToolImpl=V,o.KVField=q,o.NetworkingToolImpl=K,o.PageToolImpl=x,o.PdfFormFillerImpl=G,o.SDKPhase1NotImplementedError=H,o.SignServerToolImpl=z,o.SymbologyToolImpl=W,o.TemplateSignToolImpl=$,o.UIToolImpl=Y,o.WatermarkDisplay=h,o.createNewDocumentSdk=at,o.createPhase1ToolPlaceholder=De,o.getDigitalSignEnvironment=le,o.initializeDigitalSignEnvironment=ce,o.patchDigitalSignEnvironment=he,o.resetDigitalSignEnvironment=me,o.setDigitalSignEnvironment=ue,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.cjs.map
|