@vertexvis/viewer 1.0.2-canary.7 → 1.0.2-testing.0
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/cjs/{config-BsqvZSt9.js → config-20ozv4y8.js} +3 -3
- package/dist/cjs/{config-BsqvZSt9.js.map → config-20ozv4y8.js.map} +1 -1
- package/dist/cjs/{entities-ByDO45G0.js → entities-D6kgGria.js} +4 -4
- package/dist/cjs/{entities-ByDO45G0.js.map → entities-D6kgGria.js.map} +1 -1
- package/dist/cjs/{geometry_pb-CuOYGIHT.js → geometry_pb-BTko2Wi0.js} +3 -3
- package/dist/cjs/{geometry_pb-CuOYGIHT.js.map → geometry_pb-BTko2Wi0.js.map} +1 -1
- package/dist/cjs/index.cjs.js +5 -5
- package/dist/cjs/{png-decoder-3NSToOjc.js → png-decoder-CJbE7UJh.js} +112 -112
- package/dist/cjs/png-decoder-CJbE7UJh.js.map +1 -0
- package/dist/cjs/{queries-CwDJxlsL.js → queries-Da9I-xMf.js} +4 -4
- package/dist/cjs/{queries-CwDJxlsL.js.map → queries-Da9I-xMf.js.map} +1 -1
- package/dist/cjs/{regl-component-DTvmpYVa.js → regl-component-HhKCyGQ3.js} +3 -3
- package/dist/cjs/{regl-component-DTvmpYVa.js.map → regl-component-HhKCyGQ3.js.map} +1 -1
- package/dist/cjs/{representation_pb-BU8a5Ico.js → representation_pb-CrCGjlyP.js} +3 -3
- package/dist/cjs/{representation_pb-BU8a5Ico.js.map → representation_pb-CrCGjlyP.js.map} +1 -1
- package/dist/cjs/{streamAttributes-BVp1vEp3.js → streamAttributes-D_J-W8-2.js} +3 -3
- package/dist/cjs/{streamAttributes-BVp1vEp3.js.map → streamAttributes-D_J-W8-2.js.map} +1 -1
- package/dist/cjs/vertex-scene-tree-table-cell.cjs.entry.js +1 -1
- package/dist/cjs/vertex-scene-tree.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-dom-element_2.cjs.entry.js +1 -1
- package/dist/cjs/vertex-viewer-hit-result-indicator.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-measurement-details.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-measurement-distance.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-measurement-line_2.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-measurement-precise.cjs.entry.js +4 -4
- package/dist/cjs/vertex-viewer-pin-group.cjs.entry.js +3 -3
- package/dist/cjs/vertex-viewer-transform-widget.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-view-cube.cjs.entry.js +1 -1
- package/dist/cjs/vertex-viewer.cjs.entry.js +4 -4
- package/dist/components/index.js +1 -1
- package/dist/components/{p-BfAW7IWG.js → p-B9R0QWr4.js} +2 -2
- package/dist/components/{p-CmtoXwYo.js → p-BCOD9yfw.js} +2 -2
- package/dist/components/{p-ux26QLbe.js → p-BOJJZ1cN.js} +2 -2
- package/dist/components/{p-C7GhKZ4q.js → p-CAugdB_8.js} +2 -2
- package/dist/components/{p-C9y2eVBq.js → p-CZCXdo3t.js} +2 -2
- package/dist/components/p-CycTYKAk.js +5 -0
- package/dist/components/{p-BnIeyVZl.js.map → p-CycTYKAk.js.map} +1 -1
- package/dist/components/{p-DTDKqbV2.js → p-D12q-fpW.js} +2 -2
- package/dist/components/{p-kVbpvDF1.js → p-DF4kEsJU.js} +2 -2
- package/dist/components/{p-D9oqIZ3P.js → p-DRnMrHWY.js} +2 -2
- package/dist/components/{p-B6mpmA2-.js → p-abSJ29r7.js} +2 -2
- package/dist/components/{p-CCPuHP2m.js → p-ahjMltGJ.js} +2 -2
- package/dist/components/vertex-scene-tree-table-cell.js +1 -1
- package/dist/components/vertex-scene-tree.js +1 -1
- package/dist/components/vertex-viewer-dom-renderer.js +1 -1
- package/dist/components/vertex-viewer-hit-result-indicator.js +1 -1
- package/dist/components/vertex-viewer-measurement-details.js +1 -1
- package/dist/components/vertex-viewer-measurement-distance.js +1 -1
- package/dist/components/vertex-viewer-measurement-overlays.js +1 -1
- package/dist/components/vertex-viewer-measurement-precise.js +1 -1
- package/dist/components/vertex-viewer-pin-group.js +1 -1
- package/dist/components/vertex-viewer-pin-tool.js +1 -1
- package/dist/components/vertex-viewer-transform-widget.js +1 -1
- package/dist/components/vertex-viewer-view-cube.js +1 -1
- package/dist/components/vertex-viewer.js +1 -1
- package/dist/esm/{config-SMudJna8.js → config-lglER3mU.js} +3 -3
- package/dist/esm/{config-SMudJna8.js.map → config-lglER3mU.js.map} +1 -1
- package/dist/esm/{entities-uAlr5vlE.js → entities-zRken6VS.js} +4 -4
- package/dist/esm/{entities-uAlr5vlE.js.map → entities-zRken6VS.js.map} +1 -1
- package/dist/esm/{geometry_pb-CMlgBITt.js → geometry_pb-BiZRfctN.js} +3 -3
- package/dist/esm/{geometry_pb-CMlgBITt.js.map → geometry_pb-BiZRfctN.js.map} +1 -1
- package/dist/esm/index.js +5 -5
- package/dist/esm/index.mjs +5 -5
- package/dist/esm/{png-decoder-Bjioht9N.js → png-decoder-CiunTuhu.js} +112 -112
- package/dist/esm/png-decoder-CiunTuhu.js.map +1 -0
- package/dist/esm/{queries-CgeSF7hf.js → queries-DEzCmbTD.js} +4 -4
- package/dist/esm/{queries-CgeSF7hf.js.map → queries-DEzCmbTD.js.map} +1 -1
- package/dist/esm/{regl-component-WqWCp9d-.js → regl-component-DmkowWhg.js} +3 -3
- package/dist/esm/{regl-component-WqWCp9d-.js.map → regl-component-DmkowWhg.js.map} +1 -1
- package/dist/esm/{representation_pb-BXvH1L33.js → representation_pb-g4f0WC4k.js} +3 -3
- package/dist/esm/{representation_pb-BXvH1L33.js.map → representation_pb-g4f0WC4k.js.map} +1 -1
- package/dist/esm/{streamAttributes-6asiWDkT.js → streamAttributes-Cp8PEH9A.js} +3 -3
- package/dist/esm/{streamAttributes-6asiWDkT.js.map → streamAttributes-Cp8PEH9A.js.map} +1 -1
- package/dist/esm/vertex-scene-tree-table-cell.entry.js +1 -1
- package/dist/esm/vertex-scene-tree.entry.js +2 -2
- package/dist/esm/vertex-viewer-dom-element_2.entry.js +1 -1
- package/dist/esm/vertex-viewer-hit-result-indicator.entry.js +2 -2
- package/dist/esm/vertex-viewer-measurement-details.entry.js +2 -2
- package/dist/esm/vertex-viewer-measurement-distance.entry.js +2 -2
- package/dist/esm/vertex-viewer-measurement-line_2.entry.js +2 -2
- package/dist/esm/vertex-viewer-measurement-precise.entry.js +4 -4
- package/dist/esm/vertex-viewer-pin-group.entry.js +3 -3
- package/dist/esm/vertex-viewer-transform-widget.entry.js +2 -2
- package/dist/esm/vertex-viewer-view-cube.entry.js +1 -1
- package/dist/esm/vertex-viewer.entry.js +4 -4
- package/dist/viewer/index.esm.js +1 -1
- package/dist/viewer/p-051b5154.entry.js +5 -0
- package/dist/viewer/{p-a5ed36cd.entry.js.map → p-051b5154.entry.js.map} +1 -1
- package/dist/viewer/{p-4dbad46f.entry.js → p-11cf755a.entry.js} +2 -2
- package/dist/viewer/{p-833d698b.entry.js → p-16775f7d.entry.js} +2 -2
- package/dist/viewer/{p-a866cbdb.entry.js → p-1eb636f8.entry.js} +2 -2
- package/dist/viewer/{p-bb18c218.entry.js → p-33f44cc1.entry.js} +2 -2
- package/dist/viewer/{p-9556c963.entry.js → p-35601c85.entry.js} +2 -2
- package/dist/viewer/{p-40dba623.entry.js → p-8c369777.entry.js} +2 -2
- package/dist/viewer/{p-Dx_kRMQd.js → p-BDvACHun.js} +2 -2
- package/dist/viewer/{p-Dx_kRMQd.js.map → p-BDvACHun.js.map} +1 -1
- package/dist/viewer/p-CZXGNc0T.js +5 -0
- package/dist/viewer/p-CZXGNc0T.js.map +1 -0
- package/dist/viewer/{p-B7IxKAst.js → p-ChqXy0cG.js} +2 -2
- package/dist/viewer/{p-B7IxKAst.js.map → p-ChqXy0cG.js.map} +1 -1
- package/dist/viewer/{p-BYm9621A.js → p-CyGlYje2.js} +2 -2
- package/dist/viewer/{p-BYm9621A.js.map → p-CyGlYje2.js.map} +1 -1
- package/dist/viewer/{p-DNam7E02.js → p-D6eJC1q4.js} +2 -2
- package/dist/viewer/{p-DNam7E02.js.map → p-D6eJC1q4.js.map} +1 -1
- package/dist/viewer/{p-BJm7oO2_.js → p-Dp56p_jX.js} +2 -2
- package/dist/viewer/{p-BJm7oO2_.js.map → p-Dp56p_jX.js.map} +1 -1
- package/dist/viewer/{p-Chfn1uMz.js → p-F8e15or2.js} +2 -2
- package/dist/viewer/{p-Chfn1uMz.js.map → p-F8e15or2.js.map} +1 -1
- package/dist/viewer/{p-CvVOQvMo.js → p-WPRMWirY.js} +2 -2
- package/dist/viewer/{p-CvVOQvMo.js.map → p-WPRMWirY.js.map} +1 -1
- package/dist/viewer/{p-04ebf937.entry.js → p-a8a81cba.entry.js} +2 -2
- package/dist/viewer/{p-4d5c68b4.entry.js → p-c7e62d66.entry.js} +2 -2
- package/dist/viewer/{p-578409b2.entry.js → p-e9b83dae.entry.js} +2 -2
- package/dist/viewer/{p-69aeb12a.entry.js → p-f271dc4a.entry.js} +2 -2
- package/dist/viewer/{p-9161d8c7.entry.js → p-f65c0769.entry.js} +2 -2
- package/dist/viewer/viewer.esm.js +1 -1
- package/package.json +10 -10
- package/dist/cjs/png-decoder-3NSToOjc.js.map +0 -1
- package/dist/components/p-BnIeyVZl.js +0 -5
- package/dist/esm/png-decoder-Bjioht9N.js.map +0 -1
- package/dist/types/web-workers.d.ts +0 -1
- package/dist/viewer/p-CmW2ZNHt.js +0 -5
- package/dist/viewer/p-CmW2ZNHt.js.map +0 -1
- package/dist/viewer/p-a5ed36cd.entry.js +0 -5
- /package/dist/components/{p-BfAW7IWG.js.map → p-B9R0QWr4.js.map} +0 -0
- /package/dist/components/{p-CmtoXwYo.js.map → p-BCOD9yfw.js.map} +0 -0
- /package/dist/components/{p-ux26QLbe.js.map → p-BOJJZ1cN.js.map} +0 -0
- /package/dist/components/{p-C7GhKZ4q.js.map → p-CAugdB_8.js.map} +0 -0
- /package/dist/components/{p-C9y2eVBq.js.map → p-CZCXdo3t.js.map} +0 -0
- /package/dist/components/{p-DTDKqbV2.js.map → p-D12q-fpW.js.map} +0 -0
- /package/dist/components/{p-kVbpvDF1.js.map → p-DF4kEsJU.js.map} +0 -0
- /package/dist/components/{p-D9oqIZ3P.js.map → p-DRnMrHWY.js.map} +0 -0
- /package/dist/components/{p-B6mpmA2-.js.map → p-abSJ29r7.js.map} +0 -0
- /package/dist/components/{p-CCPuHP2m.js.map → p-ahjMltGJ.js.map} +0 -0
- /package/dist/viewer/{p-4dbad46f.entry.js.map → p-11cf755a.entry.js.map} +0 -0
- /package/dist/viewer/{p-833d698b.entry.js.map → p-16775f7d.entry.js.map} +0 -0
- /package/dist/viewer/{p-a866cbdb.entry.js.map → p-1eb636f8.entry.js.map} +0 -0
- /package/dist/viewer/{p-bb18c218.entry.js.map → p-33f44cc1.entry.js.map} +0 -0
- /package/dist/viewer/{p-9556c963.entry.js.map → p-35601c85.entry.js.map} +0 -0
- /package/dist/viewer/{p-40dba623.entry.js.map → p-8c369777.entry.js.map} +0 -0
- /package/dist/viewer/{p-04ebf937.entry.js.map → p-a8a81cba.entry.js.map} +0 -0
- /package/dist/viewer/{p-4d5c68b4.entry.js.map → p-c7e62d66.entry.js.map} +0 -0
- /package/dist/viewer/{p-578409b2.entry.js.map → p-e9b83dae.entry.js.map} +0 -0
- /package/dist/viewer/{p-69aeb12a.entry.js.map → p-f271dc4a.entry.js.map} +0 -0
- /package/dist/viewer/{p-9161d8c7.entry.js.map → p-f65c0769.entry.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2026 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import{c as e,u as t,b as s,a as n}from"./p-CHdoymO5.js";import{c as i,d as r,e as a}from"./p--8q6LyIm.js";import{u as o,m as u,a as h,p as c,b as l,r as d}from"./p-D9oqIZ3P.js";import{s as p,w}from"./p-FRKLa468.js";import{r as v,c as f}from"./p-CjG1fMh1.js";import{v as m,f as y,c as x,m as I,q as g,r as b,p as S,e as B}from"./p-DDQcM-So.js";import{P as R,t as A,Q as E,u as V,e as q,f as T,R as k,T as C}from"./p-BfAW7IWG.js";import{v as P,t as M,L as O}from"./p-BoB09nlv.js";const D={opacity:255,glossiness:4,diffuse:{r:0,g:0,b:0,a:0},ambient:{r:0,g:0,b:0,a:0},specular:{r:0,g:0,b:0,a:0},emissive:{r:0,g:0,b:0,a:0}};const _=(e,t,s,n)=>({...D,opacity:n!==null&&n!==void 0?n:D.opacity,diffuse:{r:e,g:t,b:s,a:0}});const j=(t,s)=>{const n=e.fromHexString(t);return{...D,opacity:s!==null&&s!==void 0?s:D.opacity,diffuse:n!=null?{...n}:{...D.diffuse}}};var F=Object.freeze({__proto__:null,create:_,defaultColor:D,fromHex:j});function U(e){var s;const n=t.parse(e);if(n.scheme!=="urn"||n.path==null){throw new Error("Invalid URN. Expected URN scheme.")}const[r,a,o,...u]=n.path.split(/[:/]/);if(r!=="vertexvis"&&r!=="vertex"){throw new Error("Invalid URN. Expected URN to be vertex namespace")}if(r==="vertexvis"){console.warn("vertexvis namespace is deprecated. Use 'vertex' for the namespace urn instead")}switch(a){case"stream-key":const e=N(n.query);const t=(s=z(u.join("/")))!==null&&s!==void 0?s:e.find((e=>e.type==="scene-view-state"));return{resource:{type:"stream-key",id:o},subResource:t,queries:e.filter((e=>e.type!=="scene-view-state"))};default:throw new i(`Invalid URN. Unknown resource type ${a}`)}}function z(e){if(e!=null){const[t,s]=e.split("/");switch(t){case"scene-view-states":return{type:"scene-view-state",id:s};default:return undefined}}}function N(e){if(e!=null){return e.split("&").map((e=>{const[t,s]=e.split("=");switch(t){case"supplied-id":return{type:"supplied-id",id:s};case"scene-view-state":return{type:"scene-view-state",id:s};default:throw new Error("Invalid URN. Unknown query value type")}}))}else{return[]}}var L=Object.freeze({__proto__:null,fromUrn:U});function H(e){return e.id!=null}function Q(e){return e.suppliedId!=null}var W=Object.freeze({__proto__:null,isSceneViewStateId:H,isSceneViewStateSuppliedId:Q});class Y{constructor(e,t=new Date){this.knownRemoteTime=e;this.knownLocalTime=t}localOffset(){return this.duration(this.knownLocalTime,this.localNow())}localTime(e){const t=typeof e==="number"?new Date(this.knownLocalTime.getTime()+e):e;const s=this.duration(this.knownRemoteTime,t);return this.addDuration(this.knownLocalTime,s)}remoteOffset(e=new Date){return this.duration(this.remoteTime(this.knownLocalTime),this.remoteTime(e))}remoteNow(){return this.remoteTime(this.localNow())}remoteTime(e){const t=typeof e==="number"?new Date(this.knownLocalTime.getTime()+e):e;const s=this.duration(this.knownLocalTime,t);return this.addDuration(this.knownRemoteTime,s)}addDuration(e,t){return new Date(e.getTime()+t)}duration(e,t){return t.getTime()-e.getTime()}localNow(){return new Date(Date.now())}}function G(e){const t=s.toMsbLsb(e);const n=new o.Uuid2l;n.setMsb(t.msb);n.setLsb(t.lsb);return n}class K{constructor(e,t,s,n){this.client=e;this.stream=t;this.jwtProvider=s;this.deviceIdProvider=n}async listByItem(e,{hasAnnotations:t,cursor:s,size:n=50}={}){const i=await v((async i=>{const r=this.deviceIdProvider();const a=await f(this.jwtProvider,r);const o=new p.ListItemModelViewsRequest;const u=G(e);o.setItemId(u);if(t!=null){const e=new w.BoolValue;e.setValue(t);o.setHasAnnotations(e)}const h=new c.Pager;h.setLimit(n);if(s!=null){h.setCursor(s)}o.setPage(h);this.client.listItemModelViews(o,a,i)}));return u(i.toObject())}async load(e,t){const s=h({modelViewId:t,sceneItemId:e});this.stream.updateModelView({itemModelView:s},true)}async unload(){await this.stream.updateModelView({},true)}}class Z{constructor(e,t,s){this.client=e;this.jwtProvider=t;this.deviceIdProvider=s}async listAnnotations({modelViewId:e,cursor:t,size:s=50}={}){const n=await v((async n=>{const i=this.deviceIdProvider();const r=await f(this.jwtProvider,i);const a=new p.ListPmiAnnotationsRequest;if(e!=null){const t=G(e);a.setModelViewId(t)}const o=new c.Pager;o.setLimit(s);if(t!=null){o.setCursor(t)}a.setPage(o);this.client.listPmiAnnotations(a,r,n)}));return l(n.toObject())}}const $=1e3*10;class J{constructor(e,t,s,n=$){this.stream=e;this.predicate=t;this.transform=s;this.timeout=n;this.listeners=[];this.handleMessage=this.handleMessage.bind(this)}on(e){this.listeners=[...this.listeners,e];if(this.eventDisposable==null||this.requestDisposable==null){this.addListeners()}}off(e){this.listeners=this.listeners.filter((t=>t!==e));if(this.listeners.length===0){this.removeListeners()}}once(){let e;return n.timeout(this.timeout,new Promise((t=>{e=s=>{t(s);this.off(e)};this.on(e)}))).finally((()=>{this.off(e)}))}handleMessage(e){if(this.predicate(e)){const t=this.transform(e);if(t!=null){this.listeners.forEach((e=>e(t)))}}}addListeners(){this.eventDisposable=this.stream.onEvent(this.handleMessage);this.requestDisposable=this.stream.onRequest(this.handleMessage)}removeListeners(){var e,t;(e=this.eventDisposable)===null||e===void 0?void 0:e.dispose();(t=this.requestDisposable)===null||t===void 0?void 0:t.dispose()}}class X{constructor(e,t,{animationId:s,correlationId:n},i){this.data=undefined;this.onAnimationCompleted=new J(e,(e=>{var t,n,i;return((i=(n=(t=e.event)===null||t===void 0?void 0:t.animationCompleted)===null||n===void 0?void 0:n.animationId)===null||i===void 0?void 0:i.hex)===s}),(e=>{var t,s,n;return((n=(s=(t=e.event)===null||t===void 0?void 0:t.animationCompleted)===null||s===void 0?void 0:s.animationId)===null||n===void 0?void 0:n.hex)||undefined}),i);this.onFrameReceived=new J(e,(e=>{var t,s,i;return!!((i=(s=(t=e.request)===null||t===void 0?void 0:t.drawFrame)===null||s===void 0?void 0:s.frameCorrelationIds)===null||i===void 0?void 0:i.some((e=>e===n)))}),(e=>{var s;return((s=e.request)===null||s===void 0?void 0:s.drawFrame)!=null?t(e.request.drawFrame):undefined}),i)}}function ee(e){if(typeof e==="string"){return{sceneViewStateId:{hex:e}}}else if(H(e)){return{sceneViewStateId:{hex:e.id}}}else if(Q(e)){return{sceneViewStateSuppliedId:{value:e.suppliedId}}}else{throw new Error("Unable to build scene view state identifier, input must be a string or `SceneViewStateIdentifier`.")}}function te(e,t){switch(e.type){case"and":case"or":return{operand:{itemCollection:{queries:e.expressions.map((e=>({sceneItemQuery:re(e)})))}}};case"not":return{not:{expression:te(e.query,t)}};case"item-id":case"supplied-id":return{operand:{item:{sceneItemQuery:re(e)}}};case"all":return{operand:{root:{}}};case"scene-tree-range":return{operand:{sceneTreeRange:{start:e.range.start,end:e.range.end}}};case"metadata":if(e.removeHiddenItems){return{and:{first:{operand:{metadata:{valueFilter:e.filter,keys:e.keys,exactMatch:e.exactMatch}}},second:{operand:{override:{visibility:{visibilityState:true}}}}}}}else{return{operand:{metadata:{valueFilter:e.filter,keys:e.keys,exactMatch:e.exactMatch}}}}case"all-selected":return{operand:{override:{selection:{}}}};case"all-visible":return{operand:{override:{visibility:{visibilityState:true}}}};case"point":return{operand:{point:{point:e.point,viewport:t.dimensions}}};case"volume-intersection":return{operand:{volume:{frustumByRectangle:{rectangle:e.rectangle},exclusive:e.exclusive,viewport:t.dimensions}}};default:return{}}}function se(e,t){switch(e.type){case"and":const t=e.expressions.length;if(t===1){return se({type:"annotation-id",value:e.expressions[0].value})}else if(t!==2){throw new Error("Incorrect number of query expressions provided.")}return{and:{first:se(e.expressions[0]),second:se(e.expressions[1])}};case"or":const n=e.expressions.length;if(n===1){return se({type:"annotation-id",value:e.expressions[0].value})}else if(n!==2){throw new Error("Incorrect number of query expressions provided.")}return{or:{first:se(e.expressions[0]),second:se(e.expressions[1])}};case"not":return{not:{expression:se(e.query)}};case"annotation-id":const{msb:i,lsb:r}=s.toMsbLsb(e.value);return{operand:{annotation:{id:new P.protobuf.core.Uuid2l({msb:O.fromString(i),lsb:O.fromString(r)})}}};case"all":return{operand:{all:{}}};default:return{}}}function ne(e,t,s){const n=oe(t);const i=te(e,s);return{sceneItemOperation:{queryExpression:i,operationTypes:n}}}function ie(e,t,s){const n=ue(t);const i=se(e);return{pmiAnnotationOperation:{queryExpression:i,operationTypes:n}}}function re(e){switch(e.type){case"item-id":return{id:new P.protobuf.core.Uuid({hex:e.value})};case"supplied-id":return{suppliedId:e.value};default:return{}}}function ae(e,t,s,n){const i={frameCorrelationId:{value:e},animation:s?{duration:M(s.milliseconds)}:undefined,baseCamera:n!=null&&R(n)?A(n):undefined};switch(t.flyTo.type){case"supplied":{return{...i,itemSuppliedId:t.flyTo.data}}case"internal":{return{...i,itemId:new P.protobuf.core.Uuid({hex:t.flyTo.data})}}case"camera":{return{...i,camera:A(t.flyTo.data)}}case"scene-item-query":return{...i,sceneItemQueryExpression:t.flyTo.data};case"bounding-box":{return{...i,boundingBox:{xmin:t.flyTo.data.min.x,xmax:t.flyTo.data.max.x,ymin:t.flyTo.data.min.y,ymax:t.flyTo.data.max.y,zmin:t.flyTo.data.min.z,zmax:t.flyTo.data.max.z}}}default:return{}}}function oe(e){return e.map((e=>{var t,s;switch(e.type){case"change-material":return{changeMaterial:{materialOverride:{colorMaterial:{d:e.material.opacity,ns:e.material.glossiness,ka:e.material.ambient,kd:e.material.diffuse,ks:e.material.specular,ke:e.material.emissive}}}};case"clear-override":return{clearMaterial:{}};case"change-transform":return{changeTransform:{transform:{...e.transform}}};case"clear-transform":return{clearTransform:{cascade:e.cascade}};case"hide":return{changeVisibility:{visible:false}};case"show":return{changeVisibility:{visible:true}};case"select":return{changeSelection:{selected:true}};case"deselect":return{changeSelection:{selected:false}};case"change-phantom":return{changePhantom:{phantom:(t=e.phantomState)!==null&&t!==void 0?t:true}};case"clear-phantom":return{changePhantom:{phantom:false}};case"change-end-item":return{changeEndItem:{endItem:(s=e.endItemState)!==null&&s!==void 0?s:true}};case"clear-end-item":return{changeEndItem:{endItem:false}};case"view-rendition-by-id":return{viewRendition:{id:new P.protobuf.core.Uuid({hex:e.id})}};case"view-rendition-by-supplied-id":return{viewRendition:{suppliedId:e.suppliedId}};case"view-default-rendition":return{viewDefaultRendition:{}};case"clear-rendition":return{clearRendition:{}};case"view-representation":if(e.id==="empty"){return{viewRepresentation:{predefinedId:d.RepresentationPredefinedId.REPRESENTATION_PREDEFINED_ID_EMPTY}}}else if(e.id==="entire-part"){return{viewRepresentation:{predefinedId:d.RepresentationPredefinedId.REPRESENTATION_PREDEFINED_ID_ENTIRE_PART}}}else{return{viewRepresentation:{id:new P.protobuf.core.Uuid({hex:e.id})}}}case"clear-representation":return{clearRepresentation:{}};default:return{}}}))}function ue(e){return e.map((e=>{switch(e.type){case"show":return{changeVisibility:{visible:true}};case"hide":return{changeVisibility:{visible:false}};case"select":return{changeSelection:{selected:true}};case"deselect":return{changeSelection:{selected:false}};default:return{}}}))}function he(e){return e.map((e=>{switch(e){case"camera":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_CAMERA;case"material_overrides":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_MATERIAL_OVERRIDE;case"selection":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_SELECTION;case"visibility":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_VISIBILITY;case"transforms":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_TRANSFORM;case"cross_section":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_CROSS_SECTION;case"phantom":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_PHANTOM;case"shading":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_SHADING;default:return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_INVALID}}))}class ce{constructor(e){this.flyToOptions=e}build(){return this.flyToOptions}}class le{withItemId(e){return new ce({flyTo:{type:"internal",data:e}})}withSuppliedId(e){return new ce({flyTo:{type:"supplied",data:e}})}withCamera(e){return new ce({flyTo:{type:"camera",data:e}})}withBoundingBox(e){return new ce({flyTo:{type:"bounding-box",data:e}})}build(){return this.flyToOptions}}class de{constructor(e,t,s,n,i,r){this.stream=e;this.aspect=t;this.data=s;this.boundingBox=n;this.decodeFrame=i;this.flyToOptions=r}fitToBoundingBox(e){return this.flyTo({boundingBox:e})}signedDistanceToBoundingBoxCenter(e){const{position:t,viewVector:s}=k(this.data);const n=x.center(e!==null&&e!==void 0?e:this.boundingBox);const i=m.subtract(n,t);return m.dot(s,i)/m.magnitude(s)}flyTo(e){if(typeof e!=="function"){return this.updateFlyToOptions({flyTo:this.buildFlyToType(e)})}else{return this.updateFlyToOptions(e(new le).build())}}viewAll(){return this.fitToBoundingBox(this.boundingBox)}async render(e={}){var t,n,i,r;if(this.flyToOptions==null&&e.animation){this.flyToOptions={flyTo:{type:"camera",data:this.data}}}try{(t=e.correlationId)!==null&&t!==void 0?t:e.correlationId=s.create();if(this.flyToOptions!=null){const t=ae(e.correlationId,this.flyToOptions,e.animation,this.toFrameCamera());const s=await this.stream.flyTo(t,true);return new X(this.stream,this.decodeFrame,{correlationId:e.correlationId,animationId:((i=(n=s.flyTo)===null||n===void 0?void 0:n.animationId)===null||i===void 0?void 0:i.hex)||undefined},((r=e.animation)===null||r===void 0?void 0:r.milliseconds)!=null?e.animation.milliseconds+$:undefined)}else{this.stream.replaceCamera({camera:A(this.data),frameCorrelationId:{value:e.correlationId}});return new X(this.stream,this.decodeFrame,{correlationId:e.correlationId})}}catch(e){console.warn("Error when performing render: ",e);throw e}}rotateAroundAxis(e,t){return this.rotateAroundAxisAtPoint(e,this.data.lookAt,t)}alignTo(e,t){const s=m.normalize(m.cross(this.up,m.normalize(this.viewVector)));const n=m.normalize(m.cross(m.normalize(this.viewVector),s));const i=m.angleTo(t,n)>Math.PI/2?m.negate(n):n;const r=m.isEqual(i,t)?s:m.normalize(m.cross(i,t));const a=m.transformMatrix(this.viewVector,I.makeRotation(g.fromAxisAngle(r,m.angleTo(t,i))));const o=b.create({origin:e,direction:m.normalize(a)});const u=b.at(o,m.magnitude(this.viewVector));return this.update({position:e,lookAt:u,up:t})}standardView(e){return this.update({position:e.position,viewVector:m.subtract(m.origin(),e.position),lookAt:m.origin(),up:e.up})}standardViewFixedLookAt(e){const t=b.create({origin:this.lookAt,direction:m.normalize(e.position)});const s=b.at(t,m.magnitude(this.viewVector));return this.update({up:e.up,position:s,viewVector:m.subtract(this.lookAt,s)})}buildFlyToType(e){if(e.boundingBox!=null){return{type:"bounding-box",data:e.boundingBox}}else if(e.camera!=null){return{type:"camera",data:e.camera}}else if(e.itemId!=null){return{type:"internal",data:e.itemId}}else if(e.itemSuppliedId!=null){return{type:"supplied",data:e.itemSuppliedId}}else if(e.sceneItemQueryExpression!=null){return{type:"scene-item-query",data:e.sceneItemQueryExpression}}else{throw new Error("Fly to must specify at least one option.")}}computeClippingPlanes(e){return C(this.boundingBox,e)}}class pe extends de{constructor(e,t,s,n,i,r){super(e,t,s,n,i,r);this.perspectiveData=s}moveBy(e){return this.update({position:m.add(this.position,e),lookAt:m.add(this.lookAt,e)})}rotateAroundAxisAtPoint(e,t,s){return this.update({position:m.rotateAboutAxis(e,this.position,s,t),lookAt:m.rotateAboutAxis(e,this.lookAt,s,t),up:m.rotateAboutAxis(e,this.up,s,m.origin())})}update(e){var t;const s=(t=e.fovY)!==null&&t!==void 0?t:this.fovY;return new pe(this.stream,this.aspect,{...this.perspectiveData,...e,fovY:s},this.boundingBox,this.decodeFrame,this.flyToOptions)}toFrameCamera(){var e;return new T(this.position,this.lookAt,this.up,this.near,this.far,this.aspectRatio,(e=this.fovY)!==null&&e!==void 0?e:45)}get viewVector(){return m.subtract(this.lookAt,this.position)}get position(){return{...this.perspectiveData.position}}get up(){return{...this.perspectiveData.up}}get lookAt(){return{...this.perspectiveData.lookAt}}get fovY(){return this.perspectiveData.fovY}get aspectRatio(){return this.aspect}get near(){const{near:e}=this.computeClippingPlanes(this.perspectiveData);return e}get far(){const{far:e}=this.computeClippingPlanes(this.perspectiveData);return e}updateFlyToOptions(e){return new pe(this.stream,this.aspect,this.perspectiveData,this.boundingBox,this.decodeFrame,e)}}class we extends de{constructor(e,t,s,n,i,r){super(e,t,s,n,i,r);this.orthographicData=s}moveBy(e){const t=m.add(this.lookAt,e);return this.update({lookAt:t,rotationPoint:t})}rotateAroundAxisAtPoint(e,t,s){const n=m.rotateAboutAxis(e,this.lookAt,s,t);const i=m.rotateAboutAxis(e,this.position,s,t);const r=E(m.subtract(n,i),y.create(this.boundingBox));return this.update({viewVector:r,lookAt:n,up:m.rotateAboutAxis(e,this.up,s,m.origin())})}update(e){return new we(this.stream,this.aspect,{...this.orthographicData,...e},this.boundingBox,this.decodeFrame,this.flyToOptions)}toFrameCamera(){const e=y.create(this.boundingBox);const t=E(this.viewVector,e);const s=V(this.lookAt,t,e.center);return new q(t,s,this.up,this.near,this.far,this.aspectRatio,this.fovHeight,this.rotationPoint)}get viewVector(){return{...this.orthographicData.viewVector}}get position(){return m.add(this.lookAt,m.negate(this.viewVector))}get rotationPoint(){const e=this.orthographicData.rotationPoint;if(e!=null){return e}else{return undefined}}get up(){return{...this.orthographicData.up}}get lookAt(){return{...this.orthographicData.lookAt}}get fovHeight(){return this.orthographicData.fovHeight}get aspectRatio(){return this.aspect}get near(){const{near:e}=this.computeClippingPlanes(this.orthographicData);return e}get far(){const{far:e}=this.computeClippingPlanes(this.orthographicData);return e}updateFlyToOptions(e){return new we(this.stream,this.aspect,this.orthographicData,this.boundingBox,this.decodeFrame,e)}}class ve{constructor(e,t){this.stream=e;this.data=t}async update(e){const t=await this.stream.updateCrossSectioning({crossSectioning:{sectionPlanes:e.sectionPlanes,highlightColor:e.highlightColor,lineWidth:(e===null||e===void 0?void 0:e.lineWidth)!=null?{value:e.lineWidth}:null}},true);return t.updateCrossSectioning||undefined}current(){return this.data}}class fe{constructor(e=[]){this.operations=e}build(){return this.operations.concat()}materialOverride(e){return new fe(this.operations.concat([{type:"change-material",material:e}]))}show(){return new fe(this.operations.concat([{type:"show"}]))}hide(){return new fe(this.operations.concat([{type:"hide"}]))}select(){return new fe(this.operations.concat([{type:"select"}]))}deselect(){return new fe(this.operations.concat([{type:"deselect"}]))}clearMaterialOverrides(){return new fe(this.operations.concat([{type:"clear-override"}]))}transform(e){return new fe(this.operations.concat([{type:"change-transform",transform:e}]))}clearTransforms(e=true){return new fe(this.operations.concat([{type:"clear-transform",cascade:e}]))}setPhantom(e){return new fe(this.operations.concat([{type:"change-phantom",phantomState:e}]))}clearPhantom(){return new fe(this.operations.concat([{type:"clear-phantom"}]))}setEndItem(e){return new fe(this.operations.concat([{type:"change-end-item",endItemState:e}]))}clearEndItem(){return new fe(this.operations.concat([{type:"clear-end-item"}]))}viewRenditionById(e){return new fe(this.operations.concat([{type:"view-rendition-by-id",id:e}]))}viewRenditionBySuppliedId(e){return new fe(this.operations.concat([{type:"view-rendition-by-supplied-id",suppliedId:e}]))}viewDefaultRendition(){return new fe(this.operations.concat([{type:"view-default-rendition"}]))}clearRendition(){return new fe(this.operations.concat([{type:"clear-rendition"}]))}viewRepresentation(e){return new fe(this.operations.concat({type:"view-representation",id:e}))}clearRepresentation(){return new fe(this.operations.concat({type:"clear-representation"}))}}class me{constructor(e=[]){this.operations=e}build(){return this.operations.concat()}show(){return new me(this.operations.concat([{type:"show"}]))}hide(){return new me(this.operations.concat([{type:"hide"}]))}select(){return new me(this.operations.concat([{type:"select"}]))}deselect(){return new me(this.operations.concat([{type:"deselect"}]))}}class ye{constructor(e,t){this.stream=e;this.imageScaleProvider=t}async hitItems(e,t){const s=this.imageScaleProvider();const n=await this.stream.hitItems({point:S.scale(e,(s===null||s===void 0?void 0:s.x)||1,(s===null||s===void 0?void 0:s.y)||1),includeMetadata:t===null||t===void 0?void 0:t.includeMetadata},true);return n.hitItems||undefined}}const xe=1e3*30;class Ie{constructor(e,t,s,n){this.onFrameDrawn=new J(e,(e=>{var t,n,i;return!!((i=(n=(t=e.request)===null||t===void 0?void 0:t.drawFrame)===null||n===void 0?void 0:n.frameCorrelationIds)===null||i===void 0?void 0:i.some((e=>e===s)))}),(e=>{var s;return((s=e.request)===null||s===void 0?void 0:s.drawFrame)!=null?t(e.request.drawFrame):undefined}),n!==null&&n!==void 0?n:xe)}}class ge{constructor(e,t,s,n,i){this.stream=e;this.decodeFrame=t;this.encodeCameraType=s;this.sceneId=n;this.sceneViewId=i}async applySceneViewState(e,t={}){const s=ee(e);await this.animateToSceneViewState(s,t);return await this.stream.loadSceneViewState({...s,frameCorrelationId:t.suppliedCorrelationId?{value:t.suppliedCorrelationId}:undefined,cameraType:t.cameraTypeOverride?this.encodeCameraType(t.cameraTypeOverride):undefined},true)}async applyPartialSceneViewState(e,t,s={}){const n=ee(e);const i=he(t);if(t.includes("camera")){await this.animateToSceneViewState(n,s)}return await this.stream.loadSceneViewState({...n,frameCorrelationId:s.suppliedCorrelationId?{value:s.suppliedCorrelationId}:undefined,sceneViewStateFeatureSubset:i,cameraType:s.cameraTypeOverride?this.encodeCameraType(s.cameraTypeOverride):undefined},true)}async animateToSceneViewState(e,t){var n,i,r;if(t.animation!=null){const a=s.create();const o=await this.stream.flyTo({sceneViewStateIdentifier:e,animation:{duration:M(t.animation.milliseconds)},frameCorrelationId:{value:a}},true);if(t.waitForAnimation==null||t.waitForAnimation){const e=new X(this.stream,this.decodeFrame,{animationId:(r=(i=(n=o.flyTo)===null||n===void 0?void 0:n.animationId)===null||i===void 0?void 0:i.hex)!==null&&r!==void 0?r:undefined,correlationId:a},t.animation.milliseconds+$);await e.onAnimationCompleted.once()}}}}class be{constructor(e,t){this.query=e;this.builder=t!==null&&t!==void 0?t:new fe}isItemBuilder(){return true}isAnnotationBuilder(){return false}materialOverride(e){if(typeof e==="string"){return new be(this.query,this.builder.materialOverride(j(e)))}else{return new be(this.query,this.builder.materialOverride(e))}}hide(){return new be(this.query,this.builder.hide())}show(){return new be(this.query,this.builder.show())}select(){return new be(this.query,this.builder.select())}deselect(){return new be(this.query,this.builder.deselect())}clearMaterialOverrides(){return new be(this.query,this.builder.clearMaterialOverrides())}transform(e){if(Array.isArray(e)){if(e.length!==16){throw new a("Matrix provided must contain exactly 16 values (4x4).")}return new be(this.query,this.builder.transform({r0:{x:e[0],y:e[1],z:e[2],w:e[3]},r1:{x:e[4],y:e[5],z:e[6],w:e[7]},r2:{x:e[8],y:e[9],z:e[10],w:e[11]},r3:{x:e[12],y:e[13],z:e[14],w:e[15]}}))}else{return new be(this.query,this.builder.transform(e))}}clearTransforms(e=true){return new be(this.query,this.builder.clearTransforms(e))}setPhantom(e){return new be(this.query,this.builder.setPhantom(e))}clearPhantom(){return new be(this.query,this.builder.clearPhantom())}setEndItem(e){return new be(this.query,this.builder.setEndItem(e))}clearEndItem(){return new be(this.query,this.builder.clearEndItem())}viewRenditionById(e){return new be(this.query,this.builder.viewRenditionById(e))}viewRenditionBySuppliedId(e){return new be(this.query,this.builder.viewRenditionBySuppliedId(e))}viewDefaultRendition(){return new be(this.query,this.builder.viewDefaultRendition())}clearRendition(){return new be(this.query,this.builder.clearRendition())}viewRepresentation(e){return new be(this.query,this.builder.viewRepresentation(e))}clearRepresentation(){return new be(this.query,this.builder.clearRepresentation())}build(){return{query:this.query,operations:this.builder.build()}}}class Se{constructor(e,t){this.query=e;this.builder=t!==null&&t!==void 0?t:new me}isItemBuilder(){return false}isAnnotationBuilder(){return true}hide(){return new Se(this.query,this.builder.hide())}show(){return new Se(this.query,this.builder.show())}select(){return new Se(this.query,this.builder.select())}deselect(){return new Se(this.query,this.builder.deselect())}build(){return{query:this.query,operations:this.builder.build()}}}class Be{constructor(e,t,s,n,i,r){this.sceneViewId=e;this.stream=t;this.decodeFrame=s;this.dimensions=n;this.sceneItemQueryOperations=i;this.pmiAnnotationQueryOperations=r}async execute(e){var t;const n=this.sceneItemQueryOperations.map((e=>ne(e.query,e.operations,{dimensions:this.dimensions})));const i=this.pmiAnnotationQueryOperations.map((e=>ie(e.query,e.operations)));const r=(t=e===null||e===void 0?void 0:e.suppliedCorrelationId)!==null&&t!==void 0?t:s.create();const a={sceneViewId:{hex:this.sceneViewId},elementOperations:[...n,...i],suppliedCorrelationId:{value:r}};await this.stream.createSceneAlteration(a)}}class Re extends Be{async execute(e){var t;if(e===null||e===void 0?void 0:e.awaitCorrelatedFrame){const n=(t=e.suppliedCorrelationId)!==null&&t!==void 0?t:s.create();const i=new Ie(this.stream,this.decodeFrame,n);await super.execute({...e,suppliedCorrelationId:n});await i.onFrameDrawn.once()}else{await super.execute(e)}}}class Ae extends Be{async execute(e){var t;if(e===null||e===void 0?void 0:e.skipAwaitCorrelatedFrame){await super.execute(e)}else{const n=(t=e===null||e===void 0?void 0:e.suppliedCorrelationId)!==null&&t!==void 0?t:s.create();const i=new Ie(this.stream,this.decodeFrame,n);await super.execute({...e,suppliedCorrelationId:n});await i.onFrameDrawn.once()}}}class Ee{constructor(e,t,s,n,i,r,a,o){this.stream=e;this.frame=t;this.decodeFrame=s;this.encodeCameraType=n;this.imageScaleProvider=i;this.dimensions=r;this.sceneId=a;this.sceneViewId=o;this.sceneViewStateLoader=new ge(e,s,n,a,o)}async applySceneViewState(e,t={}){return await this.sceneViewStateLoader.applySceneViewState(e,t)}async applyPartialSceneViewState(e,t,s={}){return await this.sceneViewStateLoader.applyPartialSceneViewState(e,t,s)}async reset(e={}){return await this.stream.resetSceneView({includeCamera:e.includeCamera,frameCorrelationId:e.suppliedCorrelationId?{value:e.suppliedCorrelationId}:undefined,cameraType:e.cameraTypeOverride?this.encodeCameraType(e.cameraTypeOverride):undefined},true)}items(e){const t=e(new Ke);const s=Array.isArray(t)?t:[t];const n=s.filter((e=>e.isItemBuilder()));const i=n.reduce(((e,t)=>e.concat(t.build())),[]);return new Re(this.sceneViewId,this.stream,this.decodeFrame,this.dimensions,i,[])}elements(e){const t=e(new Ye);const s=Array.isArray(t)?t:[t];const n=s.filter((e=>e.isItemBuilder()));const i=n.reduce(((e,t)=>e.concat(t.build())),[]);const r=s.filter((e=>e.isAnnotationBuilder()));const a=r.reduce(((e,t)=>e.concat(t.build())),[]);return new Ae(this.sceneViewId,this.stream,this.decodeFrame,this.dimensions,i,a)}camera(){const{scene:e}=this.frame;if(e.camera.isOrthographic()){return new we(this.stream,B.aspectRatio(this.viewport()),{viewVector:e.camera.viewVector,lookAt:e.camera.lookAt,up:e.camera.up,fovHeight:e.camera.fovHeight,rotationPoint:e.camera.lookAt},this.frame.scene.boundingBox,this.decodeFrame)}else if(e.camera.isPerspective()){return new pe(this.stream,B.aspectRatio(this.viewport()),{position:e.camera.position,lookAt:e.camera.lookAt,up:e.camera.up,fovY:e.camera.fovY},this.frame.scene.boundingBox,this.decodeFrame)}else{throw new r("Cannot retrieve camera. Scene has an unknown or invalid camera type.")}}isOrthographic(){const{scene:e}=this.frame;return e.camera.isOrthographic()}boundingBox(){return this.frame.scene.boundingBox}crossSectioning(){return new ve(this.stream,this.frame.scene.crossSection)}raycaster(){return new ye(this.stream,this.imageScaleProvider)}viewport(){return this.frame.dimensions}scale(){return this.imageScaleProvider()||S.create(1,1)}}class Ve{constructor(e){this.inverted=e}build(){if(this.inverted){return{type:"not",query:this.queryExpressionBuilder()}}else{return this.queryExpressionBuilder()}}}class qe{constructor(e=false){this.inverted=e}all(){return new Pe}not(){return new Te(!this.inverted)}withItemIds(e){return new Ue(e,"item-id",this.inverted)}withSuppliedIds(e){return new Ue(e,"supplied-id",this.inverted)}withItemId(e){return new ze({type:"item-id",value:e},this.inverted)}withSuppliedId(e){return new ze({type:"supplied-id",value:e},this.inverted)}withSceneTreeRange(e){return new Me(e,this.inverted)}withMetadata(e,t,s,n){return new Oe(e,t,s,this.inverted,n)}withSelected(){return new De(this.inverted)}withVisible(){return new _e(this.inverted)}withPoint(e){return new je(e,this.inverted)}withVolumeIntersection(e,t){return new Fe(e,this.inverted,t)}}class Te extends qe{constructor(e){super(e)}}class ke{constructor(e=false){this.inverted=e}all(){return new Pe}not(){return new Ce(!this.inverted)}withAnnotationIds(e){return new Ue(e,"annotation-id",this.inverted)}withAnnotationId(e){return new He({type:"annotation-id",value:e},this.inverted)}}class Ce extends ke{constructor(e){super(e)}}class Pe extends Ve{constructor(e=false){super(e)}queryExpressionBuilder(){return{type:"all"}}}class Me extends Ve{constructor(e,t){super(t);this.range=e}queryExpressionBuilder(){return{type:"scene-tree-range",range:this.range}}}class Oe extends Ve{constructor(e,t,s,n,i){super(n);this.filter=e;this.keys=t;this.exactMatch=s;this.removeHiddenItems=i}queryExpressionBuilder(){return{type:"metadata",filter:this.filter,keys:this.keys,exactMatch:this.exactMatch,removeHiddenItems:this.removeHiddenItems}}}class De extends Ve{constructor(e){super(e)}queryExpressionBuilder(){return{type:"all-selected"}}}class _e extends Ve{constructor(e){super(e)}queryExpressionBuilder(){return{type:"all-visible"}}}class je extends Ve{constructor(e,t){super(t);this.point=e}queryExpressionBuilder(){return{type:"point",point:this.point}}}class Fe extends Ve{constructor(e,t,s){super(t);this.rectangle=e;this.exclusive=s}queryExpressionBuilder(){return{type:"volume-intersection",rectangle:this.rectangle,exclusive:!!this.exclusive}}}class Ue extends Ve{constructor(e,t,s){super(s);this.ids=e;this.type=t}queryExpressionBuilder(){return{type:"or",expressions:this.ids.map((e=>({type:this.type,value:e})))}}}class ze extends Ve{constructor(e,t){super(t);this.query=e}queryExpressionBuilder(){return{...this.query}}and(){return new Le([this.query],this.inverted)}or(){return new Ne([this.query],this.inverted)}}class Ne extends Ve{constructor(e,t){super(t);this.expressions=e}queryExpressionBuilder(){return{type:"or",expressions:[...this.expressions]}}withItemId(e){return new Ne([...this.expressions,{type:"item-id",value:e}],this.inverted)}withSuppliedId(e){return new Ne([...this.expressions,{type:"supplied-id",value:e}],this.inverted)}or(){return this}}class Le extends Ve{constructor(e,t){super(t);this.expressions=e}queryExpressionBuilder(){return{type:"and",expressions:[...this.expressions]}}withItemId(e){return new Le([...this.expressions,{type:"item-id",value:e}],this.inverted)}withSuppliedId(e){return new Le([...this.expressions,{type:"supplied-id",value:e}],this.inverted)}and(){return this}}class He extends Ve{constructor(e,t){super(t);this.query=e}queryExpressionBuilder(){return{...this.query}}and(){return new We([this.query],this.inverted)}or(){return new Qe([this.query],this.inverted)}}class Qe extends Ve{constructor(e,t){super(t);this.expressions=e}queryExpressionBuilder(){return{type:"or",expressions:[...this.expressions]}}withAnnotationId(e){return new Qe([...this.expressions,{type:"annotation-id",value:e}],this.inverted)}or(){return this}}class We extends Ve{constructor(e,t){super(t);this.expressions=e}queryExpressionBuilder(){return{type:"and",expressions:[...this.expressions]}}withAnnotationId(e){return new We([...this.expressions,{type:"annotation-id",value:e}],this.inverted)}and(){return this}}class Ye{get items(){return new Ke}get annotations(){return new Ge}}class Ge{where(e){const t=e(new ke).build();return new Se(t)}}class Ke{where(e){const t=e(new qe).build();return new be(t)}}export{de as C,fe as I,K as M,Se as P,ye as R,Ee as S,ve as a,Ge as b,F as c,qe as d,Ye as e,Ae as f,be as g,Ke as h,Re as i,Y as j,Z as k,L as l,D as m,U as n,W as s,G as t};
|
|
5
|
-
//# sourceMappingURL=p-
|
|
4
|
+
import{c as e,u as t,b as s,a as n}from"./p-CHdoymO5.js";import{c as i,d as r,e as a}from"./p--8q6LyIm.js";import{u as o,m as u,a as h,p as c,b as l,r as d}from"./p-DRnMrHWY.js";import{s as p,w}from"./p-FRKLa468.js";import{r as v,c as f}from"./p-CjG1fMh1.js";import{v as m,f as y,c as x,m as I,q as g,r as b,p as S,e as B}from"./p-DDQcM-So.js";import{P as R,t as E,Q as A,u as V,e as T,f as q,R as k,T as C}from"./p-B9R0QWr4.js";import{v as P,t as M,L as O}from"./p-BoB09nlv.js";const D={opacity:255,glossiness:4,diffuse:{r:0,g:0,b:0,a:0},ambient:{r:0,g:0,b:0,a:0},specular:{r:0,g:0,b:0,a:0},emissive:{r:0,g:0,b:0,a:0}};const _=(e,t,s,n)=>({...D,opacity:n!==null&&n!==void 0?n:D.opacity,diffuse:{r:e,g:t,b:s,a:0}});const j=(t,s)=>{const n=e.fromHexString(t);return{...D,opacity:s!==null&&s!==void 0?s:D.opacity,diffuse:n!=null?{...n}:{...D.diffuse}}};var F=Object.freeze({__proto__:null,create:_,defaultColor:D,fromHex:j});function U(e){var s;const n=t.parse(e);if(n.scheme!=="urn"||n.path==null){throw new Error("Invalid URN. Expected URN scheme.")}const[r,a,o,...u]=n.path.split(/[:/]/);if(r!=="vertexvis"&&r!=="vertex"){throw new Error("Invalid URN. Expected URN to be vertex namespace")}if(r==="vertexvis"){console.warn("vertexvis namespace is deprecated. Use 'vertex' for the namespace urn instead")}switch(a){case"stream-key":const e=N(n.query);const t=(s=z(u.join("/")))!==null&&s!==void 0?s:e.find((e=>e.type==="scene-view-state"));return{resource:{type:"stream-key",id:o},subResource:t,queries:e.filter((e=>e.type!=="scene-view-state"))};default:throw new i(`Invalid URN. Unknown resource type ${a}`)}}function z(e){if(e!=null){const[t,s]=e.split("/");switch(t){case"scene-view-states":return{type:"scene-view-state",id:s};default:return undefined}}}function N(e){if(e!=null){return e.split("&").map((e=>{const[t,s]=e.split("=");switch(t){case"supplied-id":return{type:"supplied-id",id:s};case"scene-view-state":return{type:"scene-view-state",id:s};default:throw new Error("Invalid URN. Unknown query value type")}}))}else{return[]}}var H=Object.freeze({__proto__:null,fromUrn:U});function L(e){return e.id!=null}function Q(e){return e.suppliedId!=null}var Y=Object.freeze({__proto__:null,isSceneViewStateId:L,isSceneViewStateSuppliedId:Q});class W{constructor(e,t=new Date){this.knownRemoteTime=e;this.knownLocalTime=t}localOffset(){return this.duration(this.knownLocalTime,this.localNow())}localTime(e){const t=typeof e==="number"?new Date(this.knownLocalTime.getTime()+e):e;const s=this.duration(this.knownRemoteTime,t);return this.addDuration(this.knownLocalTime,s)}remoteOffset(e=new Date){return this.duration(this.remoteTime(this.knownLocalTime),this.remoteTime(e))}remoteNow(){return this.remoteTime(this.localNow())}remoteTime(e){const t=typeof e==="number"?new Date(this.knownLocalTime.getTime()+e):e;const s=this.duration(this.knownLocalTime,t);return this.addDuration(this.knownRemoteTime,s)}addDuration(e,t){return new Date(e.getTime()+t)}duration(e,t){return t.getTime()-e.getTime()}localNow(){return new Date(Date.now())}}function G(e){const t=s.toMsbLsb(e);const n=new o.Uuid2l;n.setMsb(t.msb);n.setLsb(t.lsb);return n}class K{constructor(e,t,s,n){this.client=e;this.stream=t;this.jwtProvider=s;this.deviceIdProvider=n}async listByItem(e,{hasAnnotations:t,cursor:s,size:n=50}={}){const i=await v((async i=>{const r=this.deviceIdProvider();const a=await f(this.jwtProvider,r);const o=new p.ListItemModelViewsRequest;const u=G(e);o.setItemId(u);if(t!=null){const e=new w.BoolValue;e.setValue(t);o.setHasAnnotations(e)}const h=new c.Pager;h.setLimit(n);if(s!=null){h.setCursor(s)}o.setPage(h);this.client.listItemModelViews(o,a,i)}));return u(i.toObject())}async load(e,t){const s=h({modelViewId:t,sceneItemId:e});this.stream.updateModelView({itemModelView:s},true)}async unload(){await this.stream.updateModelView({},true)}}class ${constructor(e,t,s){this.client=e;this.jwtProvider=t;this.deviceIdProvider=s}async listAnnotations({modelViewId:e,cursor:t,size:s=50}={}){const n=await v((async n=>{const i=this.deviceIdProvider();const r=await f(this.jwtProvider,i);const a=new p.ListPmiAnnotationsRequest;if(e!=null){const t=G(e);a.setModelViewId(t)}const o=new c.Pager;o.setLimit(s);if(t!=null){o.setCursor(t)}a.setPage(o);this.client.listPmiAnnotations(a,r,n)}));return l(n.toObject())}}const J=1e3*10;class X{constructor(e,t,s,n=J){this.stream=e;this.predicate=t;this.transform=s;this.timeout=n;this.listeners=[];this.handleMessage=this.handleMessage.bind(this)}on(e){this.listeners=[...this.listeners,e];if(this.eventDisposable==null||this.requestDisposable==null){this.addListeners()}}off(e){this.listeners=this.listeners.filter((t=>t!==e));if(this.listeners.length===0){this.removeListeners()}}once(){let e;return n.timeout(this.timeout,new Promise((t=>{e=s=>{t(s);this.off(e)};this.on(e)}))).finally((()=>{this.off(e)}))}handleMessage(e){if(this.predicate(e)){const t=this.transform(e);if(t!=null){this.listeners.forEach((e=>e(t)))}}}addListeners(){this.eventDisposable=this.stream.onEvent(this.handleMessage);this.requestDisposable=this.stream.onRequest(this.handleMessage)}removeListeners(){var e,t;(e=this.eventDisposable)===null||e===void 0?void 0:e.dispose();(t=this.requestDisposable)===null||t===void 0?void 0:t.dispose()}}class Z{constructor(e,t,{animationId:s,correlationId:n},i){this.data=undefined;this.onAnimationCompleted=new X(e,(e=>{var t,n,i;return((i=(n=(t=e.event)===null||t===void 0?void 0:t.animationCompleted)===null||n===void 0?void 0:n.animationId)===null||i===void 0?void 0:i.hex)===s}),(e=>{var t,s,n;return((n=(s=(t=e.event)===null||t===void 0?void 0:t.animationCompleted)===null||s===void 0?void 0:s.animationId)===null||n===void 0?void 0:n.hex)||undefined}),i);this.onFrameReceived=new X(e,(e=>{var t,s,i;return!!((i=(s=(t=e.request)===null||t===void 0?void 0:t.drawFrame)===null||s===void 0?void 0:s.frameCorrelationIds)===null||i===void 0?void 0:i.some((e=>e===n)))}),(e=>{var s;return((s=e.request)===null||s===void 0?void 0:s.drawFrame)!=null?t(e.request.drawFrame):undefined}),i)}}function ee(e){if(typeof e==="string"){return{sceneViewStateId:{hex:e}}}else if(L(e)){return{sceneViewStateId:{hex:e.id}}}else if(Q(e)){return{sceneViewStateSuppliedId:{value:e.suppliedId}}}else{throw new Error("Unable to build scene view state identifier, input must be a string or `SceneViewStateIdentifier`.")}}function te(e,t){switch(e.type){case"and":case"or":return{operand:{itemCollection:{queries:e.expressions.map((e=>({sceneItemQuery:re(e)})))}}};case"not":return{not:{expression:te(e.query,t)}};case"item-id":case"supplied-id":return{operand:{item:{sceneItemQuery:re(e)}}};case"all":return{operand:{root:{}}};case"scene-tree-range":return{operand:{sceneTreeRange:{start:e.range.start,end:e.range.end}}};case"metadata":if(e.removeHiddenItems){return{and:{first:{operand:{metadata:{valueFilter:e.filter,keys:e.keys,exactMatch:e.exactMatch}}},second:{operand:{override:{visibility:{visibilityState:true}}}}}}}else{return{operand:{metadata:{valueFilter:e.filter,keys:e.keys,exactMatch:e.exactMatch}}}}case"all-selected":return{operand:{override:{selection:{}}}};case"all-visible":return{operand:{override:{visibility:{visibilityState:true}}}};case"point":return{operand:{point:{point:e.point,viewport:t.dimensions}}};case"volume-intersection":return{operand:{volume:{frustumByRectangle:{rectangle:e.rectangle},exclusive:e.exclusive,viewport:t.dimensions}}};default:return{}}}function se(e,t){switch(e.type){case"and":const t=e.expressions.length;if(t===1){return se({type:"annotation-id",value:e.expressions[0].value})}else if(t!==2){throw new Error("Incorrect number of query expressions provided.")}return{and:{first:se(e.expressions[0]),second:se(e.expressions[1])}};case"or":const n=e.expressions.length;if(n===1){return se({type:"annotation-id",value:e.expressions[0].value})}else if(n!==2){throw new Error("Incorrect number of query expressions provided.")}return{or:{first:se(e.expressions[0]),second:se(e.expressions[1])}};case"not":return{not:{expression:se(e.query)}};case"annotation-id":const{msb:i,lsb:r}=s.toMsbLsb(e.value);return{operand:{annotation:{id:new P.protobuf.core.Uuid2l({msb:O.fromString(i),lsb:O.fromString(r)})}}};case"all":return{operand:{all:{}}};default:return{}}}function ne(e,t,s){const n=oe(t);const i=te(e,s);return{sceneItemOperation:{queryExpression:i,operationTypes:n}}}function ie(e,t,s){const n=ue(t);const i=se(e);return{pmiAnnotationOperation:{queryExpression:i,operationTypes:n}}}function re(e){switch(e.type){case"item-id":return{id:new P.protobuf.core.Uuid({hex:e.value})};case"supplied-id":return{suppliedId:e.value};default:return{}}}function ae(e,t,s,n){const i={frameCorrelationId:{value:e},animation:s?{duration:M(s.milliseconds)}:undefined,baseCamera:n!=null&&R(n)?E(n):undefined};switch(t.flyTo.type){case"supplied":{return{...i,itemSuppliedId:t.flyTo.data}}case"internal":{return{...i,itemId:new P.protobuf.core.Uuid({hex:t.flyTo.data})}}case"camera":{return{...i,camera:E(t.flyTo.data)}}case"scene-item-query":return{...i,sceneItemQueryExpression:t.flyTo.data};case"bounding-box":{return{...i,boundingBox:{xmin:t.flyTo.data.min.x,xmax:t.flyTo.data.max.x,ymin:t.flyTo.data.min.y,ymax:t.flyTo.data.max.y,zmin:t.flyTo.data.min.z,zmax:t.flyTo.data.max.z}}}default:return{}}}function oe(e){return e.map((e=>{var t,s;switch(e.type){case"change-material":return{changeMaterial:{materialOverride:{colorMaterial:{d:e.material.opacity,ns:e.material.glossiness,ka:e.material.ambient,kd:e.material.diffuse,ks:e.material.specular,ke:e.material.emissive}}}};case"clear-override":return{clearMaterial:{}};case"change-transform":return{changeTransform:{transform:{...e.transform}}};case"clear-transform":return{clearTransform:{cascade:e.cascade}};case"hide":return{changeVisibility:{visible:false}};case"show":return{changeVisibility:{visible:true}};case"select":return{changeSelection:{selected:true}};case"deselect":return{changeSelection:{selected:false}};case"change-phantom":return{changePhantom:{phantom:(t=e.phantomState)!==null&&t!==void 0?t:true}};case"clear-phantom":return{changePhantom:{phantom:false}};case"change-end-item":return{changeEndItem:{endItem:(s=e.endItemState)!==null&&s!==void 0?s:true}};case"clear-end-item":return{changeEndItem:{endItem:false}};case"view-rendition-by-id":return{viewRendition:{id:new P.protobuf.core.Uuid({hex:e.id})}};case"view-rendition-by-supplied-id":return{viewRendition:{suppliedId:e.suppliedId}};case"view-default-rendition":return{viewDefaultRendition:{}};case"clear-rendition":return{clearRendition:{}};case"view-representation":if(e.id==="empty"){return{viewRepresentation:{predefinedId:d.RepresentationPredefinedId.REPRESENTATION_PREDEFINED_ID_EMPTY}}}else if(e.id==="entire-part"){return{viewRepresentation:{predefinedId:d.RepresentationPredefinedId.REPRESENTATION_PREDEFINED_ID_ENTIRE_PART}}}else{return{viewRepresentation:{id:new P.protobuf.core.Uuid({hex:e.id})}}}case"clear-representation":return{clearRepresentation:{}};default:return{}}}))}function ue(e){return e.map((e=>{switch(e.type){case"show":return{changeVisibility:{visible:true}};case"hide":return{changeVisibility:{visible:false}};case"select":return{changeSelection:{selected:true}};case"deselect":return{changeSelection:{selected:false}};default:return{}}}))}function he(e){return e.map((e=>{switch(e){case"camera":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_CAMERA;case"material_overrides":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_MATERIAL_OVERRIDE;case"selection":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_SELECTION;case"visibility":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_VISIBILITY;case"transforms":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_TRANSFORM;case"cross_section":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_CROSS_SECTION;case"phantom":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_PHANTOM;case"shading":return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_SHADING;default:return P.protobuf.stream.SceneViewStateFeature.SCENE_VIEW_STATE_FEATURE_INVALID}}))}class ce{constructor(e){this.flyToOptions=e}build(){return this.flyToOptions}}class le{withItemId(e){return new ce({flyTo:{type:"internal",data:e}})}withSuppliedId(e){return new ce({flyTo:{type:"supplied",data:e}})}withCamera(e){return new ce({flyTo:{type:"camera",data:e}})}withBoundingBox(e){return new ce({flyTo:{type:"bounding-box",data:e}})}build(){return this.flyToOptions}}class de{constructor(e,t,s,n,i,r){this.stream=e;this.aspect=t;this.data=s;this.boundingBox=n;this.decodeFrame=i;this.flyToOptions=r}fitToBoundingBox(e){return this.flyTo({boundingBox:e})}signedDistanceToBoundingBoxCenter(e){const{position:t,viewVector:s}=k(this.data);const n=x.center(e!==null&&e!==void 0?e:this.boundingBox);const i=m.subtract(n,t);return m.dot(s,i)/m.magnitude(s)}flyTo(e){if(typeof e!=="function"){return this.updateFlyToOptions({flyTo:this.buildFlyToType(e)})}else{return this.updateFlyToOptions(e(new le).build())}}viewAll(){return this.fitToBoundingBox(this.boundingBox)}async render(e={}){var t,n,i,r;if(this.flyToOptions==null&&e.animation){this.flyToOptions={flyTo:{type:"camera",data:this.data}}}try{(t=e.correlationId)!==null&&t!==void 0?t:e.correlationId=s.create();if(this.flyToOptions!=null){const t=ae(e.correlationId,this.flyToOptions,e.animation,this.toFrameCamera());const s=await this.stream.flyTo(t,true);return new Z(this.stream,this.decodeFrame,{correlationId:e.correlationId,animationId:((i=(n=s.flyTo)===null||n===void 0?void 0:n.animationId)===null||i===void 0?void 0:i.hex)||undefined},((r=e.animation)===null||r===void 0?void 0:r.milliseconds)!=null?e.animation.milliseconds+J:undefined)}else{this.stream.replaceCamera({camera:E(this.data),frameCorrelationId:{value:e.correlationId}});return new Z(this.stream,this.decodeFrame,{correlationId:e.correlationId})}}catch(e){console.warn("Error when performing render: ",e);throw e}}rotateAroundAxis(e,t){return this.rotateAroundAxisAtPoint(e,this.data.lookAt,t)}alignTo(e,t){const s=m.normalize(m.cross(this.up,m.normalize(this.viewVector)));const n=m.normalize(m.cross(m.normalize(this.viewVector),s));const i=m.angleTo(t,n)>Math.PI/2?m.negate(n):n;const r=m.isEqual(i,t)?s:m.normalize(m.cross(i,t));const a=m.transformMatrix(this.viewVector,I.makeRotation(g.fromAxisAngle(r,m.angleTo(t,i))));const o=b.create({origin:e,direction:m.normalize(a)});const u=b.at(o,m.magnitude(this.viewVector));return this.update({position:e,lookAt:u,up:t})}standardView(e){return this.update({position:e.position,viewVector:m.subtract(m.origin(),e.position),lookAt:m.origin(),up:e.up})}standardViewFixedLookAt(e){const t=b.create({origin:this.lookAt,direction:m.normalize(e.position)});const s=b.at(t,m.magnitude(this.viewVector));return this.update({up:e.up,position:s,viewVector:m.subtract(this.lookAt,s)})}buildFlyToType(e){if(e.boundingBox!=null){return{type:"bounding-box",data:e.boundingBox}}else if(e.camera!=null){return{type:"camera",data:e.camera}}else if(e.itemId!=null){return{type:"internal",data:e.itemId}}else if(e.itemSuppliedId!=null){return{type:"supplied",data:e.itemSuppliedId}}else if(e.sceneItemQueryExpression!=null){return{type:"scene-item-query",data:e.sceneItemQueryExpression}}else{throw new Error("Fly to must specify at least one option.")}}computeClippingPlanes(e){return C(this.boundingBox,e)}}class pe extends de{constructor(e,t,s,n,i,r){super(e,t,s,n,i,r);this.perspectiveData=s}moveBy(e){return this.update({position:m.add(this.position,e),lookAt:m.add(this.lookAt,e)})}rotateAroundAxisAtPoint(e,t,s){return this.update({position:m.rotateAboutAxis(e,this.position,s,t),lookAt:m.rotateAboutAxis(e,this.lookAt,s,t),up:m.rotateAboutAxis(e,this.up,s,m.origin())})}update(e){var t;const s=(t=e.fovY)!==null&&t!==void 0?t:this.fovY;return new pe(this.stream,this.aspect,{...this.perspectiveData,...e,fovY:s},this.boundingBox,this.decodeFrame,this.flyToOptions)}toFrameCamera(){var e;return new q(this.position,this.lookAt,this.up,this.near,this.far,this.aspectRatio,(e=this.fovY)!==null&&e!==void 0?e:45)}get viewVector(){return m.subtract(this.lookAt,this.position)}get position(){return{...this.perspectiveData.position}}get up(){return{...this.perspectiveData.up}}get lookAt(){return{...this.perspectiveData.lookAt}}get fovY(){return this.perspectiveData.fovY}get aspectRatio(){return this.aspect}get near(){const{near:e}=this.computeClippingPlanes(this.perspectiveData);return e}get far(){const{far:e}=this.computeClippingPlanes(this.perspectiveData);return e}updateFlyToOptions(e){return new pe(this.stream,this.aspect,this.perspectiveData,this.boundingBox,this.decodeFrame,e)}}class we extends de{constructor(e,t,s,n,i,r){super(e,t,s,n,i,r);this.orthographicData=s}moveBy(e){const t=m.add(this.lookAt,e);return this.update({lookAt:t,rotationPoint:t})}rotateAroundAxisAtPoint(e,t,s){const n=m.rotateAboutAxis(e,this.lookAt,s,t);const i=m.rotateAboutAxis(e,this.position,s,t);const r=A(m.subtract(n,i),y.create(this.boundingBox));return this.update({viewVector:r,lookAt:n,up:m.rotateAboutAxis(e,this.up,s,m.origin())})}update(e){return new we(this.stream,this.aspect,{...this.orthographicData,...e},this.boundingBox,this.decodeFrame,this.flyToOptions)}toFrameCamera(){const e=y.create(this.boundingBox);const t=A(this.viewVector,e);const s=V(this.lookAt,t,e.center);return new T(t,s,this.up,this.near,this.far,this.aspectRatio,this.fovHeight,this.rotationPoint)}get viewVector(){return{...this.orthographicData.viewVector}}get position(){return m.add(this.lookAt,m.negate(this.viewVector))}get rotationPoint(){const e=this.orthographicData.rotationPoint;if(e!=null){return e}else{return undefined}}get up(){return{...this.orthographicData.up}}get lookAt(){return{...this.orthographicData.lookAt}}get fovHeight(){return this.orthographicData.fovHeight}get aspectRatio(){return this.aspect}get near(){const{near:e}=this.computeClippingPlanes(this.orthographicData);return e}get far(){const{far:e}=this.computeClippingPlanes(this.orthographicData);return e}updateFlyToOptions(e){return new we(this.stream,this.aspect,this.orthographicData,this.boundingBox,this.decodeFrame,e)}}class ve{constructor(e,t){this.stream=e;this.data=t}async update(e){const t=await this.stream.updateCrossSectioning({crossSectioning:{sectionPlanes:e.sectionPlanes,highlightColor:e.highlightColor,lineWidth:(e===null||e===void 0?void 0:e.lineWidth)!=null?{value:e.lineWidth}:null}},true);return t.updateCrossSectioning||undefined}current(){return this.data}}class fe{constructor(e=[]){this.operations=e}build(){return this.operations.concat()}materialOverride(e){return new fe(this.operations.concat([{type:"change-material",material:e}]))}show(){return new fe(this.operations.concat([{type:"show"}]))}hide(){return new fe(this.operations.concat([{type:"hide"}]))}select(){return new fe(this.operations.concat([{type:"select"}]))}deselect(){return new fe(this.operations.concat([{type:"deselect"}]))}clearMaterialOverrides(){return new fe(this.operations.concat([{type:"clear-override"}]))}transform(e){return new fe(this.operations.concat([{type:"change-transform",transform:e}]))}clearTransforms(e=true){return new fe(this.operations.concat([{type:"clear-transform",cascade:e}]))}setPhantom(e){return new fe(this.operations.concat([{type:"change-phantom",phantomState:e}]))}clearPhantom(){return new fe(this.operations.concat([{type:"clear-phantom"}]))}setEndItem(e){return new fe(this.operations.concat([{type:"change-end-item",endItemState:e}]))}clearEndItem(){return new fe(this.operations.concat([{type:"clear-end-item"}]))}viewRenditionById(e){return new fe(this.operations.concat([{type:"view-rendition-by-id",id:e}]))}viewRenditionBySuppliedId(e){return new fe(this.operations.concat([{type:"view-rendition-by-supplied-id",suppliedId:e}]))}viewDefaultRendition(){return new fe(this.operations.concat([{type:"view-default-rendition"}]))}clearRendition(){return new fe(this.operations.concat([{type:"clear-rendition"}]))}viewRepresentation(e){return new fe(this.operations.concat({type:"view-representation",id:e}))}clearRepresentation(){return new fe(this.operations.concat({type:"clear-representation"}))}}class me{constructor(e=[]){this.operations=e}build(){return this.operations.concat()}show(){return new me(this.operations.concat([{type:"show"}]))}hide(){return new me(this.operations.concat([{type:"hide"}]))}select(){return new me(this.operations.concat([{type:"select"}]))}deselect(){return new me(this.operations.concat([{type:"deselect"}]))}}class ye{constructor(e,t){this.stream=e;this.imageScaleProvider=t}async hitItems(e,t){const s=this.imageScaleProvider();const n=await this.stream.hitItems({point:S.scale(e,(s===null||s===void 0?void 0:s.x)||1,(s===null||s===void 0?void 0:s.y)||1),includeMetadata:t===null||t===void 0?void 0:t.includeMetadata},true);return n.hitItems||undefined}}const xe=1e3*30;class Ie{constructor(e,t,s,n){this.onFrameDrawn=new X(e,(e=>{var t,n,i;return!!((i=(n=(t=e.request)===null||t===void 0?void 0:t.drawFrame)===null||n===void 0?void 0:n.frameCorrelationIds)===null||i===void 0?void 0:i.some((e=>e===s)))}),(e=>{var s;return((s=e.request)===null||s===void 0?void 0:s.drawFrame)!=null?t(e.request.drawFrame):undefined}),n!==null&&n!==void 0?n:xe)}}class ge{constructor(e,t,s,n,i){this.stream=e;this.decodeFrame=t;this.encodeCameraType=s;this.sceneId=n;this.sceneViewId=i}async applySceneViewState(e,t={}){const s=ee(e);await this.animateToSceneViewState(s,t);return await this.stream.loadSceneViewState({...s,frameCorrelationId:t.suppliedCorrelationId?{value:t.suppliedCorrelationId}:undefined,cameraType:t.cameraTypeOverride?this.encodeCameraType(t.cameraTypeOverride):undefined},true)}async applyPartialSceneViewState(e,t,s={}){const n=ee(e);const i=he(t);if(t.includes("camera")){await this.animateToSceneViewState(n,s)}return await this.stream.loadSceneViewState({...n,frameCorrelationId:s.suppliedCorrelationId?{value:s.suppliedCorrelationId}:undefined,sceneViewStateFeatureSubset:i,cameraType:s.cameraTypeOverride?this.encodeCameraType(s.cameraTypeOverride):undefined},true)}async animateToSceneViewState(e,t){var n,i,r;if(t.animation!=null){const a=s.create();const o=await this.stream.flyTo({sceneViewStateIdentifier:e,animation:{duration:M(t.animation.milliseconds)},frameCorrelationId:{value:a}},true);if(t.waitForAnimation==null||t.waitForAnimation){const e=new Z(this.stream,this.decodeFrame,{animationId:(r=(i=(n=o.flyTo)===null||n===void 0?void 0:n.animationId)===null||i===void 0?void 0:i.hex)!==null&&r!==void 0?r:undefined,correlationId:a},t.animation.milliseconds+J);await e.onAnimationCompleted.once()}}}}class be{constructor(e,t){this.query=e;this.builder=t!==null&&t!==void 0?t:new fe}isItemBuilder(){return true}isAnnotationBuilder(){return false}materialOverride(e){if(typeof e==="string"){return new be(this.query,this.builder.materialOverride(j(e)))}else{return new be(this.query,this.builder.materialOverride(e))}}hide(){return new be(this.query,this.builder.hide())}show(){return new be(this.query,this.builder.show())}select(){return new be(this.query,this.builder.select())}deselect(){return new be(this.query,this.builder.deselect())}clearMaterialOverrides(){return new be(this.query,this.builder.clearMaterialOverrides())}transform(e){if(Array.isArray(e)){if(e.length!==16){throw new a("Matrix provided must contain exactly 16 values (4x4).")}return new be(this.query,this.builder.transform({r0:{x:e[0],y:e[1],z:e[2],w:e[3]},r1:{x:e[4],y:e[5],z:e[6],w:e[7]},r2:{x:e[8],y:e[9],z:e[10],w:e[11]},r3:{x:e[12],y:e[13],z:e[14],w:e[15]}}))}else{return new be(this.query,this.builder.transform(e))}}clearTransforms(e=true){return new be(this.query,this.builder.clearTransforms(e))}setPhantom(e){return new be(this.query,this.builder.setPhantom(e))}clearPhantom(){return new be(this.query,this.builder.clearPhantom())}setEndItem(e){return new be(this.query,this.builder.setEndItem(e))}clearEndItem(){return new be(this.query,this.builder.clearEndItem())}viewRenditionById(e){return new be(this.query,this.builder.viewRenditionById(e))}viewRenditionBySuppliedId(e){return new be(this.query,this.builder.viewRenditionBySuppliedId(e))}viewDefaultRendition(){return new be(this.query,this.builder.viewDefaultRendition())}clearRendition(){return new be(this.query,this.builder.clearRendition())}viewRepresentation(e){return new be(this.query,this.builder.viewRepresentation(e))}clearRepresentation(){return new be(this.query,this.builder.clearRepresentation())}build(){return{query:this.query,operations:this.builder.build()}}}class Se{constructor(e,t){this.query=e;this.builder=t!==null&&t!==void 0?t:new me}isItemBuilder(){return false}isAnnotationBuilder(){return true}hide(){return new Se(this.query,this.builder.hide())}show(){return new Se(this.query,this.builder.show())}select(){return new Se(this.query,this.builder.select())}deselect(){return new Se(this.query,this.builder.deselect())}build(){return{query:this.query,operations:this.builder.build()}}}class Be{constructor(e,t,s,n,i,r){this.sceneViewId=e;this.stream=t;this.decodeFrame=s;this.dimensions=n;this.sceneItemQueryOperations=i;this.pmiAnnotationQueryOperations=r}async execute(e){var t;const n=this.sceneItemQueryOperations.map((e=>ne(e.query,e.operations,{dimensions:this.dimensions})));const i=this.pmiAnnotationQueryOperations.map((e=>ie(e.query,e.operations)));const r=(t=e===null||e===void 0?void 0:e.suppliedCorrelationId)!==null&&t!==void 0?t:s.create();const a={sceneViewId:{hex:this.sceneViewId},elementOperations:[...n,...i],suppliedCorrelationId:{value:r}};await this.stream.createSceneAlteration(a)}}class Re extends Be{async execute(e){var t;if(e===null||e===void 0?void 0:e.awaitCorrelatedFrame){const n=(t=e.suppliedCorrelationId)!==null&&t!==void 0?t:s.create();const i=new Ie(this.stream,this.decodeFrame,n);await super.execute({...e,suppliedCorrelationId:n});await i.onFrameDrawn.once()}else{await super.execute(e)}}}class Ee extends Be{async execute(e){var t;if(e===null||e===void 0?void 0:e.skipAwaitCorrelatedFrame){await super.execute(e)}else{const n=(t=e===null||e===void 0?void 0:e.suppliedCorrelationId)!==null&&t!==void 0?t:s.create();const i=new Ie(this.stream,this.decodeFrame,n);await super.execute({...e,suppliedCorrelationId:n});await i.onFrameDrawn.once()}}}class Ae{constructor(e,t,s,n,i,r,a,o){this.stream=e;this.frame=t;this.decodeFrame=s;this.encodeCameraType=n;this.imageScaleProvider=i;this.dimensions=r;this.sceneId=a;this.sceneViewId=o;this.sceneViewStateLoader=new ge(e,s,n,a,o)}async applySceneViewState(e,t={}){return await this.sceneViewStateLoader.applySceneViewState(e,t)}async applyPartialSceneViewState(e,t,s={}){return await this.sceneViewStateLoader.applyPartialSceneViewState(e,t,s)}async reset(e={}){return await this.stream.resetSceneView({includeCamera:e.includeCamera,frameCorrelationId:e.suppliedCorrelationId?{value:e.suppliedCorrelationId}:undefined,cameraType:e.cameraTypeOverride?this.encodeCameraType(e.cameraTypeOverride):undefined},true)}items(e){const t=e(new Ke);const s=Array.isArray(t)?t:[t];const n=s.filter((e=>e.isItemBuilder()));const i=n.reduce(((e,t)=>e.concat(t.build())),[]);return new Re(this.sceneViewId,this.stream,this.decodeFrame,this.dimensions,i,[])}elements(e){const t=e(new We);const s=Array.isArray(t)?t:[t];const n=s.filter((e=>e.isItemBuilder()));const i=n.reduce(((e,t)=>e.concat(t.build())),[]);const r=s.filter((e=>e.isAnnotationBuilder()));const a=r.reduce(((e,t)=>e.concat(t.build())),[]);return new Ee(this.sceneViewId,this.stream,this.decodeFrame,this.dimensions,i,a)}camera(){const{scene:e}=this.frame;if(e.camera.isOrthographic()){return new we(this.stream,B.aspectRatio(this.viewport()),{viewVector:e.camera.viewVector,lookAt:e.camera.lookAt,up:e.camera.up,fovHeight:e.camera.fovHeight,rotationPoint:e.camera.lookAt},this.frame.scene.boundingBox,this.decodeFrame)}else if(e.camera.isPerspective()){return new pe(this.stream,B.aspectRatio(this.viewport()),{position:e.camera.position,lookAt:e.camera.lookAt,up:e.camera.up,fovY:e.camera.fovY},this.frame.scene.boundingBox,this.decodeFrame)}else{throw new r("Cannot retrieve camera. Scene has an unknown or invalid camera type.")}}isOrthographic(){const{scene:e}=this.frame;return e.camera.isOrthographic()}boundingBox(){return this.frame.scene.boundingBox}crossSectioning(){return new ve(this.stream,this.frame.scene.crossSection)}raycaster(){return new ye(this.stream,this.imageScaleProvider)}viewport(){return this.frame.dimensions}scale(){return this.imageScaleProvider()||S.create(1,1)}}class Ve{constructor(e){this.inverted=e}build(){if(this.inverted){return{type:"not",query:this.queryExpressionBuilder()}}else{return this.queryExpressionBuilder()}}}class Te{constructor(e=false){this.inverted=e}all(){return new Pe}not(){return new qe(!this.inverted)}withItemIds(e){return new Ue(e,"item-id",this.inverted)}withSuppliedIds(e){return new Ue(e,"supplied-id",this.inverted)}withItemId(e){return new ze({type:"item-id",value:e},this.inverted)}withSuppliedId(e){return new ze({type:"supplied-id",value:e},this.inverted)}withSceneTreeRange(e){return new Me(e,this.inverted)}withMetadata(e,t,s,n){return new Oe(e,t,s,this.inverted,n)}withSelected(){return new De(this.inverted)}withVisible(){return new _e(this.inverted)}withPoint(e){return new je(e,this.inverted)}withVolumeIntersection(e,t){return new Fe(e,this.inverted,t)}}class qe extends Te{constructor(e){super(e)}}class ke{constructor(e=false){this.inverted=e}all(){return new Pe}not(){return new Ce(!this.inverted)}withAnnotationIds(e){return new Ue(e,"annotation-id",this.inverted)}withAnnotationId(e){return new Le({type:"annotation-id",value:e},this.inverted)}}class Ce extends ke{constructor(e){super(e)}}class Pe extends Ve{constructor(e=false){super(e)}queryExpressionBuilder(){return{type:"all"}}}class Me extends Ve{constructor(e,t){super(t);this.range=e}queryExpressionBuilder(){return{type:"scene-tree-range",range:this.range}}}class Oe extends Ve{constructor(e,t,s,n,i){super(n);this.filter=e;this.keys=t;this.exactMatch=s;this.removeHiddenItems=i}queryExpressionBuilder(){return{type:"metadata",filter:this.filter,keys:this.keys,exactMatch:this.exactMatch,removeHiddenItems:this.removeHiddenItems}}}class De extends Ve{constructor(e){super(e)}queryExpressionBuilder(){return{type:"all-selected"}}}class _e extends Ve{constructor(e){super(e)}queryExpressionBuilder(){return{type:"all-visible"}}}class je extends Ve{constructor(e,t){super(t);this.point=e}queryExpressionBuilder(){return{type:"point",point:this.point}}}class Fe extends Ve{constructor(e,t,s){super(t);this.rectangle=e;this.exclusive=s}queryExpressionBuilder(){return{type:"volume-intersection",rectangle:this.rectangle,exclusive:!!this.exclusive}}}class Ue extends Ve{constructor(e,t,s){super(s);this.ids=e;this.type=t}queryExpressionBuilder(){return{type:"or",expressions:this.ids.map((e=>({type:this.type,value:e})))}}}class ze extends Ve{constructor(e,t){super(t);this.query=e}queryExpressionBuilder(){return{...this.query}}and(){return new He([this.query],this.inverted)}or(){return new Ne([this.query],this.inverted)}}class Ne extends Ve{constructor(e,t){super(t);this.expressions=e}queryExpressionBuilder(){return{type:"or",expressions:[...this.expressions]}}withItemId(e){return new Ne([...this.expressions,{type:"item-id",value:e}],this.inverted)}withSuppliedId(e){return new Ne([...this.expressions,{type:"supplied-id",value:e}],this.inverted)}or(){return this}}class He extends Ve{constructor(e,t){super(t);this.expressions=e}queryExpressionBuilder(){return{type:"and",expressions:[...this.expressions]}}withItemId(e){return new He([...this.expressions,{type:"item-id",value:e}],this.inverted)}withSuppliedId(e){return new He([...this.expressions,{type:"supplied-id",value:e}],this.inverted)}and(){return this}}class Le extends Ve{constructor(e,t){super(t);this.query=e}queryExpressionBuilder(){return{...this.query}}and(){return new Ye([this.query],this.inverted)}or(){return new Qe([this.query],this.inverted)}}class Qe extends Ve{constructor(e,t){super(t);this.expressions=e}queryExpressionBuilder(){return{type:"or",expressions:[...this.expressions]}}withAnnotationId(e){return new Qe([...this.expressions,{type:"annotation-id",value:e}],this.inverted)}or(){return this}}class Ye extends Ve{constructor(e,t){super(t);this.expressions=e}queryExpressionBuilder(){return{type:"and",expressions:[...this.expressions]}}withAnnotationId(e){return new Ye([...this.expressions,{type:"annotation-id",value:e}],this.inverted)}and(){return this}}class We{get items(){return new Ke}get annotations(){return new Ge}}class Ge{where(e){const t=e(new ke).build();return new Se(t)}}class Ke{where(e){const t=e(new Te).build();return new be(t)}}export{de as C,fe as I,K as M,Se as P,ye as R,Ae as S,ve as a,Ge as b,F as c,Te as d,We as e,Ee as f,be as g,Ke as h,Re as i,W as j,$ as k,H as l,D as m,U as n,Y as s,G as t};
|
|
5
|
+
//# sourceMappingURL=p-CAugdB_8.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2026 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import{m as t,a as s,g as i}from"./p-
|
|
5
|
-
//# sourceMappingURL=p-
|
|
4
|
+
import{m as t,a as s,g as i}from"./p-D12q-fpW.js";import{s as e,w as n}from"./p-FRKLa468.js";import{r,c as o}from"./p-CjG1fMh1.js";import{v as h}from"./p-BoB09nlv.js";import{m as a}from"./p-CHdoymO5.js";import{n as c}from"./p-B9R0QWr4.js";class m{constructor(t,s,i,e){this.model=t;this.client=s;this.jwtProvider=i;this.deviceId=e;this.outcome=Promise.resolve(undefined);this.debugLogs=false}addEntity(s){if(this.debugLogs){const i=t.ModelEntity.deserializeBinary(s.modelEntity);this.log(`Adding ModelEntity. [entityId={${i.getEntityId()}}, sceneItemId={${i.getSceneItemId()}}]`)}return this.performMeasurement((()=>this.model.addEntity(s)))}clearEntities(){this.log("Clearing all ModelEntities.");return this.performMeasurement((()=>{this.model.clearEntities();this.model.clearOutcome();return true}))}removeEntity(s){if(this.debugLogs){const i=t.ModelEntity.deserializeBinary(s.modelEntity);this.log(`Removing ModelEntity. [entityId={${i.getEntityId()}}, sceneItemId={${i.getSceneItemId()}}]`)}return this.performMeasurement((()=>this.model.removeEntity(s)))}setEntities(s){if(this.debugLogs){const i=Array.from(s).map((s=>t.ModelEntity.deserializeBinary(s.modelEntity)));this.log(`Setting ${i.length} ModelEntities. [entityIds=[${i.map((t=>t.getEntityId())).join(", ")}], sceneItemIds=[${i.map((t=>t.getSceneItemId())).join(", ")}]]`)}return this.performMeasurement((()=>this.model.setEntities(s)))}setDebugLogs(t){this.debugLogs=t}performMeasurement(t){const s=this.model.getEntities();const i=t();const e=this.model.getEntities();if(i){this.measureAndUpdateModel(e);this.highlightEntities(s,e)}return this.outcome}measureAndUpdateModel(t){if(t.length>0){this.outcome=this.measureEntities(t).then((t=>{this.model.setOutcome(t);return this.model.getOutcome()}))}else{this.outcome=Promise.resolve(undefined)}}async measureEntities(t){if(t.length>0){const i=await r((async s=>{const i=await o(this.jwtProvider,this.deviceId);const n=new e.MeasureRequest;n.setEntitiesList(t.map((t=>t.toProto())));this.client.measure(n,i,s)}));return s(i.toObject())}else{return undefined}}async highlightEntities(s,i){await r((async r=>{const h=await o(this.jwtProvider,this.deviceId);const a=new Set(i);const c=s.filter((t=>!a.has(t)));const m=c.map((s=>{const i=new e.ModelEntityUpdate;i.setModelEntity(t.ModelEntity.deserializeBinary(s.modelEntity));i.setHighlight((new n.BoolValue).setValue(false));return i}));const u=i.map((s=>{const i=new e.ModelEntityUpdate;i.setModelEntity(t.ModelEntity.deserializeBinary(s.modelEntity));i.setHighlight((new n.BoolValue).setValue(true));return i}));const d=new e.UpdateModelEntitiesRequest;d.setUpdatesList([...m,...u]);this.client.updateModelEntities(d,h,r)}))}log(t,...s){if(this.debugLogs){console.debug(t,s)}}}class u{constructor(t,s){this.point=t;this.modelEntity=s}static fromHit(t){if(t.hitPoint!=null&&t.modelEntity!=null){const s=a.ifInvalidThrow(c)(t.hitPoint);const i=h.protobuf.core.ModelEntity.encode(t.modelEntity).finish();return new u(s,i)}else{throw new Error("Cannot create MeasurementEntity from Hit. Hit is missing hit point and model entity")}}toProto(){const s=new e.MeasureEntity;const n=new i.Vector3f;n.setX(this.point.x);n.setY(this.point.y);n.setZ(this.point.z);s.setPoint(n);const r=t.ModelEntity.deserializeBinary(this.modelEntity);s.setModelEntity(r);return s}}export{m as M,u as a};
|
|
5
|
+
//# sourceMappingURL=p-CZCXdo3t.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Vertex Software LLC. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import{a as t}from"./p-CG9AChtV.js";import{d as e,e as n,a as r}from"./p-Ck9IspfK.js";var i={};var s={};var o={};var a;function f(){if(a)return o;a=1;Object.defineProperty(o,"__esModule",{value:true});o.DefaultSerializer=o.extendSerializer=void 0;function t(t,e){const n=t.deserialize.bind(t);const r=t.serialize.bind(t);return{deserialize(t){return e.deserialize(t,n)},serialize(t){return e.serialize(t,r)}}}o.extendSerializer=t;const e={deserialize(t){return Object.assign(Error(t.message),{name:t.name,stack:t.stack})},serialize(t){return{__error_marker:"$$error",message:t.message,name:t.name,stack:t.stack}}};const n=t=>t&&typeof t==="object"&&"__error_marker"in t&&t.__error_marker==="$$error";o.DefaultSerializer={deserialize(t){if(n(t)){return e.deserialize(t)}else{return t}},serialize(t){if(t instanceof Error){return e.serialize(t)}else{return t}}};return o}var c;function u(){if(c)return s;c=1;Object.defineProperty(s,"__esModule",{value:true});s.serialize=s.deserialize=s.registerSerializer=void 0;const t=f();let e=t.DefaultSerializer;function n(n){e=t.extendSerializer(e,n)}s.registerSerializer=n;function r(t){return e.deserialize(t)}s.deserialize=r;function i(t){return e.serialize(t)}s.serialize=i;return s}var l={};var h={};var d={};var p;function y(){if(p)return d;p=1;Object.defineProperty(d,"__esModule",{value:true});d.getBundleURL=d.getBaseURL=void 0;let t;function e(){if(!t){t=n()}return t}d.getBundleURL=e;function n(){try{throw new Error}catch(t){const e=(""+t.stack).match(/(https?|file|ftp|chrome-extension|moz-extension):\/\/[^)\n]+/g);if(e){return r(e[0])}}return"/"}function r(t){return(""+t).replace(/^((?:https?|file|ftp|chrome-extension|moz-extension):\/\/.+)?\/[^/]+(?:\?.*)?$/,"$1")+"/"}d.getBaseURL=r;return d}var w;function b(){if(w)return h;w=1;Object.defineProperty(h,"__esModule",{value:true});h.isWorkerRuntime=h.getWorkerImplementation=h.defaultPoolSize=void 0;const t=y();h.defaultPoolSize=typeof navigator!=="undefined"&&navigator.hardwareConcurrency?navigator.hardwareConcurrency:4;const e=t=>/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(t);function n(t){const e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function r(){if(typeof Worker==="undefined"){return class t{constructor(){throw Error("No web worker implementation available. You might have tried to spawn a worker within a worker in a browser that doesn't support workers in workers.")}}}class r extends Worker{constructor(r,i){var s,o;if(typeof r==="string"&&i&&i._baseURL){r=new URL(r,i._baseURL)}else if(typeof r==="string"&&!e(r)&&t.getBundleURL().match(/^file:\/\//i)){r=new URL(r,t.getBundleURL().replace(/\/[^\/]+$/,"/"));if((s=i===null||i===void 0?void 0:i.CORSWorkaround)!==null&&s!==void 0?s:true){r=n(`importScripts(${JSON.stringify(r)});`)}}if(typeof r==="string"&&e(r)){if((o=i===null||i===void 0?void 0:i.CORSWorkaround)!==null&&o!==void 0?o:true){r=n(`importScripts(${JSON.stringify(r)});`)}}super(r,i)}}class i extends r{constructor(t,e){const n=window.URL.createObjectURL(t);super(n,e)}static fromText(t,e){const n=new window.Blob([t],{type:"text/javascript"});return new i(n,e)}}return{blob:i,default:r}}let i;function s(){if(!i){i=r()}return i}h.getWorkerImplementation=s;function o(){const t=typeof self!=="undefined"&&typeof Window!=="undefined"&&self instanceof Window;return typeof self!=="undefined"&&self.postMessage&&!t?true:false}h.isWorkerRuntime=o;return h}var m={};var g={exports:{}};var v;var _;function k(){if(_)return v;_=1;var t=1e3;var e=t*60;var n=e*60;var r=n*24;var i=r*7;var s=r*365.25;v=function(t,e){e=e||{};var n=typeof t;if(n==="string"&&t.length>0){return o(t)}else if(n==="number"&&isFinite(t)){return e.long?f(t):a(t)}throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function o(o){o=String(o);if(o.length>100){return}var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(o);if(!a){return}var f=parseFloat(a[1]);var c=(a[2]||"ms").toLowerCase();switch(c){case"years":case"year":case"yrs":case"yr":case"y":return f*s;case"weeks":case"week":case"w":return f*i;case"days":case"day":case"d":return f*r;case"hours":case"hour":case"hrs":case"hr":case"h":return f*n;case"minutes":case"minute":case"mins":case"min":case"m":return f*e;case"seconds":case"second":case"secs":case"sec":case"s":return f*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return undefined}}function a(i){var s=Math.abs(i);if(s>=r){return Math.round(i/r)+"d"}if(s>=n){return Math.round(i/n)+"h"}if(s>=e){return Math.round(i/e)+"m"}if(s>=t){return Math.round(i/t)+"s"}return i+"ms"}function f(i){var s=Math.abs(i);if(s>=r){return c(i,s,r,"day")}if(s>=n){return c(i,s,n,"hour")}if(s>=e){return c(i,s,e,"minute")}if(s>=t){return c(i,s,t,"second")}return i+" ms"}function c(t,e,n,r){var i=e>=n*1.5;return Math.round(t/n)+" "+r+(i?"s":"")}return v}var x;var E;function A(){if(E)return x;E=1;function t(t){n.debug=n;n.default=n;n.coerce=f;n.disable=o;n.enable=i;n.enabled=a;n.humanize=k();n.destroy=c;Object.keys(t).forEach((e=>{n[e]=t[e]}));n.names=[];n.skips=[];n.formatters={};function e(t){let e=0;for(let n=0;n<t.length;n++){e=(e<<5)-e+t.charCodeAt(n);e|=0}return n.colors[Math.abs(e)%n.colors.length]}n.selectColor=e;function n(t){let e;let i=null;let s;let o;function a(...t){if(!a.enabled){return}const r=a;const i=Number(new Date);const s=i-(e||i);r.diff=s;r.prev=e;r.curr=i;e=i;t[0]=n.coerce(t[0]);if(typeof t[0]!=="string"){t.unshift("%O")}let o=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,((e,i)=>{if(e==="%%"){return"%"}o++;const s=n.formatters[i];if(typeof s==="function"){const n=t[o];e=s.call(r,n);t.splice(o,1);o--}return e}));n.formatArgs.call(r,t);const f=r.log||n.log;f.apply(r,t)}a.namespace=t;a.useColors=n.useColors();a.color=n.selectColor(t);a.extend=r;a.destroy=n.destroy;Object.defineProperty(a,"enabled",{enumerable:true,configurable:false,get:()=>{if(i!==null){return i}if(s!==n.namespaces){s=n.namespaces;o=n.enabled(t)}return o},set:t=>{i=t}});if(typeof n.init==="function"){n.init(a)}return a}function r(t,e){const r=n(this.namespace+(typeof e==="undefined"?":":e)+t);r.log=this.log;return r}function i(t){n.save(t);n.namespaces=t;n.names=[];n.skips=[];const e=(typeof t==="string"?t:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const t of e){if(t[0]==="-"){n.skips.push(t.slice(1))}else{n.names.push(t)}}}function s(t,e){let n=0;let r=0;let i=-1;let s=0;while(n<t.length){if(r<e.length&&(e[r]===t[n]||e[r]==="*")){if(e[r]==="*"){i=r;s=n;r++}else{n++;r++}}else if(i!==-1){r=i+1;s++;n=s}else{return false}}while(r<e.length&&e[r]==="*"){r++}return r===e.length}function o(){const t=[...n.names,...n.skips.map((t=>"-"+t))].join(",");n.enable("");return t}function a(t){for(const e of n.skips){if(s(t,e)){return false}}for(const e of n.names){if(s(t,e)){return true}}return false}function f(t){if(t instanceof Error){return t.stack||t.message}return t}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}n.enable(n.load());return n}x=t;return x}var U;function C(){if(U)return g.exports;U=1;(function(t,e){e.formatArgs=r;e.save=i;e.load=s;e.useColors=n;e.storage=o();e.destroy=(()=>{let t=false;return()=>{if(!t){t=true;console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}}})();e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){if(typeof window!=="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)){return true}if(typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)){return false}let t;return typeof document!=="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!=="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!=="undefined"&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff);if(!this.useColors){return}const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let r=0;let i=0;e[0].replace(/%[a-zA-Z%]/g,(t=>{if(t==="%%"){return}r++;if(t==="%c"){i=r}}));e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{if(t){e.storage.setItem("debug",t)}else{e.storage.removeItem("debug")}}catch(t){}}function s(){let t;try{t=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch(t){}if(!t&&typeof process!=="undefined"&&"env"in process){t=process.env.DEBUG}return t}function o(){try{return localStorage}catch(t){}}t.exports=A()(e);const{formatters:a}=t.exports;a.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}})(g,g.exports);return g.exports}var O=undefined&&undefined.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(r.next(t))}catch(t){s(t)}}function a(t){try{f(r["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):i(t.value).then(o,a)}f((r=r.apply(t,e||[])).next())}))};class T{constructor(t){this._baseObserver=t;this._pendingPromises=new Set}complete(){Promise.all(this._pendingPromises).then((()=>this._baseObserver.complete())).catch((t=>this._baseObserver.error(t)))}error(t){this._baseObserver.error(t)}schedule(t){const e=Promise.all(this._pendingPromises);const n=[];const r=t=>n.push(t);const i=Promise.resolve().then((()=>O(this,void 0,void 0,(function*(){yield e;yield t(r);this._pendingPromises.delete(i);for(const t of n){this._baseObserver.next(t)}})))).catch((t=>{this._pendingPromises.delete(i);this._baseObserver.error(t)}));this._pendingPromises.add(i)}}const F=()=>typeof Symbol==="function";const j=t=>F()&&Boolean(Symbol[t]);const S=t=>j(t)?Symbol[t]:"@@"+t;if(!j("asyncIterator")){Symbol.asyncIterator=Symbol.asyncIterator||Symbol.for("Symbol.asyncIterator")}const I=S("iterator");const M=S("observable");const B=S("species");function P(t,e){const n=t[e];if(n==null){return undefined}if(typeof n!=="function"){throw new TypeError(n+" is not a function")}return n}function R(t){let e=t.constructor;if(e!==undefined){e=e[B];if(e===null){e=undefined}}return e!==undefined?e:G}function D(t){return t instanceof G}function L(t){if(L.log){L.log(t)}else{setTimeout((()=>{throw t}),0)}}function N(t){Promise.resolve().then((()=>{try{t()}catch(t){L(t)}}))}function z(t){const e=t._cleanup;if(e===undefined){return}t._cleanup=undefined;if(!e){return}try{if(typeof e==="function"){e()}else{const t=P(e,"unsubscribe");if(t){t.call(e)}}}catch(t){L(t)}}function $(t){t._observer=undefined;t._queue=undefined;t._state="closed"}function Z(t){const e=t._queue;if(!e){return}t._queue=undefined;t._state="ready";for(const n of e){W(t,n.type,n.value);if(t._state==="closed"){break}}}function W(t,e,n){t._state="running";const r=t._observer;try{const i=r?P(r,e):undefined;switch(e){case"next":if(i)i.call(r,n);break;case"error":$(t);if(i)i.call(r,n);else throw n;break;case"complete":$(t);if(i)i.call(r);break}}catch(t){L(t)}if(t._state==="closed"){z(t)}else if(t._state==="running"){t._state="ready"}}function H(t,e,n){if(t._state==="closed"){return}if(t._state==="buffering"){t._queue=t._queue||[];t._queue.push({type:e,value:n});return}if(t._state!=="ready"){t._state="buffering";t._queue=[{type:e,value:n}];N((()=>Z(t)));return}W(t,e,n)}class q{constructor(t,e){this._cleanup=undefined;this._observer=t;this._queue=undefined;this._state="initializing";const n=new K(this);try{this._cleanup=e.call(undefined,n)}catch(t){n.error(t)}if(this._state==="initializing"){this._state="ready"}}get closed(){return this._state==="closed"}unsubscribe(){if(this._state!=="closed"){$(this);z(this)}}}class K{constructor(t){this._subscription=t}get closed(){return this._subscription._state==="closed"}next(t){H(this._subscription,"next",t)}error(t){H(this._subscription,"error",t)}complete(){H(this._subscription,"complete")}}class G{constructor(t){if(!(this instanceof G)){throw new TypeError("Observable cannot be called as a function")}if(typeof t!=="function"){throw new TypeError("Observable initializer must be a function")}this._subscriber=t}subscribe(t,e,n){if(typeof t!=="object"||t===null){t={next:t,error:e,complete:n}}return new q(t,this._subscriber)}pipe(t,...e){let n=this;for(const r of[t,...e]){n=r(n)}return n}tap(t,e,n){const r=typeof t!=="object"||t===null?{next:t,error:e,complete:n}:t;return new G((t=>this.subscribe({next(e){r.next&&r.next(e);t.next(e)},error(e){r.error&&r.error(e);t.error(e)},complete(){r.complete&&r.complete();t.complete()},start(t){r.start&&r.start(t)}})))}forEach(t){return new Promise(((e,n)=>{if(typeof t!=="function"){n(new TypeError(t+" is not a function"));return}function r(){i.unsubscribe();e(undefined)}const i=this.subscribe({next(e){try{t(e,r)}catch(t){n(t);i.unsubscribe()}},error(t){n(t)},complete(){e(undefined)}})}))}map(t){if(typeof t!=="function"){throw new TypeError(t+" is not a function")}const e=R(this);return new e((e=>this.subscribe({next(n){let r=n;try{r=t(n)}catch(t){return e.error(t)}e.next(r)},error(t){e.error(t)},complete(){e.complete()}})))}filter(t){if(typeof t!=="function"){throw new TypeError(t+" is not a function")}const e=R(this);return new e((e=>this.subscribe({next(n){try{if(!t(n))return}catch(t){return e.error(t)}e.next(n)},error(t){e.error(t)},complete(){e.complete()}})))}reduce(t,e){if(typeof t!=="function"){throw new TypeError(t+" is not a function")}const n=R(this);const r=arguments.length>1;let i=false;let s=e;return new n((e=>this.subscribe({next(n){const o=!i;i=true;if(!o||r){try{s=t(s,n)}catch(t){return e.error(t)}}else{s=n}},error(t){e.error(t)},complete(){if(!i&&!r){return e.error(new TypeError("Cannot reduce an empty sequence"))}e.next(s);e.complete()}})))}concat(...t){const e=R(this);return new e((n=>{let r;let i=0;function s(o){r=o.subscribe({next(t){n.next(t)},error(t){n.error(t)},complete(){if(i===t.length){r=undefined;n.complete()}else{s(e.from(t[i++]))}}})}s(this);return()=>{if(r){r.unsubscribe();r=undefined}}}))}flatMap(t){if(typeof t!=="function"){throw new TypeError(t+" is not a function")}const e=R(this);return new e((n=>{const r=[];const i=this.subscribe({next(i){let o;if(t){try{o=t(i)}catch(t){return n.error(t)}}else{o=i}const a=e.from(o).subscribe({next(t){n.next(t)},error(t){n.error(t)},complete(){const t=r.indexOf(a);if(t>=0)r.splice(t,1);s()}});r.push(a)},error(t){n.error(t)},complete(){s()}});function s(){if(i.closed&&r.length===0){n.complete()}}return()=>{r.forEach((t=>t.unsubscribe()));i.unsubscribe()}}))}[M](){return this}static from(t){const e=typeof this==="function"?this:G;if(t==null){throw new TypeError(t+" is not an object")}const n=P(t,M);if(n){const r=n.call(t);if(Object(r)!==r){throw new TypeError(r+" is not an object")}if(D(r)&&r.constructor===e){return r}return new e((t=>r.subscribe(t)))}if(j("iterator")){const n=P(t,I);if(n){return new e((e=>{N((()=>{if(e.closed)return;for(const r of n.call(t)){e.next(r);if(e.closed)return}e.complete()}))}))}}if(Array.isArray(t)){return new e((e=>{N((()=>{if(e.closed)return;for(const n of t){e.next(n);if(e.closed)return}e.complete()}))}))}throw new TypeError(t+" is not observable")}static of(...t){const e=typeof this==="function"?this:G;return new e((e=>{N((()=>{if(e.closed)return;for(const n of t){e.next(n);if(e.closed)return}e.complete()}))}))}static get[B](){return this}}if(F()){Object.defineProperty(G,Symbol("extensions"),{value:{symbol:M,hostReportError:L},configurable:true})}function V(t){if(typeof t==="function"){t()}else if(t&&typeof t.unsubscribe==="function"){t.unsubscribe()}}var Q=undefined&&undefined.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(r.next(t))}catch(t){s(t)}}function a(t){try{f(r["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):i(t.value).then(o,a)}f((r=r.apply(t,e||[])).next())}))};function J(t){return e=>new G((n=>{const r=new T(n);const i=e.subscribe({complete(){r.complete()},error(t){r.error(t)},next(e){r.schedule((n=>Q(this,void 0,void 0,(function*(){if(yield t(e)){n(e)}}))))}});return()=>V(i)}))}function Y(t){return t&&j("asyncIterator")&&t[Symbol.asyncIterator]}function X(t){return t&&j("iterator")&&t[Symbol.iterator]}var tt=undefined&&undefined.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(r.next(t))}catch(t){s(t)}}function a(t){try{f(r["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):i(t.value).then(o,a)}f((r=r.apply(t,e||[])).next())}))};var et=undefined&&undefined.__asyncValues||function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof __values==="function"?__values(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(e){n[e]=t[e]&&function(n){return new Promise((function(r,s){n=t[e](n),i(r,s,n.done,n.value)}))}}function i(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)}};function nt(t){return e=>new G((n=>{const r=new T(n);const i=e.subscribe({complete(){r.complete()},error(t){r.error(t)},next(e){r.schedule((n=>tt(this,void 0,void 0,(function*(){var r,i;const s=yield t(e);if(X(s)||Y(s)){try{for(var o=et(s),a;a=yield o.next(),!a.done;){const t=a.value;n(t)}}catch(t){r={error:t}}finally{try{if(a&&!a.done&&(i=o.return))yield i.call(o)}finally{if(r)throw r.error}}}else{s.map((t=>n(t)))}}))))}});return()=>V(i)}))}function rt(t){return new G((e=>{let n=0;const r=setInterval((()=>{e.next(n++)}),t);return()=>clearInterval(r)}))}var it=undefined&&undefined.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(r.next(t))}catch(t){s(t)}}function a(t){try{f(r["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):i(t.value).then(o,a)}f((r=r.apply(t,e||[])).next())}))};function st(t){return e=>new G((n=>{const r=new T(n);const i=e.subscribe({complete(){r.complete()},error(t){r.error(t)},next(e){r.schedule((n=>it(this,void 0,void 0,(function*(){const r=yield t(e);n(r)}))))}});return()=>V(i)}))}function ot(...t){if(t.length===0){return G.from([])}return new G((e=>{let n=0;const r=t.map((r=>r.subscribe({error(t){e.error(t);i()},next(t){e.next(t)},complete(){if(++n===t.length){e.complete();i()}}})));const i=()=>{r.forEach((t=>V(t)))};return i}))}class at extends G{constructor(){super((t=>{this._observers.add(t);return()=>this._observers.delete(t)}));this._observers=new Set}next(t){for(const e of this._observers){e.next(t)}}error(t){for(const e of this._observers){e.error(t)}}complete(){for(const t of this._observers){t.complete()}}}function ft(t){const e=new at;let n;let r=0;return new G((i=>{if(!n){n=t.subscribe(e)}const s=e.subscribe(i);r++;return()=>{r--;s.unsubscribe();if(r===0){V(n);n=undefined}}}))}var ct=undefined&&undefined.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(r.next(t))}catch(t){s(t)}}function a(t){try{f(r["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):i(t.value).then(o,a)}f((r=r.apply(t,e||[])).next())}))};function ut(t,e){return n=>new G((r=>{let i;let s=0;const o=new T(r);const a=n.subscribe({complete(){o.complete()},error(t){o.error(t)},next(n){o.schedule((r=>ct(this,void 0,void 0,(function*(){const o=s===0?typeof e==="undefined"?n:e:i;i=yield t(o,n,s++);r(i)}))))}});return()=>V(a)}))}var lt=Object.freeze({__proto__:null,Observable:G,Subject:at,filter:J,flatMap:nt,interval:rt,map:st,merge:ot,multicast:ft,scan:ut,unsubscribe:V});var ht=t(lt);var dt={};var pt;function yt(){if(pt)return dt;pt=1;Object.defineProperty(dt,"__esModule",{value:true});dt.allSettled=void 0;function t(t){return Promise.all(t.map((t=>{const e=t=>({status:"fulfilled",value:t});const n=t=>({status:"rejected",reason:t});const r=Promise.resolve(t);try{return r.then(e,n)}catch(t){return Promise.reject(t)}})))}dt.allSettled=t;return dt}var wt={};var bt;function mt(){if(bt)return wt;bt=1;(function(t){Object.defineProperty(t,"__esModule",{value:true});t.PoolEventType=void 0;(function(t){t["initialized"]="initialized";t["taskCanceled"]="taskCanceled";t["taskCompleted"]="taskCompleted";t["taskFailed"]="taskFailed";t["taskQueued"]="taskQueued";t["taskQueueDrained"]="taskQueueDrained";t["taskStart"]="taskStart";t["terminated"]="terminated"})(t.PoolEventType||(t.PoolEventType={}))})(wt);return wt}var gt={};var vt={};var _t;function kt(){if(_t)return vt;_t=1;Object.defineProperty(vt,"__esModule",{value:true});vt.$worker=vt.$transferable=vt.$terminate=vt.$events=vt.$errors=void 0;vt.$errors=Symbol("thread.errors");vt.$events=Symbol("thread.events");vt.$terminate=Symbol("thread.terminate");vt.$transferable=Symbol("thread.transferable");vt.$worker=Symbol("thread.worker");return vt}var xt;function Et(){if(xt)return gt;xt=1;Object.defineProperty(gt,"__esModule",{value:true});gt.Thread=void 0;const t=kt();function e(t){throw Error(t)}gt.Thread={errors(n){return n[t.$errors]||e("Error observable not found. Make sure to pass a thread instance as returned by the spawn() promise.")},events(n){return n[t.$events]||e("Events observable not found. Make sure to pass a thread instance as returned by the spawn() promise.")},terminate(e){return e[t.$terminate]()}};return gt}var At;function Ut(){if(At)return m;At=1;(function(t){var e=m&&m.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(r.next(t))}catch(t){s(t)}}function a(t){try{f(r["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):i(t.value).then(o,a)}f((r=r.apply(t,e||[])).next())}))};var n=m&&m.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(t,"__esModule",{value:true});t.Pool=t.Thread=t.PoolEventType=void 0;const r=n(C());const i=ht;const s=yt();const o=b();const a=mt();Object.defineProperty(t,"PoolEventType",{enumerable:true,get:function(){return a.PoolEventType}});const f=Et();Object.defineProperty(t,"Thread",{enumerable:true,get:function(){return f.Thread}});let c=1;function u(t){const e=[];for(let n=0;n<t;n++){e.push(n)}return e}function l(t){return new Promise((e=>setTimeout(e,t)))}function h(t,e){return t.reduce(((t,n)=>[...t,...e(n)]),[])}function d(t){return t.replace(/\W/g," ").trim().replace(/\s+/g,"-")}function p(t,e){return u(e).map((()=>({init:t(),runningTasks:[]})))}class y{constructor(t,e){this.eventSubject=new i.Subject;this.initErrors=[];this.isClosing=false;this.nextTaskID=1;this.taskQueue=[];const n=typeof e==="number"?{size:e}:e||{};const{size:s=o.defaultPoolSize}=n;this.debug=r.default(`threads:pool:${d(n.name||String(c++))}`);this.options=n;this.workers=p(t,s);this.eventObservable=i.multicast(i.Observable.from(this.eventSubject));Promise.all(this.workers.map((t=>t.init))).then((()=>this.eventSubject.next({type:a.PoolEventType.initialized,size:this.workers.length})),(t=>{this.debug("Error while initializing pool worker:",t);this.eventSubject.error(t);this.initErrors.push(t)}))}findIdlingWorker(){const{concurrency:t=1}=this.options;return this.workers.find((e=>e.runningTasks.length<t))}runPoolTask(t,n){return e(this,void 0,void 0,(function*(){const e=this.workers.indexOf(t)+1;this.debug(`Running task #${n.id} on worker #${e}...`);this.eventSubject.next({type:a.PoolEventType.taskStart,taskID:n.id,workerID:e});try{const r=yield n.run(yield t.init);this.debug(`Task #${n.id} completed successfully`);this.eventSubject.next({type:a.PoolEventType.taskCompleted,returnValue:r,taskID:n.id,workerID:e})}catch(t){this.debug(`Task #${n.id} failed`);this.eventSubject.next({type:a.PoolEventType.taskFailed,taskID:n.id,error:t,workerID:e})}}))}run(t,n){return e(this,void 0,void 0,(function*(){const r=(()=>e(this,void 0,void 0,(function*(){const e=()=>{t.runningTasks=t.runningTasks.filter((t=>t!==r))};yield l(0);try{yield this.runPoolTask(t,n)}finally{e();if(!this.isClosing){this.scheduleWork()}}})))();t.runningTasks.push(r)}))}scheduleWork(){this.debug(`Attempt de-queueing a task in order to run it...`);const t=this.findIdlingWorker();if(!t)return;const e=this.taskQueue.shift();if(!e){this.debug(`Task queue is empty`);this.eventSubject.next({type:a.PoolEventType.taskQueueDrained});return}this.run(t,e)}taskCompletion(t){return new Promise(((e,n)=>{const r=this.events().subscribe((i=>{if(i.type===a.PoolEventType.taskCompleted&&i.taskID===t){r.unsubscribe();e(i.returnValue)}else if(i.type===a.PoolEventType.taskFailed&&i.taskID===t){r.unsubscribe();n(i.error)}else if(i.type===a.PoolEventType.terminated){r.unsubscribe();n(Error("Pool has been terminated before task was run."))}}))}))}settled(t=false){return e(this,void 0,void 0,(function*(){const e=()=>h(this.workers,(t=>t.runningTasks));const n=[];const r=this.eventObservable.subscribe((t=>{if(t.type===a.PoolEventType.taskFailed){n.push(t.error)}}));if(this.initErrors.length>0){return Promise.reject(this.initErrors[0])}if(t&&this.taskQueue.length===0){yield s.allSettled(e());return n}yield new Promise(((t,e)=>{const n=this.eventObservable.subscribe({next(e){if(e.type===a.PoolEventType.taskQueueDrained){n.unsubscribe();t(void 0)}},error:e})}));yield s.allSettled(e());r.unsubscribe();return n}))}completed(t=false){return e(this,void 0,void 0,(function*(){const e=this.settled(t);const n=new Promise(((t,n)=>{const r=this.eventObservable.subscribe({next(i){if(i.type===a.PoolEventType.taskQueueDrained){r.unsubscribe();t(e)}else if(i.type===a.PoolEventType.taskFailed){r.unsubscribe();n(i.error)}},error:n})}));const r=yield Promise.race([e,n]);if(r.length>0){throw r[0]}}))}events(){return this.eventObservable}queue(t){const{maxQueuedJobs:e=Infinity}=this.options;if(this.isClosing){throw Error(`Cannot schedule pool tasks after terminate() has been called.`)}if(this.initErrors.length>0){throw this.initErrors[0]}const n=this.nextTaskID++;const r=this.taskCompletion(n);r.catch((t=>{this.debug(`Task #${n} errored:`,t)}));const i={id:n,run:t,cancel:()=>{if(this.taskQueue.indexOf(i)===-1)return;this.taskQueue=this.taskQueue.filter((t=>t!==i));this.eventSubject.next({type:a.PoolEventType.taskCanceled,taskID:i.id})},then:r.then.bind(r)};if(this.taskQueue.length>=e){throw Error("Maximum number of pool tasks queued. Refusing to queue another one.\n"+"This usually happens for one of two reasons: We are either at peak "+"workload right now or some tasks just won't finish, thus blocking the pool.")}this.debug(`Queueing task #${i.id}...`);this.taskQueue.push(i);this.eventSubject.next({type:a.PoolEventType.taskQueued,taskID:i.id});this.scheduleWork();return i}terminate(t){return e(this,void 0,void 0,(function*(){this.isClosing=true;if(!t){yield this.completed(true)}this.eventSubject.next({type:a.PoolEventType.terminated,remainingQueue:[...this.taskQueue]});this.eventSubject.complete();yield Promise.all(this.workers.map((t=>e(this,void 0,void 0,(function*(){return f.Thread.terminate(yield t.init)})))))}))}}y.EventType=a.PoolEventType;function w(t,e){return new y(t,e)}w.EventType=a.PoolEventType;t.Pool=w})(m);return m}var Ct={};var Ot={};var Tt;function Ft(){if(Tt)return Ot;Tt=1;Object.defineProperty(Ot,"__esModule",{value:true});Ot.createPromiseWithResolver=void 0;const t=()=>undefined;function e(){let e=false;let n;let r=t;const i=new Promise((t=>{if(e){t(n)}else{r=t}}));const s=t=>{e=true;n=t;r(n)};return[i,s]}Ot.createPromiseWithResolver=e;return Ot}var jt={};var St;function It(){if(St)return jt;St=1;(function(t){Object.defineProperty(t,"__esModule",{value:true});t.WorkerEventType=void 0;(function(t){t["internalError"]="internalError";t["message"]="message";t["termination"]="termination"})(t.WorkerEventType||(t.WorkerEventType={}))})(jt);return jt}var Mt={};var Bt={};var Pt;function Rt(){if(Pt)return Bt;Pt=1;Object.defineProperty(Bt,"__esModule",{value:true});Bt.ObservablePromise=void 0;const t=ht;const e=()=>undefined;const n=t=>t;const r=t=>Promise.resolve().then(t);function i(t){throw t}function s(t){return t&&typeof t.then==="function"}class o extends t.Observable{constructor(t){super((e=>{const n=this;const r=Object.assign(Object.assign({},e),{complete(){e.complete();n.onCompletion()},error(t){e.error(t);n.onError(t)},next(t){e.next(t);n.onNext(t)}});try{this.initHasRun=true;return t(r)}catch(t){r.error(t)}}));this.initHasRun=false;this.fulfillmentCallbacks=[];this.rejectionCallbacks=[];this.firstValueSet=false;this.state="pending"}onNext(t){if(!this.firstValueSet){this.firstValue=t;this.firstValueSet=true}}onError(t){this.state="rejected";this.rejection=t;for(const e of this.rejectionCallbacks){r((()=>e(t)))}}onCompletion(){this.state="fulfilled";for(const t of this.fulfillmentCallbacks){r((()=>t(this.firstValue)))}}then(t,e){const r=t||n;const s=e||i;let o=false;return new Promise(((t,e)=>{const n=n=>{if(o)return;o=true;try{t(s(n))}catch(t){e(t)}};const i=e=>{try{t(r(e))}catch(t){n(t)}};if(!this.initHasRun){this.subscribe({error:n})}if(this.state==="fulfilled"){return t(r(this.firstValue))}if(this.state==="rejected"){o=true;return t(s(this.rejection))}this.fulfillmentCallbacks.push(i);this.rejectionCallbacks.push(n)}))}catch(t){return this.then(undefined,t)}finally(t){const n=t||e;return this.then((t=>{n();return t}),(()=>n()))}static from(t){if(s(t)){return new o((e=>{const n=t=>{e.next(t);e.complete()};const r=t=>{e.error(t)};t.then(n,r)}))}else{return super.from(t)}}}Bt.ObservablePromise=o;return Bt}var Dt={};var Lt;function Nt(){if(Lt)return Dt;Lt=1;Object.defineProperty(Dt,"__esModule",{value:true});Dt.Transfer=Dt.isTransferDescriptor=void 0;const t=kt();function e(t){if(!t||typeof t!=="object")return false;return true}function n(e){return e&&typeof e==="object"&&e[t.$transferable]}Dt.isTransferDescriptor=n;function r(n,r){if(!r){if(!e(n))throw Error();r=[n]}return{[t.$transferable]:true,send:n,transferables:r}}Dt.Transfer=r;return Dt}var zt={};var $t;function Zt(){if($t)return zt;$t=1;(function(t){Object.defineProperty(t,"__esModule",{value:true});t.WorkerMessageType=t.MasterMessageType=void 0;(function(t){t["cancel"]="cancel";t["run"]="run"})(t.MasterMessageType||(t.MasterMessageType={}));(function(t){t["error"]="error";t["init"]="init";t["result"]="result";t["running"]="running";t["uncaughtError"]="uncaughtError"})(t.WorkerMessageType||(t.WorkerMessageType={}))})(zt);return zt}var Wt;function Ht(){if(Wt)return Mt;Wt=1;var t=Mt&&Mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Mt,"__esModule",{value:true});Mt.createProxyModule=Mt.createProxyFunction=void 0;const e=t(C());const n=ht;const r=u();const i=Rt();const s=Nt();const o=Zt();const a=e.default("threads:master:messages");let f=1;const c=t=>Array.from(new Set(t));const l=t=>t&&t.type===o.WorkerMessageType.error;const h=t=>t&&t.type===o.WorkerMessageType.result;const d=t=>t&&t.type===o.WorkerMessageType.running;function p(t,e){return new n.Observable((n=>{let i;const s=o=>{a("Message from worker:",o.data);if(!o.data||o.data.uid!==e)return;if(d(o.data)){i=o.data.resultType}else if(h(o.data)){if(i==="promise"){if(typeof o.data.payload!=="undefined"){n.next(r.deserialize(o.data.payload))}n.complete();t.removeEventListener("message",s)}else{if(o.data.payload){n.next(r.deserialize(o.data.payload))}if(o.data.complete){n.complete();t.removeEventListener("message",s)}}}else if(l(o.data)){const e=r.deserialize(o.data.error);if(i==="promise"||!i){n.error(e)}else{n.error(e)}t.removeEventListener("message",s)}};t.addEventListener("message",s);return()=>{if(i==="observable"||!i){const n={type:o.MasterMessageType.cancel,uid:e};t.postMessage(n)}t.removeEventListener("message",s)}}))}function y(t){if(t.length===0){return{args:[],transferables:[]}}const e=[];const n=[];for(const i of t){if(s.isTransferDescriptor(i)){e.push(r.serialize(i.send));n.push(...i.transferables)}else{e.push(r.serialize(i))}}return{args:e,transferables:n.length===0?n:c(n)}}function w(t,e){return(...r)=>{const s=f++;const{args:c,transferables:u}=y(r);const l={type:o.MasterMessageType.run,uid:s,method:e,args:c};a("Sending command to run function to worker:",l);try{t.postMessage(l,u)}catch(t){return i.ObservablePromise.from(Promise.reject(t))}return i.ObservablePromise.from(n.multicast(p(t,s)))}}Mt.createProxyFunction=w;function b(t,e){const n={};for(const r of e){n[r]=w(t,r)}return n}Mt.createProxyModule=b;return Mt}var qt;function Kt(){if(qt)return Ct;qt=1;var t=Ct&&Ct.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(r.next(t))}catch(t){s(t)}}function a(t){try{f(r["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):i(t.value).then(o,a)}f((r=r.apply(t,e||[])).next())}))};var e=Ct&&Ct.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ct,"__esModule",{value:true});Ct.spawn=void 0;const n=e(C());const r=ht;const i=u();const s=Ft();const o=kt();const a=It();const f=Ht();const c=n.default("threads:master:messages");const l=n.default("threads:master:spawn");const h=n.default("threads:master:thread-utils");const d=t=>t&&t.type==="init";const p=t=>t&&t.type==="uncaughtError";const y=typeof process!=="undefined"&&process.env.THREADS_WORKER_INIT_TIMEOUT?Number.parseInt(process.env.THREADS_WORKER_INIT_TIMEOUT,10):1e4;function w(e,n,r){return t(this,void 0,void 0,(function*(){let t;const i=new Promise(((e,i)=>{t=setTimeout((()=>i(Error(r))),n)}));const s=yield Promise.race([e,i]);clearTimeout(t);return s}))}function b(t){return new Promise(((e,n)=>{const r=s=>{c("Message from worker before finishing initialization:",s.data);if(d(s.data)){t.removeEventListener("message",r);e(s.data)}else if(p(s.data)){t.removeEventListener("message",r);n(i.deserialize(s.data.error))}};t.addEventListener("message",r)}))}function m(t,e){return new r.Observable((n=>{const r=t=>{const e={type:a.WorkerEventType.message,data:t.data};n.next(e)};const i=t=>{h("Unhandled promise rejection event in thread:",t);const e={type:a.WorkerEventType.internalError,error:Error(t.reason)};n.next(e)};t.addEventListener("message",r);t.addEventListener("unhandledrejection",i);e.then((()=>{const e={type:a.WorkerEventType.termination};t.removeEventListener("message",r);t.removeEventListener("unhandledrejection",i);n.next(e);n.complete()}))}))}function g(e){const[n,r]=s.createPromiseWithResolver();const i=()=>t(this,void 0,void 0,(function*(){h("Terminating worker");yield e.terminate();r()}));return{terminate:i,termination:n}}function v(t,e,n,r){const i=n.filter((t=>t.type===a.WorkerEventType.internalError)).map((t=>t.error));return Object.assign(t,{[o.$errors]:i,[o.$events]:n,[o.$terminate]:r,[o.$worker]:e})}function _(e,n){return t(this,void 0,void 0,(function*(){l("Initializing new thread");const t=n&&n.timeout?n.timeout:y;const r=yield w(b(e),t,`Timeout: Did not receive an init message from worker after ${t}ms. Make sure the worker calls expose().`);const i=r.exposed;const{termination:s,terminate:o}=g(e);const a=m(e,s);if(i.type==="function"){const t=f.createProxyFunction(e);return v(t,e,a,o)}else if(i.type==="module"){const t=f.createProxyModule(e,i.methods);return v(t,e,a,o)}else{const t=i.type;throw Error(`Worker init message states unexpected type of expose(): ${t}`)}}))}Ct.spawn=_;return Ct}var Gt;function Vt(){if(Gt)return l;Gt=1;(function(t){Object.defineProperty(t,"__esModule",{value:true});t.Worker=t.BlobWorker=t.isWorkerRuntime=t.Thread=t.spawn=t.Pool=void 0;const e=b();Object.defineProperty(t,"isWorkerRuntime",{enumerable:true,get:function(){return e.isWorkerRuntime}});var n=Ut();Object.defineProperty(t,"Pool",{enumerable:true,get:function(){return n.Pool}});var r=Kt();Object.defineProperty(t,"spawn",{enumerable:true,get:function(){return r.spawn}});var i=Et();Object.defineProperty(t,"Thread",{enumerable:true,get:function(){return i.Thread}});t.BlobWorker=e.getWorkerImplementation().blob;t.Worker=e.getWorkerImplementation().default})(l);return l}var Qt={};var Jt;var Yt;function Xt(){if(Yt)return Jt;Yt=1;Jt=t=>{if(!t){return false}if(typeof Symbol.observable==="symbol"&&typeof t[Symbol.observable]==="function"){return t===t[Symbol.observable]()}if(typeof t["@@observable"]==="function"){return t===t["@@observable"]()}return false};return Jt}var te={};var ee;function ne(){if(ee)return te;ee=1;Object.defineProperty(te,"__esModule",{value:true});const t=function t(){const e=typeof self!=="undefined"&&typeof Window!=="undefined"&&self instanceof Window;return typeof self!=="undefined"&&self.postMessage&&!e?true:false};const e=function t(e,n){self.postMessage(e,n)};const n=function t(e){const n=t=>{e(t.data)};const r=()=>{self.removeEventListener("message",n)};self.addEventListener("message",n);return r};te.default={isWorkerRuntime:t,postMessageToMaster:e,subscribeToMasterMessages:n};return te}var re;function ie(){if(re)return Qt;re=1;(function(t){var e=Qt&&Qt.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{f(r.next(t))}catch(t){s(t)}}function a(t){try{f(r["throw"](t))}catch(t){s(t)}}function f(t){t.done?n(t.value):i(t.value).then(o,a)}f((r=r.apply(t,e||[])).next())}))};var n=Qt&&Qt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(t,"__esModule",{value:true});t.expose=t.isWorkerRuntime=t.Transfer=t.registerSerializer=void 0;const r=n(Xt());const i=u();const s=Nt();const o=Zt();const a=n(ne());var f=u();Object.defineProperty(t,"registerSerializer",{enumerable:true,get:function(){return f.registerSerializer}});var c=Nt();Object.defineProperty(t,"Transfer",{enumerable:true,get:function(){return c.Transfer}});t.isWorkerRuntime=a.default.isWorkerRuntime;let l=false;const h=new Map;const d=t=>t&&t.type===o.MasterMessageType.cancel;const p=t=>t&&t.type===o.MasterMessageType.run;const y=t=>r.default(t)||w(t);function w(t){return t&&typeof t==="object"&&typeof t.subscribe==="function"}function b(t){return s.isTransferDescriptor(t)?{payload:t.send,transferables:t.transferables}:{payload:t,transferables:undefined}}function m(){const t={type:o.WorkerMessageType.init,exposed:{type:"function"}};a.default.postMessageToMaster(t)}function g(t){const e={type:o.WorkerMessageType.init,exposed:{type:"module",methods:t}};a.default.postMessageToMaster(e)}function v(t,e){const{payload:n,transferables:r}=b(e);const s={type:o.WorkerMessageType.error,uid:t,error:i.serialize(n)};a.default.postMessageToMaster(s,r)}function _(t,e,n){const{payload:r,transferables:i}=b(n);const s={type:o.WorkerMessageType.result,uid:t,complete:e?true:undefined,payload:r};a.default.postMessageToMaster(s,i)}function k(t,e){const n={type:o.WorkerMessageType.running,uid:t,resultType:e};a.default.postMessageToMaster(n)}function x(t){try{const e={type:o.WorkerMessageType.uncaughtError,error:i.serialize(t)};a.default.postMessageToMaster(e)}catch(e){console.error("Not reporting uncaught error back to master thread as it "+"occured while reporting an uncaught error already."+"\nLatest error:",e,"\nOriginal error:",t)}}function E(t,n,r){return e(this,void 0,void 0,(function*(){let e;try{e=n(...r)}catch(e){return v(t,e)}const s=y(e)?"observable":"promise";k(t,s);if(y(e)){const n=e.subscribe((e=>_(t,false,i.serialize(e))),(e=>{v(t,i.serialize(e));h.delete(t)}),(()=>{_(t,true);h.delete(t)}));h.set(t,n)}else{try{const n=yield e;_(t,true,i.serialize(n))}catch(e){v(t,i.serialize(e))}}}))}function A(t){if(!a.default.isWorkerRuntime()){throw Error("expose() called in the master thread.")}if(l){throw Error("expose() called more than once. This is not possible. Pass an object to expose() if you want to expose multiple functions.")}l=true;if(typeof t==="function"){a.default.subscribeToMasterMessages((e=>{if(p(e)&&!e.method){E(e.uid,t,e.args.map(i.deserialize))}}));m()}else if(typeof t==="object"&&t){a.default.subscribeToMasterMessages((e=>{if(p(e)&&e.method){E(e.uid,t[e.method],e.args.map(i.deserialize))}}));const e=Object.keys(t).filter((e=>typeof t[e]==="function"));g(e)}else{throw Error(`Invalid argument passed to expose(). Expected a function or an object, got: ${t}`)}a.default.subscribeToMasterMessages((t=>{if(d(t)){const e=t.uid;const n=h.get(e);if(n){n.unsubscribe();h.delete(e)}}}))}t.expose=A;if(typeof self!=="undefined"&&typeof self.addEventListener==="function"&&a.default.isWorkerRuntime()){self.addEventListener("error",(t=>{setTimeout((()=>x(t.error||t)),250)}));self.addEventListener("unhandledrejection",(t=>{const e=t.reason;if(e&&typeof e.message==="string"){setTimeout((()=>x(e)),250)}}))}if(typeof process!=="undefined"&&typeof process.on==="function"&&a.default.isWorkerRuntime()){process.on("uncaughtException",(t=>{setTimeout((()=>x(t)),250)}));process.on("unhandledRejection",(t=>{if(t&&typeof t.message==="string"){setTimeout((()=>x(t)),250)}}))}})(Qt);return Qt}var se;function oe(){if(se)return i;se=1;(function(t){var e=i&&i.__createBinding||(Object.create?function(t,e,n,r){if(r===undefined)r=n;Object.defineProperty(t,r,{enumerable:true,get:function(){return e[n]}})}:function(t,e,n,r){if(r===undefined)r=n;t[r]=e[n]});var n=i&&i.__exportStar||function(t,n){for(var r in t)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r))e(n,t,r)};Object.defineProperty(t,"__esModule",{value:true});t.Transfer=t.DefaultSerializer=t.expose=t.registerSerializer=void 0;var r=u();Object.defineProperty(t,"registerSerializer",{enumerable:true,get:function(){return r.registerSerializer}});n(Vt(),t);var s=ie();Object.defineProperty(t,"expose",{enumerable:true,get:function(){return s.expose}});var o=f();Object.defineProperty(t,"DefaultSerializer",{enumerable:true,get:function(){return o.DefaultSerializer}});var a=Nt();Object.defineProperty(t,"Transfer",{enumerable:true,get:function(){return a.Transfer}})})(i);return i}var ae=oe();var fe=function(){function t(){this.threads=[];this.pools=[]}t.prototype.addThread=function(t){this.threads.push(t)};t.prototype.addPool=function(t){this.pools.push(t)};t.prototype.terminate=function(t){if(t===void 0){t=false}return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,Promise.all(r(r([],this.threads.map((function(t){return ae.Thread.terminate(t)}))),this.pools.map((function(e){return e.terminate(t)}))))];case 1:e.sent();return[2]}}))}))};return t}();function ce(){if(typeof globalThis!=="undefined"){return globalThis}else if(typeof self!=="undefined"){return self}else if(typeof window!=="undefined"){return window}else if(typeof global!=="undefined"){return global}throw new Error("unable to locate global object")}var ue=ce();function le(t,e){var n=ue[e];return n!=null&&t instanceof n}function he(t){return le(t,"ArrayBuffer")||le(t,"MessagePort")||le(t,"ImageBitmap")||le(t,"OffscreenCanvas")}function de(t){return le(t,"Int8Array")||le(t,"Uint8Array")||le(t,"Uint8ClampedArray")||le(t,"Int16Array")||le(t,"Uint16Array")||le(t,"Int32Array")||le(t,"Uint32Array")||le(t,"Float32Array")||le(t,"Float64Array")||le(t,"BigInt64Array")||le(t,"BigUint64Array")}function pe(t){if(he(t)){return ae.Transfer(t)}else if(t!=null&&typeof t==="object"){var e=ye(t);return ae.Transfer(t,e)}else{return t}}function ye(t){if(he(t)){return[t]}else if(typeof t==="object"){if(Array.isArray(t)){var e=[];t.forEach((function(t){return e.push.apply(e,ye(t))}));return e}else if(de(t)){return[t.buffer]}else if(t!=null){return Object.values(t).reduce((function(t,e){t.push.apply(t,ye(e));return t}),[])}else{return[]}}else{return[]}}const we="png-decoder-worker.js";const be=`!function(){"use strict";function t(t,e,n,i){return new(n||(n=Promise))(function(r,s){function a(t){try{h(i.next(t))}catch(t){s(t)}}function o(t){try{h(i.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,o)}h((i=i.apply(t,e||[])).next())})}function e(t,e){var n,i,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(o){return function(h){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,o[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,h])}}}"function"==typeof SuppressedError&&SuppressedError;const n={deserialize:t=>Object.assign(Error(t.message),{name:t.name,stack:t.stack}),serialize:t=>({__error_marker:"$$error",message:t.message,name:t.name,stack:t.stack})};let i={deserialize(t){return(e=t)&&"object"==typeof e&&"__error_marker"in e&&"$$error"===e.__error_marker?n.deserialize(t):t;var e},serialize:t=>t instanceof Error?n.serialize(t):t};function r(t){return i.deserialize(t)}function s(t){return i.serialize(t)}function a(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}const o=Symbol("thread.transferable");function h(t,e){if(!e){if(!(n=t)||"object"!=typeof n)throw Error();e=[t]}var n;return{[o]:!0,send:t,transferables:e}}var f,l,d,c;!function(t){t.cancel="cancel",t.run="run"}(f||(f={})),function(t){t.error="error",t.init="init",t.result="result",t.running="running",t.uncaughtError="uncaughtError"}(l||(l={}));var u=a(c?d:(c=1,d=t=>!!t&&("symbol"==typeof Symbol.observable&&"function"==typeof t[Symbol.observable]?t===t[Symbol.observable]():"function"==typeof t["@@observable"]&&t===t["@@observable"]())));var p=function(){const t="undefined"!=typeof self&&"undefined"!=typeof Window&&self instanceof Window;return!("undefined"==typeof self||!self.postMessage||t)},w=function(t,e){self.postMessage(t,e)},b=function(t){const e=e=>{t(e.data)};return self.addEventListener("message",e),()=>{self.removeEventListener("message",e)}},_=function(t,e,n,i){return new(n||(n=Promise))(function(r,s){function a(t){try{h(i.next(t))}catch(t){s(t)}}function o(t){try{h(i.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,o)}h((i=i.apply(t,e||[])).next())})};let g=!1;const y=new Map,m=t=>t&&t.type===f.run,k=t=>u(t)||function(t){return t&&"object"==typeof t&&"function"==typeof t.subscribe}(t);function v(t){return function(t){return t&&"object"==typeof t&&t[o]}(t)?{payload:t.send,transferables:t.transferables}:{payload:t,transferables:void 0}}function A(t,e){const{payload:n,transferables:i}=v(e),r={type:l.error,uid:t,error:s(n)};w(r,i)}function E(t,e,n){const{payload:i,transferables:r}=v(n),s={type:l.result,uid:t,complete:!!e||void 0,payload:i};w(s,r)}function x(t){try{const e={type:l.uncaughtError,error:s(t)};w(e)}catch(e){console.error("Not reporting uncaught error back to master thread as it occured while reporting an uncaught error already.Latest error:",e,"Original error:",t)}}function U(t,e,n){return _(this,void 0,void 0,function*(){let i;try{i=e(...n)}catch(e){return A(t,e)}const r=k(i)?"observable":"promise";if(function(t,e){const n={type:l.running,uid:t,resultType:e};w(n)}(t,r),k(i)){const e=i.subscribe(e=>E(t,!1,s(e)),e=>{A(t,s(e)),y.delete(t)},()=>{E(t,!0),y.delete(t)});y.set(t,e)}else try{const e=yield i;E(t,!0,s(e))}catch(e){A(t,s(e))}})}function T(t){if(!p())throw Error("expose() called in the master thread.");if(g)throw Error("expose() called more than once. This is not possible. Pass an object to expose() if you want to expose multiple functions.");if(g=!0,"function"==typeof t)b(e=>{m(e)&&!e.method&&U(e.uid,t,e.args.map(r))}),function(){const t={type:l.init,exposed:{type:"function"}};w(t)}();else{if("object"!=typeof t||!t)throw Error(\`Invalid argument passed to expose(). Expected a function or an object, got: \${t}\`);b(e=>{m(e)&&e.method&&U(e.uid,t[e.method],e.args.map(r))});!function(t){const e={type:l.init,exposed:{type:"module",methods:t}};w(e)}(Object.keys(t).filter(e=>"function"==typeof t[e]))}b(t=>{if((e=t)&&e.type===f.cancel){const e=t.uid,n=y.get(e);n&&(n.unsubscribe(),y.delete(e))}var e})}"undefined"!=typeof self&&"function"==typeof self.addEventListener&&p()&&(self.addEventListener("error",t=>{setTimeout(()=>x(t.error||t),250)}),self.addEventListener("unhandledrejection",t=>{const e=t.reason;e&&"string"==typeof e.message&&setTimeout(()=>x(e),250)})),"undefined"!=typeof process&&"function"==typeof process.on&&p()&&(process.on("uncaughtException",t=>{setTimeout(()=>x(t),250)}),process.on("unhandledRejection",t=>{t&&"string"==typeof t.message&&setTimeout(()=>x(t),250)}));var B=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();function O(t,e){var n=B[e];return null!=n&&t instanceof n}function C(t){return O(t,"ArrayBuffer")||O(t,"MessagePort")||O(t,"ImageBitmap")||O(t,"OffscreenCanvas")}function I(t){return C(t)?h(t):null!=t&&"object"==typeof t?h(t,R(t)):t}function R(t){if(C(t))return[t];if("object"==typeof t){if(Array.isArray(t)){var e=[];return t.forEach(function(t){return e.push.apply(e,R(t))}),e}return function(t){return O(t,"Int8Array")||O(t,"Uint8Array")||O(t,"Uint8ClampedArray")||O(t,"Int16Array")||O(t,"Uint16Array")||O(t,"Int32Array")||O(t,"Uint32Array")||O(t,"Float32Array")||O(t,"Float64Array")||O(t,"BigInt64Array")||O(t,"BigUint64Array")}(t)?[t.buffer]:null!=t?Object.values(t).reduce(function(t,e){return t.push.apply(t,R(e)),t},[]):[]}return[]}function S(t,e="utf8"){return new TextDecoder(e).decode(t)}const D=new TextEncoder;const M=(()=>{const t=new Uint8Array(4);return!((new Uint32Array(t.buffer)[0]=1)&t[0])})(),L={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class F{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=8192,e={}){let n=!1;"number"==typeof t?t=new ArrayBuffer(t):(n=!0,this.lastWrittenByte=t.byteLength);const i=e.offset?e.offset>>>0:0,r=t.byteLength-i;let s=i;(ArrayBuffer.isView(t)||t instanceof F)&&(t.byteLength!==t.buffer.byteLength&&(s=t.byteOffset+i),t=t.buffer),this.lastWrittenByte=n?r:0,this.buffer=t,this.length=r,this.byteLength=r,this.byteOffset=s,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,s,r),this._mark=0,this._marks=[]}available(t=1){return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t=1){return this.offset+=t,this}back(t=1){return this.offset-=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t=1){if(!this.available(t)){const e=2*(this.offset+t),n=new Uint8Array(e);n.set(new Uint8Array(this.buffer)),this.buffer=n.buffer,this.length=e,this.byteLength=e,this._data=new DataView(this.buffer)}return this}readBoolean(){return 0!==this.readUint8()}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t=1){return this.readArray(t,"uint8")}readArray(t,e){const n=L[e].BYTES_PER_ELEMENT*t,i=this.byteOffset+this.offset,r=this.buffer.slice(i,i+n);if(this.littleEndian===M&&"uint8"!==e&&"int8"!==e){const t=new Uint8Array(this.buffer.slice(i,i+n));t.reverse();const r=new L[e](t.buffer);return this.offset+=n,r.reverse(),r}const s=new L[e](r);return this.offset+=n,s}readInt16(){const t=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}readUint16(){const t=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,t}readInt32(){const t=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}readUint32(){const t=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat32(){const t=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat64(){const t=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}readBigInt64(){const t=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,t}readBigUint64(){const t=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,t}readChar(){return String.fromCharCode(this.readInt8())}readChars(t=1){let e="";for(let n=0;n<t;n++)e+=this.readChar();return e}readUtf8(t=1){return S(this.readBytes(t))}decodeText(t=1,e="utf8"){return S(this.readBytes(t),e)}writeBoolean(t){return this.writeUint8(t?255:0),this}writeInt8(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this}writeUint8(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this}writeByte(t){return this.writeUint8(t)}writeBytes(t){this.ensureAvailable(t.length);for(let e=0;e<t.length;e++)this._data.setUint8(this.offset++,t[e]);return this._updateLastWrittenByte(),this}writeInt16(t){return this.ensureAvailable(2),this._data.setInt16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(t){return this.ensureAvailable(2),this._data.setUint16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(t){return this.ensureAvailable(4),this._data.setInt32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(t){return this.ensureAvailable(4),this._data.setUint32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(t){return this.ensureAvailable(4),this._data.setFloat32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(t){return this.ensureAvailable(8),this._data.setFloat64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(t){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(t){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(t){return this.writeUint8(t.charCodeAt(0))}writeChars(t){for(let e=0;e<t.length;e++)this.writeUint8(t.charCodeAt(e));return this}writeUtf8(t){return this.writeBytes(function(t){return D.encode(t)}(t))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function N(t){let e=t.length;for(;--e>=0;)t[e]=0}N(new Array(576));N(new Array(60));N(new Array(512));N(new Array(256));N(new Array(29));N(new Array(30));var Z=(t,e,n,i)=>{let r=65535&t,s=t>>>16&65535,a=0;for(;0!==n;){a=n>2e3?2e3:n,n-=a;do{r=r+e[i++]|0,s=s+r|0}while(--a);r%=65521,s%=65521}return r|s<<16};const $=new Uint32Array((()=>{let t,e=[];for(var n=0;n<256;n++){t=n;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e})());var P=(t,e,n,i)=>{const r=$,s=i+n;t^=-1;for(let n=i;n<s;n++)t=t>>>8^r[255&(t^e[n])];return-1^t},j={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},z={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const W=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var H=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const e in n)W(n,e)&&(t[e]=n[e])}}return t},K=t=>{let e=0;for(let n=0,i=t.length;n<i;n++)e+=t[n].length;const n=new Uint8Array(e);for(let e=0,i=0,r=t.length;e<r;e++){let r=t[e];n.set(r,i),i+=r.length}return n};let G=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){G=!1}const q=new Uint8Array(256);for(let t=0;t<256;t++)q[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;q[254]=q[254]=1;var Y=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,n,i,r,s,a=t.length,o=0;for(r=0;r<a;r++)n=t.charCodeAt(r),55296==(64512&n)&&r+1<a&&(i=t.charCodeAt(r+1),56320==(64512&i)&&(n=65536+(n-55296<<10)+(i-56320),r++)),o+=n<128?1:n<2048?2:n<65536?3:4;for(e=new Uint8Array(o),s=0,r=0;s<o;r++)n=t.charCodeAt(r),55296==(64512&n)&&r+1<a&&(i=t.charCodeAt(r+1),56320==(64512&i)&&(n=65536+(n-55296<<10)+(i-56320),r++)),n<128?e[s++]=n:n<2048?(e[s++]=192|n>>>6,e[s++]=128|63&n):n<65536?(e[s++]=224|n>>>12,e[s++]=128|n>>>6&63,e[s++]=128|63&n):(e[s++]=240|n>>>18,e[s++]=128|n>>>12&63,e[s++]=128|n>>>6&63,e[s++]=128|63&n);return e},V=(t,e)=>{const n=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let i,r;const s=new Array(2*n);for(r=0,i=0;i<n;){let e=t[i++];if(e<128){s[r++]=e;continue}let a=q[e];if(a>4)s[r++]=65533,i+=a-1;else{for(e&=2===a?31:3===a?15:7;a>1&&i<n;)e=e<<6|63&t[i++],a--;a>1?s[r++]=65533:e<65536?s[r++]=e:(e-=65536,s[r++]=55296|e>>10&1023,s[r++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&G)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let n="";for(let i=0;i<e;i++)n+=String.fromCharCode(t[i]);return n})(s,r)},X=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let n=e-1;for(;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?e:n+q[t[n]]>e?n:e};var J=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Q=16209;var tt=function(t,e){let n,i,r,s,a,o,h,f,l,d,c,u,p,w,b,_,g,y,m,k,v,A,E,x;const U=t.state;n=t.next_in,E=t.input,i=n+(t.avail_in-5),r=t.next_out,x=t.output,s=r-(e-t.avail_out),a=r+(t.avail_out-257),o=U.dmax,h=U.wsize,f=U.whave,l=U.wnext,d=U.window,c=U.hold,u=U.bits,p=U.lencode,w=U.distcode,b=(1<<U.lenbits)-1,_=(1<<U.distbits)-1;t:do{u<15&&(c+=E[n++]<<u,u+=8,c+=E[n++]<<u,u+=8),g=p[c&b];e:for(;;){if(y=g>>>24,c>>>=y,u-=y,y=g>>>16&255,0===y)x[r++]=65535&g;else{if(!(16&y)){if(64&y){if(32&y){U.mode=16191;break t}t.msg="invalid literal/length code",U.mode=Q;break t}g=p[(65535&g)+(c&(1<<y)-1)];continue e}for(m=65535&g,y&=15,y&&(u<y&&(c+=E[n++]<<u,u+=8),m+=c&(1<<y)-1,c>>>=y,u-=y),u<15&&(c+=E[n++]<<u,u+=8,c+=E[n++]<<u,u+=8),g=w[c&_];;){if(y=g>>>24,c>>>=y,u-=y,y=g>>>16&255,16&y){if(k=65535&g,y&=15,u<y&&(c+=E[n++]<<u,u+=8,u<y&&(c+=E[n++]<<u,u+=8)),k+=c&(1<<y)-1,k>o){t.msg="invalid distance too far back",U.mode=Q;break t}if(c>>>=y,u-=y,y=r-s,k>y){if(y=k-y,y>f&&U.sane){t.msg="invalid distance too far back",U.mode=Q;break t}if(v=0,A=d,0===l){if(v+=h-y,y<m){m-=y;do{x[r++]=d[v++]}while(--y);v=r-k,A=x}}else if(l<y){if(v+=h+l-y,y-=l,y<m){m-=y;do{x[r++]=d[v++]}while(--y);if(v=0,l<m){y=l,m-=y;do{x[r++]=d[v++]}while(--y);v=r-k,A=x}}}else if(v+=l-y,y<m){m-=y;do{x[r++]=d[v++]}while(--y);v=r-k,A=x}for(;m>2;)x[r++]=A[v++],x[r++]=A[v++],x[r++]=A[v++],m-=3;m&&(x[r++]=A[v++],m>1&&(x[r++]=A[v++]))}else{v=r-k;do{x[r++]=x[v++],x[r++]=x[v++],x[r++]=x[v++],m-=3}while(m>2);m&&(x[r++]=x[v++],m>1&&(x[r++]=x[v++]))}break}if(64&y){t.msg="invalid distance code",U.mode=Q;break t}g=w[(65535&g)+(c&(1<<y)-1)]}}break}}while(n<i&&r<a);m=u>>3,n-=m,u-=m<<3,c&=(1<<u)-1,t.next_in=n,t.next_out=r,t.avail_in=n<i?i-n+5:5-(n-i),t.avail_out=r<a?a-r+257:257-(r-a),U.hold=c,U.bits=u};const et=15,nt=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),it=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),rt=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),st=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var at=(t,e,n,i,r,s,a,o)=>{const h=o.bits;let f,l,d,c,u,p,w=0,b=0,_=0,g=0,y=0,m=0,k=0,v=0,A=0,E=0,x=null;const U=new Uint16Array(16),T=new Uint16Array(16);let B,O,C,I=null;for(w=0;w<=et;w++)U[w]=0;for(b=0;b<i;b++)U[e[n+b]]++;for(y=h,g=et;g>=1&&0===U[g];g--);if(y>g&&(y=g),0===g)return r[s++]=20971520,r[s++]=20971520,o.bits=1,0;for(_=1;_<g&&0===U[_];_++);for(y<_&&(y=_),v=1,w=1;w<=et;w++)if(v<<=1,v-=U[w],v<0)return-1;if(v>0&&(0===t||1!==g))return-1;for(T[1]=0,w=1;w<et;w++)T[w+1]=T[w]+U[w];for(b=0;b<i;b++)0!==e[n+b]&&(a[T[e[n+b]]++]=b);if(0===t?(x=I=a,p=20):1===t?(x=nt,I=it,p=257):(x=rt,I=st,p=0),E=0,b=0,w=_,u=s,m=y,k=0,d=-1,A=1<<y,c=A-1,1===t&&A>852||2===t&&A>592)return 1;for(;;){B=w-k,a[b]+1<p?(O=0,C=a[b]):a[b]>=p?(O=I[a[b]-p],C=x[a[b]-p]):(O=96,C=0),f=1<<w-k,l=1<<m,_=l;do{l-=f,r[u+(E>>k)+l]=B<<24|O<<16|C}while(0!==l);for(f=1<<w-1;E&f;)f>>=1;if(0!==f?(E&=f-1,E+=f):E=0,b++,0===--U[w]){if(w===g)break;w=e[n+a[b]]}if(w>y&&(E&c)!==d){for(0===k&&(k=y),u+=_,m=w-k,v=1<<m;m+k<g&&(v-=U[m+k],!(v<=0));)m++,v<<=1;if(A+=1<<m,1===t&&A>852||2===t&&A>592)return 1;d=E&c,r[d]=y<<24|m<<16|u-s}}return 0!==E&&(r[u+E]=w-k<<24|64<<16),o.bits=y,0};const{Z_FINISH:ot,Z_BLOCK:ht,Z_TREES:ft,Z_OK:lt,Z_STREAM_END:dt,Z_NEED_DICT:ct,Z_STREAM_ERROR:ut,Z_DATA_ERROR:pt,Z_MEM_ERROR:wt,Z_BUF_ERROR:bt,Z_DEFLATED:_t}=z,gt=16180,yt=16190,mt=16191,kt=16192,vt=16194,At=16199,Et=16200,xt=16206,Ut=16209,Tt=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Bt(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ot=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<gt||e.mode>16211?1:0},Ct=t=>{if(Ot(t))return ut;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=gt,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,lt},It=t=>{if(Ot(t))return ut;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Ct(t)},Rt=(t,e)=>{let n;if(Ot(t))return ut;const i=t.state;return e<0?(n=0,e=-e):(n=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?ut:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=n,i.wbits=e,It(t))},St=(t,e)=>{if(!t)return ut;const n=new Bt;t.state=n,n.strm=t,n.window=null,n.mode=gt;const i=Rt(t,e);return i!==lt&&(t.state=null),i};let Dt,Mt,Lt=!0;const Ft=t=>{if(Lt){Dt=new Int32Array(512),Mt=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(at(1,t.lens,0,288,Dt,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;at(2,t.lens,0,32,Mt,0,t.work,{bits:5}),Lt=!1}t.lencode=Dt,t.lenbits=9,t.distcode=Mt,t.distbits=5},Nt=(t,e,n,i)=>{let r;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),i>=s.wsize?(s.window.set(e.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>i&&(r=i),s.window.set(e.subarray(n-i,n-i+r),s.wnext),(i-=r)?(s.window.set(e.subarray(n-i,n),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=r))),0};var Zt={inflateReset:It,inflateReset2:Rt,inflateResetKeep:Ct,inflateInit:t=>St(t,15),inflateInit2:St,inflate:(t,e)=>{let n,i,r,s,a,o,h,f,l,d,c,u,p,w,b,_,g,y,m,k,v,A,E=0;const x=new Uint8Array(4);let U,T;const B=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ot(t)||!t.output||!t.input&&0!==t.avail_in)return ut;n=t.state,n.mode===mt&&(n.mode=kt),a=t.next_out,r=t.output,h=t.avail_out,s=t.next_in,i=t.input,o=t.avail_in,f=n.hold,l=n.bits,d=o,c=h,A=lt;t:for(;;)switch(n.mode){case gt:if(0===n.wrap){n.mode=kt;break}for(;l<16;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}if(2&n.wrap&&35615===f){0===n.wbits&&(n.wbits=15),n.check=0,x[0]=255&f,x[1]=f>>>8&255,n.check=P(n.check,x,2,0),f=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&f)<<8)+(f>>8))%31){t.msg="incorrect header check",n.mode=Ut;break}if((15&f)!==_t){t.msg="unknown compression method",n.mode=Ut;break}if(f>>>=4,l-=4,v=8+(15&f),0===n.wbits&&(n.wbits=v),v>15||v>n.wbits){t.msg="invalid window size",n.mode=Ut;break}n.dmax=1<<n.wbits,n.flags=0,t.adler=n.check=1,n.mode=512&f?16189:mt,f=0,l=0;break;case 16181:for(;l<16;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}if(n.flags=f,(255&n.flags)!==_t){t.msg="unknown compression method",n.mode=Ut;break}if(57344&n.flags){t.msg="unknown header flags set",n.mode=Ut;break}n.head&&(n.head.text=f>>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&f,x[1]=f>>>8&255,n.check=P(n.check,x,2,0)),f=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}n.head&&(n.head.time=f),512&n.flags&&4&n.wrap&&(x[0]=255&f,x[1]=f>>>8&255,x[2]=f>>>16&255,x[3]=f>>>24&255,n.check=P(n.check,x,4,0)),f=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}n.head&&(n.head.xflags=255&f,n.head.os=f>>8),512&n.flags&&4&n.wrap&&(x[0]=255&f,x[1]=f>>>8&255,n.check=P(n.check,x,2,0)),f=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}n.length=f,n.head&&(n.head.extra_len=f),512&n.flags&&4&n.wrap&&(x[0]=255&f,x[1]=f>>>8&255,n.check=P(n.check,x,2,0)),f=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(u=n.length,u>o&&(u=o),u&&(n.head&&(v=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(i.subarray(s,s+u),v)),512&n.flags&&4&n.wrap&&(n.check=P(n.check,i,u,s)),o-=u,s+=u,n.length-=u),n.length))break t;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===o)break t;u=0;do{v=i[s+u++],n.head&&v&&n.length<65536&&(n.head.name+=String.fromCharCode(v))}while(v&&u<o);if(512&n.flags&&4&n.wrap&&(n.check=P(n.check,i,u,s)),o-=u,s+=u,v)break t}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===o)break t;u=0;do{v=i[s+u++],n.head&&v&&n.length<65536&&(n.head.comment+=String.fromCharCode(v))}while(v&&u<o);if(512&n.flags&&4&n.wrap&&(n.check=P(n.check,i,u,s)),o-=u,s+=u,v)break t}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;l<16;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}if(4&n.wrap&&f!==(65535&n.check)){t.msg="header crc mismatch",n.mode=Ut;break}f=0,l=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=mt;break;case 16189:for(;l<32;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}t.adler=n.check=Tt(f),f=0,l=0,n.mode=yt;case yt:if(0===n.havedict)return t.next_out=a,t.avail_out=h,t.next_in=s,t.avail_in=o,n.hold=f,n.bits=l,ct;t.adler=n.check=1,n.mode=mt;case mt:if(e===ht||e===ft)break t;case kt:if(n.last){f>>>=7&l,l-=7&l,n.mode=xt;break}for(;l<3;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}switch(n.last=1&f,f>>>=1,l-=1,3&f){case 0:n.mode=16193;break;case 1:if(Ft(n),n.mode=At,e===ft){f>>>=2,l-=2;break t}break;case 2:n.mode=16196;break;case 3:t.msg="invalid block type",n.mode=Ut}f>>>=2,l-=2;break;case 16193:for(f>>>=7&l,l-=7&l;l<32;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}if((65535&f)!=(f>>>16^65535)){t.msg="invalid stored block lengths",n.mode=Ut;break}if(n.length=65535&f,f=0,l=0,n.mode=vt,e===ft)break t;case vt:n.mode=16195;case 16195:if(u=n.length,u){if(u>o&&(u=o),u>h&&(u=h),0===u)break t;r.set(i.subarray(s,s+u),a),o-=u,s+=u,h-=u,a+=u,n.length-=u;break}n.mode=mt;break;case 16196:for(;l<14;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}if(n.nlen=257+(31&f),f>>>=5,l-=5,n.ndist=1+(31&f),f>>>=5,l-=5,n.ncode=4+(15&f),f>>>=4,l-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=Ut;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;l<3;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}n.lens[B[n.have++]]=7&f,f>>>=3,l-=3}for(;n.have<19;)n.lens[B[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,U={bits:n.lenbits},A=at(0,n.lens,0,19,n.lencode,0,n.work,U),n.lenbits=U.bits,A){t.msg="invalid code lengths set",n.mode=Ut;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;E=n.lencode[f&(1<<n.lenbits)-1],b=E>>>24,_=E>>>16&255,g=65535&E,!(b<=l);){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}if(g<16)f>>>=b,l-=b,n.lens[n.have++]=g;else{if(16===g){for(T=b+2;l<T;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}if(f>>>=b,l-=b,0===n.have){t.msg="invalid bit length repeat",n.mode=Ut;break}v=n.lens[n.have-1],u=3+(3&f),f>>>=2,l-=2}else if(17===g){for(T=b+3;l<T;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}f>>>=b,l-=b,v=0,u=3+(7&f),f>>>=3,l-=3}else{for(T=b+7;l<T;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}f>>>=b,l-=b,v=0,u=11+(127&f),f>>>=7,l-=7}if(n.have+u>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=Ut;break}for(;u--;)n.lens[n.have++]=v}}if(n.mode===Ut)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=Ut;break}if(n.lenbits=9,U={bits:n.lenbits},A=at(1,n.lens,0,n.nlen,n.lencode,0,n.work,U),n.lenbits=U.bits,A){t.msg="invalid literal/lengths set",n.mode=Ut;break}if(n.distbits=6,n.distcode=n.distdyn,U={bits:n.distbits},A=at(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,U),n.distbits=U.bits,A){t.msg="invalid distances set",n.mode=Ut;break}if(n.mode=At,e===ft)break t;case At:n.mode=Et;case Et:if(o>=6&&h>=258){t.next_out=a,t.avail_out=h,t.next_in=s,t.avail_in=o,n.hold=f,n.bits=l,tt(t,c),a=t.next_out,r=t.output,h=t.avail_out,s=t.next_in,i=t.input,o=t.avail_in,f=n.hold,l=n.bits,n.mode===mt&&(n.back=-1);break}for(n.back=0;E=n.lencode[f&(1<<n.lenbits)-1],b=E>>>24,_=E>>>16&255,g=65535&E,!(b<=l);){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}if(_&&!(240&_)){for(y=b,m=_,k=g;E=n.lencode[k+((f&(1<<y+m)-1)>>y)],b=E>>>24,_=E>>>16&255,g=65535&E,!(y+b<=l);){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}f>>>=y,l-=y,n.back+=y}if(f>>>=b,l-=b,n.back+=b,n.length=g,0===_){n.mode=16205;break}if(32&_){n.back=-1,n.mode=mt;break}if(64&_){t.msg="invalid literal/length code",n.mode=Ut;break}n.extra=15&_,n.mode=16201;case 16201:if(n.extra){for(T=n.extra;l<T;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}n.length+=f&(1<<n.extra)-1,f>>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;E=n.distcode[f&(1<<n.distbits)-1],b=E>>>24,_=E>>>16&255,g=65535&E,!(b<=l);){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}if(!(240&_)){for(y=b,m=_,k=g;E=n.distcode[k+((f&(1<<y+m)-1)>>y)],b=E>>>24,_=E>>>16&255,g=65535&E,!(y+b<=l);){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}f>>>=y,l-=y,n.back+=y}if(f>>>=b,l-=b,n.back+=b,64&_){t.msg="invalid distance code",n.mode=Ut;break}n.offset=g,n.extra=15&_,n.mode=16203;case 16203:if(n.extra){for(T=n.extra;l<T;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}n.offset+=f&(1<<n.extra)-1,f>>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=Ut;break}n.mode=16204;case 16204:if(0===h)break t;if(u=c-h,n.offset>u){if(u=n.offset-u,u>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=Ut;break}u>n.wnext?(u-=n.wnext,p=n.wsize-u):p=n.wnext-u,u>n.length&&(u=n.length),w=n.window}else w=r,p=a-n.offset,u=n.length;u>h&&(u=h),h-=u,n.length-=u;do{r[a++]=w[p++]}while(--u);0===n.length&&(n.mode=Et);break;case 16205:if(0===h)break t;r[a++]=n.length,h--,n.mode=Et;break;case xt:if(n.wrap){for(;l<32;){if(0===o)break t;o--,f|=i[s++]<<l,l+=8}if(c-=h,t.total_out+=c,n.total+=c,4&n.wrap&&c&&(t.adler=n.check=n.flags?P(n.check,r,c,a-c):Z(n.check,r,c,a-c)),c=h,4&n.wrap&&(n.flags?f:Tt(f))!==n.check){t.msg="incorrect data check",n.mode=Ut;break}f=0,l=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;l<32;){if(0===o)break t;o--,f+=i[s++]<<l,l+=8}if(4&n.wrap&&f!==(4294967295&n.total)){t.msg="incorrect length check",n.mode=Ut;break}f=0,l=0}n.mode=16208;case 16208:A=dt;break t;case Ut:A=pt;break t;case 16210:return wt;default:return ut}return t.next_out=a,t.avail_out=h,t.next_in=s,t.avail_in=o,n.hold=f,n.bits=l,(n.wsize||c!==t.avail_out&&n.mode<Ut&&(n.mode<xt||e!==ot))&&Nt(t,t.output,t.next_out,c-t.avail_out),d-=t.avail_in,c-=t.avail_out,t.total_in+=d,t.total_out+=c,n.total+=c,4&n.wrap&&c&&(t.adler=n.check=n.flags?P(n.check,r,c,t.next_out-c):Z(n.check,r,c,t.next_out-c)),t.data_type=n.bits+(n.last?64:0)+(n.mode===mt?128:0)+(n.mode===At||n.mode===vt?256:0),(0===d&&0===c||e===ot)&&A===lt&&(A=bt),A},inflateEnd:t=>{if(Ot(t))return ut;let e=t.state;return e.window&&(e.window=null),t.state=null,lt},inflateGetHeader:(t,e)=>{if(Ot(t))return ut;const n=t.state;return 2&n.wrap?(n.head=e,e.done=!1,lt):ut},inflateSetDictionary:(t,e)=>{const n=e.length;let i,r,s;return Ot(t)?ut:(i=t.state,0!==i.wrap&&i.mode!==yt?ut:i.mode===yt&&(r=1,r=Z(r,e,n,0),r!==i.check)?pt:(s=Nt(t,e,n,n),s?(i.mode=16210,wt):(i.havedict=1,lt)))},inflateInfo:"pako inflate (from Nodeca project)"};var $t=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Pt=Object.prototype.toString,{Z_NO_FLUSH:jt,Z_FINISH:zt,Z_OK:Wt,Z_STREAM_END:Ht,Z_NEED_DICT:Kt,Z_STREAM_ERROR:Gt,Z_DATA_ERROR:qt,Z_MEM_ERROR:Yt}=z;function Vt(t){this.options=H({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(15&e.windowBits||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new J,this.strm.avail_out=0;let n=Zt.inflateInit2(this.strm,e.windowBits);if(n!==Wt)throw new Error(j[n]);if(this.header=new $t,Zt.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Y(e.dictionary):"[object ArrayBuffer]"===Pt.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=Zt.inflateSetDictionary(this.strm,e.dictionary),n!==Wt)))throw new Error(j[n])}Vt.prototype.push=function(t,e){const n=this.strm,i=this.options.chunkSize,r=this.options.dictionary;let s,a,o;if(this.ended)return!1;for(a=e===~~e?e:!0===e?zt:jt,"[object ArrayBuffer]"===Pt.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),s=Zt.inflate(n,a),s===Kt&&r&&(s=Zt.inflateSetDictionary(n,r),s===Wt?s=Zt.inflate(n,a):s===qt&&(s=Kt));n.avail_in>0&&s===Ht&&n.state.wrap>0&&0!==t[n.next_in];)Zt.inflateReset(n),s=Zt.inflate(n,a);switch(s){case Gt:case qt:case Kt:case Yt:return this.onEnd(s),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||s===Ht))if("string"===this.options.to){let t=X(n.output,n.next_out),e=n.next_out-t,r=V(n.output,t);n.next_out=e,n.avail_out=i-e,e&&n.output.set(n.output.subarray(t,t+e),0),this.onData(r)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==Wt||0!==o){if(s===Ht)return s=Zt.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Vt.prototype.onData=function(t){this.chunks.push(t)},Vt.prototype.onEnd=function(t){t===Wt&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=K(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Xt={Inflate:Vt,inflate:function(t,e){const n=new Vt(e);if(n.push(t),n.err)throw n.msg||j[n.err];return n.result}};const{Inflate:Jt,inflate:Qt}=Xt;var te=Jt,ee=Qt;const ne=[];for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)1&e?e=3988292384^e>>>1:e>>>=1;ne[t]=e}const ie=4294967295;function re(t,e){return(function(t,e,n){let i=t;for(let t=0;t<n;t++)i=ne[255&(i^e[t])]^i>>>8;return i}(ie,t,e)^ie)>>>0}function se(t,e,n){const i=t.readUint32(),r=re(new Uint8Array(t.buffer,t.byteOffset+t.offset-e-4,e),e);if(r!==i)throw new Error(\`CRC mismatch for chunk \${n}. Expected \${i}, found \${r}\`)}function ae(t,e,n){for(let i=0;i<n;i++)e[i]=t[i]}function oe(t,e,n,i){let r=0;for(;r<i;r++)e[r]=t[r];for(;r<n;r++)e[r]=t[r]+e[r-i]&255}function he(t,e,n,i){let r=0;if(0===n.length)for(;r<i;r++)e[r]=t[r];else for(;r<i;r++)e[r]=t[r]+n[r]&255}function fe(t,e,n,i,r){let s=0;if(0===n.length){for(;s<r;s++)e[s]=t[s];for(;s<i;s++)e[s]=t[s]+(e[s-r]>>1)&255}else{for(;s<r;s++)e[s]=t[s]+(n[s]>>1)&255;for(;s<i;s++)e[s]=t[s]+(e[s-r]+n[s]>>1)&255}}function le(t,e,n,i,r){let s=0;if(0===n.length){for(;s<r;s++)e[s]=t[s];for(;s<i;s++)e[s]=t[s]+e[s-r]&255}else{for(;s<r;s++)e[s]=t[s]+n[s]&255;for(;s<i;s++)e[s]=t[s]+de(e[s-r],n[s],n[s-r])&255}}function de(t,e,n){const i=t+e-n,r=Math.abs(i-t),s=Math.abs(i-e),a=Math.abs(i-n);return r<=s&&r<=a?t:s<=a?e:n}function ce(t,e,n,i,r,s){switch(t){case 0:ae(e,n,r);break;case 1:oe(e,n,r,s);break;case 2:he(e,n,i,r);break;case 3:fe(e,n,i,r,s);break;case 4:le(e,n,i,r,s);break;default:throw new Error(\`Unsupported filter: \${t}\`)}}const ue=new Uint16Array([255]),pe=255===new Uint8Array(ue.buffer)[0];function we(t){return(255&t)<<8|t>>8&255}const be=new Uint16Array([255]),_e=255===new Uint8Array(be.buffer)[0],ge=new Uint8Array(0);function ye(t){const{data:e,width:n,height:i,channels:r,depth:s}=t,a=Math.ceil(s/8)*r,o=Math.ceil(s/8*r*n),h=new Uint8Array(i*o);let f,l,d=ge,c=0;for(let t=0;t<i;t++){switch(f=e.subarray(c+1,c+1+o),l=h.subarray(t*o,(t+1)*o),e[c]){case 0:ae(f,l,o);break;case 1:oe(f,l,o,a);break;case 2:he(f,l,d,o);break;case 3:fe(f,l,d,o,a);break;case 4:le(f,l,d,o,a);break;default:throw new Error(\`Unsupported filter: \${e[c]}\`)}d=l,c+=o+1}if(16===s){const t=new Uint16Array(h.buffer);if(_e)for(let e=0;e<t.length;e++)t[e]=me(t[e]);return t}return h}function me(t){return(255&t)<<8|t>>8&255}const ke=Uint8Array.of(137,80,78,71,13,10,26,10);function ve(t){if(!function(t){if(t.length<ke.length)return!1;for(let e=0;e<ke.length;e++)if(t[e]!==ke[e])return!1;return!0}(t.readBytes(ke.length)))throw new Error("wrong PNG signature")}const Ae=new TextDecoder("latin1");function Ee(t){if(function(t){if(!xe.test(t))throw new Error("invalid latin1 text")}(t),0===t.length||t.length>79)throw new Error("keyword length must be between 1 and 79")}const xe=/^[\0-ÿ]*$/;function Ue(t,e,n){const i=Te(e);t[i]=function(t,e){return Ae.decode(t.readBytes(e))}(e,n-i.length-1)}function Te(t){for(t.mark();0!==t.readByte(););const e=t.offset;t.reset();const n=Ae.decode(t.readBytes(e-t.offset-1));return t.skip(1),Ee(n),n}const Be=-1,Oe=0,Ce=2,Ie=3,Re=4,Se=6,De=-1,Me=0,Le=-1,Fe=0,Ne=-1,Ze=0,$e=1,Pe=0,je=1,ze=2,We=0,He=1;class Ke extends F{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;constructor(t,e={}){super(t);const{checkCrc:n=!1}=e;this._checkCrc=n,this._inflator=new te,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=De,this._filterMethod=Le,this._interlaceMethod=Ne,this._colorType=Be,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(ve(this);!this._end;){const t=this.readUint32(),e=this.readChars(4);this.decodeChunk(t,e)}return this.decodeImage(),this._png}decodeApng(){for(ve(this);!this._end;){const t=this.readUint32(),e=this.readChars(4);this.decodeApngChunk(t,e)}return this.decodeApngImage(),this._apng}decodeChunk(t,e){const n=this.offset;switch(e){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(t);break;case"IDAT":this.decodeIDAT(t);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(t);break;case"iCCP":this.decodeiCCP(t);break;case"tEXt":Ue(this._png.text,this,t);break;case"pHYs":this.decodepHYs();break;default:this.skip(t)}if(this.offset-n!==t)throw new Error(\`Length mismatch while decoding chunk \${e}\`);this._checkCrc?se(this,t+4,e):this.skip(4)}decodeApngChunk(t,e){const n=this.offset;switch("fdAT"!==e&&"IDAT"!==e&&this._writingDataChunks&&this.pushDataToFrame(),e){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(t);break;default:this.decodeChunk(t,e),this.offset=n+t}if(this.offset-n!==t)throw new Error(\`Length mismatch while decoding chunk \${e}\`);this._checkCrc?se(this,t+4,e):this.skip(4)}decodeIHDR(){const t=this._png;t.width=this.readUint32(),t.height=this.readUint32(),t.depth=function(t){if(1!==t&&2!==t&&4!==t&&8!==t&&16!==t)throw new Error(\`invalid bit depth: \${t}\`);return t}(this.readUint8());const e=this.readUint8();let n;switch(this._colorType=e,e){case Oe:n=1;break;case Ce:n=3;break;case Ie:n=1;break;case Re:n=2;break;case Se:n=4;break;default:throw new Error(\`Unknown color type: \${e}\`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==Me)throw new Error(\`Unsupported compression method: \${this._compressionMethod}\`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const t={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(t)}decodePLTE(t){if(t%3!=0)throw new RangeError(\`PLTE field length must be a multiple of 3. Got \${t}\`);const e=t/3;this._hasPalette=!0;const n=[];this._palette=n;for(let t=0;t<e;t++)n.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(t){this._writingDataChunks=!0;const e=t,n=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,n,e)),this._inflator.err)throw new Error(\`Error while decompressing the data: \${this._inflator.err}\`);this.skip(t)}decodeFDAT(t){this._writingDataChunks=!0;let e=t,n=this.offset+this.byteOffset;if(n+=4,e-=4,this._inflator.push(new Uint8Array(this.buffer,n,e)),this._inflator.err)throw new Error(\`Error while decompressing the data: \${this._inflator.err}\`);this.skip(t)}decodetRNS(t){switch(this._colorType){case Oe:case Ce:if(t%2!=0)throw new RangeError(\`tRNS chunk length must be a multiple of 2. Got \${t}\`);if(t/2>this._png.width*this._png.height)throw new Error(\`tRNS chunk contains more alpha values than there are pixels (\${t/2} vs \${this._png.width*this._png.height})\`);this._hasTransparency=!0,this._transparency=new Uint16Array(t/2);for(let e=0;e<t/2;e++)this._transparency[e]=this.readUint16();break;case Ie:{if(t>this._palette.length)throw new Error(\`tRNS chunk contains more alpha values than there are palette colors (\${t} vs \${this._palette.length})\`);let e=0;for(;e<t;e++){const t=this.readByte();this._palette[e].push(t)}for(;e<this._palette.length;e++)this._palette[e].push(255);break}default:throw new Error(\`tRNS chunk is not supported for color type \${this._colorType}\`)}}decodeiCCP(t){const e=Te(this),n=this.readUint8();if(n!==Me)throw new Error(\`Unsupported iCCP compression method: \${n}\`);const i=this.readBytes(t-e.length-2);this._png.iccEmbeddedProfile={name:e,profile:ee(i)}}decodepHYs(){const t=this.readUint32(),e=this.readUint32(),n=this.readByte();this._png.resolution={x:t,y:e,unit:n}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let t=0;t<this._numberOfFrames;t++){const e={sequenceNumber:this._frames[t].sequenceNumber,delayNumber:this._frames[t].delayNumber,delayDenominator:this._frames[t].delayDenominator,data:8===this._apng.depth?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},n=this._frames.at(t);if(n){if(n.data=ye({data:n.data,width:n.width,height:n.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),0===t||0===n.xOffset&&0===n.yOffset&&n.width===this._png.width&&n.height===this._png.height)e.data=n.data;else{const i=this._apng.frames.at(t-1);this.disposeFrame(n,i,e),this.addFrameDataToCanvas(e,n)}this._apng.frames.push(e)}}return this._apng}disposeFrame(t,e,n){switch(t.disposeOp){case Pe:break;case je:for(let e=0;e<this._png.height;e++)for(let i=0;i<this._png.width;i++){const r=(e*t.width+i)*this._png.channels;for(let t=0;t<this._png.channels;t++)n.data[r+t]=0}break;case ze:n.data.set(e.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(t,e){const n=1<<this._png.depth,i=(t,n)=>({index:((t+e.yOffset)*this._png.width+e.xOffset+n)*this._png.channels,frameIndex:(t*e.width+n)*this._png.channels});switch(e.blendOp){case We:for(let n=0;n<e.height;n++)for(let r=0;r<e.width;r++){const{index:s,frameIndex:a}=i(n,r);for(let n=0;n<this._png.channels;n++)t.data[s+n]=e.data[a+n]}break;case He:for(let r=0;r<e.height;r++)for(let s=0;s<e.width;s++){const{index:a,frameIndex:o}=i(r,s);for(let i=0;i<this._png.channels;i++){const r=e.data[o+this._png.channels-1]/n,s=i%(this._png.channels-1)==0?1:e.data[o+i],h=Math.floor(r*s+(1-r)*t.data[a+i]);t.data[a+i]+=h}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){if(this._inflator.err)throw new Error(\`Error while decompressing the data: \${this._inflator.err}\`);const t=this._isAnimated?(this._frames?.at(0)).data:this._inflator.result;if(this._filterMethod!==Fe)throw new Error(\`Filter method \${this._filterMethod} not supported\`);if(this._interlaceMethod===Ze)this._png.data=ye({data:t,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else{if(this._interlaceMethod!==$e)throw new Error(\`Interlace method \${this._interlaceMethod} not supported\`);this._png.data=function(t){const{data:e,width:n,height:i,channels:r,depth:s}=t,a=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],o=Math.ceil(s/8)*r,h=new Uint8Array(i*n*o);let f=0;for(let t=0;t<7;t++){const r=a[t],s=Math.ceil((n-r.x)/r.xStep),l=Math.ceil((i-r.y)/r.yStep);if(s<=0||l<=0)continue;const d=s*o,c=new Uint8Array(d);for(let t=0;t<l;t++){const a=e[f++],l=e.subarray(f,f+d);f+=d;const u=new Uint8Array(d);ce(a,l,u,c,d,o),c.set(u);for(let e=0;e<s;e++){const s=r.x+e*r.xStep,a=r.y+t*r.yStep;if(!(s>=n||a>=i))for(let t=0;t<o;t++)h[(a*n+s)*o+t]=u[e*o+t]}}}if(16===s){const t=new Uint16Array(h.buffer);if(pe)for(let e=0;e<t.length;e++)t[e]=we(t[e]);return t}return h}({data:t,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth})}this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){const t=this._inflator.result,e=this._frames.at(-1);e?e.data=t:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:Pe,blendOp:We,data:t}),this._inflator=new te,this._writingDataChunks=!1}}var Ge;!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.METRE=1]="METRE"}(Ge||(Ge={})),function(n){var i={}.expose,r=void 0===i?T:i;function s(n){var i=this;return function(){for(var r=[],s=0;s<arguments.length;s++)r[s]=arguments[s];return t(i,void 0,void 0,function(){return e(this,function(t){switch(t.label){case 0:return[4,n.apply(void 0,r)];case 1:return[2,I(t.sent())]}})})}}if("function"==typeof n)return r(s(n));var a=Object.entries(n).reduce(function(t,e){var n=e[0],i=e[1];return t[n]=s(i),t},{});r(a)}(async function(t){return e=t instanceof Uint8Array?t:new Uint8Array(t),new Ke(e,n).decode();var e,n})}();\n`;function me(){return new fe}function ge(){return ae.BlobWorker.fromText(be,{name:we})}async function ve(t){const e=await ae.spawn(ge());if(t!=null){t.addThread(e)}return(...t)=>e.apply(null,[...t.map((t=>pe(t)))])}function _e(t){return ae.Pool((()=>ve(t.terminate)),t)}export{me as makeController,ge as makeWorker,_e as spawnPool,ve as spawnWorker};
|
|
5
|
+
//# sourceMappingURL=p-CycTYKAk.js.map
|