@virtualdisplay.io/client 4.0.0-alpha.2 → 4.0.0-alpha.6

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +36 -161
  3. package/dist/browser-DbgxVbZp.js +1227 -0
  4. package/dist/browser-DiwLZG-y.cjs +8 -0
  5. package/dist/chunk-350yNsax.cjs +1 -0
  6. package/dist/chunk-efA98nb6.js +13 -0
  7. package/dist/src/attributes/attribute.d.ts +38 -0
  8. package/dist/src/attributes/attribute.d.ts.map +1 -0
  9. package/dist/src/attributes/attributes.d.ts +43 -0
  10. package/dist/src/attributes/attributes.d.ts.map +1 -0
  11. package/dist/src/attributes/selections.d.ts +16 -0
  12. package/dist/src/attributes/selections.d.ts.map +1 -0
  13. package/dist/src/attributes/value.d.ts +13 -0
  14. package/dist/src/attributes/value.d.ts.map +1 -0
  15. package/dist/src/camera/camera.d.ts +40 -0
  16. package/dist/src/camera/camera.d.ts.map +1 -0
  17. package/dist/src/camera/index.d.ts +4 -0
  18. package/dist/src/camera/index.d.ts.map +1 -0
  19. package/dist/src/camera/position.d.ts +56 -0
  20. package/dist/src/camera/position.d.ts.map +1 -0
  21. package/dist/src/client/client.d.ts +46 -0
  22. package/dist/src/client/client.d.ts.map +1 -0
  23. package/dist/src/client/error.d.ts +26 -0
  24. package/dist/src/client/error.d.ts.map +1 -0
  25. package/dist/src/client/iframe-builder.d.ts +27 -0
  26. package/dist/src/client/iframe-builder.d.ts.map +1 -0
  27. package/dist/src/client/options.d.ts +11 -0
  28. package/dist/src/client/options.d.ts.map +1 -0
  29. package/dist/src/client/ready-state-tracker.d.ts +13 -0
  30. package/dist/src/client/ready-state-tracker.d.ts.map +1 -0
  31. package/dist/src/client/types.d.ts +19 -0
  32. package/dist/src/client/types.d.ts.map +1 -0
  33. package/dist/src/index.d.ts +11 -0
  34. package/dist/src/index.d.ts.map +1 -0
  35. package/dist/src/snapshot/index.d.ts +3 -0
  36. package/dist/src/snapshot/index.d.ts.map +1 -0
  37. package/dist/src/snapshot/photo.d.ts +47 -0
  38. package/dist/src/snapshot/photo.d.ts.map +1 -0
  39. package/dist/src/snapshot/snapshot.d.ts +30 -0
  40. package/dist/src/snapshot/snapshot.d.ts.map +1 -0
  41. package/dist/src/ui/action-bar.d.ts +17 -0
  42. package/dist/src/ui/action-bar.d.ts.map +1 -0
  43. package/dist/src/ui/camera-controls.d.ts +8 -0
  44. package/dist/src/ui/camera-controls.d.ts.map +1 -0
  45. package/dist/src/ui/controls/attribute-group.d.ts +6 -0
  46. package/dist/src/ui/controls/attribute-group.d.ts.map +1 -0
  47. package/dist/src/ui/event-bus.d.ts +12 -0
  48. package/dist/src/ui/event-bus.d.ts.map +1 -0
  49. package/dist/src/ui/loading.d.ts +43 -0
  50. package/dist/src/ui/loading.d.ts.map +1 -0
  51. package/dist/src/ui/standard-interface.d.ts +35 -0
  52. package/dist/src/ui/standard-interface.d.ts.map +1 -0
  53. package/dist/src/ui/styles.d.ts +3 -0
  54. package/dist/src/ui/styles.d.ts.map +1 -0
  55. package/dist/src/ui/toolbar.d.ts +14 -0
  56. package/dist/src/ui/toolbar.d.ts.map +1 -0
  57. package/dist/src/utils/logger.d.ts +11 -0
  58. package/dist/src/utils/logger.d.ts.map +1 -0
  59. package/dist/virtualdisplay.client.cjs.js +225 -1
  60. package/dist/virtualdisplay.client.es.js +1384 -186
  61. package/dist/virtualdisplay.client.umd.js +232 -1
  62. package/package.json +3 -3
  63. package/dist/index.d.ts +0 -1
@@ -1 +1,232 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.VirtualdisplayClient={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t={NO_MAPPING:`NO_MAPPING`,ATTRIBUTE_NOT_FOUND:`ATTRIBUTE_NOT_FOUND`,VALUE_NOT_FOUND:`VALUE_NOT_FOUND`,PARENT_NOT_FOUND:`PARENT_NOT_FOUND`,INVALID_PARAMETER:`INVALID_PARAMETER`,SNAPSHOT_FAILED:`SNAPSHOT_FAILED`},n=class e extends Error{code;constructor(t,n){super(t),this.name=`VirtualdisplayError`,this.code=n,Error.captureStackTrace!==void 0&&Error.captureStackTrace(this,e)}static noMapping(){return new e(`No attributes available. Waiting for server metadata.`,t.NO_MAPPING)}static attributeNotFound(n){return new e(`Attribute "${n}" not found in mapping`,t.ATTRIBUTE_NOT_FOUND)}static valueNotFound(n,r){return new e(`Value "${r}" not found for attribute "${n}"`,t.VALUE_NOT_FOUND)}static parentNotFound(n){return new e(`Parent element not found: ${n}`,t.PARENT_NOT_FOUND)}static invalidParameter(n){return new e(n,t.INVALID_PARAMETER)}static snapshotFailed(n,r){return new e(`Snapshot failed for "${n}": ${r}`,t.SNAPSHOT_FAILED)}},r=class{defaultServer=`https://server.virtualdisplay.io`;options;constructor(e){this.options=e}create(){let e=this.createIframe();return this.attachToParent(e),e}createIframe(){let e=document.createElement(`iframe`);return e.src=this.buildUrl(),Object.assign(e.style,{width:`100%`,height:`100%`,border:`none`}),e.setAttribute(`allow`,`xr-spatial-tracking; fullscreen`),e}attachToParent(e){this.getParentElement().appendChild(e)}buildUrl(){let e=this.getServerUrl(),t=new URL(e);return t.searchParams.set(`license`,this.options.license),t.searchParams.set(`model`,this.options.model),this.options.debug===!0&&t.searchParams.set(`debug`,`true`),this.options.language!==void 0&&t.searchParams.set(`language`,this.options.language),t.toString()}getServerUrl(){return this.defaultServer}getParentElement(){if(typeof this.options.parent!=`string`)return this.options.parent;let e=document.querySelector(this.options.parent);if(e===null)throw n.parentNotFound(this.options.parent);return e}};function i(e){let t=new Date(e.timestamp).toLocaleTimeString(`en-GB`,{hour12:!1}),n=e.level.toUpperCase().padEnd(5),r=e.trace_id?.slice(0,8)??`--------`,i=e.msg,a=[`timestamp`,`level`,`msg`,`service`,`trace_id`,`span_id`],o=Object.entries(e).filter(([e])=>!a.includes(e)).map(([e,t])=>`${e}=${JSON.stringify(t)}`).join(` `);return`${t} ${n} [${r}] ${i}${o?` `+o:``}`}function a(e){return JSON.stringify(e)}function o(e,t){let n=t?i(e):a(e);e.level===`error`?console.error(n):e.level===`warn`?console.warn(n):console.log(n)}function s(){return new Date}function c(e){return e.toISOString()}var l=class e{constructor(e){this.config=e}log(e,t,n={}){let r=this.config.traceProvider?.()??{};o({timestamp:c(s()),level:e,msg:t,service:this.config.service,...r,...n},this.config.isDev)}debug(e,t){this.config.isDev&&this.log(`debug`,e,t)}info(e,t){this.log(`info`,e,t)}warn(e,t){this.log(`warn`,e,t)}error(e,t){this.log(`error`,e,t)}with(t){let n=new e(this.config);return n.log=((e,n,r={})=>{this.log(e,n,{...t,...r})}).bind(this),n}};function u(e,t){return new l({service:e,isDev:t?.isDev===void 0?typeof process<`u`?process.env.NODE_ENV!==`production`:!0:t.isDev,traceProvider:t?.traceProvider})}function d(e){if(e!==void 0)return typeof e==`object`&&e&&!Array.isArray(e)&&!(e instanceof Error)?e:e instanceof Error?{error:e.message}:{value:e}}function f(e){return{debug:(t,n)=>e.debug(t,d(n)),info:(t,n)=>e.info(t,d(n)),warn:(t,n)=>e.warn(t,d(n)),error:(t,n)=>e.error(t,d(n))}}var p=!1,m=f(u(`client`,{isDev:!1}));function h(){p=!0,m=f(u(`client`,{isDev:!0}))}function g(){return p}var _=class{ready=!1;onReady;constructor(e){this.onReady=e}handleMappingReceived(){this.markReady(`Mapping received from server`)}handleMutationResult(e){e.isInitial&&this.markReady(`Initial mutations processed`)}get isReady(){return this.ready}clear(){this.ready=!1}markReady(e){this.ready||(this.ready=!0,m.info(`${e} - client is now ready`),this.onReady?.())}},v=class{isSelectedValue=!1;constructor(e,t){this.value=e,this.attribute=t}get isSelected(){return this.isSelectedValue}setSelected(e){this.isSelectedValue=e}},y=class{name;defaultValue;values;onSelect;onChangeCallback;constructor(e){this.name=e.name,this.defaultValue=e.defaultValue,this.onSelect=e.onSelect,this.values=this.createValues(e.values)}select(e){if(!this.values.has(e))throw n.valueNotFound(this.name,e);this.onSelect(this.name,e)}getValues(){return Array.from(this.values.values())}getValue(e){return this.values.get(e)}onChange(e){this.onChangeCallback=e}handleResult(e){let t;for(let n of this.values.values()){let r=n.value===e;n.setSelected(r),r&&(t=n)}t!==void 0&&this.onChangeCallback!==void 0&&this.onChangeCallback(t)}createValues(e){let t=new Map;for(let n of e){let e=new v(n,this.name);n===this.defaultValue&&e.setSelected(!0),t.set(n,e)}return t}},b=class{attributes=new Map;constructor(e,t,n){for(let n of e){let e=this.buildOptions(n,t);this.attributes.set(n.name,new y(e))}this.onMutationFailed=n}onMutationFailed;get(e){return this.attributes.get(e)}defaults(){let e=[];for(let t of this.attributes.values())t.defaultValue!==void 0&&e.push({name:t.name,value:t.defaultValue});return e}handleResults(e){for(let t of e){if(!t.success){this.onMutationFailed?.(t.name,t.value);continue}this.get(t.name)?.handleResult(t.value)}}buildOptions(e,t){let n={name:e.name,values:e.values,onSelect:(e,n)=>{t([{name:e,value:n}],!1)}};return e.defaultValue===void 0?n:{...n,defaultValue:e.defaultValue}}},x={READY:`ready`,MUTATION:`mutation`,STATE:`state`,CONFIG:`config`,CAMERA:`camera`,SNAPSHOT:`snapshot`,MAPPING:`mapping`},S=new Set(Object.values(x));function C(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.target==`string`?!1:typeof t.type==`string`&&S.has(t.type)}function w(e){let t=k(e);return t!==null&&t.type===x.READY}function T(e){let t=k(e);return t!==null&&t.type===x.MUTATION&&Array.isArray(t.results)}function E(e){let t=k(e);return t!==null&&t.type===x.SNAPSHOT&&(`data`in t||`error`in t)}function D(e){let t=k(e);return t!==null&&t.type===x.CAMERA&&Array.isArray(t.transforms)}function O(e){let t=k(e);return t!==null&&t.type===x.MAPPING&&Array.isArray(t.attributes)}function k(e){return typeof e!=`object`||!e?null:e}var A=class{pending=[];isReady=!1;constructor(e){this.processor=e}enqueue(e){if(this.isReady){this.processor(e);return}this.pending.push(e)}markReady(){if(this.isReady||(this.isReady=!0,this.pending.length===0))return;let e=[...this.pending];this.pending.length=0;for(let t of e)this.processor(t)}get ready(){return this.isReady}get pendingCount(){return this.pending.length}hasPending(e){return this.pending.some(t=>t.type===e)}clear(){this.pending.length=0}},j=class{handlers=new Map;publisher;consumer;shouldBuffer;listener=null;sourceId;constructor(e,t){this.getTarget=e,this.sourceId=`vd-${Math.random().toString(36).slice(2,8)}`,this.publisher=new A(e=>this.post(e)),this.consumer=new A(e=>this.routeToHandler(e)),this.shouldBuffer=t?.shouldBuffer??null,t?.bufferIncoming!==!0&&this.consumer.markReady()}on(e,t){this.handlers.set(e,t)}off(e){this.handlers.delete(e)}send(e){this.publisher.enqueue(e)}markReady(){this.publisher.markReady()}markConsumerReady(){this.consumer.markReady()}consumerHasPending(e){return this.consumer.hasPending(e)}start(){this.listener===null&&(this.listener=e=>{let{data:t}=e;if(!C(t)||t._source===this.sourceId)return;let n=t;if(this.shouldBuffer!==null&&!this.shouldBuffer(n)){this.routeToHandler(n);return}this.consumer.enqueue(n)},window.addEventListener(`message`,this.listener))}destroy(){this.listener!==null&&(window.removeEventListener(`message`,this.listener),this.listener=null),this.publisher.clear(),this.consumer.clear(),this.handlers.clear()}get ready(){return this.publisher.ready}get pendingCount(){return this.publisher.pendingCount}post(e){let t=this.getTarget();t!==null&&t.postMessage({...e,_source:this.sourceId},`*`)}routeToHandler(e){let t=this.handlers.get(e.type);if(t===void 0)return;let n=t(e);n instanceof Promise&&n.catch(t=>{let n=t instanceof Error?t.message:String(t);console.error(`Virtualdisplay: error handling ${e.type}: ${n}`)})}};new Set([x.CAMERA]);var M=class{registry;pendingCallbacks=[];constructor(e,t){this.send=e,this.onMutationFailed=t}handleMappingReceived(e){m.debug(`Initializing from server mapping`,{attributeCount:e.attributes.length}),this.registry=new b(e.attributes,(e,t)=>this.sendMutation(e,t),this.onMutationFailed);let t=this.registry.defaults();t.length>0&&this.sendMutation(t,!0),this.replayPendingCallbacks()}handleMutationResult(e){this.registry?.handleResults(e.results)}select(e,t){this.sendMutation([{name:e,value:t}],!1)}getValues(e){return this.registry?.get(e)?.getValues()??[]}getValue(e,t){return this.registry?.get(e)?.getValue(t)}onChange(e,t){if(this.registry===void 0){this.pendingCallbacks.push({name:e,callback:t});return}let n=this.registry.get(e);if(n===void 0){m.warn(`onChange: attribute "${e}" not found — callback will not fire`);return}n.onChange(t)}getAttribute(e){return this.registry?.get(e)}get hasMapping(){return this.registry!==void 0}sendMutation(e,t){let n={type:x.MUTATION,mutations:e,isInitial:t};this.send(n)}replayPendingCallbacks(){for(let{name:e,callback:t}of this.pendingCallbacks){let n=this.registry?.get(e);n===void 0&&m.warn(`onChange: attribute "${e}" not found — buffered callback will not fire`),n?.onChange(t)}this.pendingCallbacks.length=0}},N=class{commands=[];constructor(e){this.send=e}rotate(e){return this.validateFiniteNumber(e,`rotate`),this.commands.push({action:`rotate`,value:e}),this}tilt(e){return this.validateFiniteNumber(e,`tilt`),this.commands.push({action:`tilt`,value:e}),this}zoom(e){return this.validateFiniteNumber(e,`zoom`),this.commands.push({action:`zoom`,value:e}),this}set(){if(this.commands.length===0)throw n.invalidParameter(`No camera commands to execute. Call rotate(), tilt(), or zoom() before set().`);let e={type:x.CAMERA,commands:this.commands};this.send(e),this.commands=[]}validateFiniteNumber(e,t){if(!Number.isFinite(e))throw n.invalidParameter(`${t}() requires a finite number, got ${String(e)}`)}reset(){let e={type:x.CAMERA,commands:[{action:`reset`}]};this.send(e)}},P=class{state;changeCallbacks=[];constructor(){this.state={rotation:0,tilt:0,zoom:0}}get rotation(){return this.state.rotation}get tilt(){return this.state.tilt}get zoom(){return this.state.zoom}onChange(e){this.changeCallbacks.push(e)}handlePositionUpdate(e){this.update(e.transforms)}update(e){let t=!1;for(let n of e)switch(n.type){case`rotation`:this.state.rotation=n.value,t=!0;break;case`tilt`:this.state.tilt=n.value,t=!0;break;case`zoom`:this.state.zoom=n.value,t=!0;break;default:break}if(t){let e={rotation:this.rotation,tilt:this.tilt,zoom:this.zoom};for(let t of this.changeCallbacks)t(e)}}},F=class{developedCallbacks=new Set;errorCallbacks=new Set;developed=!1;failed=!1;photoData=null;constructor(e){this.filename=e}onDeveloped(e){return this.developed&&this.photoData!==null?(e(this.photoData),this):(this.developedCallbacks.add(e),this)}onError(e){return this.errorCallbacks.add(e),this}getFilename(){return this.filename}develop(e){this.developed||this.failed||(this.photoData=e,this.developed=!0,this.developedCallbacks.forEach(e=>{e(this.photoData)}),this.developedCallbacks.clear(),this.errorCallbacks.clear())}fail(e){this.developed||this.failed||(this.failed=!0,this.errorCallbacks.forEach(t=>{t(e)}),this.developedCallbacks.clear(),this.errorCallbacks.clear())}},I=class{validExtensions=[`.png`];pendingPhotos=new Map;constructor(e){this.send=e}take(e){this.validateFilename(e),m.debug(`Taking snapshot`,{filename:e});let t=new F(e);return this.pendingPhotos.set(t.getFilename(),t),this.send({type:x.SNAPSHOT,filename:e}),t}handleSnapshotResult(e){let r=this.pendingPhotos.get(e.filename);if(r===void 0){m.warn(`No pending photo found for filename`,{filename:e.filename,pendingFilenames:Array.from(this.pendingPhotos.keys())});return}if(this.pendingPhotos.delete(e.filename),e.error!==void 0){r.fail(new n(e.error,t.SNAPSHOT_FAILED));return}e.data!==void 0&&r.develop({filename:e.filename,data:e.data})}validateFilename(e){if(e===``||typeof e!=`string`)throw new n(`Filename must be a non-empty string`,t.INVALID_PARAMETER);if(!this.validExtensions.some(t=>e.toLowerCase().endsWith(t)))throw new n(`Invalid filename: "${e}". Filename must end with one of: ${this.validExtensions.join(`, `)}`,t.INVALID_PARAMETER);if(e.includes(`..`)||e.includes(`/`)||e.includes(`\\`))throw new n(`Filename cannot contain path separators or ".."`,t.INVALID_PARAMETER)}},L=class{send;constructor(e){this.send=e}sendInitialConfig(e){let t=this.buildUIConfig(e),n=this.buildViewerConfig(t,e.camera);n!==void 0&&this.sendConfig(n)}buildUIConfig(e){let t=this.extractUIValues(e);if(Object.values(t).some(e=>e!==void 0))return{...t.arEnabled!==void 0&&{arEnabled:t.arEnabled},...t.fullscreenEnabled!==void 0&&{fullscreenEnabled:t.fullscreenEnabled},...t.loadingIndicatorEnabled!==void 0&&{loadingIndicatorEnabled:t.loadingIndicatorEnabled}}}extractUIValues(e){return{arEnabled:e.arEnabled??e.ui?.arEnabled,fullscreenEnabled:e.fullscreenEnabled??e.ui?.fullscreenEnabled,loadingIndicatorEnabled:e.loadingIndicatorEnabled??e.ui?.loadingIndicatorEnabled}}buildViewerConfig(e,t){if(!(e===void 0&&t===void 0))return{...e!==void 0&&{ui:e},...t!==void 0&&{camera:t}}}setArEnabled(e){m.debug(`Setting AR button enabled: ${e}`),this.updateUIConfig({arEnabled:e})}setFullscreenEnabled(e){m.debug(`Setting fullscreen button enabled: ${e}`),this.updateUIConfig({fullscreenEnabled:e})}setLoadingIndicatorEnabled(e){m.debug(`Setting loading indicator enabled: ${e}`),this.updateUIConfig({loadingIndicatorEnabled:e})}updateUIConfig(e){m.debug(`Updating UI configuration`,e),Object.keys(e).length>0&&this.sendConfig({ui:e})}hideAllUI(){m.debug(`Hiding all UI elements`),this.sendUIConfig({arEnabled:!1,fullscreenEnabled:!1,loadingIndicatorEnabled:!1})}showAllUI(){m.debug(`Showing all UI elements`),this.sendUIConfig({arEnabled:!0,fullscreenEnabled:!0,loadingIndicatorEnabled:!0})}sendUIConfig(e){this.sendConfig({ui:e})}sendConfig(e){let t={type:x.CONFIG,config:e};m.debug(`Sending config`,t),this.send(t)}},R=class{attributes;readyStateTracker;messenger;viewerService;cameraApi;cameraPositionApi;snapshotApi;options;iframe;readyCallbacks=[];mutationFailedCallbacks=[];constructor(e){this.options=e,this.initializeLogging(),this.messenger=new j(()=>this.iframe?.contentWindow??null);let t=e=>{this.messenger.send(e)};this.attributes=new M(t,(e,t)=>{for(let n of this.mutationFailedCallbacks)n({attribute:e,value:t})}),this.readyStateTracker=new _(()=>{let e=this.readyCallbacks;this.readyCallbacks=[];for(let t of e)t(this)}),this.viewerService=new L(t),this.cameraApi=new N(t),this.cameraPositionApi=new P,this.snapshotApi=new I(t),this.registerHandlers(),this.messenger.start(),this.createAndConnectIframe()}registerHandlers(){this.messenger.on(x.READY,e=>{w(e)&&(m.info(`Server ready — flushing publisher queue`),this.messenger.markReady(),this.viewerService.sendInitialConfig(this.options))}),this.messenger.on(x.MUTATION,e=>{T(e)&&(this.attributes.handleMutationResult(e),this.readyStateTracker.handleMutationResult(e))}),this.messenger.on(x.SNAPSHOT,e=>{E(e)&&this.snapshotApi.handleSnapshotResult(e)}),this.messenger.on(x.CAMERA,e=>{D(e)&&this.cameraPositionApi.handlePositionUpdate(e)}),this.messenger.on(x.MAPPING,e=>{O(e)&&(this.attributes.handleMappingReceived(e),this.readyStateTracker.handleMappingReceived())})}initializeLogging(){this.options.debug===!0&&h(),m.info(`Initializing Virtualdisplay client`,{model:this.options.model,debug:this.options.debug,language:this.options.language})}createAndConnectIframe(){m.debug(`Creating iframe for Virtualdisplay viewer`),this.iframe=new r(this.options).create(),m.debug(`Iframe created, waiting for server READY`)}select(e,t){this.attributes.select(e,t)}getValues(e){return this.attributes.getValues(e)}getValue(e,t){return this.attributes.getValue(e,t)}onChange(e,t){this.attributes.onChange(e,t)}getAttribute(e){return this.attributes.getAttribute(e)}get isReady(){return this.readyStateTracker.isReady}onReady(e){if(this.readyStateTracker.isReady){e(this);return}this.readyCallbacks.push(e)}onMutationFailed(e){this.mutationFailedCallbacks.push(e)}get viewer(){return this.viewerService}get camera(){return this.cameraApi}get cameraPosition(){return this.cameraPositionApi}get snapshot(){return this.snapshotApi}destroy(){m.info(`Destroying Virtualdisplay client`),this.readyStateTracker.clear(),this.readyCallbacks=[],this.messenger.destroy(),this.iframe?.parentElement!==null&&this.iframe?.parentElement!==void 0&&this.iframe.parentElement.removeChild(this.iframe),this.iframe=void 0,m.debug(`Virtualdisplay client destroyed`)}};e.Attribute=y,e.AttributeValue=v,e.Camera=N,e.ERROR_CODES=t,e.Photo=F,e.Snapshot=I,e.VirtualdisplayClient=R,e.VirtualdisplayError=n,e.VirtualdisplayViewerService=L,e.enableDebugMode=h,e.isDebugMode=g,Object.defineProperty(e,`logger`,{enumerable:!0,get:function(){return m}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.VirtualdisplayClient={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=(e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),u={NO_MAPPING:`NO_MAPPING`,ATTRIBUTE_NOT_FOUND:`ATTRIBUTE_NOT_FOUND`,VALUE_NOT_FOUND:`VALUE_NOT_FOUND`,PARENT_NOT_FOUND:`PARENT_NOT_FOUND`,INVALID_PARAMETER:`INVALID_PARAMETER`,SNAPSHOT_FAILED:`SNAPSHOT_FAILED`},d=class e extends Error{code;constructor(e,t){super(e),this.name=`VirtualdisplayError`,this.code=t}static noMapping(){return new e(`No attributes available. Waiting for server metadata.`,u.NO_MAPPING)}static attributeNotFound(t){return new e(`Attribute "${t}" not found in mapping`,u.ATTRIBUTE_NOT_FOUND)}static valueNotFound(t,n){return new e(`Value "${n}" not found for attribute "${t}"`,u.VALUE_NOT_FOUND)}static parentNotFound(t){return new e(`Parent element not found: ${t}`,u.PARENT_NOT_FOUND)}static invalidParameter(t){return new e(t,u.INVALID_PARAMETER)}static snapshotFailed(t,n){return new e(`Snapshot failed for "${t}": ${n}`,u.SNAPSHOT_FAILED)}},f=class{defaultServer=`https://server.virtualdisplay.io`;options;constructor(e){this.options=e}create(){let e=this.createContainer(),t=this.createIframe();return e.appendChild(t),this.attachToParent(e),{container:e,iframe:t}}createContainer(){let e=document.createElement(`div`);return e.className=`vd-container`,Object.assign(e.style,{position:`relative`,width:`100%`,height:`100%`,overflow:`hidden`}),e}createIframe(){let e=document.createElement(`iframe`);return e.src=this.buildUrl(),Object.assign(e.style,{width:`100%`,height:`100%`,border:`none`,display:`block`}),e.setAttribute(`allow`,`xr-spatial-tracking; fullscreen`),e}attachToParent(e){this.getParentElement().appendChild(e)}buildUrl(){let e=this.getServerUrl(),t=new URL(e);return t.searchParams.set(`license`,this.options.license),t.searchParams.set(`model`,this.options.model),this.options.language!==void 0&&t.searchParams.set(`language`,this.options.language),this.options.debug===!0&&t.searchParams.set(`debug`,`true`),t.toString()}getServerUrl(){return this.defaultServer}getParentElement(){if(typeof this.options.parent!=`string`)return this.options.parent;let e=document.querySelector(this.options.parent);if(e===null)throw d.parentNotFound(this.options.parent);return e}};function p(e){let t=new Date(e.timestamp).toLocaleTimeString(`en-GB`,{hour12:!1}),n=e.level.toUpperCase().padEnd(5),r=e.trace_id?.slice(0,8)??`--------`,i=e.msg,a=[`timestamp`,`level`,`msg`,`service`,`trace_id`,`span_id`],o=Object.entries(e).filter(([e])=>!a.includes(e)).map(([e,t])=>`${e}=${JSON.stringify(t)}`).join(` `);return`${t} ${n} [${r}] ${i}${o?` `+o:``}`}function m(e){return JSON.stringify(e)}function h(e,t){let n=t?p(e):m(e);e.level===`error`?console.error(n):e.level===`warn`?console.warn(n):console.log(n)}function g(){return new Date}function _(e){return e.toISOString()}var v=class e{constructor(e){this.config=e}log(e,t,n={}){let r=this.config.traceProvider?.()??{};h({timestamp:_(g()),level:e,msg:t,service:this.config.service,...r,...n},this.config.isDev)}debug(e,t){this.config.isDev&&this.log(`debug`,e,t)}info(e,t){this.log(`info`,e,t)}warn(e,t){this.log(`warn`,e,t)}error(e,t){this.log(`error`,e,t)}with(t){let n=new e(this.config);return n.log=((e,n,r={})=>{this.log(e,n,{...t,...r})}).bind(this),n}};function y(e,t){return new v({service:e,isDev:t?.isDev===void 0?typeof process<`u`?process.env.NODE_ENV!==`production`:!0:t.isDev,traceProvider:t?.traceProvider})}function b(e){if(e!==void 0)return typeof e==`object`&&e&&!Array.isArray(e)&&!(e instanceof Error)?e:e instanceof Error?{error:e.message}:{value:e}}function x(e){return{debug:(t,n)=>e.debug(t,b(n)),info:(t,n)=>e.info(t,b(n)),warn:(t,n)=>e.warn(t,b(n)),error:(t,n)=>e.error(t,b(n))}}var S=!1,C=x(y(`client`,{isDev:!1}));function ee(){S=!0,C=x(y(`client`,{isDev:!0}))}function te(){return S}var ne=class{ready=!1;onReady;constructor(e){this.onReady=e}handleMappingReceived(){this.ready||(this.ready=!0,C.info(`Mapping received from server, client is now ready`),this.onReady?.())}get isReady(){return this.ready}clear(){this.ready=!1}},re=class{isSelectedValue=!1;constructor(e,t){this.value=e,this.attribute=t}get isSelected(){return this.isSelectedValue}setSelected(e){this.isSelectedValue=e}},ie=class{name;defaultValue;values;onSelect;onChangeCallback;constructor(e){this.name=e.name,this.defaultValue=e.defaultValue,this.onSelect=e.onSelect,this.values=this.createValues(e.values)}select(e){if(!this.values.has(e))throw d.valueNotFound(this.name,e);this.onSelect(this.name,e)}getValues(){return Array.from(this.values.values())}getValue(e){return this.values.get(e)}onChange(e){this.onChangeCallback=e}handleResult(e){let t;for(let n of this.values.values()){let r=n.value===e;n.setSelected(r),r&&(t=n)}t!==void 0&&this.onChangeCallback!==void 0&&this.onChangeCallback(t)}createValues(e){let t=new Map;for(let n of e){let e=new re(n,this.name);n===this.defaultValue&&e.setSelected(!0),t.set(n,e)}return t}},ae=class{attributes=new Map;constructor(e,t,n){for(let n of e){let e=this.buildOptions(n,t);this.attributes.set(n.name,new ie(e))}this.onMutationFailed=n}onMutationFailed;get(e){return this.attributes.get(e)}defaults(){let e=[];for(let t of this.attributes.values())t.defaultValue!==void 0&&e.push({name:t.name,value:t.defaultValue});return e}handleResults(e){for(let t of e){if(!t.success){this.onMutationFailed?.(t.name,t.value);continue}this.get(t.name)?.handleResult(t.value)}}buildOptions(e,t){let n={name:e.name,values:e.values,onSelect:(e,n)=>{t([{name:e,value:n}],!1)}};return e.defaultValue===void 0?n:{...n,defaultValue:e.defaultValue}}},w={HANDSHAKE:`handshake`,MUTATION:`mutation`,STATE:`state`,LOADING_INDICATOR:`loading_indicator`,CAMERA:`camera`,SNAPSHOT:`snapshot`,MAPPING:`mapping`,AR_ACTIVATE:`ar_activate`,CONFIG:`config`,INTERACTION:`interaction`},oe=new Set(Object.values(w));function se(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.target==`string`?!1:typeof t.type==`string`&&oe.has(t.type)}function ce(e){let t=T(e);return t!==null&&t.type===w.HANDSHAKE}function le(e){let t=T(e);return t!==null&&t.type===w.MUTATION&&Array.isArray(t.results)}function ue(e){let t=T(e);return t!==null&&t.type===w.SNAPSHOT&&(`data`in t||`error`in t)}function de(e){let t=T(e);return t!==null&&t.type===w.CAMERA&&Array.isArray(t.transforms)}function fe(e){let t=T(e);return t!==null&&t.type===w.MAPPING&&Array.isArray(t.attributes)}function pe(e){let t=T(e);return t!==null&&t.type===w.LOADING_INDICATOR&&typeof t.progress==`number`}function me(e){let t=T(e);return t!==null&&t.type===w.CONFIG&&typeof t.viewerSettings==`object`}function T(e){return typeof e!=`object`||!e?null:e}var he=class{pending=[];isReady=!1;constructor(e){this.processor=e}enqueue(e){if(this.isReady){this.processor(e);return}this.pending.push(e)}markReady(){if(this.isReady||(this.isReady=!0,this.pending.length===0))return;let e=[...this.pending];this.pending.length=0;for(let t of e)this.processor(t)}get ready(){return this.isReady}get pendingCount(){return this.pending.length}hasPending(e){return this.pending.some(t=>t.type===e)}clear(){this.pending.length=0}},ge=class{handlers=new Map;publisher;consumer;shouldBuffer;listener=null;sourceId;constructor(e,t){this.getTarget=e,this.sourceId=`vd-${Math.random().toString(36).slice(2,8)}`,this.publisher=new he(e=>this.post(e)),this.consumer=new he(e=>this.routeToHandler(e)),this.shouldBuffer=t?.shouldBuffer??null,t?.bufferIncoming!==!0&&this.consumer.markReady()}on(e,t){this.handlers.set(e,t)}off(e){this.handlers.delete(e)}send(e){this.publisher.enqueue(e)}markReady(){this.publisher.markReady()}markConsumerReady(){this.consumer.markReady()}consumerHasPending(e){return this.consumer.hasPending(e)}start(){this.listener===null&&(this.listener=e=>{let{data:t}=e;if(!se(t)||t._source===this.sourceId)return;let n=t;if(this.shouldBuffer!==null&&!this.shouldBuffer(n)){this.routeToHandler(n);return}this.consumer.enqueue(n)},window.addEventListener(`message`,this.listener))}destroy(){this.listener!==null&&(window.removeEventListener(`message`,this.listener),this.listener=null),this.publisher.clear(),this.consumer.clear(),this.handlers.clear()}get ready(){return this.publisher.ready}get pendingCount(){return this.publisher.pendingCount}post(e){let t=this.getTarget();t!==null&&t.postMessage({...e,_source:this.sourceId},`*`)}routeToHandler(e){let t=this.handlers.get(e.type);if(t===void 0)return;let n=t(e);n instanceof Promise&&n.catch(t=>{let n=t instanceof Error?t.message:String(t);console.error(`Virtualdisplay: error handling ${e.type}: ${n}`)})}};new Set([w.CAMERA]);var _e=class{registry;pendingCallbacks=[];constructor(e,t){this.send=e,this.onMutationFailed=t}handleMappingReceived(e){C.debug(`Initializing from server mapping`,{attributeCount:e.attributes.length}),this.registry=new ae(e.attributes,(e,t)=>this.sendMutation(e,t),this.onMutationFailed),this.replayPendingCallbacks()}handleMutationResult(e){this.registry?.handleResults(e.results)}select(e,t){this.sendMutation([{name:e,value:t}],!1)}getValues(e){return this.registry?.get(e)?.getValues()??[]}getValue(e,t){return this.registry?.get(e)?.getValue(t)}onChange(e,t){if(this.registry===void 0){this.pendingCallbacks.push({name:e,callback:t});return}let n=this.registry.get(e);if(n===void 0){C.warn(`onChange: attribute "${e}" not found — callback will not fire`);return}n.onChange(t)}getAttribute(e){return this.registry?.get(e)}get hasMapping(){return this.registry!==void 0}sendMutation(e,t){let n={type:w.MUTATION,mutations:e,isInitial:t};this.send(n)}replayPendingCallbacks(){for(let{name:e,callback:t}of this.pendingCallbacks){let n=this.registry?.get(e);n===void 0&&C.warn(`onChange: attribute "${e}" not found — buffered callback will not fire`),n?.onChange(t)}this.pendingCallbacks.length=0}},ve=class{commands=[];constructor(e){this.send=e}rotate(e){return this.validateFiniteNumber(e,`rotate`),this.commands.push({action:`rotate`,value:e}),this}tilt(e){return this.validateFiniteNumber(e,`tilt`),this.commands.push({action:`tilt`,value:e}),this}zoom(e){return this.validateFiniteNumber(e,`zoom`),this.commands.push({action:`zoom`,value:e}),this}set(){if(this.commands.length===0)throw d.invalidParameter(`No camera commands to execute. Call rotate(), tilt(), or zoom() before set().`);let e={type:w.CAMERA,commands:this.commands};this.send(e),this.commands=[]}validateFiniteNumber(e,t){if(!Number.isFinite(e))throw d.invalidParameter(`${t}() requires a finite number, got ${String(e)}`)}reset(){let e={type:w.CAMERA,commands:[{action:`reset`}]};this.send(e)}},ye=class{state;limitsState;changeCallbacks=[];constructor(){this.state={rotation:0,tilt:0,zoom:100}}get rotation(){return this.state.rotation}get tilt(){return this.state.tilt}get zoom(){return this.state.zoom}onChange(e){this.changeCallbacks.push(e)}get limits(){return this.limitsState}applyLimits(e){this.limitsState=e;let t={rotation:this.rotation,tilt:this.tilt,zoom:this.zoom};for(let e of this.changeCallbacks)e(t)}handlePositionUpdate(e){this.update(e.transforms)}update(e){let t=!1;for(let n of e)switch(n.type){case`rotation`:this.state.rotation=n.value,t=!0;break;case`tilt`:this.state.tilt=n.value,t=!0;break;case`zoom`:this.state.zoom=n.value,t=!0;break;default:break}if(t){let e={rotation:this.rotation,tilt:this.tilt,zoom:this.zoom};for(let t of this.changeCallbacks)t(e)}}},be=class{developedCallbacks=new Set;errorCallbacks=new Set;developed=!1;failed=!1;photoData=null;constructor(e){this.filename=e}onDeveloped(e){return this.developed&&this.photoData!==null?(e(this.photoData),this):(this.developedCallbacks.add(e),this)}onError(e){return this.errorCallbacks.add(e),this}getFilename(){return this.filename}develop(e){this.developed||this.failed||(this.photoData=e,this.developed=!0,this.developedCallbacks.forEach(e=>{e(this.photoData)}),this.developedCallbacks.clear(),this.errorCallbacks.clear())}fail(e){this.developed||this.failed||(this.failed=!0,this.errorCallbacks.forEach(t=>{t(e)}),this.developedCallbacks.clear(),this.errorCallbacks.clear())}},xe=class{validExtensions=[`.png`];pendingPhotos=new Map;constructor(e){this.send=e}take(e){this.validateFilename(e),C.debug(`Taking snapshot`,{filename:e});let t=new be(e);return this.pendingPhotos.set(t.getFilename(),t),this.send({type:w.SNAPSHOT,filename:e}),t}handleSnapshotResult(e){let t=this.pendingPhotos.get(e.filename);if(t===void 0){C.warn(`No pending photo found for filename`,{filename:e.filename,pendingFilenames:Array.from(this.pendingPhotos.keys())});return}if(this.pendingPhotos.delete(e.filename),e.error!==void 0){t.fail(new d(e.error,u.SNAPSHOT_FAILED));return}e.data!==void 0&&t.develop({filename:e.filename,data:e.data})}validateFilename(e){if(e===``||typeof e!=`string`)throw new d(`Filename must be a non-empty string`,u.INVALID_PARAMETER);if(!this.validExtensions.some(t=>e.toLowerCase().endsWith(t)))throw new d(`Invalid filename: "${e}". Filename must end with one of: ${this.validExtensions.join(`, `)}`,u.INVALID_PARAMETER);if(e.includes(`..`)||e.includes(`/`)||e.includes(`\\`))throw new d(`Filename cannot contain path separators or ".."`,u.INVALID_PARAMETER)}},Se=class{container=null;attach(e){this.container=e}dispatch(e,t,n=!1){let r=new CustomEvent(e,{detail:t,cancelable:n});return this.container?.dispatchEvent(r),r}on(e,t){let n=e=>{let n=e;t({...n.detail,preventDefault:()=>{n.preventDefault()}})};return this.container?.addEventListener(e,n),()=>{this.container?.removeEventListener(e,n)}}},Ce={},we=[`en`,`nl`,`de`],E=[`baseLocale`],Te=[],D,Ee;function De(e){if(Te.length===0)return;let t=typeof e==`string`?e:e.href;if(D===t)return Ee;let n=new URL(t,`http://dummy.com`),r;for(let e of Te)if(new Ce(e.match,n.href).exec(n.href)){r=e;break}return D=t,Ee=r,r}function Oe(e){let t=De(e);return t&&t.exclude!==!0&&Array.isArray(t.strategy)?t.strategy:E}var ke=void 0,O=typeof window>`u`;globalThis.__paraglide=globalThis.__paraglide??{},globalThis.__paraglide.ssr=globalThis.__paraglide.ssr??{};var Ae=!1,k=()=>{if(ke){let e=ke?.getStore()?.locale;if(e)return e}let e=E;!O&&typeof window<`u`&&window.location?.href&&(e=Oe(window.location.href));let t=je(e,typeof window<`u`?window.location?.href:void 0);if(t)return Ae||(Ae=!0,A(t,{reload:!1})),t;throw Error(`No locale found. Read the docs https://inlang.com/m/gerre34r/library-inlang-paraglideJs/errors#no-locale-found`)};function je(e,t){let n;for(let t of e){if(t===`baseLocale`)n=`en`;else if(Pe(t)&&M.has(t)){let e=M.get(t);if(e){let t=e.getLocale();if(t instanceof Promise)continue;if(t!==void 0)return Ne(t)}}let e=j(n);if(e)return e}}var Me=e=>{e?window.location.href=e:window.location.reload()},A=(e,t)=>{let n={reload:!0,...t},r;try{r=k()}catch{}let i=[],a=E;!O&&typeof window<`u`&&window.location?.href&&(a=Oe(window.location.href));for(let t of a)if(t===`baseLocale`)continue;else if(Pe(t)&&M.has(t)){let n=M.get(t);if(n){let r=n.setLocale(e);r instanceof Promise&&(r=r.catch(e=>{throw Error(`Custom strategy "${t}" setLocale failed.`,{cause:e})}),i.push(r))}}let o=()=>{!O&&n.reload&&window.location&&e!==r&&Me(void 0)};if(i.length)return Promise.all(i).then(()=>{o()});o()};function j(e){if(typeof e!=`string`)return;let t=e.toLowerCase();for(let e of we)if(e.toLowerCase()===t)return e}function Ne(e){let t=j(e);if(t)return t;throw Error(`Invalid locale: ${e}. Expected one of: ${we.join(`, `)}`)}var M=new Map;function Pe(e){return typeof e==`string`&&/^custom-[A-Za-z0-9_-]+$/.test(e)}var Fe=()=>`Activate AR`,Ie=()=>`AR activeren`,Le=()=>`AR aktivieren`,Re=((e={},t={})=>{let n=t.locale??k();return n===`en`?Fe(e):n===`nl`?Ie(e):Le(e)}),ze=()=>`Scan to view in AR`,Be=()=>`Scan om in AR te bekijken`,Ve=()=>`Scannen für AR-Ansicht`,He=((e={},t={})=>{let n=t.locale??k();return n===`en`?ze(e):n===`nl`?Be(e):Ve(e)}),Ue=()=>`Use your smartphone camera to scan this QR code`,We=()=>`Gebruik de camera van uw smartphone om deze QR-code te scannen`,Ge=()=>`Verwenden Sie die Kamera Ihres Smartphones, um diesen QR-Code zu scannen`,Ke=((e={},t={})=>{let n=t.locale??k();return n===`en`?Ue(e):n===`nl`?We(e):Ge(e)}),qe=()=>`The 3D model will open in your phone's AR mode`,Je=()=>`Het 3D-model wordt geopend in de AR-modus van uw telefoon`,Ye=()=>`Das 3D-Modell wird im AR-Modus Ihres Telefons geöffnet`,Xe=((e={},t={})=>{let n=t.locale??k();return n===`en`?qe(e):n===`nl`?Je(e):Ye(e)}),Ze=()=>`Close`,Qe=()=>`Sluiten`,$e=()=>`Schließen`,et=((e={},t={})=>{let n=t.locale??k();return n===`en`?Ze(e):n===`nl`?Qe(e):$e(e)}),tt=()=>`Toggle fullscreen`,nt=()=>`Volledig scherm`,rt=()=>`Vollbild umschalten`,it=((e={},t={})=>{let n=t.locale??k();return n===`en`?tt(e):n===`nl`?nt(e):rt(e)}),at=()=>`Downloading`,ot=()=>`Downloaden`,st=()=>`Herunterladen`,ct=((e={},t={})=>{let n=t.locale??k();return n===`en`?at(e):n===`nl`?ot(e):st(e)}),lt=()=>`Rendering`,ut=()=>`Renderen`,dt=()=>`Rendern`,ft=((e={},t={})=>{let n=t.locale??k();return n===`en`?lt(e):n===`nl`?ut(e):dt(e)}),pt=()=>`Screenshot`,mt=()=>`Screenshot`,ht=()=>`Screenshot`,gt=((e={},t={})=>{let n=t.locale??k();return n===`en`?pt(e):n===`nl`?mt(e):ht(e)}),_t=()=>`Reset camera`,vt=()=>`Camera resetten`,yt=()=>`Kamera zurücksetzen`,bt=((e={},t={})=>{let n=t.locale??k();return n===`en`?_t(e):n===`nl`?vt(e):yt(e)}),xt=()=>`Zoom in`,St=()=>`Inzoomen`,Ct=()=>`Hineinzoomen`,wt=((e={},t={})=>{let n=t.locale??k();return n===`en`?xt(e):n===`nl`?St(e):Ct(e)}),Tt=()=>`Zoom out`,Et=()=>`Uitzoomen`,Dt=()=>`Herauszoomen`,Ot=((e={},t={})=>{let n=t.locale??k();return n===`en`?Tt(e):n===`nl`?Et(e):Dt(e)}),kt=()=>`Rotate left`,At=()=>`Naar links draaien`,jt=()=>`Nach links drehen`,Mt=((e={},t={})=>{let n=t.locale??k();return n===`en`?kt(e):n===`nl`?At(e):jt(e)}),Nt=()=>`Rotate right`,Pt=()=>`Naar rechts draaien`,Ft=()=>`Nach rechts drehen`,It=((e={},t={})=>{let n=t.locale??k();return n===`en`?Nt(e):n===`nl`?Pt(e):Ft(e)}),Lt=()=>`Tilt up`,Rt=()=>`Omhoog kantelen`,zt=()=>`Nach oben kippen`,Bt=((e={},t={})=>{let n=t.locale??k();return n===`en`?Lt(e):n===`nl`?Rt(e):zt(e)}),Vt=()=>`Tilt down`,Ht=()=>`Omlaag kantelen`,Ut=()=>`Nach unten kippen`,Wt=((e={},t={})=>{let n=t.locale??k();return n===`en`?Vt(e):n===`nl`?Ht(e):Ut(e)});function Gt(e){let t=Math.max(0,Math.min(1,e));return t*t*(3-2*t)}function Kt(e,t,n,r,i,a){let[o,s,c]=e,l=Math.cos(t),u=Math.sin(t),d=l*o+u*c,f=-u*o+l*c,p=Math.cos(n),m=Math.sin(n),h=p*s-m*f,g=m*s+p*f,_=.55;return[r+d*a*_,i-h*a*_,g]}function qt(e,t,n){e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(n[0],n[1]),e.strokeStyle=`#000`,e.lineWidth=2,e.stroke()}function Jt(e,t,n,r,i){let a=t(n),o=t(r);qt(e,a,[a[0]+(o[0]-a[0])*i,a[1]+(o[1]-a[1])*i,a[2]])}var N=[-1,-1,1],P=[1,-1,1],F=[1,-1,-1],I=[-1,-1,-1],L=[-1,1,1],R=[1,1,1],z=[1,1,-1],B=[-1,1,-1],Yt=[[N,P],[P,F],[F,I],[I,N],[N,L],[P,R],[F,z],[I,B],[L,R],[R,z],[z,B],[B,L]],Xt=400,Zt=`-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif`;function Qt(){let e=document.createElement(`div`);Object.assign(e.style,{position:`absolute`,inset:`0`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,background:`#fff`,zIndex:`20`,opacity:`0`,transition:`opacity 0.3s ease-in-out`});let t=document.createElement(`canvas`);Object.assign(t.style,{width:`100%`,height:`100%`,position:`absolute`,inset:`0`});let n=document.createElement(`div`);Object.assign(n.style,{position:`absolute`,top:`56%`,left:`0`,right:`0`,textAlign:`center`,pointerEvents:`none`});let r=document.createElement(`span`);Object.assign(r.style,{fontSize:`13px`,fontWeight:`400`,color:`#000`,fontVariantNumeric:`tabular-nums`,fontFamily:Zt});let i=document.createElement(`span`);return Object.assign(i.style,{fontSize:`13px`,color:`#000`,fontFamily:Zt}),i.textContent=ct(),n.appendChild(r),n.appendChild(i),e.appendChild(t),e.appendChild(n),{overlay:e,canvas:t,pctEl:r,phaseEl:i}}var $t=class{overlay;canvas;ctx;pctEl;phaseEl;animationId=null;showTimerId=null;startTime;hidden=!1;visible=!1;constructor(e,t={}){this.startTime=performance.now();let n=Qt();this.overlay=n.overlay,this.canvas=n.canvas,this.pctEl=n.pctEl,this.phaseEl=n.phaseEl,e.appendChild(this.overlay),this.ctx=this.canvas.getContext(`2d`),this.ctx!==null&&(this.sizeCanvas(),this.tick());let r=t.showDelay??Xt;this.showTimerId=setTimeout(()=>{this.reveal()},r)}get loadingTexts(){return{downloading:ct(),rendering:ft()}}updateProgress(e,t){this.hidden||(this.pctEl.textContent=`${Math.round(e)}%`,this.phaseEl.textContent=t===``?``:` \u00B7 ${t}`)}showError(e){if(this.hidden=!1,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.ctx!==null){let e=Math.min(devicePixelRatio,2),t=this.canvas.width/e,n=this.canvas.height/e;this.ctx.fillStyle=`#fff`,this.ctx.fillRect(0,0,t*e,n*e)}this.pctEl.textContent=``,this.phaseEl.textContent=e,this.phaseEl.style.color=`#b91c1c`,this.reveal()}hide(){if(!this.hidden){if(this.hidden=!0,this.cancelShowTimer(),!this.visible){this.destroy();return}this.overlay.style.opacity=`0`,this.overlay.addEventListener(`transitionend`,()=>{this.destroy()},{once:!0}),setTimeout(()=>{this.destroy()},500)}}destroy(){this.cancelShowTimer(),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.overlay.remove()}reveal(){this.hidden||this.visible||(this.visible=!0,this.overlay.style.opacity=`1`)}cancelShowTimer(){this.showTimerId!==null&&(clearTimeout(this.showTimerId),this.showTimerId=null)}sizeCanvas(){if(this.ctx===null)return;let e=Math.min(devicePixelRatio,2),t=this.overlay.clientWidth||440,n=this.overlay.clientHeight||360;this.canvas.width=t*e,this.canvas.height=n*e,this.ctx.scale(e,e),this.ctx.lineCap=`round`,this.ctx.lineJoin=`round`}tick=()=>{this.hidden||(this.drawFrame(),this.animationId=requestAnimationFrame(this.tick))};drawFrame(){if(this.ctx===null)return;let e=this.canvas.width/Math.min(devicePixelRatio,2),t=this.canvas.height/Math.min(devicePixelRatio,2),n=(performance.now()-this.startTime)/1e3;this.ctx.fillStyle=`#fff`,this.ctx.fillRect(0,0,e,t);let r=e/2,i=t*.44,a=Math.min(e,t)*.08,o=e=>Kt(e,.785,.615,r,i,a),s=n%6/6,c=Yt.length,l;l=s<.35?Gt(s/.35)*c:s<.55?c:s<.9?(1-Gt((s-.55)/.35))*c:0,this.ctx.shadowBlur=5,this.ctx.shadowColor=`rgba(30,30,30,0.08)`;for(let e=0;e<c&&!(e>=l);e++){let t=Yt[e];if(t===void 0)continue;let n=Math.min(1,l-e);Jt(this.ctx,o,t[0],t[1],n)}this.ctx.shadowBlur=0}},en={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},tn=([e,t,n])=>{let r=document.createElementNS(`http://www.w3.org/2000/svg`,e);return Object.keys(t).forEach(e=>{r.setAttribute(e,String(t[e]))}),n?.length&&n.forEach(e=>{let t=tn(e);r.appendChild(t)}),r},nn=(e,t={})=>tn([`svg`,{...en,...t},e]),rn=[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`}],[`path`,{d:`M12 22V12`}]],an=[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`}],[`circle`,{cx:`12`,cy:`13`,r:`3`}]],on=[[`path`,{d:`m6 9 6 6 6-6`}]],sn=[[`path`,{d:`m15 18-6-6 6-6`}]],cn=[[`path`,{d:`m9 18 6-6-6-6`}]],ln=[[`path`,{d:`m18 15-6-6-6 6`}]],un=[[`path`,{d:`M15 3h6v6`}],[`path`,{d:`m21 3-7 7`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M9 21H3v-6`}]],dn=[[`path`,{d:`m14 10 7-7`}],[`path`,{d:`M20 10h-6V4`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M4 14h6v6`}]],fn=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}]],pn=[[`circle`,{cx:`11`,cy:`11`,r:`8`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`}]],mn=[[`circle`,{cx:`11`,cy:`11`,r:`8`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`}]];function V(e,{size:t=20,strokeWidth:n=1.75}={}){return nn(e,{width:t,height:t,"stroke-width":n})}var H={ar:e=>V(rn,e),fullscreen:e=>V(un,e),exitFullscreen:e=>V(dn,e),screenshot:e=>V(an,e),tiltUp:e=>V(ln,e),tiltDown:e=>V(on,e),rotateLeft:e=>V(sn,e),rotateRight:e=>V(cn,e),zoomIn:e=>V(pn,e),zoomOut:e=>V(mn,e),reset:e=>V(fn,e)},U=class{element;constructor({variant:e=`default`,size:t=`default`,label:n,icon:r,onClick:i,disabled:a=!1}={}){this.element=document.createElement(`button`),this.element.className=`ui-btn ui-btn--${e} ui-btn--size-${t}`,n!==void 0&&(this.element.setAttribute(`aria-label`,n),this.element.title=n),r===void 0?n!==void 0&&(this.element.textContent=n):this.element.appendChild(r),i&&this.element.addEventListener(`click`,i),this.element.disabled=a}setIcon(e){let t=this.element.querySelector(`svg`);t===null?this.element.appendChild(e):t.replaceWith(e)}},W={brand:{DEFAULT:`#171717`,primary:`#171717`,hover:`#262626`,light:`#f5f5f5`,50:`#fafafa`,100:`#f5f5f5`,200:`#e5e5e5`,300:`#d4d4d4`,400:`#a3a3a3`,500:`#737373`,600:`#525252`,700:`#404040`,800:`#262626`,900:`#171717`,950:`#0a0a0a`},semantic:{success:`#16a34a`,warning:`#ca8a04`,error:`#dc2626`,info:`#0891b2`},neutral:{50:`#fafafa`,100:`#f5f5f5`,200:`#e5e5e5`,300:`#d4d4d4`,400:`#a3a3a3`,500:`#737373`,600:`#525252`,700:`#404040`,800:`#262626`,900:`#171717`,950:`#0a0a0a`},white:`#ffffff`,black:`#000000`},G={px:`1px`,0:`0`,.5:`0.125rem`,1:`0.25rem`,1.5:`0.375rem`,2:`0.5rem`,2.5:`0.625rem`,3:`0.75rem`,3.5:`0.875rem`,4:`1rem`,5:`1.25rem`,6:`1.5rem`,7:`1.75rem`,8:`2rem`,9:`2.25rem`,10:`2.5rem`,12:`3rem`,14:`3.5rem`,16:`4rem`,20:`5rem`,24:`6rem`};G[1],G[2],G[4],G[6],G[8],G[12];var hn=class{element;constructor(){this.element=document.createElement(`div`),Object.assign(this.element.style,{background:W.white,borderRadius:G[3],padding:G[6],boxShadow:`0 ${G[2]} ${G[8]} oklch(0% 0 0 / 20%)`,maxWidth:`20rem`,width:`100%`})}},gn=class{card;backdrop;keyHandler=null;constructor(e={}){this.options=e,this.card=new hn,this.backdrop=this.createBackdrop(),this.backdrop.appendChild(this.card.element)}open(){document.body.appendChild(this.backdrop),this.keyHandler=e=>{e.key===`Escape`&&this.close()},document.addEventListener(`keydown`,this.keyHandler)}close(){this.backdrop.remove(),this.keyHandler!==null&&(document.removeEventListener(`keydown`,this.keyHandler),this.keyHandler=null),this.options.onClose?.()}createBackdrop(){let e=document.createElement(`div`);return Object.assign(e.style,{position:`fixed`,inset:G[0],background:`oklch(0% 0 0 / 50%)`,zIndex:`9999`,display:`flex`,alignItems:`center`,justifyContent:`center`}),e.addEventListener(`click`,t=>{t.target===e&&this.close()}),e}},_n=class{element;selectCallback=null;constructor(e,t,n){this.element=document.createElement(`div`),this.element.className=`ui-toggle-group`;for(let r=0;r<e.length;r++){let i=e[r],a=document.createElement(`button`);a.className=`ui-toggle-group-item`,a.dataset.value=i,a.textContent=n?.[r]??i,a.dataset.state=i===t?`on`:`off`,a.addEventListener(`click`,()=>{this.selectCallback?.(i)}),this.element.appendChild(a)}}setSelected(e){for(let t of this.element.querySelectorAll(`.ui-toggle-group-item`))t.dataset.state=t.dataset.value===e?`on`:`off`}onSelect(e){this.selectCallback=e}},vn=class{element;select;constructor(e,t,n,r,i){this.select=document.createElement(`select`),this.select.className=`ui-native-select`,this.select.dataset.name=e;let a=document.createElement(`option`);a.value=``,a.disabled=!0,a.textContent=n,this.select.appendChild(a);let o=!1;for(let e=0;e<t.length;e++){let n=t[e],a=document.createElement(`option`);a.value=n,a.textContent=i?.[e]??n,n===r&&(a.selected=!0,o=!0),this.select.appendChild(a)}o||(a.selected=!0);let s=nn(on,{width:16,height:16,"stroke-width":2});s.classList.add(`ui-native-select-icon`),this.element=document.createElement(`div`),this.element.className=`ui-native-select-wrap`,this.element.appendChild(this.select),this.element.appendChild(s)}setSelected(e){this.select.value=e}onSelect(e){this.select.addEventListener(`change`,()=>{e(this.select.value)})}},K={fontFamily:{sans:[`Mona Sans`,`ui-sans-serif`,`system-ui`,`sans-serif`,`Apple Color Emoji`,`Segoe UI Emoji`,`Segoe UI Symbol`,`Noto Color Emoji`],mono:[`JetBrains Mono`,`ui-monospace`,`monospace`]},fontSize:{xs:`0.75rem`,sm:`0.875rem`,base:`1rem`,lg:`1.125rem`,xl:`1.25rem`,"2xl":`1.5rem`,"3xl":`1.875rem`,"4xl":`2.25rem`},fontWeight:{normal:`400`,medium:`500`,semibold:`600`,bold:`700`},lineHeight:{tight:`1.25`,normal:`1.5`,relaxed:`1.75`}},yn=s(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),q=s((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),J=s((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),bn=s(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),xn=s(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Sn=s((e=>{var t=q().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Cn=s((e=>{var t=q().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),wn=s((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),Y=s((e=>{var t=J(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Tn=s((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),En=s((e=>{var t=Tn();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Dn=s(((e,t)=>{var n=En();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),On=s((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),kn=s((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
+ ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),X=s((e=>{var t=On(),n=kn();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),An=s((e=>{var t=q(),n=Y(),r=J(),i=X(),a=On(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),jn=s((e=>{var t=q(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),Mn=s(((e,t)=>{var n=X();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),Nn=s(((e,t)=>{var n=X(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),Pn=s(((e,t)=>{var n=X();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),Fn=s(((e,t)=>{var n=X(),r=q();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
+ Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),In=s(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),Ln=s((e=>{var t=X(),n=Mn(),r=Nn(),i=Pn(),a=Fn(),o=kn(),s=q(),c=In();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
+ Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),Rn=s((e=>{var t=q(),n=J(),r=bn(),i=xn(),a=Sn(),o=Cn(),s=wn(),c=Y(),l=Dn(),u=An(),d=jn(),f=X(),p=Ln();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
5
+ The chosen QR Code version cannot contain this amount of data.
6
+ Minimum version required to store current data is: `+c+`.
7
+ `);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),zn=s((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[a[t*i+r]?1:0]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),Bn=s((e=>{var t=zn();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),Vn=s((e=>{var t=zn();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
8
+ `;return typeof a==`function`&&a(null,p),p}})),Hn=s((e=>{var t=yn(),n=Rn(),r=Bn(),i=Vn();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})})),Un=K.fontFamily.sans.join(`, `),Wn=class{qrLib=null;dialog=null;async show(e){this.hide(),this.qrLib??=await Promise.resolve().then(()=>l(Hn(),1));let t=await this.qrLib.toDataURL(e,{width:256,margin:4,errorCorrectionLevel:`M`,color:{dark:W.black,light:W.white}});this.dialog=new gn({onClose:()=>{this.dialog=null}}),Object.assign(this.dialog.card.element.style,{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:G[3],fontFamily:Un}),this.dialog.card.element.appendChild(this.createText(He(),{fontSize:K.fontSize.base,fontWeight:K.fontWeight.semibold,color:W.neutral[900]})),this.dialog.card.element.appendChild(this.createText(Ke(),{fontSize:K.fontSize.sm,color:W.neutral[600]})),this.dialog.card.element.appendChild(this.createQrImage(t)),this.dialog.card.element.appendChild(this.createText(Xe(),{fontSize:K.fontSize.xs,color:W.neutral[500]}));let n=new U({variant:`outline`,label:et(),onClick:()=>{this.hide()}});this.dialog.card.element.appendChild(n.element),this.dialog.open()}hide(){this.dialog?.close(),this.dialog=null}createText(e,t){let n=document.createElement(`p`);return n.textContent=e,Object.assign(n.style,{margin:`0`,textAlign:`center`,...t}),n}createQrImage(e){let t=document.createElement(`img`);return t.src=e,t.alt=`QR code`,Object.assign(t.style,{width:G[24],height:G[24],borderRadius:G[1]}),t}},Z=K.fontFamily.sans.join(`, `),Gn=`
9
+ :root {
10
+ --primary: oklch(5% 0 0);
11
+ --primary-foreground: oklch(100% 0 0);
12
+ --secondary: oklch(92% 0 0);
13
+ --secondary-foreground: oklch(5% 0 0);
14
+ --background: oklch(100% 0 0);
15
+ --foreground: oklch(5% 0 0);
16
+ --border: oklch(92% 0 0);
17
+ --ring: oklch(44% 0 0);
18
+ --radius: 0.625rem;
19
+ --accent: oklch(92% 0 0);
20
+ --accent-foreground: oklch(5% 0 0);
21
+ --muted-foreground: oklch(44% 0 0);
22
+ }
23
+
24
+ /* ── Button ──────────────────────────────────────────────── */
25
+ .ui-btn {
26
+ display: inline-flex;
27
+ align-items: center;
28
+ justify-content: center;
29
+ gap: 0.5rem;
30
+ border: 1px solid transparent;
31
+ border-radius: var(--radius);
32
+ font-family: ${Z};
33
+ font-size: 0.875rem;
34
+ font-weight: 600;
35
+ white-space: nowrap;
36
+ cursor: pointer;
37
+ transition: all 200ms;
38
+ flex-shrink: 0;
39
+ }
40
+ .ui-btn:active { transform: scale(0.98); }
41
+ .ui-btn:disabled { opacity: 0.5; pointer-events: none; }
42
+ .ui-btn svg { inline-size: 1rem; block-size: 1rem; pointer-events: none; flex-shrink: 0; }
43
+
44
+ .ui-btn--default {
45
+ background: var(--primary);
46
+ color: var(--primary-foreground);
47
+ box-shadow: 0 1px 3px oklch(5% 0 0 / 20%);
48
+ }
49
+ .ui-btn--default:hover { background: oklch(10% 0 0); }
50
+
51
+ .ui-btn--outline {
52
+ background: var(--background);
53
+ color: var(--foreground);
54
+ border-color: var(--border);
55
+ box-shadow: 0 1px 2px oklch(5% 0 0 / 8%);
56
+ }
57
+ .ui-btn--outline:hover { background: var(--accent); border-color: oklch(85% 0 0); }
58
+
59
+ .ui-btn--secondary {
60
+ background: var(--secondary);
61
+ color: var(--secondary-foreground);
62
+ box-shadow: 0 1px 2px oklch(5% 0 0 / 8%);
63
+ }
64
+ .ui-btn--secondary:hover { background: oklch(88% 0 0); }
65
+
66
+ .ui-btn--ghost { background: transparent; color: var(--foreground); }
67
+ .ui-btn--ghost:hover { background: var(--accent); }
68
+
69
+ .ui-btn--size-default { block-size: 2.25rem; padding: 0 1rem; }
70
+ .ui-btn--size-sm { block-size: 2rem; padding: 0 0.75rem; border-radius: calc(var(--radius) - 0.125rem); }
71
+ .ui-btn--size-lg { block-size: 2.5rem; padding: 0 1.5rem; }
72
+ .ui-btn--size-icon { inline-size: 2.25rem; block-size: 2.25rem; padding: 0; }
73
+ .ui-btn--size-icon-sm { inline-size: 2rem; block-size: 2rem; padding: 0; }
74
+ .ui-btn--size-icon-lg { inline-size: 2.5rem; block-size: 2.5rem; padding: 0; }
75
+
76
+ /* ── Toggle group ────────────────────────────────────────── */
77
+ .ui-toggle-group { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; }
78
+
79
+ .ui-toggle-group-item {
80
+ display: inline-flex;
81
+ align-items: center;
82
+ justify-content: center;
83
+ block-size: 2rem;
84
+ padding: 0 0.75rem;
85
+ border: 1px solid var(--border);
86
+ border-radius: var(--radius);
87
+ background: var(--background);
88
+ color: var(--foreground);
89
+ font-family: ${Z};
90
+ font-size: 0.875rem;
91
+ font-weight: 600;
92
+ cursor: pointer;
93
+ white-space: nowrap;
94
+ transition: all 200ms;
95
+ box-shadow: 0 1px 2px oklch(5% 0 0 / 8%);
96
+ }
97
+ .ui-toggle-group-item:hover { background: var(--accent); border-color: oklch(85% 0 0); }
98
+ .ui-toggle-group-item:active { transform: scale(0.98); }
99
+ .ui-toggle-group-item[data-state="on"] {
100
+ background: var(--primary);
101
+ color: var(--primary-foreground);
102
+ border-color: var(--primary);
103
+ }
104
+ .ui-toggle-group-item[data-state="on"]:hover { background: oklch(10% 0 0); }
105
+
106
+ /* ── Native select ───────────────────────────────────────── */
107
+ .ui-native-select-wrap {
108
+ position: relative;
109
+ display: inline-flex;
110
+ min-inline-size: 8rem;
111
+ }
112
+
113
+ .ui-native-select {
114
+ display: block;
115
+ inline-size: 100%;
116
+ block-size: 2.25rem;
117
+ padding: 0 2.25rem 0 0.75rem;
118
+ border: 1px solid var(--border);
119
+ border-radius: var(--radius);
120
+ background: var(--background);
121
+ appearance: none;
122
+ color: var(--foreground);
123
+ font-family: ${Z};
124
+ font-size: 0.875rem;
125
+ font-weight: 400;
126
+ cursor: pointer;
127
+ transition: color 200ms, box-shadow 200ms, border-color 200ms;
128
+ box-shadow: 0 1px 2px oklch(5% 0 0 / 8%);
129
+ }
130
+ .ui-native-select:hover { border-color: oklch(85% 0 0); }
131
+ .ui-native-select:focus-visible {
132
+ outline: none;
133
+ border-color: var(--ring);
134
+ box-shadow: 0 0 0 3px oklch(5% 0 0 / 12%);
135
+ }
136
+
137
+ .ui-native-select-icon {
138
+ position: absolute;
139
+ inset-block-start: 50%;
140
+ inset-inline-end: 0.625rem;
141
+ transform: translateY(-50%);
142
+ color: var(--muted-foreground);
143
+ pointer-events: none;
144
+ }
145
+ `,Kn=!1;function qn(){if(Kn||typeof document>`u`)return;Kn=!0;let e=document.createElement(`style`);e.id=`vd-ui-vanilla`,e.textContent=Gn,document.head.appendChild(e)}function Jn(e,t){let n=document.createElement(`a`);n.href=`data:image/png;base64,${e}`,n.download=t,n.click()}var Yn=class{element;screenshotBtn=null;constructor(e){this.options=e,this.element=document.createElement(`div`),this.element.className=`vd-toolbar`}syncButton(e,t,n){if(t&&e===null){let e=n();return this.element.appendChild(e.element),e}return!t&&e!==null?(e.element.remove(),null):e}applySettings(e){this.screenshotBtn=this.syncButton(this.screenshotBtn,e.screenshot===!0,()=>new U({variant:`outline`,size:`icon`,label:gt(),icon:H.screenshot(),onClick:()=>{this.options.snapshotApi.take(`snapshot.png`).onDeveloped(({data:e,filename:t})=>{Jn(e,t)})}}))}},Xn=class{element;arBtn=null;fullscreenBtn=null;onFullscreenChange;constructor(e){this.options=e,this.element=document.createElement(`div`),this.element.className=`vd-action-bar`,this.onFullscreenChange=()=>{if(this.fullscreenBtn===null)return;let e=document.fullscreenElement!==null;this.fullscreenBtn.setIcon(e?H.exitFullscreen():H.fullscreen())},document.addEventListener(`fullscreenchange`,this.onFullscreenChange)}syncButton(e,t,n){if(t&&e===null){let e=n();return this.element.appendChild(e.element),e}return!t&&e!==null?(e.element.remove(),null):e}applySettings(e){this.arBtn=this.syncButton(this.arBtn,e.ar!==!1&&this.options.onAr!==void 0,()=>new U({variant:`outline`,size:`icon`,label:Re(),icon:H.ar(),onClick:()=>{this.options.onAr?.()}})),this.fullscreenBtn=this.syncButton(this.fullscreenBtn,e.fullscreen!==!1&&this.options.onFullscreen!==void 0,()=>new U({variant:`outline`,size:`icon`,label:it(),icon:H.fullscreen(),onClick:()=>{this.options.onFullscreen?.()}}))}destroy(){document.removeEventListener(`fullscreenchange`,this.onFullscreenChange)}},Q=.5,Zn=class e{element;constructor(t,n){this.element=Object.assign(document.createElement(`div`),{className:`vd-camera-controls`});let r=n.rotation,i=n.tilt,a=n.zoom,o=0,s=e=>Math.max(n.limits?.minZoom??1,Math.min(n.limits?.maxZoom??1/0,e)),c=e=>{let t=n.limits?.minRotate,r=n.limits?.maxRotate;return t!==void 0||r!==void 0?Math.max(t??-1/0,Math.min(r??1/0,e)):e},l=e=>{let a=n.limits?.minTilt,s=n.limits?.maxTilt;if(a!==void 0||s!==void 0){i=Math.max(a??0,Math.min(s??180,i+e)),t.tilt(i).set();return}let c=i+e;c>180||c<0?(i=c>180?360-c:-c,o=(o+180)%360,t.tilt(i).rotate(r+o).set()):(i=c,t.tilt(i).set())},u=new U({variant:`outline`,size:`icon`,label:Ot(),icon:H.zoomOut(),onClick:()=>{a=s(a-10),t.zoom(a).set()}}),d=new U({variant:`outline`,size:`icon`,label:wt(),icon:H.zoomIn(),onClick:()=>{a=s(a+10),t.zoom(a).set()}}),f=new U({variant:`outline`,size:`icon`,label:Bt(),icon:H.tiltUp(),onClick:()=>{l(-15)}}),p=new U({variant:`outline`,size:`icon`,label:Mt(),icon:H.rotateLeft(),onClick:()=>{r=c(r-15),t.rotate(r+o).set()}}),m=new U({variant:`outline`,size:`icon`,label:bt(),icon:H.reset(),onClick:()=>{o=0,t.reset()}}),h=new U({variant:`outline`,size:`icon`,label:It(),icon:H.rotateRight(),onClick:()=>{r=c(r+15),t.rotate(r+o).set()}}),g=new U({variant:`outline`,size:`icon`,label:Wt(),icon:H.tiltDown(),onClick:()=>{l(15)}}),_=e=>{let t=n.limits;t!==void 0&&(u.element.disabled=t.minZoom!==void 0&&e.zoom<=t.minZoom+Q,d.element.disabled=t.maxZoom!==void 0&&e.zoom>=t.maxZoom-Q,f.element.disabled=t.minTilt!==void 0&&e.tilt<=t.minTilt+Q,g.element.disabled=t.maxTilt!==void 0&&e.tilt>=t.maxTilt-Q,p.element.disabled=t.minRotate!==void 0&&e.rotation<=t.minRotate+Q,h.element.disabled=t.maxRotate!==void 0&&e.rotation>=t.maxRotate-Q)};n.onChange(e=>{r=e.rotation-o,i=e.tilt,a=e.zoom,_(e)}),this.element.appendChild(e.buildZoom(u,d)),this.element.appendChild(e.buildDpad(f,p,m,h,g))}static buildZoom(e,t){let n=document.createElement(`div`);return n.className=`vd-zoom`,n.appendChild(e.element),n.appendChild(t.element),n}static buildDpad(e,t,n,r,i){let a=document.createElement(`div`);a.className=`vd-dpad`;for(let[o,s]of[[e,`up`],[t,`left`],[n,`center`],[r,`right`],[i,`down`]])o.element.classList.add(`vd-dpad-${s}`),a.appendChild(o.element);return a}},Qn=5;function $(e){let t=e.replace(/([A-Z])/g,` $1`).trim();return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function $n(e,t,n,r,i){let a=document.createElement(`div`);a.className=`vd-attribute`,a.dataset.name=e.name;let o=document.createElement(`span`);o.className=`vd-attribute-label`,o.textContent=$(e.name),a.appendChild(o);let s=e.values.find(n=>t.getValue(e.name,n)?.isSelected===!0),c=e.values.map($),l=e.values.length<=Qn?new _n(e.values,s,c):new vn(e.name,e.values,$(e.name),s,c);return l.onSelect(t=>{n.dispatch(`ui:select`,{attribute:e.name,value:t},!0).defaultPrevented||r(e.name,t)}),i(e.name,t=>{l.setSelected(t.value),n.dispatch(`ui:selected`,{attribute:e.name,value:t.value})}),a.appendChild(l.element),a}var er=K.fontFamily.sans.join(`, `),tr=`
146
+ /* Override browser's default black fullscreen backdrop */
147
+ .vd-container:fullscreen {
148
+ background: oklch(100% 0 0);
149
+ }
150
+
151
+ /* Top-right: screenshot + camera controls */
152
+ .vd-toolbar {
153
+ position: absolute;
154
+ inset-block-start: ${G[3]};
155
+ inset-inline-end: ${G[3]};
156
+ display: flex;
157
+ flex-direction: column;
158
+ align-items: flex-end;
159
+ gap: ${G[1.5]};
160
+ z-index: 10;
161
+ }
162
+
163
+ /* Bottom-right: AR + fullscreen */
164
+ .vd-action-bar {
165
+ position: absolute;
166
+ inset-block-end: ${G[3]};
167
+ inset-inline-end: ${G[3]};
168
+ display: flex;
169
+ flex-direction: row;
170
+ gap: ${G[1.5]};
171
+ z-index: 10;
172
+ }
173
+
174
+ /* Camera controls card inside .vd-toolbar */
175
+ .vd-camera-controls {
176
+ display: flex;
177
+ flex-direction: column;
178
+ gap: ${G[1]};
179
+ background: color-mix(in oklch, ${W.white} 85%, transparent);
180
+ backdrop-filter: blur(8px);
181
+ border-radius: ${G[2]};
182
+ padding: ${G[2]};
183
+ }
184
+
185
+ .vd-zoom {
186
+ display: flex;
187
+ gap: ${G[.5]};
188
+ }
189
+
190
+ .vd-dpad {
191
+ display: grid;
192
+ grid-template-columns: repeat(3, ${G[9]});
193
+ grid-template-rows: repeat(3, ${G[9]});
194
+ gap: ${G[.5]};
195
+ }
196
+
197
+ .vd-dpad-up { grid-column: 2; grid-row: 1; }
198
+ .vd-dpad-left { grid-column: 1; grid-row: 2; }
199
+ .vd-dpad-center { grid-column: 2; grid-row: 2; }
200
+ .vd-dpad-right { grid-column: 3; grid-row: 2; }
201
+ .vd-dpad-down { grid-column: 2; grid-row: 3; }
202
+
203
+ /* Bottom-left: attribute selectors */
204
+ .vd-attributes {
205
+ position: absolute;
206
+ inset-block-end: ${G[3]};
207
+ inset-inline-start: ${G[3]};
208
+ display: flex;
209
+ flex-direction: column;
210
+ gap: ${G[2]};
211
+ background: color-mix(in oklch, ${W.white} 85%, transparent);
212
+ backdrop-filter: blur(8px);
213
+ border-radius: ${G[2]};
214
+ padding: ${G[2]};
215
+ font-family: ${er};
216
+ z-index: 10;
217
+ }
218
+
219
+ .vd-attribute {
220
+ display: flex;
221
+ flex-direction: column;
222
+ gap: ${G[1]};
223
+ }
224
+
225
+ .vd-attribute-label {
226
+ font-size: ${K.fontSize.xs};
227
+ font-weight: ${K.fontWeight.medium};
228
+ color: ${W.neutral[900]};
229
+ font-family: ${er};
230
+ }
231
+
232
+ `;function nr(){if(qn(),document.getElementById(`vd-styles`)!==null)return;let e=document.createElement(`style`);e.id=`vd-styles`,e.textContent=tr,document.head.appendChild(e)}var rr=class{options;settings={};container=null;loading=null;toolbar=null;actionBar=null;cameraControls=null;attributes=null;constructor(e){this.options=e}attach(e){nr(),this.container=e,this.loading=new $t(e),this.toolbar=new Yn({snapshotApi:this.options.snapshotApi}),this.toolbar.applySettings(this.settings),e.appendChild(this.toolbar.element),this.actionBar=new Xn({onAr:this.options.onAr,onFullscreen:()=>{document.fullscreenElement===null?this.container?.requestFullscreen():document.exitFullscreen()}}),this.actionBar.applySettings(this.settings),e.appendChild(this.actionBar.element)}onReady(){this.loading?.hide(),this.loading=null,this.cameraControls!==null&&(this.cameraControls.element.style.display=`flex`),this.attributes!==null&&(this.attributes.style.display=`flex`)}updateProgress(e,t){this.loading?.updateProgress(e,t)}showError(e){this.loading?.showError(e)}applyViewerSettings(e){this.settings=e,e.language!==void 0&&A(e.language),this.toolbar?.applySettings(e),this.actionBar?.applySettings(e),this.cameraControls!==null&&(this.cameraControls.element.style.display=e.cameraControls===!0?`flex`:`none`)}renderAttributeControls(e,t){if(!(this.container===null||this.toolbar===null)&&(this.cameraControls?.element.remove(),this.cameraControls=null,this.attributes?.remove(),this.attributes=null,this.settings.cameraControls===!0&&(this.cameraControls=new Zn(this.options.cameraApi,this.options.cameraPositionApi),this.cameraControls.element.style.display=`none`,this.toolbar.element.appendChild(this.cameraControls.element)),t.length!==0)){this.attributes=document.createElement(`div`),this.attributes.className=`vd-attributes`,this.attributes.style.display=`none`;for(let n of t)this.attributes.appendChild($n(n,e,this.options.eventBus,this.options.onSelect,this.options.onSubscribe));this.container.appendChild(this.attributes)}}get viewerSettings(){return this.settings}destroy(){this.loading?.destroy(),this.toolbar?.element.remove(),this.actionBar?.destroy(),this.actionBar?.element.remove(),this.cameraControls?.element.remove(),this.attributes?.remove(),this.container=null}},ir=class{attributes;readyStateTracker;messenger;cameraApi;cameraPositionApi;snapshotApi;eventBus;ui;qrModal;options;iframe;container;readyCallbacks=[];mutationFailedCallbacks=[];constructor(e){this.options=e,this.initializeLogging(),this.messenger=new ge(()=>this.iframe?.contentWindow??null);let t=e=>{this.messenger.send(e)};this.attributes=new _e(t,(e,t)=>{for(let n of this.mutationFailedCallbacks)n({attribute:e,value:t})}),this.snapshotApi=new xe(t),this.cameraApi=new ve(t),this.cameraPositionApi=new ye,this.eventBus=new Se,this.qrModal=new Wn,this.readyStateTracker=new ne(()=>{let e=this.readyCallbacks;this.readyCallbacks=[];for(let t of e)t(this);this.ui.onReady()}),this.ui=new rr({snapshotApi:this.snapshotApi,cameraApi:this.cameraApi,cameraPositionApi:this.cameraPositionApi,eventBus:this.eventBus,onSelect:(e,t)=>this.attributes.select(e,t),onSubscribe:(e,t)=>this.attributes.onChange(e,t),onAr:()=>{this.qrModal.show(this.iframe?.src??``)}}),this.registerHandlers(),this.messenger.start(),this.createAndConnectIframe()}registerHandlers(){this.messenger.on(w.HANDSHAKE,e=>{ce(e)&&(C.info(`Server handshake received, flushing publisher queue`),this.messenger.markReady())}),this.messenger.on(w.MUTATION,e=>{le(e)&&this.attributes.handleMutationResult(e)}),this.messenger.on(w.SNAPSHOT,e=>{ue(e)&&this.snapshotApi.handleSnapshotResult(e)}),this.messenger.on(w.CAMERA,e=>{de(e)&&this.cameraPositionApi.handlePositionUpdate(e)}),this.messenger.on(w.LOADING_INDICATOR,e=>{pe(e)&&(e.error===void 0?this.ui.updateProgress(e.progress,e.phase):this.ui.showError(e.error))}),this.messenger.on(w.CONFIG,e=>{me(e)&&(e.viewerSettings!==void 0&&this.ui.applyViewerSettings(e.viewerSettings),this.cameraPositionApi.applyLimits(e.cameraLimits))}),this.messenger.on(w.MAPPING,e=>{fe(e)&&(this.attributes.handleMappingReceived(e),this.ui.renderAttributeControls(this.attributes,e.attributes),this.readyStateTracker.handleMappingReceived())})}initializeLogging(){this.options.debug===!0&&ee(),C.info(`Initializing Virtualdisplay client`,{model:this.options.model})}createAndConnectIframe(){let e=new f(this.options).create();this.container=e.container,this.iframe=e.iframe,this.eventBus.attach(this.container),this.ui.attach(this.container)}select(e,t){this.attributes.select(e,t)}getValues(e){return this.attributes.getValues(e)}getValue(e,t){return this.attributes.getValue(e,t)}onChange(e,t){this.attributes.onChange(e,t)}getAttribute(e){return this.attributes.getAttribute(e)}get isReady(){return this.readyStateTracker.isReady}onReady(e){if(this.readyStateTracker.isReady){e(this);return}this.readyCallbacks.push(e)}onMutationFailed(e){this.mutationFailedCallbacks.push(e)}on(e,t){this.eventBus.on(e,t)}get camera(){return this.cameraApi}get cameraPosition(){return this.cameraPositionApi}get snapshot(){return this.snapshotApi}get viewerSettings(){return this.ui.viewerSettings}destroy(){this.readyStateTracker.clear(),this.readyCallbacks=[],this.messenger.destroy(),this.qrModal.hide(),this.ui.destroy(),this.container?.parentElement!==null&&this.container?.parentElement!==void 0&&this.container.parentElement.removeChild(this.container),this.container=void 0,this.iframe=void 0}};e.Attribute=ie,e.AttributeValue=re,e.Camera=ve,e.ERROR_CODES=u,e.Photo=be,e.Snapshot=xe,e.VirtualdisplayClient=ir,e.VirtualdisplayError=d,e.enableDebugMode=ee,e.isDebugMode=te,Object.defineProperty(e,`logger`,{enumerable:!0,get:function(){return C}})});
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@virtualdisplay.io/client",
3
3
  "description": "TypeScript-first 3D model integration library with iframe-based architecture",
4
- "version": "4.0.0-alpha.2",
4
+ "version": "4.0.0-alpha.6",
5
5
  "author": "Virtualdisplay <support@virtualdisplay.io>",
6
6
  "homepage": "https://virtualdisplay.io",
7
7
  "license": "MIT",
8
8
  "type": "module",
9
9
  "exports": {
10
10
  ".": {
11
- "types": "./dist/index.d.ts",
11
+ "types": "./dist/src/index.d.ts",
12
12
  "import": "./dist/virtualdisplay.client.es.js",
13
13
  "require": "./dist/virtualdisplay.client.cjs.js"
14
14
  }
15
15
  },
16
16
  "main": "dist/virtualdisplay.client.cjs.js",
17
17
  "module": "dist/virtualdisplay.client.es.js",
18
- "types": "dist/index.d.ts",
18
+ "types": "dist/src/index.d.ts",
19
19
  "files": [
20
20
  "dist",
21
21
  "CHANGELOG.md"
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { }