@virtualdisplay.io/client 4.0.0-alpha.26 → 4.0.0-alpha.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +125 -14
- package/dist/virtualdisplay.client.cjs.js +12 -12
- package/dist/virtualdisplay.client.es.js +379 -398
- package/dist/virtualdisplay.client.umd.js +15 -15
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c={HANDSHAKE:"handshake",SESSION:"session",MUTATION:"mutation",STATE:"state",LOADING_INDICATOR:"loading_indicator",CAMERA:"camera",SNAPSHOT:"snapshot",MAPPING:"mapping",AR_ACTIVATE:"ar_activate",FULLSCREEN:"fullscreen",CONFIG:"config",ANNOTATION_TOGGLE:"annotation_toggle",FOCUS:"focus",PRICING:"pricing",QR_SHOWN:"qr_shown",SYNC:"sync",SELECTABLE:"selectable",APP_RESOLVED:"app_resolved"},J={FOCUS:"focus",UNFOCUS:"unfocus"},De={FOCUSED:"focused"},$e={HIDDEN:"hidden"},Ue=new Set(Object.values(c));function Be(n){if(typeof n!="object"||n===null)return!1;const e=n;return typeof e.target=="string"?!1:typeof e.type=="string"&&Ue.has(e.type)}function Ve(n){const e=S(n);return e!==null&&e.type===c.HANDSHAKE}function je(n){const e=S(n);return e!==null&&e.type===c.SESSION&&typeof e.sessionId=="string"}function He(n){const e=S(n);return e!==null&&e.type===c.APP_RESOLVED&&typeof e.appType=="string"&&e.appType!==""&&typeof e.name=="string"}function qe(n){const e=S(n);return e!==null&&e.type===c.MUTATION&&Array.isArray(e.results)}function Ge(n){const e=S(n);return e!==null&&e.type===c.SNAPSHOT&&("data"in e||"error"in e)}function Ze(n){const e=S(n);return e!==null&&e.type===c.CAMERA&&Array.isArray(e.transforms)}function We(n){const e=S(n);return e!==null&&e.type===c.MAPPING&&Array.isArray(e.attributes)}function Ye(n){const e=S(n);return e!==null&&e.type===c.LOADING_INDICATOR&&typeof e.progress=="number"}function Qe(n){const e=S(n);return e!==null&&e.type===c.SYNC&&typeof e.connected=="boolean"}function Ke(n){const e=S(n);return e!==null&&e.type===c.SELECTABLE&&Array.isArray(e.attributes)}function Xe(n){const e=S(n);return e!==null&&e.type===c.CONFIG&&typeof e.viewerSettings=="object"}function Je(n){const e=S(n);return e!==null&&e.type===c.FOCUS&&typeof e.state=="string"}function et(n){const e=S(n);return e!==null&&e.type===c.PRICING&&typeof e.pricing=="object"&&e.pricing!==null}function S(n){return typeof n!="object"||n===null?null:n}class ee{constructor(e){this.processor=e}processor;pending=[];isReady=!1;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;const e=[...this.pending];this.pending.length=0;for(const 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}}class tt{constructor(e,t){this.getTarget=e,this.sourceId=`vd-${Math.random().toString(36).slice(2,8)}`,this.targetOrigin="*",this.isValid=t?.isValid??Be,this.publisher=new ee(i=>this.post(i)),this.consumer=new ee(i=>this.routeToHandler(i)),t?.bufferIncoming!==!0&&this.consumer.markReady()}getTarget;handlers=new Map;publisher;consumer;listener=null;sourceId;targetOrigin;isValid;on(e,t){this.handlers.set(e,t)}setTargetOrigin(e){this.targetOrigin=e}send(e){this.publisher.enqueue(e)}receive(e){this.isValid(e)&&this.consumer.enqueue(e)}markReady(){this.publisher.markReady()}markConsumerReady(){this.consumer.markReady()}consumerHasPending(e){return this.consumer.hasPending(e)}start(){this.listener===null&&(this.listener=e=>{const{data:t}=e;if(!this.isValid(t)||t._source===this.sourceId)return;const i=this.getTarget();if(i!==null&&e.source!==null&&e.source!==i)return;const s=t;this.consumer.enqueue(s)},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){const t=this.getTarget();t!==null&&t.postMessage({...e,_source:this.sourceId},this.targetOrigin)}routeToHandler(e){const t=this.handlers.get(e.type);if(t===void 0)return;const i=t(e);i instanceof Promise&&i.catch(s=>{const o=s instanceof Error?s.message:String(s);console.error(`Virtualdisplay: error handling ${e.type}: ${o}`)})}}class me{constructor(e){this.send=e}send;setEnabled(e){this.send({type:c.ANNOTATION_TOGGLE,enabled:e})}}class pe{constructor(e,t){this.value=e,this.attribute=t}value;attribute;isSelectedValue=!1;get isSelected(){return this.isSelectedValue}setSelected(e){this.isSelectedValue=e}}const _={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"};class g extends Error{code;constructor(e,t){super(e),this.name="VirtualdisplayError",this.code=t}static valueNotFound(e,t){return new g(`Value "${t}" not found for attribute "${e}"`,_.VALUE_NOT_FOUND)}static parentNotFound(e){return new g(`Parent element not found: ${e}`,_.PARENT_NOT_FOUND)}static invalidParameter(e){return new g(e,_.INVALID_PARAMETER)}}class fe{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 g.valueNotFound(this.name,e);this.onSelect(this.name,e)}getValues(){return Array.from(this.values.values())}getValue(e){return this.values.get(e)}get selected(){for(const e of this.values.values())if(e.isSelected)return e.value}onChange(e){this.onChangeCallback=e}handleResult(e){let t;for(const i of this.values.values()){const s=i.value===e;i.setSelected(s),s&&(t=i)}t!==void 0&&this.onChangeCallback!==void 0&&this.onChangeCallback(t)}createValues(e){const t=new Map;for(const i of e){const s=new pe(i,this.name);i===this.defaultValue&&s.setSelected(!0),t.set(i,s)}return t}}class nt{attributes=new Map;constructor(e,t,i){for(const s of e){const o=this.buildOptions(s,t);this.attributes.set(s.name,new fe(o))}this.onMutationFailed=i}onMutationFailed;get(e){return this.attributes.get(e)}getSelection(){const e={};for(const[t,i]of this.attributes){const s=i.selected;s!==void 0&&(e[t]=s)}return e}handleResults(e){for(const t of e){if(!t.success){this.onMutationFailed?.(t.name,t.value);continue}this.get(t.name)?.handleResult(t.value)}}buildOptions(e,t){const i={name:e.name,values:e.values,onSelect:(s,o)=>{t([{name:s,value:o}],!1)}};return e.defaultValue!==void 0?{...i,defaultValue:e.defaultValue}:i}}const O=4096,P=16384,it=[1024,256,64],st=20,Z=["timestamp","level","msg","service","trace_id","span_id"];function ot(n){const e=new Date(n.timestamp).toLocaleTimeString("en-GB",{hour12:!1}),t=n.level.toUpperCase().padEnd(5),i=n.trace_id?.slice(0,8)??"--------",s=n.msg,o=Object.entries(n).filter(([r])=>!Z.includes(r)).map(([r,a])=>`${r}=${I(a,O).line}`).join(" ");return`${e} ${t} [${i}] ${s}${o?" "+o:""}`}function rt(n){for(const s of[O,...it]){const{line:o,truncated:r}=I(n,s);if(!r){if(o.length<=P)return o;continue}const{line:a}=I({...n,log_truncated:!0},s);if(a.length<=P)return a}const e=Object.keys(n).filter(s=>!Z.includes(s)),t={...lt(n,Z),log_truncated:!0,log_dropped_count:e.length},i=I({...t,log_dropped_attrs:e.slice(0,st)},O);return i.line.length<=P?i.line:I(t,O).line}function I(n,e){const t=[];let i=!1;return{line:JSON.stringify(n,function(r,a){if(typeof a=="string")return a.length>e&&(i=!0),at(a,e);if(typeof a=="bigint")return a.toString();if(typeof a!="object"||a===null)return a;for(;t.length>0&&t.at(-1)!==this;)t.pop();return t.includes(a)?"[Circular]":(t.push(a),a)}),truncated:i}}function at(n,e){return n.length<=e?n:`${n.slice(0,e)}...[truncated ${n.length-e} chars]`}function lt(n,e){const t={};for(const i of e)n[i]!==void 0&&(t[i]=n[i]);return t}function ct(n,e){const t=e?ot(n):rt(n);n.level==="error"?console.error(t):n.level==="warn"?console.warn(t):console.log(t)}function ge(n,e=0){const t={name:n.name,message:n.message};n.stack!==void 0&&(t.stack=n.stack);for(const i of Object.getOwnPropertyNames(n)){if(i==="name"||i==="message"||i==="stack"||i==="cause")continue;const s=n[i];s!==void 0&&(t[i]=s)}return n.cause!==void 0&&n.cause!==null&&(t.cause=n.cause instanceof Error&&e<5?ge(n.cause,e+1):String(n.cause)),t}function ut(n){const e={};for(const[t,i]of Object.entries(n))e[t]=i instanceof Error?ge(i):i;return e}function dt(){return new Date}function ht(n){return n.toISOString()}function be(){return typeof navigator>"u"?"":navigator.userAgent}function mt(){return typeof navigator>"u"?!1:navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}function pt(){return/iPhone|iPad|iPod/i.test(be())||mt()}function ft(){return/Android/i.test(be())}function gt(){return pt()||ft()}class bt{constructor(e){this.config=e}config;log(e,t,i={}){const s=this.config.traceProvider?.()??{},o={timestamp:ht(dt()),level:e,msg:t,service:this.config.service,...s,...ut(i)};ct(o,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)}}function ve(n,e){const t=e?.isDev!==void 0?e.isDev:typeof process<"u"?process.env.NODE_ENV!=="production":!0;return new bt({service:n,isDev:t,traceProvider:e?.traceProvider})}function L(n){if(n!==void 0)return typeof n=="object"&&n!==null&&!Array.isArray(n)&&!(n instanceof Error)?n:n instanceof Error?{error:n.message}:{value:n}}function ye(n){return{debug:(e,t)=>n.debug(e,L(t)),info:(e,t)=>n.info(e,L(t)),warn:(e,t)=>n.warn(e,L(t)),error:(e,t)=>n.error(e,L(t))}}let Se=!1;exports.logger=ye(ve("client",{isDev:!1}));function we(){Se=!0,exports.logger=ye(ve("client",{isDev:!0}))}function vt(){return Se}class yt{constructor(e,t){this.send=e,this.onMutationFailed=t}send;onMutationFailed;registry;pendingCallbacks=[];handleMappingReceived(e){exports.logger.debug("Initializing from server mapping",{attributeCount:e.attributes.length}),this.registry=new nt(e.attributes,(t,i)=>this.sendMutation(t,i),this.onMutationFailed),this.replayPendingCallbacks()}handleMutationResult(e){this.registry?.handleResults(e.results)}select(e,t){this.sendMutation([{name:e,value:t}],!1)}selectTransient(e,t){this.sendMutation([{name:e,value:t}],!1,!0)}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}const i=this.registry.get(e);if(i===void 0){exports.logger.warn(`onChange: attribute "${e}" not found — callback will not fire`);return}i.onChange(t)}getAttribute(e){return this.registry?.get(e)}getSelection(){return this.registry?.getSelection()??{}}get hasMapping(){return this.registry!==void 0}sendMutation(e,t,i=!1){const s={type:c.MUTATION,mutations:e,isInitial:t,...i&&{transient:!0}};this.send(s)}replayPendingCallbacks(){for(const{name:e,callback:t}of this.pendingCallbacks){const i=this.registry?.get(e);i===void 0&&exports.logger.warn(`onChange: attribute "${e}" not found — buffered callback will not fire`),i?.onChange(t)}this.pendingCallbacks.length=0}}class St{snapshot;callbacks=[];handleSnapshot(e){this.snapshot=e.attributes;for(const t of this.callbacks)t(e.attributes)}onChange(e){this.callbacks.push(e),this.snapshot!==void 0&&e(this.snapshot)}selectableFor(e){return this.snapshot?.find(i=>i.name===e)?.selectable??null}get current(){return this.snapshot??[]}}let Ce=class{constructor(e){this.send=e}send;commands=[];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 g.invalidParameter("No camera commands to execute. Call rotate(), tilt(), or zoom() before set().");const e={type:c.CAMERA,commands:this.commands};this.send(e),this.commands=[]}validateFiniteNumber(e,t){if(!Number.isFinite(e))throw g.invalidParameter(`${t}() requires a finite number, got ${String(e)}`)}reset(){const e={type:c.CAMERA,commands:[{action:"reset"}]};this.send(e)}};class wt{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;const t={rotation:this.rotation,tilt:this.tilt,zoom:this.zoom};for(const i of this.changeCallbacks)i(t)}handlePositionUpdate(e){this.update(e.transforms)}update(e){let t=!1;for(const i of e)switch(i.type){case"rotation":this.state.rotation=i.value,t=!0;break;case"tilt":this.state.tilt=i.value,t=!0;break;case"zoom":this.state.zoom=i.value,t=!0;break}if(t){const i={rotation:this.rotation,tilt:this.tilt,zoom:this.zoom};for(const s of this.changeCallbacks)s(i)}}}function Ct(n,e){const t=n.filter(o=>_t(o,e));if(t.length===0)return;const i=Math.max(...t.map(te)),s=t.filter(o=>te(o)===i);return s.length===1?s[0]:void 0}function _t(n,e){return Object.entries(n.attributes).every(([t,i])=>e[t]===i)}function te(n){return Object.keys(n.attributes).length}class _e{constructor(e,t){this.dispatchChange=e,this.dispatchSubmit=t}dispatchChange;dispatchSubmit;pricing;selection={};resolved;changeCallbacks=[];renderCallbacks=[];submitCallback;submitDefaultLabel;get current(){return this.resolved}get vatDisplay(){return this.pricing?.vatDisplay}get buttonLabel(){const e=this.pricing?.buttonLabel;if(e!=null&&e!=="")return e;if(this.submitDefaultLabel!==void 0&&this.submitDefaultLabel!=="")return this.submitDefaultLabel}get submittable(){return this.submitCallback===void 0?!1:this.pricing===void 0?!0:this.resolved?.availability==="available"}get submitEnabled(){return this.submittable&&this.buttonLabel!==void 0}onChange(e){this.changeCallbacks.push(e)}onSubmit(e,t){this.submitCallback=e,this.submitDefaultLabel=t?.defaultLabel,this.notifyRender()}onRender(e){return this.renderCallbacks.push(e),()=>{const t=this.renderCallbacks.indexOf(e);t!==-1&&this.renderCallbacks.splice(t,1)}}async submit(){if(!this.submittable)return;const e=this.resolved!==void 0?{attributes:this.resolved.attributes,reference:this.resolved.reference}:{attributes:{...this.selection},reference:""};this.dispatchSubmit(e),await this.submitCallback?.(e)}handlePricingReceived(e){this.pricing=e,this.recompute()}handleSelectionChanged(e){this.selection=e,this.recompute()}recompute(){this.resolved=this.resolve();for(const e of this.changeCallbacks)e(this.resolved);this.dispatchChange(this.resolved),this.notifyRender()}notifyRender(){for(const e of this.renderCallbacks)e()}resolve(){if(this.pricing===void 0)return;const e=Ct(this.pricing.rules,this.selection);if(!(e===void 0||e.availability===$e.HIDDEN))return{attributes:{...this.selection},reference:e.reference,price:e.priceCents,currency:this.pricing.currency,availability:e.availability}}}class ke{constructor(e,t){this.send=e,this.dispatch=t}send;dispatch;focused=null;attributes=[];changeCallbacks=[];get current(){return this.focused}set(e){if(typeof e!="string"||e.length===0)throw g.invalidParameter(`set() requires a non-empty component name, got ${String(e)}`);this.send({type:c.FOCUS,action:J.FOCUS,component:e})}clear(){this.send({type:c.FOCUS,action:J.UNFOCUS})}onChange(e){this.changeCallbacks.push(e)}handleStateReceived(e){e.state===De.FOCUSED&&e.component!==void 0?(this.focused=e.component,this.attributes=e.attributes??[]):(this.focused=null,this.attributes=[]);const t=this.focused!==null?{component:this.focused,attributes:this.attributes}:null;for(const i of this.changeCallbacks)i(t);this.dispatch(t)}}class Ae{constructor(e){this.filename=e}filename;developedCallbacks=new Set;errorCallbacks=new Set;developed=!1;failed=!1;photoData=null;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(t=>{t(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())}}const ne=3e4;class Ee{constructor(e){this.send=e}send;validExtensions=[".png"];pendingPhotos=new Map;take(e){this.validateFilename(e),exports.logger.debug("Taking snapshot",{filename:e});const t=new Ae(e),i=setTimeout(()=>{this.pendingPhotos.delete(e),exports.logger.warn("Snapshot timed out",{filename:e}),t.fail(new g(`Snapshot timed out: the viewer did not respond within ${ne}ms`,_.SNAPSHOT_FAILED))},ne);return this.pendingPhotos.set(e,{photo:t,timeout:i}),this.send({type:c.SNAPSHOT,filename:e}),t}handleSnapshotResult(e){const t=this.pendingPhotos.get(e.filename);if(t===void 0){exports.logger.warn("No pending photo found for filename",{filename:e.filename,pendingFilenames:Array.from(this.pendingPhotos.keys())});return}clearTimeout(t.timeout),this.pendingPhotos.delete(e.filename);const{photo:i}=t;if(e.error!==void 0){i.fail(new g(e.error,_.SNAPSHOT_FAILED));return}e.data!==void 0&&i.develop({filename:e.filename,data:e.data})}clear(){if(this.pendingPhotos.size===0)return;const e=new g("Client destroyed before snapshot completed",_.SNAPSHOT_FAILED);for(const{photo:t,timeout:i}of this.pendingPhotos.values())clearTimeout(i),t.fail(e);this.pendingPhotos.clear()}validateFilename(e){if(e===""||typeof e!="string")throw new g("Filename must be a non-empty string",_.INVALID_PARAMETER);if(!this.validExtensions.some(i=>e.toLowerCase().endsWith(i)))throw new g(`Invalid filename: "${e}". Filename must end with one of: ${this.validExtensions.join(", ")}`,_.INVALID_PARAMETER);if(e.includes("..")||e.includes("/")||e.includes("\\"))throw new g('Filename cannot contain path separators or ".."',_.INVALID_PARAMETER)}}class kt{container=null;attach(e){this.container=e}dispatch(e,t,i=!1){const s=new CustomEvent(e,{detail:t,cancelable:i});return this.container?.dispatchEvent(s),s}on(e,t){const i=s=>{const o=s,r={...o.detail,preventDefault:()=>{o.preventDefault()}};t(r)};return this.container?.addEventListener(e,i),()=>{this.container?.removeEventListener(e,i)}}}const At={},Et="en",xe=["en","nl","de"],Q=["baseLocale"],ie=[],W=typeof window>"u";globalThis.__paraglide=globalThis.__paraglide??{};globalThis.__paraglide.ssr=globalThis.__paraglide.ssr??{};let se=!1,m=()=>{let n=Q;!W&&typeof window<"u"&&window.location?.href&&(n=Re(window.location.href));const e=xt(n);if(e)return se||(se=!0,Te(e,{reload:!1})),e;throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found")};function xt(n,e){let t;for(const i of n){if(i==="baseLocale")t=Et;else if(Ie(i)&&M.has(i)){const o=M.get(i);if(o){const r=o.getLocale();if(r instanceof Promise)continue;if(r!==void 0)return It(r)}}const s=K(t);if(s)return s}}const Tt=n=>{window.location.reload()};let Te=(n,e)=>{const t={reload:!0,...e};let i;try{i=m()}catch{}const s=[];let o=Q;!W&&typeof window<"u"&&window.location?.href&&(o=Re(window.location.href));for(const a of o)if(a!=="baseLocale"&&Ie(a)&&M.has(a)){const u=M.get(a);if(u){let d=u.setLocale(n);d instanceof Promise&&(d=d.catch(f=>{throw new Error(`Custom strategy "${a}" setLocale failed.`,{cause:f})}),s.push(d))}}const r=()=>{!W&&t.reload&&window.location&&n!==i&&Tt()};if(s.length)return Promise.all(s).then(()=>{r()});r()},Rt=()=>typeof window<"u"?window.location.origin:"http://fallback.com";function K(n){if(typeof n!="string")return;const e=n.toLowerCase();for(const t of xe)if(t.toLowerCase()===e)return t}function It(n){const e=K(n);if(e)return e;throw new Error(`Invalid locale: ${n}. Expected one of: ${xe.join(", ")}`)}function Lt(n){return Ot(n)}function Ot(n){const e=typeof n=="string"?new URL(n,Rt()):new URL(n),t=e.pathname.split("/").filter(Boolean);return t.length>0&&K(t[0])&&(e.pathname="/"+t.slice(1).join("/")),e}let oe,re;function Mt(n){if(ie.length===0)return;const e=typeof n=="string"?n:n.href;if(oe===e)return re;const t=new URL(e,"http://example.com"),i=Lt(t),s=i.href===t.href?[t]:[t,i];let o;for(const r of s){for(const a of ie)if(new At(a.match,r.href).exec(r.href)){o=a;break}if(o)break}return oe=e,re=o,o}function Re(n){const e=Mt(n);return e&&e.exclude!==!0&&Array.isArray(e.strategy)?e.strategy:Q}const M=new Map;function Ie(n){return typeof n=="string"&&/^custom-[A-Za-z0-9_-]+$/.test(n)}const Nt=()=>"Activate AR",zt=()=>"AR activeren",Pt=()=>"AR aktivieren",Ft=((n={},e={})=>{const t=e.locale??m();return t==="nl"?zt():t==="de"?Pt():Nt()}),Dt=()=>"Scan to view in AR",$t=()=>"Scan om in AR te bekijken",Ut=()=>"Scannen für AR-Ansicht",Bt=((n={},e={})=>{const t=e.locale??m();return t==="nl"?$t():t==="de"?Ut():Dt()}),Vt=()=>"Use your smartphone camera to scan this QR code",jt=()=>"Gebruik de camera van je smartphone om deze QR-code te scannen",Ht=()=>"Verwende die Kamera deines Smartphones, um diesen QR-Code zu scannen",qt=((n={},e={})=>{const t=e.locale??m();return t==="nl"?jt():t==="de"?Ht():Vt()}),Gt=()=>"Your phone will open the 3D model in AR mode.",Zt=()=>"Je telefoon opent het 3D-model in AR-modus.",Wt=()=>"Dein Telefon öffnet das 3D-Modell im AR-Modus.",Yt=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Zt():t==="de"?Wt():Gt()}),Qt=()=>"Close",Kt=()=>"Sluiten",Xt=()=>"Schließen",Jt=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Kt():t==="de"?Xt():Qt()}),en=()=>"Fullscreen",tn=()=>"Volledig scherm",nn=()=>"Vollbild",sn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?tn():t==="de"?nn():en()}),on=()=>"Downloading",rn=()=>"Downloaden",an=()=>"Herunterladen",Le=((n={},e={})=>{const t=e.locale??m();return t==="nl"?rn():t==="de"?an():on()}),ln=()=>"Rendering",cn=()=>"Renderen",un=()=>"Rendern",dn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?cn():t==="de"?un():ln()}),hn=()=>"Screenshot",mn=()=>"Screenshot",pn=()=>"Screenshot",fn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?mn():t==="de"?pn():hn()}),gn=()=>"Configure",bn=()=>"Configureren",vn=()=>"Konfigurieren",yn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?bn():t==="de"?vn():gn()}),Sn=()=>"Close",wn=()=>"Sluiten",Cn=()=>"Schließen",_n=((n={},e={})=>{const t=e.locale??m();return t==="nl"?wn():t==="de"?Cn():Sn()}),kn=()=>"Reset camera",An=()=>"Camera resetten",En=()=>"Kamera zurücksetzen",xn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?An():t==="de"?En():kn()}),Tn=()=>"Zoom in",Rn=()=>"Inzoomen",In=()=>"Hineinzoomen",Ln=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Rn():t==="de"?In():Tn()}),On=()=>"Zoom out",Mn=()=>"Uitzoomen",Nn=()=>"Herauszoomen",zn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Mn():t==="de"?Nn():On()}),Pn=()=>"Rotate left",Fn=()=>"Naar links draaien",Dn=()=>"Nach links drehen",$n=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Fn():t==="de"?Dn():Pn()}),Un=()=>"Rotate right",Bn=()=>"Naar rechts draaien",Vn=()=>"Nach rechts drehen",jn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Bn():t==="de"?Vn():Un()}),Hn=()=>"Tilt up",qn=()=>"Omhoog kantelen",Gn=()=>"Nach oben kippen",Zn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?qn():t==="de"?Gn():Hn()}),Wn=()=>"Tilt down",Yn=()=>"Omlaag kantelen",Qn=()=>"Nach unten kippen",Kn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Yn():t==="de"?Qn():Wn()}),Xn=()=>"Working…",Jn=()=>"Bezig…",ei=()=>"Läuft…",ti=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Jn():t==="de"?ei():Xn()}),ni=()=>"Done",ii=()=>"Gelukt",si=()=>"Fertig",oi=((n={},e={})=>{const t=e.locale??m();return t==="nl"?ii():t==="de"?si():ni()}),ri=()=>"Failed",ai=()=>"Mislukt",li=()=>"Fehlgeschlagen",ci=((n={},e={})=>{const t=e.locale??m();return t==="nl"?ai():t==="de"?li():ri()});const ui={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"};const Oe=([n,e,t])=>{const i=document.createElementNS("http://www.w3.org/2000/svg",n);return Object.keys(e).forEach(s=>{i.setAttribute(s,String(e[s]))}),t?.length&&t.forEach(s=>{const o=Oe(s);i.appendChild(o)}),i},Me=(n,e={})=>{const i={...ui,...e};return Oe(["svg",i,n])};const di=[["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"}]];const hi=[["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"}]];const Ne=[["path",{d:"m6 9 6 6 6-6"}]];const mi=[["path",{d:"m15 18-6-6 6-6"}]];const pi=[["path",{d:"m9 18 6-6-6-6"}]];const fi=[["path",{d:"m18 15-6-6-6 6"}]];const gi=[["path",{d:"M15 3h6v6"}],["path",{d:"m21 3-7 7"}],["path",{d:"m3 21 7-7"}],["path",{d:"M9 21H3v-6"}]];const bi=[["path",{d:"m14 10 7-7"}],["path",{d:"M20 10h-6V4"}],["path",{d:"m3 21 7-7"}],["path",{d:"M4 14h6v6"}]];const vi=[["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"}]];const yi=[["path",{d:"M10 5H3"}],["path",{d:"M12 19H3"}],["path",{d:"M14 3v4"}],["path",{d:"M16 17v4"}],["path",{d:"M21 12h-9"}],["path",{d:"M21 19h-5"}],["path",{d:"M21 5h-7"}],["path",{d:"M8 10v4"}],["path",{d:"M8 12H3"}]];const Si=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];const wi=[["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"}]];const Ci=[["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 y(n,{size:e=20,strokeWidth:t=1.75}={}){return Me(n,{width:e,height:e,"stroke-width":t})}const b={ar:n=>y(di,n),fullscreen:n=>y(gi,n),exitFullscreen:n=>y(bi,n),screenshot:n=>y(hi,n),tiltUp:n=>y(fi,n),tiltDown:n=>y(Ne,n),rotateLeft:n=>y(mi,n),rotateRight:n=>y(pi,n),zoomIn:n=>y(wi,n),zoomOut:n=>y(Ci,n),reset:n=>y(vi,n),configurator:n=>y(yi,n),close:n=>y(Si,n)};class v{element;constructor({variant:e="default",size:t="default",label:i,icon:s,onClick:o,disabled:r=!1}={}){this.element=document.createElement("button"),this.element.className=`ui-btn ui-btn--${e} ui-btn--size-${t}`,i!==void 0&&(this.element.setAttribute("aria-label",i),this.element.title=i),s!==void 0?this.element.appendChild(s):i!==void 0&&(this.element.textContent=i),o&&this.element.addEventListener("click",o),this.element.disabled=r}setIcon(e){const t=this.element.querySelector("svg");t!==null?t.replaceWith(e):this.element.appendChild(e)}}const p={semantic:{error:"#dc2626"},neutral:{500:"#737373",600:"#525252",900:"#171717"},white:"#ffffff",black:"#000000"},l={0:"0",.5:"0.125rem",1:"0.25rem",1.5:"0.375rem",2:"0.5rem",3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",8:"2rem",9:"2.25rem"};class _i{element;constructor(){this.element=document.createElement("div"),Object.assign(this.element.style,{background:p.white,borderRadius:l[3],padding:l[6],boxShadow:`0 ${l[2]} ${l[8]} oklch(0% 0 0 / 20%)`,maxWidth:"20rem",width:"100%"})}}class ki{constructor(e={}){this.options=e,this.card=new _i,this.backdrop=this.createBackdrop(),this.backdrop.appendChild(this.card.element)}options;card;backdrop;keyHandler=null;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(){const e=document.createElement("div");return Object.assign(e.style,{position:"fixed",inset:l[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}}class Ai{element;selectCallback=null;constructor(e,t,i){this.element=document.createElement("div"),this.element.className="ui-toggle-group";for(let s=0;s<e.length;s++){const o=e[s],r=document.createElement("button");r.className="ui-toggle-group-item",r.dataset.value=o,r.textContent=i?.[s]??o,r.dataset.state=o===t?"on":"off",r.setAttribute("aria-pressed",o===t?"true":"false"),r.addEventListener("click",()=>{this.selectCallback?.(o)}),this.element.appendChild(r)}}setSelected(e){for(const t of this.element.querySelectorAll(".ui-toggle-group-item")){const i=t.dataset.value===e;t.dataset.state=i?"on":"off",t.setAttribute("aria-pressed",i?"true":"false")}}onSelect(e){this.selectCallback=e}setEnabled(e){for(const t of this.element.querySelectorAll(".ui-toggle-group-item")){const i=e===null||e.includes(t.dataset.value??"");t.disabled=!i,t.setAttribute("aria-disabled",i?"false":"true")}}}class Ei{element;select;constructor(e,t,i,s,o){this.select=document.createElement("select"),this.select.className="ui-native-select",this.select.dataset.name=e,this.select.setAttribute("aria-label",i);const r=document.createElement("option");r.value="",r.disabled=!0,r.textContent=i,this.select.appendChild(r);let a=!1;for(let d=0;d<t.length;d++){const f=t[d],h=document.createElement("option");h.value=f,h.textContent=o?.[d]??f,f===s&&(h.selected=!0,a=!0),this.select.appendChild(h)}a||(r.selected=!0);const u=Me(Ne,{width:16,height:16,"stroke-width":2});u.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(u)}setSelected(e){this.select.value=e}onSelect(e){this.select.addEventListener("change",()=>{e(this.select.value)})}setEnabled(e){for(const t of this.select.options)t.value!==""&&(t.disabled=e!==null&&!e.includes(t.value))}}class xi{element;input;valueText;values;options;selectCallback=null;settleCallback=null;constructor(e,t){if(e.length===0)throw new Error("Virtualdisplay: Slider needs at least one value");this.values=e,this.options=t,this.input=document.createElement("input"),this.input.type="range",this.input.className="ui-slider-input",this.input.min="0",this.input.max=String(e.length-1),this.input.step="1",this.input.setAttribute("aria-label",t.label),this.valueText=document.createElement("span"),this.valueText.className="ui-slider-value",this.valueText.setAttribute("aria-hidden","true");const i=document.createElement("div");i.className="ui-slider-track",i.appendChild(this.input),i.appendChild(this.buildEnds()),this.element=document.createElement("div"),this.element.className="ui-slider",this.element.appendChild(i),this.element.appendChild(this.valueText);const s=t.initialSelected===void 0?0:e.indexOf(t.initialSelected);this.applyIndex(s===-1?0:s),this.listen()}setSelected(e){const t=this.values.indexOf(e);t!==-1&&this.applyIndex(t)}onSelect(e){this.selectCallback=e}onSettle(e){this.settleCallback=e}listen(){this.input.addEventListener("input",()=>{const e=this.values[this.currentIndex];e!==void 0&&(this.applyIndex(this.currentIndex),this.selectCallback?.(e))}),this.input.addEventListener("change",()=>{const e=this.values[this.currentIndex];e!==void 0&&this.settleCallback?.(e)})}get currentIndex(){return Number(this.input.value)}applyIndex(e){this.input.value=String(e);const t=this.displayAt(e);this.valueText.textContent=t,this.input.setAttribute("aria-valuetext",t);const i=this.values.length===1?100:e/(this.values.length-1)*100;this.element.style.setProperty("--ui-slider-pct",`${i}%`)}buildEnds(){const e=document.createElement("div");e.className="ui-slider-ends",e.setAttribute("aria-hidden","true");for(const t of[0,this.values.length-1]){const i=document.createElement("span");i.textContent=this.labelAt(t),e.appendChild(i)}return e}labelAt(e){return this.options.labels?.[e]??this.values[e]??""}displayAt(e){const t=this.labelAt(e);return this.options.unit===void 0?t:`${t} ${this.options.unit}`}}const w={fontFamily:{sans:["Mona Sans","ui-sans-serif","system-ui","sans-serif","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"]},fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem"},fontWeight:{medium:"500",semibold:"600"}},E=w.fontFamily.sans.join(", "),Ti=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c={HANDSHAKE:"handshake",SESSION:"session",MUTATION:"mutation",STATE:"state",LOADING_INDICATOR:"loading_indicator",CAMERA:"camera",SNAPSHOT:"snapshot",MAPPING:"mapping",AR_ACTIVATE:"ar_activate",FULLSCREEN:"fullscreen",CONFIG:"config",ANNOTATION_TOGGLE:"annotation_toggle",FOCUS:"focus",PRICING:"pricing",QR_SHOWN:"qr_shown",SYNC:"sync",SELECTABLE:"selectable",APP_RESOLVED:"app_resolved"},P="main",ee={FOCUS:"focus",UNFOCUS:"unfocus"},De={FOCUSED:"focused"},$e={HIDDEN:"hidden"},Ue=new Set(Object.values(c));function Be(n){if(typeof n!="object"||n===null)return!1;const e=n;return typeof e.target=="string"?!1:typeof e.type=="string"&&Ue.has(e.type)}function Ve(n){const e=S(n);return e!==null&&e.type===c.HANDSHAKE}function je(n){const e=S(n);return e!==null&&e.type===c.SESSION&&typeof e.sessionId=="string"}function He(n){const e=S(n);return e!==null&&e.type===c.APP_RESOLVED&&typeof e.appType=="string"&&e.appType!==""&&typeof e.name=="string"}function qe(n){const e=S(n);return e!==null&&e.type===c.MUTATION&&typeof e.instance=="string"&&e.instance!==""&&Array.isArray(e.results)}function Ge(n){const e=S(n);return e!==null&&e.type===c.SNAPSHOT&&("data"in e||"error"in e)}function Ze(n){const e=S(n);return e!==null&&e.type===c.CAMERA&&Array.isArray(e.transforms)}function We(n){const e=S(n);return e!==null&&e.type===c.MAPPING&&typeof e.instance=="string"&&e.instance!==""&&Array.isArray(e.attributes)}function Ye(n){const e=S(n);return e!==null&&e.type===c.LOADING_INDICATOR&&typeof e.progress=="number"}function Qe(n){const e=S(n);return e!==null&&e.type===c.SYNC&&typeof e.connected=="boolean"}function Ke(n){const e=S(n);return e!==null&&e.type===c.SELECTABLE&&typeof e.instance=="string"&&e.instance!==""&&Array.isArray(e.attributes)}function Xe(n){const e=S(n);return e!==null&&e.type===c.CONFIG&&typeof e.viewerSettings=="object"}function Je(n){const e=S(n);return e!==null&&e.type===c.FOCUS&&typeof e.instance=="string"&&e.instance!==""&&typeof e.state=="string"}function et(n){const e=S(n);return e!==null&&e.type===c.PRICING&&typeof e.instance=="string"&&e.instance!==""&&typeof e.pricing=="object"&&e.pricing!==null}function S(n){return typeof n!="object"||n===null?null:n}class te{constructor(e){this.processor=e}processor;pending=[];isReady=!1;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;const e=[...this.pending];this.pending.length=0;for(const 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}}class tt{constructor(e,t){this.getTarget=e,this.sourceId=`vd-${Math.random().toString(36).slice(2,8)}`,this.targetOrigin="*",this.isValid=t?.isValid??Be,this.publisher=new te(i=>this.post(i)),this.consumer=new te(i=>this.routeToHandler(i)),t?.bufferIncoming!==!0&&this.consumer.markReady()}getTarget;handlers=new Map;publisher;consumer;listener=null;sourceId;targetOrigin;isValid;on(e,t){this.handlers.set(e,t)}setTargetOrigin(e){this.targetOrigin=e}send(e){this.publisher.enqueue(e)}receive(e){this.isValid(e)&&this.consumer.enqueue(e)}markReady(){this.publisher.markReady()}markConsumerReady(){this.consumer.markReady()}consumerHasPending(e){return this.consumer.hasPending(e)}start(){this.listener===null&&(this.listener=e=>{const{data:t}=e;if(!this.isValid(t)||t._source===this.sourceId)return;const i=this.getTarget();if(i!==null&&e.source!==null&&e.source!==i)return;const s=t;this.consumer.enqueue(s)},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()}post(e){const t=this.getTarget();t!==null&&t.postMessage({...e,_source:this.sourceId},this.targetOrigin)}routeToHandler(e){const t=this.handlers.get(e.type);if(t===void 0)return;const i=t(e);i instanceof Promise&&i.catch(s=>{const o=s instanceof Error?s.message:String(s);console.error(`Virtualdisplay: error handling ${e.type}: ${o}`)})}}class pe{constructor(e,t){this.send=e,this.instance=t}send;instance;setEnabled(e){this.send({type:c.ANNOTATION_TOGGLE,instance:this.instance,enabled:e})}}class fe{constructor(e,t){this.value=e,this.attribute=t}value;attribute;isSelectedValue=!1;get isSelected(){return this.isSelectedValue}setSelected(e){this.isSelectedValue=e}}const k={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"};class g extends Error{code;constructor(e,t){super(e),this.name="VirtualdisplayError",this.code=t}static valueNotFound(e,t){return new g(`Value "${t}" not found for attribute "${e}"`,k.VALUE_NOT_FOUND)}static parentNotFound(e){return new g(`Parent element not found: ${e}`,k.PARENT_NOT_FOUND)}static invalidParameter(e){return new g(e,k.INVALID_PARAMETER)}}class ge{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 g.valueNotFound(this.name,e);this.onSelect(this.name,e)}getValues(){return Array.from(this.values.values())}getValue(e){return this.values.get(e)}get selected(){for(const e of this.values.values())if(e.isSelected)return e.value}onChange(e){this.onChangeCallback=e}handleResult(e){let t;for(const i of this.values.values()){const s=i.value===e;i.setSelected(s),s&&(t=i)}t!==void 0&&this.onChangeCallback!==void 0&&this.onChangeCallback(t)}createValues(e){const t=new Map;for(const i of e){const s=new fe(i,this.name);i===this.defaultValue&&s.setSelected(!0),t.set(i,s)}return t}}class nt{attributes=new Map;constructor(e,t,i){for(const s of e){const o=this.buildOptions(s,t);this.attributes.set(s.name,new ge(o))}this.onMutationFailed=i}onMutationFailed;get(e){return this.attributes.get(e)}getSelection(){const e={};for(const[t,i]of this.attributes){const s=i.selected;s!==void 0&&(e[t]=s)}return e}handleResults(e){for(const t of e){if(!t.success){this.onMutationFailed?.(t.name,t.value);continue}this.get(t.name)?.handleResult(t.value)}}buildOptions(e,t){const i={name:e.name,values:e.values,onSelect:(s,o)=>{t([{name:s,value:o}],!1)}};return e.defaultValue!==void 0?{...i,defaultValue:e.defaultValue}:i}}const L=4096,F=16384,it=[1024,256,64],st=20,W=["timestamp","level","msg","service","trace_id","span_id"];function ot(n){const e=new Date(n.timestamp).toLocaleTimeString("en-GB",{hour12:!1}),t=n.level.toUpperCase().padEnd(5),i=n.trace_id?.slice(0,8)??"--------",s=n.msg,o=Object.entries(n).filter(([r])=>!W.includes(r)).map(([r,a])=>`${r}=${I(a,L).line}`).join(" ");return`${e} ${t} [${i}] ${s}${o?" "+o:""}`}function rt(n){for(const s of[L,...it]){const{line:o,truncated:r}=I(n,s);if(!r){if(o.length<=F)return o;continue}const{line:a}=I({...n,log_truncated:!0},s);if(a.length<=F)return a}const e=Object.keys(n).filter(s=>!W.includes(s)),t={...lt(n,W),log_truncated:!0,log_dropped_count:e.length},i=I({...t,log_dropped_attrs:e.slice(0,st)},L);return i.line.length<=F?i.line:I(t,L).line}function I(n,e){const t=[];let i=!1;return{line:JSON.stringify(n,function(r,a){if(typeof a=="string")return a.length>e&&(i=!0),at(a,e);if(typeof a=="bigint")return a.toString();if(typeof a!="object"||a===null)return a;for(;t.length>0&&t.at(-1)!==this;)t.pop();return t.includes(a)?"[Circular]":(t.push(a),a)}),truncated:i}}function at(n,e){return n.length<=e?n:`${n.slice(0,e)}...[truncated ${n.length-e} chars]`}function lt(n,e){const t={};for(const i of e)n[i]!==void 0&&(t[i]=n[i]);return t}function ct(n,e){const t=e?ot(n):rt(n);n.level==="error"?console.error(t):n.level==="warn"?console.warn(t):console.log(t)}function be(n,e=0){const t={name:n.name,message:n.message};n.stack!==void 0&&(t.stack=n.stack);for(const i of Object.getOwnPropertyNames(n)){if(i==="name"||i==="message"||i==="stack"||i==="cause")continue;const s=n[i];s!==void 0&&(t[i]=s)}return n.cause!==void 0&&n.cause!==null&&(t.cause=n.cause instanceof Error&&e<5?be(n.cause,e+1):String(n.cause)),t}function ut(n){const e={};for(const[t,i]of Object.entries(n))e[t]=i instanceof Error?be(i):i;return e}function dt(){return new Date}function ht(n){return n.toISOString()}function ve(){return typeof navigator>"u"?"":navigator.userAgent}function mt(){return typeof navigator>"u"?!1:navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}function pt(){return/iPhone|iPad|iPod/i.test(ve())||mt()}function ft(){return/Android/i.test(ve())}function gt(){return pt()||ft()}class bt{constructor(e){this.config=e}config;log(e,t,i={}){const s=this.config.traceProvider?.()??{},o={timestamp:ht(dt()),level:e,msg:t,service:this.config.service,...s,...ut(i)};ct(o,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)}}function ye(n,e){const t=e?.isDev!==void 0?e.isDev:typeof process<"u"?process.env.NODE_ENV!=="production":!0;return new bt({service:n,isDev:t,traceProvider:e?.traceProvider})}function O(n){if(n!==void 0)return typeof n=="object"&&n!==null&&!Array.isArray(n)&&!(n instanceof Error)?n:n instanceof Error?{error:n.message}:{value:n}}function Se(n){return{debug:(e,t)=>n.debug(e,O(t)),info:(e,t)=>n.info(e,O(t)),warn:(e,t)=>n.warn(e,O(t)),error:(e,t)=>n.error(e,O(t))}}let we=!1;exports.logger=Se(ye("client",{isDev:!1}));function Ce(){we=!0,exports.logger=Se(ye("client",{isDev:!0}))}function vt(){return we}class yt{constructor(e,t,i){this.send=e,this.instance=t,this.onMutationFailed=i}send;instance;onMutationFailed;registry;pendingCallbacks=[];handleMappingReceived(e){exports.logger.debug("Initializing from server mapping",{attributeCount:e.attributes.length}),this.registry=new nt(e.attributes,(t,i)=>this.sendMutation(t,i),this.onMutationFailed),this.replayPendingCallbacks()}handleMutationResult(e){this.registry?.handleResults(e.results)}select(e,t){this.sendMutation([{name:e,value:t}],!1)}selectTransient(e,t){this.sendMutation([{name:e,value:t}],!1,!0)}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}const i=this.registry.get(e);if(i===void 0){exports.logger.warn(`onChange: attribute "${e}" not found — callback will not fire`);return}i.onChange(t)}getAttribute(e){return this.registry?.get(e)}getSelection(){return this.registry?.getSelection()??{}}sendMutation(e,t,i=!1){const s={type:c.MUTATION,instance:this.instance,mutations:e,isInitial:t,...i&&{transient:!0}};this.send(s)}replayPendingCallbacks(){for(const{name:e,callback:t}of this.pendingCallbacks){const i=this.registry?.get(e);i===void 0&&exports.logger.warn(`onChange: attribute "${e}" not found — buffered callback will not fire`),i?.onChange(t)}this.pendingCallbacks.length=0}}class St{snapshot;callbacks=[];handleSnapshot(e){this.snapshot=e.attributes;for(const t of this.callbacks)t(e.attributes)}onChange(e){this.callbacks.push(e),this.snapshot!==void 0&&e(this.snapshot)}selectableFor(e){return this.snapshot?.find(i=>i.name===e)?.selectable??null}get current(){return this.snapshot??[]}}let ke=class{constructor(e){this.send=e}send;commands=[];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 g.invalidParameter("No camera commands to execute. Call rotate(), tilt(), or zoom() before set().");const e={type:c.CAMERA,commands:this.commands};this.send(e),this.commands=[]}validateFiniteNumber(e,t){if(!Number.isFinite(e))throw g.invalidParameter(`${t}() requires a finite number, got ${String(e)}`)}reset(){const e={type:c.CAMERA,commands:[{action:"reset"}]};this.send(e)}};class wt{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;const t={rotation:this.rotation,tilt:this.tilt,zoom:this.zoom};for(const i of this.changeCallbacks)i(t)}handlePositionUpdate(e){this.update(e.transforms)}update(e){let t=!1;for(const i of e)switch(i.type){case"rotation":this.state.rotation=i.value,t=!0;break;case"tilt":this.state.tilt=i.value,t=!0;break;case"zoom":this.state.zoom=i.value,t=!0;break}if(t){const i={rotation:this.rotation,tilt:this.tilt,zoom:this.zoom};for(const s of this.changeCallbacks)s(i)}}}function Ct(n,e){const t=n.filter(o=>kt(o,e));if(t.length===0)return;const i=Math.max(...t.map(ne)),s=t.filter(o=>ne(o)===i);return s.length===1?s[0]:void 0}function kt(n,e){return Object.entries(n.attributes).every(([t,i])=>e[t]===i)}function ne(n){return Object.keys(n.attributes).length}class _e{constructor(e,t){this.dispatchChange=e,this.dispatchSubmit=t}dispatchChange;dispatchSubmit;pricing;selection={};resolved;changeCallbacks=[];renderCallbacks=[];submitCallback;submitDefaultLabel;get current(){return this.resolved}get vatDisplay(){return this.pricing?.vatDisplay}get buttonLabel(){const e=this.pricing?.buttonLabel;if(e!=null&&e!=="")return e;if(this.submitDefaultLabel!==void 0&&this.submitDefaultLabel!=="")return this.submitDefaultLabel}get submittable(){return this.submitCallback===void 0?!1:this.pricing===void 0?!0:this.resolved?.availability==="available"}get submitEnabled(){return this.submittable&&this.buttonLabel!==void 0}onChange(e){this.changeCallbacks.push(e)}onSubmit(e,t){this.submitCallback=e,this.submitDefaultLabel=t?.defaultLabel,this.notifyRender()}onRender(e){return this.renderCallbacks.push(e),()=>{const t=this.renderCallbacks.indexOf(e);t!==-1&&this.renderCallbacks.splice(t,1)}}async submit(){if(!this.submittable)return;const e=this.resolved!==void 0?{attributes:this.resolved.attributes,reference:this.resolved.reference}:{attributes:{...this.selection},reference:""};this.dispatchSubmit(e),await this.submitCallback?.(e)}handlePricingReceived(e){this.pricing=e,this.recompute()}handleSelectionChanged(e){this.selection=e,this.recompute()}recompute(){this.resolved=this.resolve();for(const e of this.changeCallbacks)e(this.resolved);this.dispatchChange(this.resolved),this.notifyRender()}notifyRender(){for(const e of this.renderCallbacks)e()}resolve(){if(this.pricing===void 0)return;const e=Ct(this.pricing.rules,this.selection);if(!(e===void 0||e.availability===$e.HIDDEN))return{attributes:{...this.selection},reference:e.reference,price:e.priceCents,currency:this.pricing.currency,availability:e.availability}}}class Ae{constructor(e,t,i){this.send=e,this.dispatch=t,this.instance=i}send;dispatch;instance;focused=null;attributes=[];changeCallbacks=[];get current(){return this.focused}set(e){if(typeof e!="string"||e.length===0)throw g.invalidParameter(`set() requires a non-empty component name, got ${String(e)}`);this.send({type:c.FOCUS,instance:this.instance,action:ee.FOCUS,component:e})}clear(){this.send({type:c.FOCUS,instance:this.instance,action:ee.UNFOCUS})}onChange(e){this.changeCallbacks.push(e)}handleStateReceived(e){e.state===De.FOCUSED&&e.component!==void 0?(this.focused=e.component,this.attributes=e.attributes??[]):(this.focused=null,this.attributes=[]);const t=this.focused!==null?{component:this.focused,attributes:this.attributes}:null;for(const i of this.changeCallbacks)i(t);this.dispatch(t)}}class Ee{constructor(e){this.filename=e}filename;developedCallbacks=new Set;errorCallbacks=new Set;developed=!1;failed=!1;photoData=null;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(t=>{t(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())}}const ie=3e4;class xe{constructor(e){this.send=e}send;validExtensions=[".png"];pendingPhotos=new Map;take(e){this.validateFilename(e),exports.logger.debug("Taking snapshot",{filename:e});const t=new Ee(e),i=setTimeout(()=>{this.pendingPhotos.delete(e),exports.logger.warn("Snapshot timed out",{filename:e}),t.fail(new g(`Snapshot timed out: the viewer did not respond within ${ie}ms`,k.SNAPSHOT_FAILED))},ie);return this.pendingPhotos.set(e,{photo:t,timeout:i}),this.send({type:c.SNAPSHOT,filename:e}),t}handleSnapshotResult(e){const t=this.pendingPhotos.get(e.filename);if(t===void 0){exports.logger.warn("No pending photo found for filename",{filename:e.filename,pendingFilenames:Array.from(this.pendingPhotos.keys())});return}clearTimeout(t.timeout),this.pendingPhotos.delete(e.filename);const{photo:i}=t;if(e.error!==void 0){i.fail(new g(e.error,k.SNAPSHOT_FAILED));return}e.data!==void 0&&i.develop({filename:e.filename,data:e.data})}clear(){if(this.pendingPhotos.size===0)return;const e=new g("Client destroyed before snapshot completed",k.SNAPSHOT_FAILED);for(const{photo:t,timeout:i}of this.pendingPhotos.values())clearTimeout(i),t.fail(e);this.pendingPhotos.clear()}validateFilename(e){if(e===""||typeof e!="string")throw new g("Filename must be a non-empty string",k.INVALID_PARAMETER);if(!this.validExtensions.some(i=>e.toLowerCase().endsWith(i)))throw new g(`Invalid filename: "${e}". Filename must end with one of: ${this.validExtensions.join(", ")}`,k.INVALID_PARAMETER);if(e.includes("..")||e.includes("/")||e.includes("\\"))throw new g('Filename cannot contain path separators or ".."',k.INVALID_PARAMETER)}}class _t{container=null;attach(e){this.container=e}dispatch(e,t,i=!1){const s=new CustomEvent(e,{detail:t,cancelable:i});return this.container?.dispatchEvent(s),s}on(e,t){const i=s=>{const o=s,r={...o.detail,preventDefault:()=>{o.preventDefault()}};t(r)};return this.container?.addEventListener(e,i),()=>{this.container?.removeEventListener(e,i)}}}const At={},Et="en",Te=["en","nl","de"],K=["baseLocale"],se=[],Y=typeof window>"u";globalThis.__paraglide=globalThis.__paraglide??{};globalThis.__paraglide.ssr=globalThis.__paraglide.ssr??{};let oe=!1,m=()=>{let n=K;!Y&&typeof window<"u"&&window.location?.href&&(n=Ie(window.location.href));const e=xt(n);if(e)return oe||(oe=!0,Re(e,{reload:!1})),e;throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found")};function xt(n,e){let t;for(const i of n){if(i==="baseLocale")t=Et;else if(Oe(i)&&N.has(i)){const o=N.get(i);if(o){const r=o.getLocale();if(r instanceof Promise)continue;if(r!==void 0)return It(r)}}const s=X(t);if(s)return s}}const Tt=n=>{window.location.reload()};let Re=(n,e)=>{const t={reload:!0,...e};let i;try{i=m()}catch{}const s=[];let o=K;!Y&&typeof window<"u"&&window.location?.href&&(o=Ie(window.location.href));for(const a of o)if(a!=="baseLocale"&&Oe(a)&&N.has(a)){const u=N.get(a);if(u){let d=u.setLocale(n);d instanceof Promise&&(d=d.catch(f=>{throw new Error(`Custom strategy "${a}" setLocale failed.`,{cause:f})}),s.push(d))}}const r=()=>{!Y&&t.reload&&window.location&&n!==i&&Tt()};if(s.length)return Promise.all(s).then(()=>{r()});r()},Rt=()=>typeof window<"u"?window.location.origin:"http://fallback.com";function X(n){if(typeof n!="string")return;const e=n.toLowerCase();for(const t of Te)if(t.toLowerCase()===e)return t}function It(n){const e=X(n);if(e)return e;throw new Error(`Invalid locale: ${n}. Expected one of: ${Te.join(", ")}`)}function Ot(n){return Lt(n)}function Lt(n){const e=typeof n=="string"?new URL(n,Rt()):new URL(n),t=e.pathname.split("/").filter(Boolean);return t.length>0&&X(t[0])&&(e.pathname="/"+t.slice(1).join("/")),e}let re,ae;function Nt(n){if(se.length===0)return;const e=typeof n=="string"?n:n.href;if(re===e)return ae;const t=new URL(e,"http://example.com"),i=Ot(t),s=i.href===t.href?[t]:[t,i];let o;for(const r of s){for(const a of se)if(new At(a.match,r.href).exec(r.href)){o=a;break}if(o)break}return re=e,ae=o,o}function Ie(n){const e=Nt(n);return e&&e.exclude!==!0&&Array.isArray(e.strategy)?e.strategy:K}const N=new Map;function Oe(n){return typeof n=="string"&&/^custom-[A-Za-z0-9_-]+$/.test(n)}const Mt=()=>"Activate AR",zt=()=>"AR activeren",Pt=()=>"AR aktivieren",Ft=((n={},e={})=>{const t=e.locale??m();return t==="nl"?zt():t==="de"?Pt():Mt()}),Dt=()=>"Scan to view in AR",$t=()=>"Scan om in AR te bekijken",Ut=()=>"Scannen für AR-Ansicht",Bt=((n={},e={})=>{const t=e.locale??m();return t==="nl"?$t():t==="de"?Ut():Dt()}),Vt=()=>"Use your smartphone camera to scan this QR code",jt=()=>"Gebruik de camera van je smartphone om deze QR-code te scannen",Ht=()=>"Verwende die Kamera deines Smartphones, um diesen QR-Code zu scannen",qt=((n={},e={})=>{const t=e.locale??m();return t==="nl"?jt():t==="de"?Ht():Vt()}),Gt=()=>"Your phone will open the 3D model in AR mode.",Zt=()=>"Je telefoon opent het 3D-model in AR-modus.",Wt=()=>"Dein Telefon öffnet das 3D-Modell im AR-Modus.",Yt=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Zt():t==="de"?Wt():Gt()}),Qt=()=>"Close",Kt=()=>"Sluiten",Xt=()=>"Schließen",Jt=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Kt():t==="de"?Xt():Qt()}),en=()=>"Fullscreen",tn=()=>"Volledig scherm",nn=()=>"Vollbild",sn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?tn():t==="de"?nn():en()}),on=()=>"Downloading",rn=()=>"Downloaden",an=()=>"Herunterladen",ln=((n={},e={})=>{const t=e.locale??m();return t==="nl"?rn():t==="de"?an():on()}),cn=()=>"Screenshot",un=()=>"Screenshot",dn=()=>"Screenshot",hn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?un():t==="de"?dn():cn()}),mn=()=>"Configure",pn=()=>"Configureren",fn=()=>"Konfigurieren",gn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?pn():t==="de"?fn():mn()}),bn=()=>"Close",vn=()=>"Sluiten",yn=()=>"Schließen",Sn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?vn():t==="de"?yn():bn()}),wn=()=>"Reset camera",Cn=()=>"Camera resetten",kn=()=>"Kamera zurücksetzen",_n=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Cn():t==="de"?kn():wn()}),An=()=>"Zoom in",En=()=>"Inzoomen",xn=()=>"Hineinzoomen",Tn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?En():t==="de"?xn():An()}),Rn=()=>"Zoom out",In=()=>"Uitzoomen",On=()=>"Herauszoomen",Ln=((n={},e={})=>{const t=e.locale??m();return t==="nl"?In():t==="de"?On():Rn()}),Nn=()=>"Rotate left",Mn=()=>"Naar links draaien",zn=()=>"Nach links drehen",Pn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Mn():t==="de"?zn():Nn()}),Fn=()=>"Rotate right",Dn=()=>"Naar rechts draaien",$n=()=>"Nach rechts drehen",Un=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Dn():t==="de"?$n():Fn()}),Bn=()=>"Tilt up",Vn=()=>"Omhoog kantelen",jn=()=>"Nach oben kippen",Hn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Vn():t==="de"?jn():Bn()}),qn=()=>"Tilt down",Gn=()=>"Omlaag kantelen",Zn=()=>"Nach unten kippen",Wn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Gn():t==="de"?Zn():qn()}),Yn=()=>"Working…",Qn=()=>"Bezig…",Kn=()=>"Läuft…",Xn=((n={},e={})=>{const t=e.locale??m();return t==="nl"?Qn():t==="de"?Kn():Yn()}),Jn=()=>"Done",ei=()=>"Gelukt",ti=()=>"Fertig",ni=((n={},e={})=>{const t=e.locale??m();return t==="nl"?ei():t==="de"?ti():Jn()}),ii=()=>"Failed",si=()=>"Mislukt",oi=()=>"Fehlgeschlagen",ri=((n={},e={})=>{const t=e.locale??m();return t==="nl"?si():t==="de"?oi():ii()});const ai={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"};const Le=([n,e,t])=>{const i=document.createElementNS("http://www.w3.org/2000/svg",n);return Object.keys(e).forEach(s=>{i.setAttribute(s,String(e[s]))}),t?.length&&t.forEach(s=>{const o=Le(s);i.appendChild(o)}),i},Ne=(n,e={})=>{const i={...ai,...e};return Le(["svg",i,n])};const li=[["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"}]];const ci=[["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"}]];const Me=[["path",{d:"m6 9 6 6 6-6"}]];const ui=[["path",{d:"m15 18-6-6 6-6"}]];const di=[["path",{d:"m9 18 6-6-6-6"}]];const hi=[["path",{d:"m18 15-6-6-6 6"}]];const mi=[["path",{d:"M15 3h6v6"}],["path",{d:"m21 3-7 7"}],["path",{d:"m3 21 7-7"}],["path",{d:"M9 21H3v-6"}]];const pi=[["path",{d:"m14 10 7-7"}],["path",{d:"M20 10h-6V4"}],["path",{d:"m3 21 7-7"}],["path",{d:"M4 14h6v6"}]];const fi=[["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"}]];const gi=[["path",{d:"M10 5H3"}],["path",{d:"M12 19H3"}],["path",{d:"M14 3v4"}],["path",{d:"M16 17v4"}],["path",{d:"M21 12h-9"}],["path",{d:"M21 19h-5"}],["path",{d:"M21 5h-7"}],["path",{d:"M8 10v4"}],["path",{d:"M8 12H3"}]];const bi=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];const vi=[["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"}]];const yi=[["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 y(n,{size:e=20,strokeWidth:t=1.75}={}){return Ne(n,{width:e,height:e,"stroke-width":t})}const b={ar:n=>y(li,n),fullscreen:n=>y(mi,n),exitFullscreen:n=>y(pi,n),screenshot:n=>y(ci,n),tiltUp:n=>y(hi,n),tiltDown:n=>y(Me,n),rotateLeft:n=>y(ui,n),rotateRight:n=>y(di,n),zoomIn:n=>y(vi,n),zoomOut:n=>y(yi,n),reset:n=>y(fi,n),configurator:n=>y(gi,n),close:n=>y(bi,n)};class v{element;constructor({variant:e="default",size:t="default",label:i,icon:s,onClick:o,disabled:r=!1}={}){this.element=document.createElement("button"),this.element.className=`ui-btn ui-btn--${e} ui-btn--size-${t}`,i!==void 0&&(this.element.setAttribute("aria-label",i),this.element.title=i),s!==void 0?this.element.appendChild(s):i!==void 0&&(this.element.textContent=i),o&&this.element.addEventListener("click",o),this.element.disabled=r}setIcon(e){const t=this.element.querySelector("svg");t!==null?t.replaceWith(e):this.element.appendChild(e)}}const p={semantic:{error:"#dc2626"},neutral:{500:"#737373",600:"#525252",900:"#171717"},white:"#ffffff",black:"#000000"},l={0:"0",.5:"0.125rem",1:"0.25rem",1.5:"0.375rem",2:"0.5rem",3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",8:"2rem",9:"2.25rem"};class Si{element;constructor(){this.element=document.createElement("div"),Object.assign(this.element.style,{background:p.white,borderRadius:l[3],padding:l[6],boxShadow:`0 ${l[2]} ${l[8]} oklch(0% 0 0 / 20%)`,maxWidth:"20rem",width:"100%"})}}class wi{constructor(e={}){this.options=e,this.card=new Si,this.backdrop=this.createBackdrop(),this.backdrop.appendChild(this.card.element)}options;card;backdrop;keyHandler=null;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(){const e=document.createElement("div");return Object.assign(e.style,{position:"fixed",inset:l[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}}class Ci{element;selectCallback=null;constructor(e,t,i){this.element=document.createElement("div"),this.element.className="ui-toggle-group";for(let s=0;s<e.length;s++){const o=e[s],r=document.createElement("button");r.className="ui-toggle-group-item",r.dataset.value=o,r.textContent=i?.[s]??o,r.dataset.state=o===t?"on":"off",r.setAttribute("aria-pressed",o===t?"true":"false"),r.addEventListener("click",()=>{this.selectCallback?.(o)}),this.element.appendChild(r)}}setSelected(e){for(const t of this.element.querySelectorAll(".ui-toggle-group-item")){const i=t.dataset.value===e;t.dataset.state=i?"on":"off",t.setAttribute("aria-pressed",i?"true":"false")}}onSelect(e){this.selectCallback=e}setEnabled(e){for(const t of this.element.querySelectorAll(".ui-toggle-group-item")){const i=e===null||e.includes(t.dataset.value??"");t.disabled=!i,t.setAttribute("aria-disabled",i?"false":"true")}}}class ki{element;select;constructor(e,t,i,s,o){this.select=document.createElement("select"),this.select.className="ui-native-select",this.select.dataset.name=e,this.select.setAttribute("aria-label",i);const r=document.createElement("option");r.value="",r.disabled=!0,r.textContent=i,this.select.appendChild(r);let a=!1;for(let d=0;d<t.length;d++){const f=t[d],h=document.createElement("option");h.value=f,h.textContent=o?.[d]??f,f===s&&(h.selected=!0,a=!0),this.select.appendChild(h)}a||(r.selected=!0);const u=Ne(Me,{width:16,height:16,"stroke-width":2});u.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(u)}setSelected(e){this.select.value=e}onSelect(e){this.select.addEventListener("change",()=>{e(this.select.value)})}setEnabled(e){for(const t of this.select.options)t.value!==""&&(t.disabled=e!==null&&!e.includes(t.value))}}class _i{element;input;valueText;values;options;selectCallback=null;settleCallback=null;constructor(e,t){if(e.length===0)throw new Error("Virtualdisplay: Slider needs at least one value");this.values=e,this.options=t,this.input=document.createElement("input"),this.input.type="range",this.input.className="ui-slider-input",this.input.min="0",this.input.max=String(e.length-1),this.input.step="1",this.input.setAttribute("aria-label",t.label),this.valueText=document.createElement("span"),this.valueText.className="ui-slider-value",this.valueText.setAttribute("aria-hidden","true");const i=document.createElement("div");i.className="ui-slider-track",i.appendChild(this.input),i.appendChild(this.buildEnds()),this.element=document.createElement("div"),this.element.className="ui-slider",this.element.appendChild(i),this.element.appendChild(this.valueText);const s=t.initialSelected===void 0?0:e.indexOf(t.initialSelected);this.applyIndex(s===-1?0:s),this.listen()}setSelected(e){const t=this.values.indexOf(e);t!==-1&&this.applyIndex(t)}onSelect(e){this.selectCallback=e}onSettle(e){this.settleCallback=e}listen(){this.input.addEventListener("input",()=>{const e=this.values[this.currentIndex];e!==void 0&&(this.applyIndex(this.currentIndex),this.selectCallback?.(e))}),this.input.addEventListener("change",()=>{const e=this.values[this.currentIndex];e!==void 0&&this.settleCallback?.(e)})}get currentIndex(){return Number(this.input.value)}applyIndex(e){this.input.value=String(e);const t=this.displayAt(e);this.valueText.textContent=t,this.input.setAttribute("aria-valuetext",t);const i=this.values.length===1?100:e/(this.values.length-1)*100;this.element.style.setProperty("--ui-slider-pct",`${i}%`)}buildEnds(){const e=document.createElement("div");e.className="ui-slider-ends",e.setAttribute("aria-hidden","true");for(const t of[0,this.values.length-1]){const i=document.createElement("span");i.textContent=this.labelAt(t),e.appendChild(i)}return e}labelAt(e){return this.options.labels?.[e]??this.values[e]??""}displayAt(e){const t=this.labelAt(e);return this.options.unit===void 0?t:`${t} ${this.options.unit}`}}const w={fontFamily:{sans:["Mona Sans","ui-sans-serif","system-ui","sans-serif","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"]},fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem"},fontWeight:{medium:"500",semibold:"600"}},E=w.fontFamily.sans.join(", "),Ai=`
|
|
2
2
|
--primary: oklch(5% 0 0);
|
|
3
3
|
--primary-foreground: oklch(100% 0 0);
|
|
4
4
|
--secondary: oklch(92% 0 0);
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
--accent: oklch(92% 0 0);
|
|
12
12
|
--accent-foreground: oklch(5% 0 0);
|
|
13
13
|
--muted-foreground: oklch(44% 0 0);
|
|
14
|
-
`,
|
|
15
|
-
:root { ${
|
|
14
|
+
`,Ei=`
|
|
15
|
+
:root { ${Ai} }
|
|
16
16
|
|
|
17
17
|
/* ── Button ──────────────────────────────────────────────── */
|
|
18
18
|
.ui-btn {
|
|
@@ -381,12 +381,12 @@
|
|
|
381
381
|
0%, 100% { opacity: 1; }
|
|
382
382
|
50% { opacity: 0.55; }
|
|
383
383
|
}
|
|
384
|
-
`;let ae=!1;function ze(){if(ae||typeof document>"u")return;ae=!0;const n=document.createElement("style");n.id="vd-ui-vanilla",n.textContent=Ri,document.head.appendChild(n)}const Ii=w.fontFamily.sans.join(", ");class Li{qrLib=null;dialog=null;qrSlot=null;show(){this.hide(),ze(),this.dialog=new ki({onClose:()=>{this.dialog=null,this.qrSlot=null}}),Object.assign(this.dialog.card.element.style,{display:"flex",flexDirection:"column",alignItems:"center",gap:l[3],fontFamily:Ii}),this.dialog.card.element.appendChild(this.createText(Bt(),{fontSize:w.fontSize.base,fontWeight:w.fontWeight.semibold,color:p.neutral[900]})),this.dialog.card.element.appendChild(this.createText(qt(),{fontSize:w.fontSize.sm,color:p.neutral[600]})),this.qrSlot=this.createQrSlot(),this.dialog.card.element.appendChild(this.qrSlot),this.dialog.card.element.appendChild(this.createText(Yt(),{fontSize:w.fontSize.xs,color:p.neutral[500]}));const e=new v({variant:"outline",label:Jt(),onClick:()=>{this.hide()}});this.dialog.card.element.appendChild(e.element),this.dialog.open()}async update(e){this.qrLib??=await Promise.resolve().then(()=>require("./browser-DfB_An57.cjs")).then(i=>i.browser);const t=await this.qrLib.toDataURL(e,{width:256,margin:4,errorCorrectionLevel:"M",color:{dark:p.black,light:p.white}});return this.qrSlot===null?!1:(this.qrSlot.classList.remove("ui-qr-slot--loading"),this.qrSlot.replaceChildren(this.createQrImage(t)),!0)}hide(){this.dialog?.close(),this.dialog=null,this.qrSlot=null}createText(e,t){const i=document.createElement("p");return i.textContent=e,Object.assign(i.style,{margin:"0",textAlign:"center",...t}),i}createQrSlot(){const e=document.createElement("div");return e.className="ui-qr-slot ui-qr-slot--loading",e}createQrImage(e){const t=document.createElement("img");return t.src=e,t.alt="QR code",t}}function le(n){const e=Math.max(0,Math.min(1,n));return e*e*(3-2*e)}function Oi(n,e,t,i,s,o){const[r,a,u]=n,d=Math.cos(e),f=Math.sin(e),h=d*r+f*u,A=-f*r+d*u,k=Math.cos(t),C=Math.sin(t),R=k*a-C*A,z=C*a+k*A,X=.55;return[i+h*o*X,s-R*o*X,z]}function Mi(n,e,t){n.beginPath(),n.moveTo(e[0],e[1]),n.lineTo(t[0],t[1]),n.strokeStyle="#000",n.lineWidth=2,n.stroke()}function Ni(n,e,t,i,s){const o=e(t),r=e(i),a=[o[0]+(r[0]-o[0])*s,o[1]+(r[1]-o[1])*s,o[2]];Mi(n,o,a)}const F=[-1,-1,1],D=[1,-1,1],$=[1,-1,-1],U=[-1,-1,-1],B=[-1,1,1],V=[1,1,1],j=[1,1,-1],H=[-1,1,-1],ce=[[F,D],[D,$],[$,U],[U,F],[F,B],[D,V],[$,j],[U,H],[B,V],[V,j],[j,H],[H,B]],zi=400,ue='-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif';function Pi(){const n=document.createElement("div");Object.assign(n.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"});const e=document.createElement("canvas");Object.assign(e.style,{width:"100%",height:"100%",position:"absolute",inset:"0"});const t=document.createElement("div");Object.assign(t.style,{position:"absolute",top:"56%",left:"0",right:"0",textAlign:"center",pointerEvents:"none"});const i=document.createElement("span");Object.assign(i.style,{fontSize:"13px",fontWeight:"400",color:"#000",fontVariantNumeric:"tabular-nums",fontFamily:ue});const s=document.createElement("span");return Object.assign(s.style,{fontSize:"13px",color:"#000",fontFamily:ue}),s.textContent=Le(),t.appendChild(i),t.appendChild(s),n.appendChild(e),n.appendChild(t),{overlay:n,canvas:e,pctEl:i,phaseEl:s}}class Fi{overlay;canvas;ctx;pctEl;phaseEl;animationId=null;showTimerId=null;startTime;hidden=!1;visible=!1;constructor(e,t={}){this.startTime=performance.now();const i=Pi();this.overlay=i.overlay,this.canvas=i.canvas,this.pctEl=i.pctEl,this.phaseEl=i.phaseEl,e.appendChild(this.overlay),this.ctx=this.canvas.getContext("2d"),this.ctx!==null&&(this.sizeCanvas(),this.tick());const s=t.showDelay??zi;this.showTimerId=setTimeout(()=>{this.reveal()},s)}get loadingTexts(){return{downloading:Le(),rendering:dn()}}updateProgress(e,t){this.hidden||(this.pctEl.textContent=`${Math.round(e)}%`,this.phaseEl.textContent=t!==""?` · ${t}`:"")}showError(e){if(this.hidden=!1,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.ctx!==null){const t=Math.min(devicePixelRatio,2),i=this.canvas.width/t,s=this.canvas.height/t;this.ctx.fillStyle="#fff",this.ctx.fillRect(0,0,i*t,s*t)}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;const e=Math.min(devicePixelRatio,2),t=this.overlay.clientWidth||440,i=this.overlay.clientHeight||360;this.canvas.width=t*e,this.canvas.height=i*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;const e=this.canvas.width/Math.min(devicePixelRatio,2),t=this.canvas.height/Math.min(devicePixelRatio,2),i=(performance.now()-this.startTime)/1e3;this.ctx.fillStyle="#fff",this.ctx.fillRect(0,0,e,t);const s=e/2,o=t*.44,r=Math.min(e,t)*.08,a=.785,u=.615,d=C=>Oi(C,a,u,s,o,r),f=6,h=i%f/f,A=ce.length;let k;h<.35?k=le(h/.35)*A:h<.55?k=A:h<.9?k=(1-le((h-.55)/.35))*A:k=0,this.ctx.shadowBlur=5,this.ctx.shadowColor="rgba(30,30,30,0.08)";for(let C=0;C<A&&!(C>=k);C++){const R=ce[C];if(R===void 0)continue;const z=Math.min(1,k-C);Ni(this.ctx,d,R[0],R[1],z)}this.ctx.shadowBlur=0}}class Di{constructor(e){this.options=e,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"flex",gap:"0.375rem"}),this.onFullscreenChange=()=>{this.setFullscreenIcon(document.fullscreenElement!==null)},document.addEventListener("fullscreenchange",this.onFullscreenChange)}options;element;arBtn=null;fullscreenBtn=null;onFullscreenChange;setFullscreenIcon(e){this.fullscreenBtn!==null&&this.fullscreenBtn.setIcon(e?b.exitFullscreen():b.fullscreen())}syncButton(e,t,i){if(t&&e===null){const s=i();return this.element.appendChild(s.element),s}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 v({variant:"outline",size:"icon",label:Ft(),icon:b.ar(),onClick:()=>{this.options.onAr?.()}})),this.fullscreenBtn=this.syncButton(this.fullscreenBtn,e.fullscreen!==!1&&this.options.onFullscreen!==void 0,()=>new v({variant:"outline",size:"icon",label:sn(),icon:b.fullscreen(),onClick:()=>{this.options.onFullscreen?.()}}))}destroy(){document.removeEventListener("fullscreenchange",this.onFullscreenChange)}}const T=.5;class N{element;constructor(e,t){this.element=Object.assign(document.createElement("div"),{className:"vd-camera-controls"});const i={targetRotation:t.rotation,targetTilt:t.tilt,targetZoom:t.zoom,thetaOffset:0},s=$i(e,t,i);t.onChange(o=>{i.targetRotation=o.rotation-i.thetaOffset,i.targetTilt=o.tilt,i.targetZoom=o.zoom,Ui(s,t,o)}),this.element.appendChild(N.buildZoom(s.zoomOut,s.zoomIn)),this.element.appendChild(N.buildDpad(s.tiltUp,s.rotateLeft,s.reset,s.rotateRight,s.tiltDown))}static buildZoom(e,t){const i=document.createElement("div");return i.className="vd-zoom",i.appendChild(e.element),i.appendChild(t.element),i}static buildDpad(e,t,i,s,o){const r=document.createElement("div");r.className="vd-dpad";for(const[a,u]of[[e,"up"],[t,"left"],[i,"center"],[s,"right"],[o,"down"]])a.element.classList.add(`vd-dpad-${u}`),r.appendChild(a.element);return r}}function $i(n,e,t){const i=r=>Math.max(e.limits?.minZoom??1,Math.min(e.limits?.maxZoom??1/0,r)),s=r=>{const a=e.limits?.minRotate,u=e.limits?.maxRotate;return a!==void 0||u!==void 0?Math.max(a??-1/0,Math.min(u??1/0,r)):r},o=r=>{const a=e.limits?.minTilt,u=e.limits?.maxTilt;if(a!==void 0||u!==void 0){t.targetTilt=Math.max(a??0,Math.min(u??180,t.targetTilt+r)),n.tilt(t.targetTilt).set();return}const d=t.targetTilt+r;d>180||d<0?(t.targetTilt=d>180?360-d:-d,t.thetaOffset=(t.thetaOffset+180)%360,n.tilt(t.targetTilt).rotate(t.targetRotation+t.thetaOffset).set()):(t.targetTilt=d,n.tilt(t.targetTilt).set())};return{zoomOut:new v({variant:"outline",size:"icon",label:zn(),icon:b.zoomOut(),onClick:()=>{t.targetZoom=i(t.targetZoom-10),n.zoom(t.targetZoom).set()}}),zoomIn:new v({variant:"outline",size:"icon",label:Ln(),icon:b.zoomIn(),onClick:()=>{t.targetZoom=i(t.targetZoom+10),n.zoom(t.targetZoom).set()}}),tiltUp:new v({variant:"outline",size:"icon",label:Zn(),icon:b.tiltUp(),onClick:()=>{o(-15)}}),rotateLeft:new v({variant:"outline",size:"icon",label:$n(),icon:b.rotateLeft(),onClick:()=>{t.targetRotation=s(t.targetRotation-15),n.rotate(t.targetRotation+t.thetaOffset).set()}}),reset:new v({variant:"outline",size:"icon",label:xn(),icon:b.reset(),onClick:()=>{t.thetaOffset=0,n.reset()}}),rotateRight:new v({variant:"outline",size:"icon",label:jn(),icon:b.rotateRight(),onClick:()=>{t.targetRotation=s(t.targetRotation+15),n.rotate(t.targetRotation+t.thetaOffset).set()}}),tiltDown:new v({variant:"outline",size:"icon",label:Kn(),icon:b.tiltDown(),onClick:()=>{o(15)}})}}function Ui(n,e,t){const i=e.limits;i!==void 0&&(n.zoomOut.element.disabled=i.minZoom!==void 0&&t.zoom<=i.minZoom+T,n.zoomIn.element.disabled=i.maxZoom!==void 0&&t.zoom>=i.maxZoom-T,n.tiltUp.element.disabled=i.minTilt!==void 0&&t.tilt<=i.minTilt+T,n.tiltDown.element.disabled=i.maxTilt!==void 0&&t.tilt>=i.maxTilt-T,n.rotateLeft.element.disabled=i.minRotate!==void 0&&t.rotation<=i.minRotate+T,n.rotateRight.element.disabled=i.maxRotate!==void 0&&t.rotation>=i.maxRotate-T)}const x={SELECT:"ui:select",SELECTED:"ui:selected",FOCUS_CHANGE:"vd:focus-change",CONFIGURATION_CHANGE:"vd:configuration-change",CONFIGURATION_SUBMIT:"vd:configuration-submit"},Pe={mm:1,cm:10,m:1e3,in:25.4},de=3;function Bi(n){const e=n.stepMm/Pe[n.displayUnit];for(let t=0;t<=de;t++){const i=e*10**t;if(Math.abs(i-Math.round(i))<1e-9)return t}return de}function Vi(n,e,t){const i=Bi(e),s=n/Pe[e.displayUnit];return new Intl.NumberFormat(t,{minimumFractionDigits:i,maximumFractionDigits:i}).format(s)}function ji(n,e,t,i,s,o,r){const a=m(),u=n.values.map(h=>Vi(Number(h),e,a)),d=n.values.find(h=>t.getValue(n.name,h)?.isSelected===!0)??n.defaultValue,f=new xi(n.values,{label:n.name,labels:u,unit:e.displayUnit,...d!==void 0&&{initialSelected:d}});return f.onSelect(h=>{s(n.name,h)}),f.onSettle(h=>{i.dispatch(x.SELECT,{attribute:n.name,value:h},!0).defaultPrevented||o(n.name,h)}),r(n.name,h=>{f.setSelected(h.value),i.dispatch(x.SELECTED,{attribute:n.name,value:h.value})}),{element:f.element,setSelectable:()=>{}}}const Hi=5;let qi=0;function Y(n){const e=n.replace(/([A-Z])/g," $1").trim();return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Gi(n,e,t,i,s,o){const r=document.createElement("div");r.className="vd-attribute",r.dataset.name=n.name;const a=document.createElement("span");a.className="vd-attribute-label",a.textContent=Y(n.name),a.id=`vd-attribute-label-${qi++}`,r.appendChild(a),r.setAttribute("role","group"),r.setAttribute("aria-labelledby",a.id);const u=f=>{r.style.display=f?"none":""},d=n.dimension!==void 0?ji(n,n.dimension,e,t,s,i,o):Zi(n,e,t,i,o);return r.appendChild(d.element),{element:r,setSelectable:d.setSelectable,setHidden:u}}function Zi(n,e,t,i,s){const o=n.values.find(u=>e.getValue(n.name,u)?.isSelected===!0),r=n.values.map(Y),a=n.values.length<=Hi?new Ai(n.values,o,r):new Ei(n.name,n.values,Y(n.name),o,r);return a.onSelect(u=>{t.dispatch(x.SELECT,{attribute:n.name,value:u},!0).defaultPrevented||i(n.name,u)}),s(n.name,u=>{a.setSelected(u.value),t.dispatch(x.SELECTED,{attribute:n.name,value:u.value})}),{element:a.element,setSelectable:u=>{a.setEnabled(u)}}}const Wi=80,Yi=2500;class Qi{constructor(e,t=Yi){this.configuration=e,this.resetMs=t,this.element=document.createElement("div"),this.element.className="vd-commerce vd-hidden";const i=document.createElement("div");i.className="vd-commerce-price",this.priceEl=document.createElement("span"),this.priceEl.className="vd-price",this.vatEl=document.createElement("span"),this.vatEl.className="vd-vat",i.append(this.priceEl,this.vatEl),this.button=new v({variant:"default",onClick:()=>{this.handleSubmit()}}),this.button.element.classList.add("vd-cta","vd-hidden"),this.element.append(i,this.button.element),this.unsubscribe=this.configuration.onRender(()=>{this.update()}),this.update()}configuration;resetMs;element;priceEl;vatEl;button;unsubscribe;state="idle";resetTimer;update(){this.renderPrice(this.configuration.current),this.renderButton();const e=this.configuration.current!==void 0||this.configuration.submitEnabled;this.element.classList.toggle("vd-hidden",!e)}destroy(){this.unsubscribe(),this.resetTimer!==void 0&&clearTimeout(this.resetTimer),this.element.remove()}renderPrice(e){if(e===void 0){this.priceEl.textContent="",this.vatEl.textContent="";return}this.priceEl.textContent=Ki(e.price,e.currency),this.vatEl.textContent=he(this.configuration.vatDisplay)}renderButton(){const e=this.configuration.submitEnabled;this.button.element.classList.toggle("vd-hidden",!e),e&&this.state==="idle"&&this.setButtonText(he(this.configuration.buttonLabel))}async handleSubmit(){if(this.state!=="busy"){this.setState("busy",ti());try{await this.configuration.submit(),this.setState("success",oi())}catch{this.setState("failed",ci())}this.scheduleReset()}}scheduleReset(){this.resetTimer!==void 0&&clearTimeout(this.resetTimer),this.resetTimer=setTimeout(()=>{this.state="idle",this.update()},this.resetMs)}setState(e,t){this.state=e,this.element.dataset.submit=e,this.button.element.disabled=e==="busy",this.setButtonText(t)}setButtonText(e){this.button.element.textContent=e,this.button.element.setAttribute("aria-label",e)}}function he(n){return(n??"").slice(0,Wi)}function Ki(n,e){try{const t=new Intl.NumberFormat(m(),{style:"currency",currency:e}),i=t.resolvedOptions().maximumFractionDigits??2;return t.format(n/10**i)}catch{return`${e} ${(n/100).toFixed(2)}`}}class Fe{slot=null;panel=null;attach(e,t){this.panel=t,t.style.display="none",this.slot=document.createElement("div"),this.slot.className="vd-slot-bottom-left",this.slot.appendChild(t),e.appendChild(this.slot)}setVisible(e){this.panel!==null&&(this.panel.style.display=e?"flex":"none")}destroy(){this.slot?.remove(),this.slot=null,this.panel=null}}const Xi=572;class Ji{constructor(e){this.actionBarSlot=e}actionBarSlot;element=null;body=null;openButton=null;closeButton=null;container=null;observer=null;collapsible=!1;expanded=!0;visible=!1;attach(e,t){this.container=e,t.classList.add("vd-attributes-sidebar"),this.closeButton=new v({variant:"ghost",size:"icon-sm",label:_n(),icon:b.close({size:18}),onClick:()=>{this.expanded=!1,this.render()}});const i=document.createElement("div");i.className="vd-sidebar-header",i.appendChild(this.closeButton.element),this.body=document.createElement("div"),this.body.className="vd-sidebar-body",this.body.appendChild(t),this.element=document.createElement("div"),this.element.className="vd-sidebar vd-hidden",this.element.append(i,this.body),e.appendChild(this.element),this.openButton=new v({variant:"outline",size:"icon",label:yn(),icon:b.configurator({size:18}),onClick:()=>{this.expanded=!0,this.render()}}),this.openButton.element.classList.add("vd-configurator-toggle","vd-hidden"),this.actionBarSlot.appendChild(this.openButton.element),this.observe()}setVisible(e){this.visible=e,this.render()}destroy(){this.observer?.disconnect(),this.observer=null,this.openButton?.element.remove(),this.element?.remove(),this.container?.classList.remove("vd-layout-sidebar-right","vd-layout-sidebar-permanent"),this.container=null}observe(){typeof ResizeObserver>"u"||this.container===null||(this.observer=new ResizeObserver(e=>{const t=e[0]?.contentRect.width??0;this.setCollapsible(t>0&&t<Xi)}),this.observer.observe(this.container))}setCollapsible(e){e!==this.collapsible&&(this.collapsible=e,this.expanded=!e,this.render())}render(){if(this.element===null||this.openButton===null||this.closeButton===null||this.container===null)return;const e=this.visible&&this.expanded,t=this.visible&&!this.expanded;this.element.classList.toggle("vd-hidden",!this.visible),this.element.classList.toggle("vd-sidebar-collapsed",t),this.openButton.element.classList.toggle("vd-hidden",!t),this.closeButton.element.style.display=this.collapsible?"":"none",this.container.classList.toggle("vd-layout-sidebar-right",e),this.container.classList.toggle("vd-layout-sidebar-permanent",e&&!this.collapsible)}}class es{attach(e,t){}setVisible(e){}destroy(){}}const ts={"inframe-bottom-left":()=>new Fe,"sidebar-right":n=>new Ji(n),hidden:()=>new es};function ns(n,e){return(ts[n??""]??(()=>new Fe))(e)}const q=w.fontFamily.sans.join(", "),G=`
|
|
384
|
+
`;let le=!1;function ze(){if(le||typeof document>"u")return;le=!0;const n=document.createElement("style");n.id="vd-ui-vanilla",n.textContent=Ei,document.head.appendChild(n)}const xi=w.fontFamily.sans.join(", ");class Ti{qrLib=null;dialog=null;qrSlot=null;show(){this.hide(),ze(),this.dialog=new wi({onClose:()=>{this.dialog=null,this.qrSlot=null}}),Object.assign(this.dialog.card.element.style,{display:"flex",flexDirection:"column",alignItems:"center",gap:l[3],fontFamily:xi}),this.dialog.card.element.appendChild(this.createText(Bt(),{fontSize:w.fontSize.base,fontWeight:w.fontWeight.semibold,color:p.neutral[900]})),this.dialog.card.element.appendChild(this.createText(qt(),{fontSize:w.fontSize.sm,color:p.neutral[600]})),this.qrSlot=this.createQrSlot(),this.dialog.card.element.appendChild(this.qrSlot),this.dialog.card.element.appendChild(this.createText(Yt(),{fontSize:w.fontSize.xs,color:p.neutral[500]}));const e=new v({variant:"outline",label:Jt(),onClick:()=>{this.hide()}});this.dialog.card.element.appendChild(e.element),this.dialog.open()}async update(e){this.qrLib??=await Promise.resolve().then(()=>require("./browser-DfB_An57.cjs")).then(i=>i.browser);const t=await this.qrLib.toDataURL(e,{width:256,margin:4,errorCorrectionLevel:"M",color:{dark:p.black,light:p.white}});return this.qrSlot===null?!1:(this.qrSlot.classList.remove("ui-qr-slot--loading"),this.qrSlot.replaceChildren(this.createQrImage(t)),!0)}hide(){this.dialog?.close(),this.dialog=null,this.qrSlot=null}createText(e,t){const i=document.createElement("p");return i.textContent=e,Object.assign(i.style,{margin:"0",textAlign:"center",...t}),i}createQrSlot(){const e=document.createElement("div");return e.className="ui-qr-slot ui-qr-slot--loading",e}createQrImage(e){const t=document.createElement("img");return t.src=e,t.alt="QR code",t}}function ce(n){const e=Math.max(0,Math.min(1,n));return e*e*(3-2*e)}function Ri(n,e,t,i,s,o){const[r,a,u]=n,d=Math.cos(e),f=Math.sin(e),h=d*r+f*u,A=-f*r+d*u,_=Math.cos(t),C=Math.sin(t),R=_*a-C*A,z=C*a+_*A,J=.55;return[i+h*o*J,s-R*o*J,z]}function Ii(n,e,t){n.beginPath(),n.moveTo(e[0],e[1]),n.lineTo(t[0],t[1]),n.strokeStyle="#000",n.lineWidth=2,n.stroke()}function Oi(n,e,t,i,s){const o=e(t),r=e(i),a=[o[0]+(r[0]-o[0])*s,o[1]+(r[1]-o[1])*s,o[2]];Ii(n,o,a)}const D=[-1,-1,1],$=[1,-1,1],U=[1,-1,-1],B=[-1,-1,-1],V=[-1,1,1],j=[1,1,1],H=[1,1,-1],q=[-1,1,-1],ue=[[D,$],[$,U],[U,B],[B,D],[D,V],[$,j],[U,H],[B,q],[V,j],[j,H],[H,q],[q,V]],Li=400,de='-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif';function Ni(){const n=document.createElement("div");Object.assign(n.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"});const e=document.createElement("canvas");Object.assign(e.style,{width:"100%",height:"100%",position:"absolute",inset:"0"});const t=document.createElement("div");Object.assign(t.style,{position:"absolute",top:"56%",left:"0",right:"0",textAlign:"center",pointerEvents:"none"});const i=document.createElement("span");Object.assign(i.style,{fontSize:"13px",fontWeight:"400",color:"#000",fontVariantNumeric:"tabular-nums",fontFamily:de});const s=document.createElement("span");return Object.assign(s.style,{fontSize:"13px",color:"#000",fontFamily:de}),s.textContent=ln(),t.appendChild(i),t.appendChild(s),n.appendChild(e),n.appendChild(t),{overlay:n,canvas:e,pctEl:i,phaseEl:s}}class Mi{overlay;canvas;ctx;pctEl;phaseEl;animationId=null;showTimerId=null;startTime;hidden=!1;visible=!1;constructor(e,t={}){this.startTime=performance.now();const i=Ni();this.overlay=i.overlay,this.canvas=i.canvas,this.pctEl=i.pctEl,this.phaseEl=i.phaseEl,e.appendChild(this.overlay),this.ctx=this.canvas.getContext("2d"),this.ctx!==null&&(this.sizeCanvas(),this.tick());const s=t.showDelay??Li;this.showTimerId=setTimeout(()=>{this.reveal()},s)}updateProgress(e,t){this.hidden||(this.pctEl.textContent=`${Math.round(e)}%`,this.phaseEl.textContent=t!==""?` · ${t}`:"")}showError(e){if(this.hidden=!1,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.ctx!==null){const t=Math.min(devicePixelRatio,2),i=this.canvas.width/t,s=this.canvas.height/t;this.ctx.fillStyle="#fff",this.ctx.fillRect(0,0,i*t,s*t)}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;const e=Math.min(devicePixelRatio,2),t=this.overlay.clientWidth||440,i=this.overlay.clientHeight||360;this.canvas.width=t*e,this.canvas.height=i*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;const e=this.canvas.width/Math.min(devicePixelRatio,2),t=this.canvas.height/Math.min(devicePixelRatio,2),i=(performance.now()-this.startTime)/1e3;this.ctx.fillStyle="#fff",this.ctx.fillRect(0,0,e,t);const s=e/2,o=t*.44,r=Math.min(e,t)*.08,a=.785,u=.615,d=C=>Ri(C,a,u,s,o,r),f=6,h=i%f/f,A=ue.length;let _;h<.35?_=ce(h/.35)*A:h<.55?_=A:h<.9?_=(1-ce((h-.55)/.35))*A:_=0,this.ctx.shadowBlur=5,this.ctx.shadowColor="rgba(30,30,30,0.08)";for(let C=0;C<A&&!(C>=_);C++){const R=ue[C];if(R===void 0)continue;const z=Math.min(1,_-C);Oi(this.ctx,d,R[0],R[1],z)}this.ctx.shadowBlur=0}}class zi{constructor(e){this.options=e,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"flex",gap:"0.375rem"}),this.onFullscreenChange=()=>{this.setFullscreenIcon(document.fullscreenElement!==null)},document.addEventListener("fullscreenchange",this.onFullscreenChange)}options;element;arBtn=null;fullscreenBtn=null;onFullscreenChange;setFullscreenIcon(e){this.fullscreenBtn!==null&&this.fullscreenBtn.setIcon(e?b.exitFullscreen():b.fullscreen())}syncButton(e,t,i){if(t&&e===null){const s=i();return this.element.appendChild(s.element),s}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 v({variant:"outline",size:"icon",label:Ft(),icon:b.ar(),onClick:()=>{this.options.onAr?.()}})),this.fullscreenBtn=this.syncButton(this.fullscreenBtn,e.fullscreen!==!1&&this.options.onFullscreen!==void 0,()=>new v({variant:"outline",size:"icon",label:sn(),icon:b.fullscreen(),onClick:()=>{this.options.onFullscreen?.()}}))}destroy(){document.removeEventListener("fullscreenchange",this.onFullscreenChange)}}const T=.5;class M{element;constructor(e,t){this.element=Object.assign(document.createElement("div"),{className:"vd-camera-controls"});const i={targetRotation:t.rotation,targetTilt:t.tilt,targetZoom:t.zoom,thetaOffset:0},s=Pi(e,t,i);t.onChange(o=>{i.targetRotation=o.rotation-i.thetaOffset,i.targetTilt=o.tilt,i.targetZoom=o.zoom,Fi(s,t,o)}),this.element.appendChild(M.buildZoom(s.zoomOut,s.zoomIn)),this.element.appendChild(M.buildDpad(s.tiltUp,s.rotateLeft,s.reset,s.rotateRight,s.tiltDown))}static buildZoom(e,t){const i=document.createElement("div");return i.className="vd-zoom",i.appendChild(e.element),i.appendChild(t.element),i}static buildDpad(e,t,i,s,o){const r=document.createElement("div");r.className="vd-dpad";for(const[a,u]of[[e,"up"],[t,"left"],[i,"center"],[s,"right"],[o,"down"]])a.element.classList.add(`vd-dpad-${u}`),r.appendChild(a.element);return r}}function Pi(n,e,t){const i=r=>Math.max(e.limits?.minZoom??1,Math.min(e.limits?.maxZoom??1/0,r)),s=r=>{const a=e.limits?.minRotate,u=e.limits?.maxRotate;return a!==void 0||u!==void 0?Math.max(a??-1/0,Math.min(u??1/0,r)):r},o=r=>{const a=e.limits?.minTilt,u=e.limits?.maxTilt;if(a!==void 0||u!==void 0){t.targetTilt=Math.max(a??0,Math.min(u??180,t.targetTilt+r)),n.tilt(t.targetTilt).set();return}const d=t.targetTilt+r;d>180||d<0?(t.targetTilt=d>180?360-d:-d,t.thetaOffset=(t.thetaOffset+180)%360,n.tilt(t.targetTilt).rotate(t.targetRotation+t.thetaOffset).set()):(t.targetTilt=d,n.tilt(t.targetTilt).set())};return{zoomOut:new v({variant:"outline",size:"icon",label:Ln(),icon:b.zoomOut(),onClick:()=>{t.targetZoom=i(t.targetZoom-10),n.zoom(t.targetZoom).set()}}),zoomIn:new v({variant:"outline",size:"icon",label:Tn(),icon:b.zoomIn(),onClick:()=>{t.targetZoom=i(t.targetZoom+10),n.zoom(t.targetZoom).set()}}),tiltUp:new v({variant:"outline",size:"icon",label:Hn(),icon:b.tiltUp(),onClick:()=>{o(-15)}}),rotateLeft:new v({variant:"outline",size:"icon",label:Pn(),icon:b.rotateLeft(),onClick:()=>{t.targetRotation=s(t.targetRotation-15),n.rotate(t.targetRotation+t.thetaOffset).set()}}),reset:new v({variant:"outline",size:"icon",label:_n(),icon:b.reset(),onClick:()=>{t.thetaOffset=0,n.reset()}}),rotateRight:new v({variant:"outline",size:"icon",label:Un(),icon:b.rotateRight(),onClick:()=>{t.targetRotation=s(t.targetRotation+15),n.rotate(t.targetRotation+t.thetaOffset).set()}}),tiltDown:new v({variant:"outline",size:"icon",label:Wn(),icon:b.tiltDown(),onClick:()=>{o(15)}})}}function Fi(n,e,t){const i=e.limits;i!==void 0&&(n.zoomOut.element.disabled=i.minZoom!==void 0&&t.zoom<=i.minZoom+T,n.zoomIn.element.disabled=i.maxZoom!==void 0&&t.zoom>=i.maxZoom-T,n.tiltUp.element.disabled=i.minTilt!==void 0&&t.tilt<=i.minTilt+T,n.tiltDown.element.disabled=i.maxTilt!==void 0&&t.tilt>=i.maxTilt-T,n.rotateLeft.element.disabled=i.minRotate!==void 0&&t.rotation<=i.minRotate+T,n.rotateRight.element.disabled=i.maxRotate!==void 0&&t.rotation>=i.maxRotate-T)}const x={SELECT:"ui:select",SELECTED:"ui:selected",FOCUS_CHANGE:"vd:focus-change",CONFIGURATION_CHANGE:"vd:configuration-change",CONFIGURATION_SUBMIT:"vd:configuration-submit"},Pe={mm:1,cm:10,m:1e3,in:25.4},he=3;function Di(n){const e=n.stepMm/Pe[n.displayUnit];for(let t=0;t<=he;t++){const i=e*10**t;if(Math.abs(i-Math.round(i))<1e-9)return t}return he}function $i(n,e,t){const i=Di(e),s=n/Pe[e.displayUnit];return new Intl.NumberFormat(t,{minimumFractionDigits:i,maximumFractionDigits:i}).format(s)}function Ui(n,e,t,i,s,o,r){const a=m(),u=n.values.map(h=>$i(Number(h),e,a)),d=n.values.find(h=>t.getValue(n.name,h)?.isSelected===!0)??n.defaultValue,f=new _i(n.values,{label:n.name,labels:u,unit:e.displayUnit,...d!==void 0&&{initialSelected:d}});return f.onSelect(h=>{s(n.name,h)}),f.onSettle(h=>{i.dispatch(x.SELECT,{attribute:n.name,value:h},!0).defaultPrevented||o(n.name,h)}),r(n.name,h=>{f.setSelected(h.value),i.dispatch(x.SELECTED,{attribute:n.name,value:h.value})}),{element:f.element,setSelectable:()=>{}}}const Bi=5;let Vi=0;function Q(n){const e=n.replace(/([A-Z])/g," $1").trim();return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function ji(n,e,t,i,s,o){const r=document.createElement("div");r.className="vd-attribute",r.dataset.name=n.name;const a=document.createElement("span");a.className="vd-attribute-label",a.textContent=Q(n.name),a.id=`vd-attribute-label-${Vi++}`,r.appendChild(a),r.setAttribute("role","group"),r.setAttribute("aria-labelledby",a.id);const u=f=>{r.style.display=f?"none":""},d=n.dimension!==void 0?Ui(n,n.dimension,e,t,s,i,o):Hi(n,e,t,i,o);return r.appendChild(d.element),{element:r,setSelectable:d.setSelectable,setHidden:u}}function Hi(n,e,t,i,s){const o=n.values.find(u=>e.getValue(n.name,u)?.isSelected===!0),r=n.values.map(Q),a=n.values.length<=Bi?new Ci(n.values,o,r):new ki(n.name,n.values,Q(n.name),o,r);return a.onSelect(u=>{t.dispatch(x.SELECT,{attribute:n.name,value:u},!0).defaultPrevented||i(n.name,u)}),s(n.name,u=>{a.setSelected(u.value),t.dispatch(x.SELECTED,{attribute:n.name,value:u.value})}),{element:a.element,setSelectable:u=>{a.setEnabled(u)}}}const qi=80,Gi=2500;class Zi{constructor(e,t=Gi){this.configuration=e,this.resetMs=t,this.element=document.createElement("div"),this.element.className="vd-commerce vd-hidden";const i=document.createElement("div");i.className="vd-commerce-price",this.priceEl=document.createElement("span"),this.priceEl.className="vd-price",this.vatEl=document.createElement("span"),this.vatEl.className="vd-vat",i.append(this.priceEl,this.vatEl),this.button=new v({variant:"default",onClick:()=>{this.handleSubmit()}}),this.button.element.classList.add("vd-cta","vd-hidden"),this.element.append(i,this.button.element),this.unsubscribe=this.configuration.onRender(()=>{this.update()}),this.update()}configuration;resetMs;element;priceEl;vatEl;button;unsubscribe;state="idle";resetTimer;update(){this.renderPrice(this.configuration.current),this.renderButton();const e=this.configuration.current!==void 0||this.configuration.submitEnabled;this.element.classList.toggle("vd-hidden",!e)}destroy(){this.unsubscribe(),this.resetTimer!==void 0&&clearTimeout(this.resetTimer),this.element.remove()}renderPrice(e){if(e===void 0){this.priceEl.textContent="",this.vatEl.textContent="";return}this.priceEl.textContent=Wi(e.price,e.currency),this.vatEl.textContent=me(this.configuration.vatDisplay)}renderButton(){const e=this.configuration.submitEnabled;this.button.element.classList.toggle("vd-hidden",!e),e&&this.state==="idle"&&this.setButtonText(me(this.configuration.buttonLabel))}async handleSubmit(){if(this.state!=="busy"){this.setState("busy",Xn());try{await this.configuration.submit(),this.setState("success",ni())}catch{this.setState("failed",ri())}this.scheduleReset()}}scheduleReset(){this.resetTimer!==void 0&&clearTimeout(this.resetTimer),this.resetTimer=setTimeout(()=>{this.state="idle",this.update()},this.resetMs)}setState(e,t){this.state=e,this.element.dataset.submit=e,this.button.element.disabled=e==="busy",this.setButtonText(t)}setButtonText(e){this.button.element.textContent=e,this.button.element.setAttribute("aria-label",e)}}function me(n){return(n??"").slice(0,qi)}function Wi(n,e){try{const t=new Intl.NumberFormat(m(),{style:"currency",currency:e}),i=t.resolvedOptions().maximumFractionDigits??2;return t.format(n/10**i)}catch{return`${e} ${(n/100).toFixed(2)}`}}class Fe{slot=null;panel=null;attach(e,t){this.panel=t,t.style.display="none",this.slot=document.createElement("div"),this.slot.className="vd-slot-bottom-left",this.slot.appendChild(t),e.appendChild(this.slot)}setVisible(e){this.panel!==null&&(this.panel.style.display=e?"flex":"none")}destroy(){this.slot?.remove(),this.slot=null,this.panel=null}}const Yi=572;class Qi{constructor(e){this.actionBarSlot=e}actionBarSlot;element=null;body=null;openButton=null;closeButton=null;container=null;observer=null;collapsible=!1;expanded=!0;visible=!1;attach(e,t){this.container=e,t.classList.add("vd-attributes-sidebar"),this.closeButton=new v({variant:"ghost",size:"icon-sm",label:Sn(),icon:b.close({size:18}),onClick:()=>{this.expanded=!1,this.render()}});const i=document.createElement("div");i.className="vd-sidebar-header",i.appendChild(this.closeButton.element),this.body=document.createElement("div"),this.body.className="vd-sidebar-body",this.body.appendChild(t),this.element=document.createElement("div"),this.element.className="vd-sidebar vd-hidden",this.element.append(i,this.body),e.appendChild(this.element),this.openButton=new v({variant:"outline",size:"icon",label:gn(),icon:b.configurator({size:18}),onClick:()=>{this.expanded=!0,this.render()}}),this.openButton.element.classList.add("vd-configurator-toggle","vd-hidden"),this.actionBarSlot.appendChild(this.openButton.element),this.observe()}setVisible(e){this.visible=e,this.render()}destroy(){this.observer?.disconnect(),this.observer=null,this.openButton?.element.remove(),this.element?.remove(),this.container?.classList.remove("vd-layout-sidebar-right","vd-layout-sidebar-permanent"),this.container=null}observe(){typeof ResizeObserver>"u"||this.container===null||(this.observer=new ResizeObserver(e=>{const t=e[0]?.contentRect.width??0;this.setCollapsible(t>0&&t<Yi)}),this.observer.observe(this.container))}setCollapsible(e){e!==this.collapsible&&(this.collapsible=e,this.expanded=!e,this.render())}render(){if(this.element===null||this.openButton===null||this.closeButton===null||this.container===null)return;const e=this.visible&&this.expanded,t=this.visible&&!this.expanded;this.element.classList.toggle("vd-hidden",!this.visible),this.element.classList.toggle("vd-sidebar-collapsed",t),this.openButton.element.classList.toggle("vd-hidden",!t),this.closeButton.element.style.display=this.collapsible?"":"none",this.container.classList.toggle("vd-layout-sidebar-right",e),this.container.classList.toggle("vd-layout-sidebar-permanent",e&&!this.collapsible)}}class Ki{attach(e,t){}setVisible(e){}destroy(){}}const Xi={"inframe-bottom-left":()=>new Fe,"sidebar-right":n=>new Qi(n),hidden:()=>new Ki};function Ji(n,e){return(Xi[n??""]??(()=>new Fe))(e)}const G=w.fontFamily.sans.join(", "),Z=`
|
|
385
385
|
position: absolute;
|
|
386
386
|
display: flex;
|
|
387
387
|
z-index: 10;
|
|
388
388
|
transition: inset-inline-end 0.18s ease;
|
|
389
|
-
`,
|
|
389
|
+
`,es=`
|
|
390
390
|
/* Override browser's default black fullscreen backdrop */
|
|
391
391
|
.vd-container:fullscreen {
|
|
392
392
|
background: oklch(100% 0 0);
|
|
@@ -394,7 +394,7 @@
|
|
|
394
394
|
|
|
395
395
|
/* Layout slots — four corners */
|
|
396
396
|
.vd-slot-top-right {
|
|
397
|
-
${
|
|
397
|
+
${Z}
|
|
398
398
|
inset-block-start: ${l[3]};
|
|
399
399
|
inset-inline-end: ${l[3]};
|
|
400
400
|
flex-direction: column;
|
|
@@ -403,7 +403,7 @@
|
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
.vd-slot-bottom-left {
|
|
406
|
-
${
|
|
406
|
+
${Z}
|
|
407
407
|
inset-block-end: ${l[3]};
|
|
408
408
|
inset-inline-start: ${l[3]};
|
|
409
409
|
flex-direction: column;
|
|
@@ -412,7 +412,7 @@
|
|
|
412
412
|
}
|
|
413
413
|
|
|
414
414
|
.vd-slot-bottom-right {
|
|
415
|
-
${
|
|
415
|
+
${Z}
|
|
416
416
|
inset-block-end: ${l[3]};
|
|
417
417
|
inset-inline-end: ${l[3]};
|
|
418
418
|
flex-direction: row;
|
|
@@ -458,7 +458,7 @@
|
|
|
458
458
|
border-radius: ${l[3]};
|
|
459
459
|
padding: ${l[3]};
|
|
460
460
|
box-shadow: 0 ${l[1]} ${l[4]} color-mix(in oklch, ${p.neutral[900]} 6%, transparent);
|
|
461
|
-
font-family: ${
|
|
461
|
+
font-family: ${G};
|
|
462
462
|
}
|
|
463
463
|
|
|
464
464
|
.vd-attribute {
|
|
@@ -474,7 +474,7 @@
|
|
|
474
474
|
color: ${p.neutral[500]};
|
|
475
475
|
text-transform: uppercase;
|
|
476
476
|
letter-spacing: 0.05em;
|
|
477
|
-
font-family: ${
|
|
477
|
+
font-family: ${G};
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
/* sidebar-right layout — a docked, full-height right panel */
|
|
@@ -556,7 +556,7 @@
|
|
|
556
556
|
gap: ${l[2]};
|
|
557
557
|
padding-block-start: ${l[3]};
|
|
558
558
|
border-block-start: 1px solid color-mix(in oklch, ${p.neutral[900]} 8%, transparent);
|
|
559
|
-
font-family: ${
|
|
559
|
+
font-family: ${G};
|
|
560
560
|
}
|
|
561
561
|
|
|
562
562
|
.vd-commerce-price {
|
|
@@ -588,4 +588,4 @@
|
|
|
588
588
|
color: ${p.white};
|
|
589
589
|
}
|
|
590
590
|
|
|
591
|
-
`;function ss(){if(ze(),document.getElementById("vd-styles")!==null)return;const n=document.createElement("style");n.id="vd-styles",n.textContent=is,document.head.appendChild(n)}function os(n,e){const t=document.createElement("a");t.href=`data:image/png;base64,${n}`,t.download=e,t.click()}class rs{options;settings={};container=null;loading=null;slots={topRight:null,bottomRight:null};screenshotBtn=null;actionBar=null;cameraControls=null;attributes=null;groupHandles=new Map;lastSelectable=null;layout=null;commerce=null;constructor(e){this.options=e}attach(e){ss(),this.container=e,this.loading=new Fi(e),this.slots.topRight=this.createSlot(e,"vd-slot-top-right"),this.slots.bottomRight=this.createSlot(e,"vd-slot-bottom-right")}onReady(){this.loading?.hide(),this.loading=null,this.mountToolbar(),this.cameraControls!==null&&(this.cameraControls.element.style.display="flex"),this.layout?.setVisible(!0)}mountToolbar(){if(this.actionBar!==null||this.slots.bottomRight===null||this.container===null)return;const e=typeof this.container.requestFullscreen=="function";this.actionBar=new Di({onAr:this.options.onAr,onFullscreen:e?()=>{this.toggleFullscreen()}:void 0}),this.actionBar.applySettings(this.settings),this.slots.bottomRight.appendChild(this.actionBar.element),this.syncScreenshotButton(),this.placeScreenshotButton()}toggleFullscreen(){this.container!==null&&(document.fullscreenElement!==null?document.exitFullscreen():(this.options.onFullscreenEnter?.(),this.container.requestFullscreen()))}updateProgress(e,t){this.loading?.updateProgress(e,t)}showError(e){this.loading?.showError(e)}applyViewerSettings(e){this.settings=e,e.language!==void 0&&Te(e.language,{reload:!1}),this.syncScreenshotButton(),this.actionBar?.applySettings(e),this.cameraControls!==null&&(this.cameraControls.element.style.display=e.cameraControls===!0?"flex":"none"),this.placeScreenshotButton()}renderAttributeControls(e,t){if(!(this.container===null||this.slots.topRight===null||this.slots.bottomRight===null)&&(this.cameraControls?.element.remove(),this.cameraControls=null,this.teardownConfigurator(),this.settings.cameraControls===!0&&(this.cameraControls=new N(this.options.cameraApi,this.options.cameraPositionApi),this.cameraControls.element.style.display="none",this.slots.topRight.appendChild(this.cameraControls.element)),this.placeScreenshotButton(),t.length!==0)){this.attributes=document.createElement("div"),this.attributes.className="vd-attributes",this.groupHandles=new Map;for(const i of t){const s=Gi(i,e,this.options.eventBus,this.options.onSelect,this.options.onSelectTransient,this.options.onSubscribe);this.groupHandles.set(i.name,s),this.attributes.appendChild(s.element)}this.commerce=new Qi(this.options.configuration),this.attributes.appendChild(this.commerce.element),this.layout=ns(this.settings.configuratorLayout,this.slots.bottomRight),this.layout.attach(this.container,this.attributes),this.lastSelectable!==null&&this.applySelectable(this.lastSelectable)}}applySelectable(e){this.lastSelectable=e;for(const[t,i]of this.groupHandles){const s=e.find(o=>o.name===t);i.setSelectable(s?.selectable??null),i.setHidden(s?.hidden===!0)}}get viewerSettings(){return this.settings}teardownConfigurator(){this.commerce?.destroy(),this.commerce=null,this.attributes?.remove(),this.attributes=null,this.groupHandles=new Map,this.layout?.destroy(),this.layout=null}destroy(){this.loading?.destroy(),this.screenshotBtn?.element.remove(),this.actionBar?.destroy(),this.actionBar?.element.remove(),this.cameraControls?.element.remove(),this.teardownConfigurator();for(const e of Object.values(this.slots))e?.remove();this.container=null}createSlot(e,t){const i=document.createElement("div");return i.className=t,e.appendChild(i),i}syncScreenshotButton(){const e=this.settings.screenshot===!0;e&&this.screenshotBtn===null&&(this.screenshotBtn=new v({variant:"outline",size:"icon",label:fn(),icon:b.screenshot(),onClick:()=>{this.options.snapshotApi.take("snapshot.png").onDeveloped(({data:t,filename:i})=>{os(t,i)})}})),!e&&this.screenshotBtn!==null&&(this.screenshotBtn.element.remove(),this.screenshotBtn=null)}placeScreenshotButton(){this.screenshotBtn===null||this.slots.topRight===null||(this.cameraControls!==null?this.cameraControls.element.appendChild(this.screenshotBtn.element):this.slots.topRight.appendChild(this.screenshotBtn.element))}}const as={};class ls{defaultServer="https://server.virtualdisplay.io";options;serverHost;extraParams;constructor(e,t,i){this.options=e,this.serverHost=t,this.extraParams=i}create(){const e=this.createContainer(),t=this.createIframe();return e.appendChild(t),this.attachToParent(e),{container:e,iframe:t}}createContainer(){const e=document.createElement("div");return e.className="vd-container",Object.assign(e.style,{position:"relative",width:"100%",height:"100%",overflow:"hidden"}),e}createIframe(){const e=document.createElement("iframe");return e.src=this.buildUrl(),e.setAttribute("allow","xr-spatial-tracking; fullscreen"),e}attachToParent(e){this.getParentElement().appendChild(e)}buildUrl(){const e=this.getServerUrl(),t=new URL(e);this.setAddressParams(t),this.options.language!==void 0&&t.searchParams.set("language",this.options.language),this.options.session!==void 0&&t.searchParams.set("session",this.options.session),this.options.debug===!0&&t.searchParams.set("debug","true"),this.options.traceparent!==void 0&&t.searchParams.set("traceparent",this.options.traceparent);for(const[i,s]of Object.entries(this.extraParams??{}))t.searchParams.set(i,s);return t.toString()}setAddressParams(e){if(this.options.app===void 0){e.searchParams.set("license",this.options.license),e.searchParams.set("model",this.options.model);return}e.searchParams.set("app",this.options.app),(this.options.license!==void 0||this.options.model!==void 0)&&exports.logger.warn("Both `app` and `license`/`model` were supplied: `app` wins, the pair was ignored")}getServerUrl(){if(this.serverHost!==void 0)return this.serverHost;if(as?.VITE_VIRTUALDISPLAY_SERVER_HOST===void 0)return this.defaultServer}getParentElement(){if(typeof this.options.parent!="string")return this.options.parent;const e=document.querySelector(this.options.parent);if(e===null)throw g.parentNotFound(this.options.parent);return e}}function cs(n){const{messenger:e}=n;e.on(c.HANDSHAKE,t=>{Ve(t)&&(exports.logger.info("Server handshake received, flushing publisher queue"),e.markReady())}),e.on(c.SESSION,t=>{je(t)&&n.onSession(t.sessionId)}),e.on(c.MUTATION,t=>{qe(t)&&(n.attributes.handleMutationResult(t),n.configuration.handleSelectionChanged(n.attributes.getSelection()))}),e.on(c.SNAPSHOT,t=>{Ge(t)&&n.snapshot.handleSnapshotResult(t)}),e.on(c.CAMERA,t=>{Ze(t)&&n.cameraPosition.handlePositionUpdate(t)}),e.on(c.LOADING_INDICATOR,t=>{Ye(t)&&(t.error!==void 0?n.ui.showError(t.error):n.ui.updateProgress(t.progress,t.phase))}),e.on(c.CONFIG,t=>{Xe(t)&&n.applyConfig(t)}),e.on(c.MAPPING,t=>{We(t)&&(n.attributes.handleMappingReceived(t),n.configuration.handleSelectionChanged(n.attributes.getSelection()),n.ui.renderAttributeControls(n.attributes,t.attributes),n.readyStateTracker.handleMappingReceived())}),us(n)}function us(n){const{messenger:e}=n;e.on(c.FOCUS,t=>{Je(t)&&n.focus.handleStateReceived(t)}),e.on(c.PRICING,t=>{et(t)&&n.configuration.handlePricingReceived(t.pricing)}),e.on(c.SYNC,t=>{Qe(t)&&n.onSync(t.connected)}),e.on(c.SELECTABLE,t=>{Ke(t)&&(n.selectable.handleSnapshot(t),n.ui.applySelectable(t.attributes))}),e.on(c.APP_RESOLVED,t=>{He(t)&&n.onAppResolved(t)})}class ds{ready=!1;onReady;constructor(e){this.onReady=e}handleMappingReceived(){this.ready||(this.ready=!0,exports.logger.info("Mapping received from server, client is now ready"),this.onReady?.())}get isReady(){return this.ready}clear(){this.ready=!1}}class hs{attributes;selectableState;readyStateTracker;messenger;cameraApi;cameraPositionApi;focusApi;configurationApi;snapshotApi;annotationsApi;eventBus;ui;options;serverHost;iframeParams;arActivation;syncTracker;iframe;container;readyCallbacks=[];mutationFailedCallbacks=[];viewerSessionId;resolvedApp;appResolvedCallbacks=[];constructor(e,t){this.options=e;const i=t??{};this.serverHost=i.serverHost,this.iframeParams=i.iframeParams,this.initializeLogging(),this.messenger=new tt(()=>this.iframe?.contentWindow??null,i.messengerOptions);const s=o=>{this.messenger.send(o)};this.attributes=new yt(s,(o,r)=>{this.notifyMutationFailed(o,r)}),this.selectableState=new St,this.snapshotApi=new Ee(s),this.annotationsApi=new me(s),this.cameraApi=new Ce(s),this.cameraPositionApi=new wt,this.focusApi=new ke(s,o=>{this.dispatchFocusChange(o)}),this.configurationApi=new _e(o=>{this.dispatchConfigurationChange(o)},o=>{this.dispatchConfigurationSubmit(o)}),this.eventBus=new kt,this.arActivation=i.createArActivation?.(s),this.syncTracker=i.createSyncTracker?.(),this.readyStateTracker=new ds(()=>{this.notifyReady()}),this.ui=this.createStandardInterface(),this.wireIncomingMessages(),i.registerHandlers?.(this.messenger,s),this.messenger.start(),this.createAndConnectIframe()}createStandardInterface(){const e=this.arActivation;return new rs({snapshotApi:this.snapshotApi,cameraApi:this.cameraApi,cameraPositionApi:this.cameraPositionApi,eventBus:this.eventBus,configuration:this.configurationApi,onSelect:(t,i)=>this.attributes.select(t,i),onSelectTransient:(t,i)=>this.attributes.selectTransient(t,i),onSubscribe:(t,i)=>this.attributes.onChange(t,i),...e!==void 0&&{onAr:()=>{e.activate()}},onFullscreenEnter:()=>{this.trackFullscreen()}})}wireIncomingMessages(){cs({messenger:this.messenger,attributes:this.attributes,selectable:this.selectableState,configuration:this.configurationApi,snapshot:this.snapshotApi,cameraPosition:this.cameraPositionApi,focus:this.focusApi,ui:this.ui,readyStateTracker:this.readyStateTracker,applyConfig:e=>{this.handleConfig(e)},onSession:e=>{this.handleSession(e)},onSync:e=>{this.syncTracker?.handleSync(e)},onAppResolved:e=>{this.handleAppResolved({appType:e.appType,name:e.name,...e.slug!==void 0&&{slug:e.slug},...e.submit!==void 0&&{submit:e.submit}})}})}handleAppResolved(e){this.resolvedApp=e;for(const t of this.appResolvedCallbacks)t(e)}handleSession(e){this.viewerSessionId=e,this.arActivation?.onSession(e)}notifyMutationFailed(e,t){for(const i of this.mutationFailedCallbacks)i({attribute:e,value:t})}notifyReady(){const e=this.readyCallbacks;this.readyCallbacks=[];for(const t of e)t(this);this.ui.onReady()}dispatchFocusChange(e){this.container?.dispatchEvent(new CustomEvent(x.FOCUS_CHANGE,{detail:e,bubbles:!0}))}dispatchConfigurationChange(e){this.container?.dispatchEvent(new CustomEvent(x.CONFIGURATION_CHANGE,{detail:e??null,bubbles:!0}))}dispatchConfigurationSubmit(e){this.container?.dispatchEvent(new CustomEvent(x.CONFIGURATION_SUBMIT,{detail:e,bubbles:!0}))}handleConfig(e){const t=e.viewerSettings,i=this.options.viewerSettings;if(t!==void 0||i!==void 0){const s=i!==void 0?{...t??{},...i}:t;if(i!==void 0&&t!==void 0){const o=Object.entries(i).filter(([r,a])=>t[r]!==a).map(([r,a])=>`${r} (metadata: ${t[r]??"undefined"}, override: ${a})`);o.length>0&&exports.logger.warn(`Viewer settings override active: ${o.join(", ")}`)}this.ui.applyViewerSettings(s),this.annotationsApi.setEnabled(s.annotations!==!1)}this.cameraPositionApi.applyLimits(e.cameraLimits)}trackFullscreen(){this.messenger.send({type:c.FULLSCREEN})}initializeLogging(){this.options.debug===!0&&we(),exports.logger.info("Initializing Virtualdisplay client",{...this.options.app===void 0?{model:this.options.model}:{app:this.options.app}})}createAndConnectIframe(){const t=new ls(this.options,this.serverHost,this.iframeParams).create();this.container=t.container,this.iframe=t.iframe,this.eventBus.attach(this.container),this.ui.attach(this.container);try{const i=new URL(this.iframe.src).origin;this.messenger.setTargetOrigin(i)}catch{}}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)}onSelectableChange(e){this.selectableState.onChange(e)}onAppResolved(e){this.appResolvedCallbacks.push(e),this.resolvedApp!==void 0&&e(this.resolvedApp)}getSelectable(e){return this.selectableState.selectableFor(e)}activateAr(){this.arActivation?.activate()}on(e,t){this.eventBus.on(e,t)}get annotations(){return this.annotationsApi}get camera(){return this.cameraApi}get focus(){return this.focusApi}get configuration(){return this.configurationApi}get cameraPosition(){return this.cameraPositionApi}get snapshot(){return this.snapshotApi}get sessionId(){return this.viewerSessionId}get viewerSettings(){return this.ui.viewerSettings}destroy(){this.readyStateTracker.clear(),this.readyCallbacks=[],this.mutationFailedCallbacks.length=0,this.snapshotApi.clear(),this.messenger.destroy(),this.arActivation?.destroy(),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}}const ms="ar.virtualdisplay.io";function ps(n){const e=new URL(`https://${ms}/go`);return n.sessionId!==void 0?e.searchParams.set("session",n.sessionId):n.app!==void 0?e.searchParams.set("app",n.app):n.license!==void 0&&n.model!==void 0&&(e.searchParams.set("license",n.license),e.searchParams.set("model",n.model)),e.toString()}const fs=1500;class gs{options;qrModal=new Li;sessionId;waiters=[];pendingTimers=new Set;destroyed=!1;constructor(e){this.options=e}onSession(e){this.sessionId=e;const t=this.waiters;this.waiters=[];for(const i of t)i(e)}activate(){if(gt()){this.options.send({type:c.AR_ACTIVATE});return}this.showQrCode()}destroy(){this.destroyed=!0;for(const e of this.pendingTimers)clearTimeout(e);this.pendingTimers.clear(),this.waiters=[],this.qrModal.hide()}async showQrCode(){this.qrModal.show();const e=await this.waitForSessionId();if(this.destroyed)return;const t=ps({sessionId:e,app:this.options.app,license:this.options.license,model:this.options.model}),i=await this.qrModal.update(t);if(this.destroyed){this.qrModal.hide();return}i&&this.options.send({type:c.QR_SHOWN})}waitForSessionId(){return this.sessionId!==void 0?Promise.resolve(this.sessionId):new Promise(e=>{const t=setTimeout(()=>{this.pendingTimers.delete(t),e(void 0)},fs);this.pendingTimers.add(t),this.waiters.push(i=>{this.pendingTimers.delete(t),clearTimeout(t),e(i)})})}}class bs{callbacks=[];lastKnown;handleSync(e){this.lastKnown=e;for(const t of this.callbacks)t(e)}onChange(e){this.callbacks.push(e),this.lastKnown!==void 0&&e(this.lastKnown)}}class vs extends hs{syncStatusTracker;constructor(e){const t=new bs;super(e,{createArActivation:i=>new gs({app:e.app,license:e.license,model:e.model,send:i}),createSyncTracker:()=>t}),this.syncStatusTracker=t}onSyncChange(e){this.syncStatusTracker.onChange(e)}}exports.Annotations=me;exports.Attribute=fe;exports.AttributeValue=pe;exports.Camera=Ce;exports.Configuration=_e;exports.ERROR_CODES=_;exports.Focus=ke;exports.Photo=Ae;exports.Snapshot=Ee;exports.VD_EVENTS=x;exports.VirtualdisplayClient=vs;exports.VirtualdisplayError=g;exports.enableDebugMode=we;exports.isDebugMode=vt;
|
|
591
|
+
`;function ts(){if(ze(),document.getElementById("vd-styles")!==null)return;const n=document.createElement("style");n.id="vd-styles",n.textContent=es,document.head.appendChild(n)}function ns(n,e){const t=document.createElement("a");t.href=`data:image/png;base64,${n}`,t.download=e,t.click()}class is{options;settings={};container=null;loading=null;slots={topRight:null,bottomRight:null};screenshotBtn=null;actionBar=null;cameraControls=null;attributes=null;groupHandles=new Map;lastSelectable=null;layout=null;commerce=null;constructor(e){this.options=e}attach(e){ts(),this.container=e,this.loading=new Mi(e),this.slots.topRight=this.createSlot(e,"vd-slot-top-right"),this.slots.bottomRight=this.createSlot(e,"vd-slot-bottom-right")}onReady(){this.loading?.hide(),this.loading=null,this.mountToolbar(),this.cameraControls!==null&&(this.cameraControls.element.style.display="flex"),this.layout?.setVisible(!0)}mountToolbar(){if(this.actionBar!==null||this.slots.bottomRight===null||this.container===null)return;const e=typeof this.container.requestFullscreen=="function";this.actionBar=new zi({onAr:this.options.onAr,onFullscreen:e?()=>{this.toggleFullscreen()}:void 0}),this.actionBar.applySettings(this.settings),this.slots.bottomRight.appendChild(this.actionBar.element),this.syncScreenshotButton(),this.placeScreenshotButton()}toggleFullscreen(){this.container!==null&&(document.fullscreenElement!==null?document.exitFullscreen():(this.options.onFullscreenEnter?.(),this.container.requestFullscreen()))}updateProgress(e,t){this.loading?.updateProgress(e,t)}showError(e){this.loading?.showError(e)}applyViewerSettings(e){this.settings=e,e.language!==void 0&&Re(e.language,{reload:!1}),this.syncScreenshotButton(),this.actionBar?.applySettings(e),this.cameraControls!==null&&(this.cameraControls.element.style.display=e.cameraControls===!0?"flex":"none"),this.placeScreenshotButton()}renderAttributeControls(e,t){if(!(this.container===null||this.slots.topRight===null||this.slots.bottomRight===null)&&(this.cameraControls?.element.remove(),this.cameraControls=null,this.teardownConfigurator(),this.settings.cameraControls===!0&&(this.cameraControls=new M(this.options.cameraApi,this.options.cameraPositionApi),this.cameraControls.element.style.display="none",this.slots.topRight.appendChild(this.cameraControls.element)),this.placeScreenshotButton(),t.length!==0)){this.attributes=document.createElement("div"),this.attributes.className="vd-attributes",this.groupHandles=new Map;for(const i of t){const s=ji(i,e,this.options.eventBus,this.options.onSelect,this.options.onSelectTransient,this.options.onSubscribe);this.groupHandles.set(i.name,s),this.attributes.appendChild(s.element)}this.commerce=new Zi(this.options.configuration),this.attributes.appendChild(this.commerce.element),this.layout=Ji(this.settings.configuratorLayout,this.slots.bottomRight),this.layout.attach(this.container,this.attributes),this.lastSelectable!==null&&this.applySelectable(this.lastSelectable)}}applySelectable(e){this.lastSelectable=e;for(const[t,i]of this.groupHandles){const s=e.find(o=>o.name===t);i.setSelectable(s?.selectable??null),i.setHidden(s?.hidden===!0)}}get viewerSettings(){return this.settings}teardownConfigurator(){this.commerce?.destroy(),this.commerce=null,this.attributes?.remove(),this.attributes=null,this.groupHandles=new Map,this.layout?.destroy(),this.layout=null}destroy(){this.loading?.destroy(),this.screenshotBtn?.element.remove(),this.actionBar?.destroy(),this.actionBar?.element.remove(),this.cameraControls?.element.remove(),this.teardownConfigurator();for(const e of Object.values(this.slots))e?.remove();this.container=null}createSlot(e,t){const i=document.createElement("div");return i.className=t,e.appendChild(i),i}syncScreenshotButton(){const e=this.settings.screenshot===!0;e&&this.screenshotBtn===null&&(this.screenshotBtn=new v({variant:"outline",size:"icon",label:hn(),icon:b.screenshot(),onClick:()=>{this.options.snapshotApi.take("snapshot.png").onDeveloped(({data:t,filename:i})=>{ns(t,i)})}})),!e&&this.screenshotBtn!==null&&(this.screenshotBtn.element.remove(),this.screenshotBtn=null)}placeScreenshotButton(){this.screenshotBtn===null||this.slots.topRight===null||(this.cameraControls!==null?this.cameraControls.element.appendChild(this.screenshotBtn.element):this.slots.topRight.appendChild(this.screenshotBtn.element))}}const ss={};class os{defaultServer="https://server.virtualdisplay.io";options;serverHost;extraParams;constructor(e,t,i){this.options=e,this.serverHost=t,this.extraParams=i}create(){const e=this.createContainer(),t=this.createIframe();return e.appendChild(t),this.attachToParent(e),{container:e,iframe:t}}createContainer(){const e=document.createElement("div");return e.className="vd-container",Object.assign(e.style,{position:"relative",width:"100%",height:"100%",overflow:"hidden"}),e}createIframe(){const e=document.createElement("iframe");return e.src=this.buildUrl(),e.setAttribute("allow","xr-spatial-tracking; fullscreen"),e}attachToParent(e){this.getParentElement().appendChild(e)}buildUrl(){const e=this.getServerUrl(),t=new URL(e);this.setAddressParams(t),this.options.language!==void 0&&t.searchParams.set("language",this.options.language),this.options.session!==void 0&&t.searchParams.set("session",this.options.session),this.options.debug===!0&&t.searchParams.set("debug","true"),this.options.traceparent!==void 0&&t.searchParams.set("traceparent",this.options.traceparent);for(const[i,s]of Object.entries(this.extraParams??{}))t.searchParams.set(i,s);return t.toString()}setAddressParams(e){if(this.options.app===void 0){e.searchParams.set("license",this.options.license),e.searchParams.set("model",this.options.model);return}e.searchParams.set("app",this.options.app),(this.options.license!==void 0||this.options.model!==void 0)&&exports.logger.warn("Both `app` and `license`/`model` were supplied: `app` wins, the pair was ignored")}getServerUrl(){if(this.serverHost!==void 0)return this.serverHost;if(ss?.VITE_VIRTUALDISPLAY_SERVER_HOST===void 0)return this.defaultServer}getParentElement(){if(typeof this.options.parent!="string")return this.options.parent;const e=document.querySelector(this.options.parent);if(e===null)throw g.parentNotFound(this.options.parent);return e}}function rs(n){const{messenger:e}=n;e.on(c.HANDSHAKE,t=>{Ve(t)&&(exports.logger.info("Server handshake received, flushing publisher queue"),e.markReady())}),e.on(c.SESSION,t=>{je(t)&&n.onSession(t.sessionId)}),e.on(c.MUTATION,t=>{qe(t)&&(n.attributes.handleMutationResult(t),n.configuration.handleSelectionChanged(n.attributes.getSelection()))}),e.on(c.SNAPSHOT,t=>{Ge(t)&&n.snapshot.handleSnapshotResult(t)}),e.on(c.CAMERA,t=>{Ze(t)&&n.cameraPosition.handlePositionUpdate(t)}),e.on(c.LOADING_INDICATOR,t=>{Ye(t)&&(t.error!==void 0?n.ui.showError(t.error):n.ui.updateProgress(t.progress,t.phase))}),e.on(c.CONFIG,t=>{Xe(t)&&n.applyConfig(t)}),e.on(c.MAPPING,t=>{We(t)&&(n.attributes.handleMappingReceived(t),n.configuration.handleSelectionChanged(n.attributes.getSelection()),n.ui.renderAttributeControls(n.attributes,t.attributes),n.readyStateTracker.handleMappingReceived())}),as(n)}function as(n){const{messenger:e}=n;e.on(c.FOCUS,t=>{Je(t)&&n.focus.handleStateReceived(t)}),e.on(c.PRICING,t=>{et(t)&&n.configuration.handlePricingReceived(t.pricing)}),e.on(c.SYNC,t=>{Qe(t)&&n.onSync(t.connected)}),e.on(c.SELECTABLE,t=>{Ke(t)&&(n.selectable.handleSnapshot(t),n.ui.applySelectable(t.attributes))}),e.on(c.APP_RESOLVED,t=>{He(t)&&n.onAppResolved(t)})}class ls{ready=!1;onReady;constructor(e){this.onReady=e}handleMappingReceived(){this.ready||(this.ready=!0,exports.logger.info("Mapping received from server, client is now ready"),this.onReady?.())}get isReady(){return this.ready}clear(){this.ready=!1}}function cs(n){if(n===void 0)return;const{annotations:e,...t}=n;return e===void 0?t:e===!0?{...t,annotations:"show"}:e===!1?{...t,annotations:"hide"}:{...t,annotations:e}}class us{attributes;selectableState;readyStateTracker;messenger;cameraApi;cameraPositionApi;focusApi;configurationApi;snapshotApi;annotationsApi;eventBus;ui;options;serverHost;iframeParams;arActivation;syncTracker;iframe;container;readyCallbacks=[];mutationFailedCallbacks=[];viewerSessionId;resolvedApp;appResolvedCallbacks=[];constructor(e,t){this.options=e;const i=t??{};this.serverHost=i.serverHost,this.iframeParams=i.iframeParams,this.initializeLogging(),this.messenger=new tt(()=>this.iframe?.contentWindow??null,i.messengerOptions);const s=o=>{this.messenger.send(o)};this.attributes=new yt(s,P,(o,r)=>{this.notifyMutationFailed(o,r)}),this.selectableState=new St,this.snapshotApi=new xe(s),this.annotationsApi=new pe(s,P),this.cameraApi=new ke(s),this.cameraPositionApi=new wt,this.focusApi=new Ae(s,o=>{this.dispatchFocusChange(o)},P),this.configurationApi=new _e(o=>{this.dispatchConfigurationChange(o)},o=>{this.dispatchConfigurationSubmit(o)}),this.eventBus=new _t,this.arActivation=i.createArActivation?.(s),this.syncTracker=i.createSyncTracker?.(),this.readyStateTracker=new ls(()=>{this.notifyReady()}),this.ui=this.createStandardInterface(),this.wireIncomingMessages(),i.registerHandlers?.(this.messenger,s),this.messenger.start(),this.createAndConnectIframe()}createStandardInterface(){const e=this.arActivation;return new is({snapshotApi:this.snapshotApi,cameraApi:this.cameraApi,cameraPositionApi:this.cameraPositionApi,eventBus:this.eventBus,configuration:this.configurationApi,onSelect:(t,i)=>this.attributes.select(t,i),onSelectTransient:(t,i)=>this.attributes.selectTransient(t,i),onSubscribe:(t,i)=>this.attributes.onChange(t,i),...e!==void 0&&{onAr:()=>{e.activate()}},onFullscreenEnter:()=>{this.trackFullscreen()}})}wireIncomingMessages(){rs({messenger:this.messenger,attributes:this.attributes,selectable:this.selectableState,configuration:this.configurationApi,snapshot:this.snapshotApi,cameraPosition:this.cameraPositionApi,focus:this.focusApi,ui:this.ui,readyStateTracker:this.readyStateTracker,applyConfig:e=>{this.handleConfig(e)},onSession:e=>{this.handleSession(e)},onSync:e=>{this.syncTracker?.handleSync(e)},onAppResolved:e=>{this.handleAppResolved({appType:e.appType,name:e.name,...e.slug!==void 0&&{slug:e.slug},...e.submit!==void 0&&{submit:e.submit}})}})}handleAppResolved(e){this.resolvedApp=e;for(const t of this.appResolvedCallbacks)t(e)}handleSession(e){this.viewerSessionId=e,this.arActivation?.onSession(e)}notifyMutationFailed(e,t){for(const i of this.mutationFailedCallbacks)i({attribute:e,value:t})}notifyReady(){const e=this.readyCallbacks;this.readyCallbacks=[];for(const t of e)t(this);this.ui.onReady()}dispatchFocusChange(e){this.container?.dispatchEvent(new CustomEvent(x.FOCUS_CHANGE,{detail:e,bubbles:!0}))}dispatchConfigurationChange(e){this.container?.dispatchEvent(new CustomEvent(x.CONFIGURATION_CHANGE,{detail:e??null,bubbles:!0}))}dispatchConfigurationSubmit(e){this.container?.dispatchEvent(new CustomEvent(x.CONFIGURATION_SUBMIT,{detail:e,bubbles:!0}))}handleConfig(e){const t=e.viewerSettings,i=cs(this.options.viewerSettings);if(t!==void 0||i!==void 0){const s=i!==void 0?{...t??{},...i}:t;if(i!==void 0&&t!==void 0){const o=Object.entries(i).filter(([r,a])=>t[r]!==a).map(([r,a])=>`${r} (metadata: ${t[r]??"undefined"}, override: ${a})`);o.length>0&&exports.logger.warn(`Viewer settings override active: ${o.join(", ")}`)}this.ui.applyViewerSettings(s),this.echoAnnotationsDifference(t?.annotations,s.annotations)}this.cameraPositionApi.applyLimits(e.cameraLimits)}echoAnnotationsDifference(e,t){t===void 0||t===e||this.annotationsApi.setEnabled(t==="show"||t==="toggle-shown")}trackFullscreen(){this.messenger.send({type:c.FULLSCREEN})}initializeLogging(){this.options.debug===!0&&Ce(),exports.logger.info("Initializing Virtualdisplay client",{...this.options.app===void 0?{model:this.options.model}:{app:this.options.app}})}createAndConnectIframe(){const t=new os(this.options,this.serverHost,this.iframeParams).create();this.container=t.container,this.iframe=t.iframe,this.eventBus.attach(this.container),this.ui.attach(this.container);try{const i=new URL(this.iframe.src).origin;this.messenger.setTargetOrigin(i)}catch{}}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)}onSelectableChange(e){this.selectableState.onChange(e)}onAppResolved(e){this.appResolvedCallbacks.push(e),this.resolvedApp!==void 0&&e(this.resolvedApp)}getSelectable(e){return this.selectableState.selectableFor(e)}activateAr(){this.arActivation?.activate()}on(e,t){this.eventBus.on(e,t)}get annotations(){return this.annotationsApi}get camera(){return this.cameraApi}get focus(){return this.focusApi}get configuration(){return this.configurationApi}get cameraPosition(){return this.cameraPositionApi}get snapshot(){return this.snapshotApi}get sessionId(){return this.viewerSessionId}get viewerSettings(){return this.ui.viewerSettings}destroy(){this.readyStateTracker.clear(),this.readyCallbacks=[],this.mutationFailedCallbacks.length=0,this.snapshotApi.clear(),this.messenger.destroy(),this.arActivation?.destroy(),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}}const ds="ar.virtualdisplay.io";function hs(n){const e=new URL(`https://${ds}/go`);return n.sessionId!==void 0?e.searchParams.set("session",n.sessionId):n.app!==void 0?e.searchParams.set("app",n.app):n.license!==void 0&&n.model!==void 0&&(e.searchParams.set("license",n.license),e.searchParams.set("model",n.model)),e.toString()}const ms=1500;class ps{options;qrModal=new Ti;sessionId;waiters=[];pendingTimers=new Set;destroyed=!1;constructor(e){this.options=e}onSession(e){this.sessionId=e;const t=this.waiters;this.waiters=[];for(const i of t)i(e)}activate(){if(gt()){this.options.send({type:c.AR_ACTIVATE});return}this.showQrCode()}destroy(){this.destroyed=!0;for(const e of this.pendingTimers)clearTimeout(e);this.pendingTimers.clear(),this.waiters=[],this.qrModal.hide()}async showQrCode(){this.qrModal.show();const e=await this.waitForSessionId();if(this.destroyed)return;const t=hs({sessionId:e,app:this.options.app,license:this.options.license,model:this.options.model}),i=await this.qrModal.update(t);if(this.destroyed){this.qrModal.hide();return}i&&this.options.send({type:c.QR_SHOWN})}waitForSessionId(){return this.sessionId!==void 0?Promise.resolve(this.sessionId):new Promise(e=>{const t=setTimeout(()=>{this.pendingTimers.delete(t),e(void 0)},ms);this.pendingTimers.add(t),this.waiters.push(i=>{this.pendingTimers.delete(t),clearTimeout(t),e(i)})})}}class fs{callbacks=[];lastKnown;handleSync(e){this.lastKnown=e;for(const t of this.callbacks)t(e)}onChange(e){this.callbacks.push(e),this.lastKnown!==void 0&&e(this.lastKnown)}}class gs extends us{syncStatusTracker;constructor(e){const t=new fs;super(e,{createArActivation:i=>new ps({app:e.app,license:e.license,model:e.model,send:i}),createSyncTracker:()=>t}),this.syncStatusTracker=t}onSyncChange(e){this.syncStatusTracker.onChange(e)}}exports.Annotations=pe;exports.Attribute=ge;exports.AttributeValue=fe;exports.Camera=ke;exports.Configuration=_e;exports.ERROR_CODES=k;exports.Focus=Ae;exports.Photo=Ee;exports.Snapshot=xe;exports.VD_EVENTS=x;exports.VirtualdisplayClient=gs;exports.VirtualdisplayError=g;exports.enableDebugMode=Ce;exports.isDebugMode=vt;
|