@neurodyn/core-ar 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core-ar.embed.min.js +2 -2
- package/dist/index.js +31 -6
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(()=>{"use strict";let e,t,i;function r(e,t){let i;try{i=new URL(e)}catch{throw TypeError(`${t} must be an absolute HTTP(S) URL`)}if("http:"!==i.protocol&&"https:"!==i.protocol)throw TypeError(`${t} must be an absolute HTTP(S) URL`);return i.origin}function n(){if(!e)throw Error("Core AR widget runtime is not configured");return e}function o(){return"u"<typeof navigator?"":navigator.userAgent||navigator.vendor||""}function a(){if("u"<typeof window||"u"<typeof navigator)return!1;let e="MacIntel"===navigator.platform&&navigator.maxTouchPoints>1;return(/iPad|iPhone|iPod/.test(o())||e)&&!("MSStream"in window)}function s(){if("u"<typeof window||"u"<typeof navigator)return!1;let e=navigator.maxTouchPoints>1,t=window.matchMedia?.("(pointer: coarse)").matches??!1,i=/Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone|Opera Mini|IEMobile|Mobile/i.test(o());return e&&t&&(i||a())}function l(){let e=o();return[[/edg/i,"Microsoft Edge"],[/trident/i,"Microsoft Internet Explorer"],[/firefox|fxios/i,"Mozilla Firefox"],[/opr\//i,"Opera"],[/ucbrowser/i,"UC Browser"],[/samsungbrowser/i,"Samsung Browser"],[/chrome|chromium|crios/i,"Google Chrome"],[/safari/i,"Apple Safari"]].find(([t])=>t.test(e))?.[1]??"Other"}function d(){let e=function(){let e=o(),t=e.match(/\bOS (\d+)/)?.[1]??e.match(/Version\/(\d+)/)?.[1];if(!t)return null;let i=Number.parseInt(t,10);return Number.isNaN(i)?null:i}();return null!==e&&e>=17}function c(e){let t;try{t=new URL(e)}catch{throw TypeError("Native AR asset URL must be absolute HTTP(S)")}if("http:"!==t.protocol&&"https:"!==t.protocol)throw TypeError("Native AR asset URL must be absolute HTTP(S)");return t.href}function u(e,t){let i=c(e.glbUrl),r=c(e.usdzUrl),n=encodeURIComponent(i),o=`intent://arvr.google.com/scene-viewer/1.0?file=${n}&resizable=false${"wall"===t||"ceiling"===t?"&enable_vertical_placement=true":""}&mode=ar_preferred#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;end;`,s=`${r}#allowsContentScaling=0`;return a()?s:o}function g(e,t=0){let i=document.createElement("a"),r=document.createElement("img");i.rel="ar",i.href=e,i.hidden=!0,r.alt="",r.hidden=!0,i.appendChild(r),document.body.appendChild(i),window.setTimeout(()=>{i.click(),i.remove()},t)}function h(e,t,i){let r=function(e,t,i){let{brand:r}=i??n();if(a()){let i=new URL("https://appclip.apple.com/id");return i.searchParams.set("p","com.us.vizbl.Clip"),i.searchParams.set("tinuuid",e),t&&i.searchParams.set("hid",t),i.searchParams.set("region","arizo"===r?"ru":"en"),i.toString()}return`intent:/${window.location.pathname}#Intent;scheme=open;package=com.us.vizbl;end`}(e,t,i);window.self===window.top||l().toLowerCase().includes("edge")?window.location.assign(r):window.open(r,"_top")}function m(e,t,i=!1,r){let{viewerOrigin:o}=r??n(),a=new URL("/ar/index.html",o);return a.searchParams.set("tinuuid",e),t&&a.searchParams.set("hid",t),i&&a.searchParams.set("appview","true"),a.toString()}function p(){let e=new WeakMap;return function(t){let i=e.get(t);i?.cleanup?.();let r={revision:(i?.revision??0)+1};return e.set(t,r),{isCurrent:()=>e.get(t)===r,register(i){let n=!1,o=()=>{n||(n=!0,i())};return e.get(t)!==r?(o(),o):(r.cleanup=o,()=>{e.get(t)===r&&e.delete(t),o()})}}}}let f=0,v={arizo:{conjunction:"и",privacyLabel:"Политика конфиденциальности",privacyUrl:"https://arizo.ru/privacy-policy/",termsLabel:"Условия использования",termsUrl:"https://arizo.ru/terms-of-use/"},vizbl:{conjunction:"and",privacyLabel:"Privacy Policy",privacyUrl:"https://vizbl.com/legal/privacy-policy",termsLabel:"Terms of Use",termsUrl:"https://vizbl.com/legal/terms-of-use"}};function w(){return window.QRCode}function b(e,t,i){let r=document.createElement("a");return r.dataset.vizblLegalLink=e,r.href=t,r.rel="noopener noreferrer",r.target="_blank",r.textContent=i,Object.assign(r.style,{color:"inherit",textDecoration:"underline",textUnderlineOffset:"2px",whiteSpace:"nowrap"}),r}async function y(e,r="vizblQrModal",o,a){let s,l=++f;i?.(),document.querySelectorAll("[data-vizbl-qr-modal]").forEach(e=>e.remove());let d=function(e){let{brand:t,viewerOrigin:i}=e??n(),r="arizo"===t,o=document.createElement("div");o.dataset.vizblQrModal="",o.setAttribute("aria-label","View object in augmented reality"),o.setAttribute("aria-modal","true"),o.setAttribute("role","dialog"),Object.assign(o.style,{alignItems:"center",backgroundColor:"rgba(0,0,0,0.25)",display:"none",height:"100%",justifyContent:"center",left:"0",position:"fixed",top:"0",width:"100%",zIndex:"9999"});let a=document.createElement("div");Object.assign(a.style,{backgroundColor:"#fff",borderRadius:"12px",boxSizing:"border-box",color:"#000",fontFamily:"Inter, sans-serif",minHeight:"372px",padding:"48px 52px 40px",position:"relative",width:"min(460px, calc(100vw - 32px))"});let s=document.createElement("button");s.type="button",s.dataset.vizblQrClose="",s.setAttribute("aria-label","Close QR code"),s.textContent="\xd7",Object.assign(s.style,{background:"none",border:"none",color:"#AEB1B7",cursor:"pointer",fontSize:"24px",position:"absolute",right:"20px",top:"20px"});let l=document.createElement("div");l.dataset.vizblQrCode="",l.style.margin="0 auto",l.style.width="fit-content";let d=document.createElement("p");d.textContent=r?"Отсканируйте этот QR-код камерой телефона, чтобы примерить объект в интерьере":"Scan this QR code with your phone camera to view the object in Augmented Reality",Object.assign(d.style,{fontSize:"16px",fontWeight:"500",lineHeight:"24px",margin:"24px 0 0",textAlign:"center"});let c=document.createElement("p");Object.assign(c.style,{color:"#93979F",fontSize:"12px",lineHeight:"16px",margin:"12px 0 0",textAlign:"center"});let u=v[t],g=b("terms",u.termsUrl,u.termsLabel),h=b("privacy",u.privacyUrl,u.privacyLabel);c.append(r?"*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 12 или новее с Safari либо Android 7.0 или новее с Chrome.":"*Requires an AR-compatible device and browser. We recommend iOS 12 or later with Safari, or Android 7.0 or later with Chrome.",document.createElement("br"),g,` ${u.conjunction} `,h);let m=document.createElement("p");m.textContent=`Powered by ${r?"Arizo":"Vizbl"}`,Object.assign(m.style,{color:"#93979F",fontSize:"11px",letterSpacing:"1.5px",margin:"24px 0 4px",textAlign:"center",textTransform:"uppercase"});let p=document.createElement("a");p.dataset.vizblBrandLink="",p.href=r?"https://arizo.ru":"https://vizbl.com",p.style.display="block",p.style.textAlign="center";let f=document.createElement("img");return f.alt=`${r?"Arizo":"Vizbl"} logo`,f.src=`${i}/${r?"logoArizo.svg":"logo.svg"}`,f.height=20,f.width=r?76:60,p.appendChild(f),a.append(s,l,d,c,m,p),o.appendChild(a),o}(a);d.id=r;let c=d.querySelector("[data-vizbl-qr-close]"),u=Array.from(d.querySelectorAll("button, a[href]")),g=!1,h=e=>{if("Escape"===e.key){e.preventDefault(),s();return}if("Tab"!==e.key||0===u.length)return;let t=u[0],i=u.at(-1)??t;e.shiftKey&&(document.activeElement===t||!d.contains(document.activeElement))?(e.preventDefault(),i.focus()):e.shiftKey||document.activeElement!==i||(e.preventDefault(),t.focus())};i=s=()=>{g||(g=!0,document.removeEventListener("keydown",h),d.remove(),i===s&&(i=void 0),o?.focus({preventScroll:!0}))},c?.addEventListener("click",s),d.addEventListener("click",e=>{e.target===d&&s()}),document.body.appendChild(d),document.addEventListener("keydown",h),function(){let e="https://fonts.googleapis.com/css2?family=Inter&display=swap";if(Array.from(document.querySelectorAll('link[rel="stylesheet"]')).some(t=>t.href===e||t.getAttribute("href")===e))return;let t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}();try{let i=await function(e){let i=w();if(i)return Promise.resolve(i);if(t)return t;let{qrCodeScriptUrl:r}=e??n();return t=new Promise((e,i)=>{let n,o=document.createElement("script"),a=()=>{n();let r=w();r?e(r):(o.remove(),t=void 0,i(Error("QR code runtime did not expose QRCode")))},s=()=>{n(),o.remove(),t=void 0,i(Error("Failed to load QR code runtime"))};n=()=>{o.removeEventListener("load",a),o.removeEventListener("error",s)},o.addEventListener("load",a,{once:!0}),o.addEventListener("error",s,{once:!0}),o.src=r,o.async=!0,o.dataset.vizblQrScript="true",document.head.appendChild(o)})}(a);if(l!==f||!d.isConnected)return s(),s;let r=d.querySelector("[data-vizbl-qr-code]");return r&&new i(r,{correctLevel:i.CorrectLevel.L,height:148,text:e,width:148}),d.style.display="flex",c?.focus({preventScroll:!0}),s}catch(e){throw s(),e}}class E extends Error{code;constructor(e){super(e),this.code=e,this.name="WidgetRuntimeError"}}function A(e){return e.runtimeConfig??n()}function I(e,t,i={}){let r=new URL(t,e);for(let[e,t]of Object.entries(i))t&&r.searchParams.set(e,t);return r.toString()}async function C(e,t,i){try{return await (i.fetchImpl??i.runtimeConfig?.fetchImpl??n().fetchImpl)(e,{...t,signal:i.signal})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw e;throw new E("NETWORK_ERROR")}}async function S(e){try{let t=await e.json();return[t.code,t.error,t.message].flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>"string"==typeof e).join(" ").toLowerCase()}catch{return""}}async function k(e,t){let i=await S(e);return new E(429===e.status?"RATE_LIMITED":e.status>=500?"API_UNAVAILABLE":404===e.status&&"object"===t?"OBJECT_NOT_FOUND":i.includes("domain")||i.includes("origin")?"DOMAIN_NOT_ALLOWED":i.includes("revoked")?"KEY_REVOKED":i.includes("expired")?"activation"===t?"KEY_EXPIRED":"SESSION_EXPIRED":i.includes("policy")||i.includes("not available for this object")?"POLICY_DENIED":401===e.status||403===e.status?"activation"===t?"INVALID_KEY":"SESSION_EXPIRED":"REQUEST_FAILED")}async function x(e){try{return await e.json()}catch{throw new E("INVALID_RESPONSE")}}function T(e){if(!e||"object"!=typeof e||"string"!=typeof e.token||!e.token.trim()||"string"!=typeof e.sid||!e.sid.trim()||"number"!=typeof e.expiresIn||!Number.isFinite(e.expiresIn)||e.expiresIn<=0)throw new E("INVALID_RESPONSE");return e}async function L(e,t={}){let{apiOrigin:i}=A(t),r=await C(I(i,"/public/widget/activate-core",{mode:t.mode}),{cache:"no-store",headers:{"x-api-key":e},method:"POST"},t);if(!r.ok)throw await k(r,"activation");let n=await x(r);if("string"!=typeof n.productType)throw new E("INVALID_RESPONSE");return{...T(n.widgetSession),productType:n.productType}}async function z(e,t,i={}){let{apiOrigin:r}=A(i),n=await C(`${r}/public/widget/token`,{body:JSON.stringify({token:t,...i.mode?{mode:i.mode}:{}}),cache:"no-store",headers:{"Content-Type":"application/json","x-api-key":e},method:"POST"},i);if(!n.ok)throw await k(n,"token");return T(await x(n))}async function O(e,t,i={}){let{apiOrigin:r}=A(i),n=await C(I(r,`/public/objects/by-tinuuid/${encodeURIComponent(e)}`,{variantId:i.variantId}),{cache:"no-store",headers:{"x-widget-session-token":t},method:"GET"},i);if(!n.ok)throw await k(n,"object");let o=await x(n);if(!o||"object"!=typeof o||Array.isArray(o))throw new E("INVALID_RESPONSE");return o}async function R(e,t,i,r={}){let{apiOrigin:n}=A(r),o=await C(`${n}/public/widget/events`,{body:JSON.stringify({event:e,...i?{objectId:i}:{},...r.variantId?{variantId:r.variantId}:{},timestamp:new Date().toISOString()}),cache:"no-store",headers:{"Content-Type":"application/json","x-widget-session-token":t},keepalive:!0,method:"POST"},r);if(!o.ok)throw await k(o,"event");let a=await x(o);if(!a||"object"!=typeof a||Array.isArray(a)||"boolean"!=typeof a.ok)throw new E("INVALID_RESPONSE")}async function N(e,t,i){let r=i??n(),{fetchImpl:o,legacyApiOrigin:a}=r,s=await C(`${a}/obj/Fetch`,{body:JSON.stringify({tinuuid:e}),headers:{"Content-Type":"application/json"},method:"POST"},{fetchImpl:o,runtimeConfig:r,signal:t});if(!s.ok)throw await k(s,"object");let l=await x(s);if(!l||"object"!=typeof l||Array.isArray(l))throw new E("INVALID_RESPONSE");return l}async function D(e,t){let{fetchImpl:i,legacyApiOrigin:r}=t??n();await i(`${r}/obj/IncrViews`,{body:JSON.stringify({tinuuid:e}),headers:{"Content-Type":"application/json"},method:"POST"})}function P(e){try{let t=e?.();t instanceof Promise&&t.catch(()=>void 0)}catch{}}let j=p();function _(e){if(e?.aborted)throw new DOMException("Aborted","AbortError")}async function U(e,t={}){let i,r,n=j(e),o=e.getAttribute("data-native-link"),c=e.dataset.objectTinuuid?.trim(),p=e.dataset.objectHid?.trim()||void 0;if(!c)throw Error("Object ID is required");_(t.signal);let f=t.loadObject??((e,i)=>N(e,i,t.runtimeConfig)),v=t.object??await f(c,t.signal);if(_(t.signal),!n.isCurrent())return()=>void 0;let w=p?v.materials.find(e=>e.hid===p):v.materials[0];if(!w?.native?.glbUrl||!w.native.usdzUrl)throw Error("Native AR assets are unavailable");let b=u(w.native,v.type),E=s(),A=!1,I=0;e.querySelector("img")||((i=document.createElement("img")).alt="",i.hidden=!0,e.appendChild(i));let C=()=>t.trackView?t.trackView():D(c,t.runtimeConfig),S=i=>{i.preventDefault();let o=++I;r?.(),r=void 0,Promise.resolve(t.getDesktopQrUrl?.()??m(c,p,!0,t.runtimeConfig)).then(i=>{if(o===I&&n.isCurrent())return P(()=>t.onAction?.("interacted")),y(i,`vizbl-${c}`,e,t.runtimeConfig)}).then(e=>{if(e){if(o!==I||!n.isCurrent())return void e();r=e}}).catch(()=>void 0)},k=async e=>{let i;if(i=l().toLowerCase(),["firefox","edge","opera"].some(e=>i.includes(e))){if(e.preventDefault(),A)return;A=!0,P(()=>t.onAction?.("ar_launched"));try{await Promise.resolve(C()).catch(()=>void 0)}finally{A=!1,a()&&d()?h(c,p,t.runtimeConfig):g(b)}return}P(()=>t.onAction?.("ar_launched")),P(C),a()&&d()?(e.preventDefault(),h(c,p,t.runtimeConfig)):g(b)};return E?(e.dataset.nativeLink=b,e.addEventListener("click",k)):e.addEventListener("click",S),n.register(()=>{I+=1,e.removeEventListener("click",S),e.removeEventListener("click",k),r?.(),i?.remove(),null===o?e.removeAttribute("data-native-link"):e.setAttribute("data-native-link",o)})}var V=!1;if("u">typeof window){var M={get passive(){V=!0;return}};window.addEventListener("testPassive",null,M),window.removeEventListener("testPassive",null,M)}var $="u">typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),B=[],q=!1,H=-1,W=void 0,F=void 0,K=void 0,Q=function(e){return B.some(function(t){return!!(t.options.allowTouchMove&&t.options.allowTouchMove(e))})},Y=function(e){var t=e||window.event;return!!Q(t.target)||t.touches.length>1||(t.preventDefault&&t.preventDefault(),!1)},X=function(e){if(void 0===K){var t=!!e&&!0===e.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(t&&i>0){var r=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);K=document.body.style.paddingRight,document.body.style.paddingRight=r+i+"px"}}void 0===W&&(W=document.body.style.overflow,document.body.style.overflow="hidden")},J=function(){void 0!==K&&(document.body.style.paddingRight=K,K=void 0),void 0!==W&&(document.body.style.overflow=W,W=void 0)},Z=function(){if(void 0!==F){var e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);document.body.style.position=F.position,document.body.style.top=F.top,document.body.style.left=F.left,window.scrollTo(t,e),F=void 0}},G=function(e,t){var i=e.targetTouches[0].clientY-H;return!Q(e.target)&&(t&&0===t.scrollTop&&i>0?Y(e):t&&t.scrollHeight-t.scrollTop<=t.clientHeight&&i<0?Y(e):(e.stopPropagation(),!0))},ee=function(e,t){e?!B.some(function(t){return t.targetElement===e})&&(B=[].concat(function(e){if(!Array.isArray(e))return Array.from(e);for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}(B),[{targetElement:e,options:t||{}}]),$?window.requestAnimationFrame(function(){if(void 0===F){F={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var e=window,t=e.scrollY,i=e.scrollX,r=e.innerHeight;document.body.style.position="fixed",document.body.style.top=-t,document.body.style.left=-i,setTimeout(function(){return window.requestAnimationFrame(function(){var e=r-window.innerHeight;e&&t>=r&&(document.body.style.top=-(t+e))})},300)}}):X(t),$&&(e.ontouchstart=function(e){1===e.targetTouches.length&&(H=e.targetTouches[0].clientY)},e.ontouchmove=function(t){1===t.targetTouches.length&&G(t,e)},q||(document.addEventListener("touchmove",Y,V?{passive:!1}:void 0),q=!0))):console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},et=function(e){e?(B=B.filter(function(t){return t.targetElement!==e}),$&&(e.ontouchstart=null,e.ontouchmove=null,q&&0===B.length&&(document.removeEventListener("touchmove",Y,V?{passive:!1}:void 0),q=!1)),$?Z():J()):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};let ei=["cm","inch"],er=["x","y","z"],en=[...er],eo="vizbl_viewer",ea=p();function es(e){return e&&ei.includes(e)?e:"inch"}function el(e){if(!e)return en;let t=Array.from(new Set(e.split(",").map(e=>e.trim().toLowerCase()).filter(e=>er.includes(e))));return t.length>0?t:en}function ed(e){let t=new URL("/model-viewer",e.modelViewerOrigin??n().modelViewerOrigin),i=e.dimensionAxes??en;t.searchParams.set("tinuuid",e.tinuuid),e.hid&&t.searchParams.set("hid",e.hid),t.searchParams.set("size-type",e.sizeType),i.length<en.length&&t.searchParams.set("dimension-axes",i.join(","));let r=new URLSearchParams;return e.apiKey&&r.set("api-key",e.apiKey),e.mode&&r.set("mode",e.mode),e.widgetSessionToken&&r.set("widget-session-token",e.widgetSessionToken),t.hash=r.toString(),t.toString()}let ec=p();function eu(e){if(e?.aborted)throw new DOMException("Aborted","AbortError")}async function eg(e,t={}){let i,r,n=ec(e),o=e.getAttribute("href"),a=e.getAttribute("rel"),l=e.dataset.objectTinuuid?.trim(),d=e.dataset.objectHid?.trim()||void 0;if(!l)throw Error("Object ID is required");eu(t.signal);let c=t.loadObject??((e,i)=>N(e,i,t.runtimeConfig)),g=t.object??await c(l,t.signal);if(eu(t.signal),!n.isCurrent())return()=>void 0;let h=d?g.materials.find(e=>e.hid===d):g.materials[0];if(!h?.native?.glbUrl||!h.native.usdzUrl)throw Error("Native AR assets are unavailable");let p=u(h.native,g.type),f=s(),v=0;e.rel="ar",e.querySelector("img")||((i=document.createElement("img")).alt="",i.hidden=!0,e.appendChild(i));let w=i=>{i.preventDefault();let o=++v;r?.(),r=void 0,Promise.resolve(t.getDesktopQrUrl?.()??m(l,d,!1,t.runtimeConfig)).then(i=>{if(o===v&&n.isCurrent())return P(()=>t.onAction?.("interacted")),y(i,`vizbl-${l}`,e,t.runtimeConfig)}).then(e=>{if(e){if(o!==v||!n.isCurrent())return void e();r=e}}).catch(()=>void 0)},b=()=>{P(t.trackView??(()=>D(l,t.runtimeConfig))),P(()=>t.onAction?.("ar_launched"))};return f?(e.href=p,e.addEventListener("click",b)):(e.href="#",e.addEventListener("click",w)),n.register(()=>{v+=1,e.removeEventListener("click",w),e.removeEventListener("click",b),r?.(),i?.remove(),null===o?e.removeAttribute("href"):e.setAttribute("href",o),null===a?e.removeAttribute("rel"):e.setAttribute("rel",a)})}let eh=["advanced-ar","ar-one-click","ar-viewer"],em={arizo:"arizo-core",vizbl:"vizbl-core"},ep=new Set(["core-ar","core-ar-shopify"]),ef={"advanced-ar":"View in advanced AR","ar-one-click":"View in AR","ar-viewer":"View in 3D & AR"},ev={"advanced-ar":"advanced-ar-view","ar-one-click":"ar-view","ar-viewer":"ar-viewer"},ew=["api-key","dev","dimension-axes","object-id","size-type","trigger-class","type","variant-id"],eb=new Set(["API_UNAVAILABLE","INVALID_RESPONSE","NETWORK_ERROR","REQUEST_FAILED","SESSION_EXPIRED"]),ey="core-ar-widget-styles";class eE extends Error{code;constructor(e){super(e),this.code=e,this.name="CoreArWidgetComponentError"}}function eA(e){return eh.includes(e)}function eI(e,t){let i=Array.isArray(e.materials)?e.materials:[],r=t?i.find(e=>e.hid===t):i[0];if(!r)throw new eE(t?"VARIANT_NOT_FOUND":"MODEL_UNAVAILABLE");return r}function eC(e,t){if("ar-one-click"===e&&t.policy?.instantArView===!1)throw new eE("POLICY_DENIED")}let eS="u"<typeof HTMLElement?class{}:HTMLElement;class ek extends eS{static get observedAttributes(){return[...ew]}get triggerClass(){return this.getAttribute("trigger-class")??""}set triggerClass(e){let t="string"==typeof e?e.trim():"";t?this.setAttribute("trigger-class",t):this.removeAttribute("trigger-class")}get unstyled(){return this.hasAttribute("unstyled")}set unstyled(e){this.toggleAttribute("unstyled",!!e)}abortController;actionResetTimer;cleanup;customLabelNodes=null;initializationRevision=0;object;queued=!1;session;trigger;variantId;widgetMode;connectedCallback(){!function(){if(document.getElementById(ey))return;let e=document.createElement("style");e.id=ey,e.textContent=`
|
|
1
|
+
(()=>{"use strict";let e,t,i;function r(e,t){let i;try{i=new URL(e)}catch{throw TypeError(`${t} must be an absolute HTTP(S) URL`)}if("http:"!==i.protocol&&"https:"!==i.protocol)throw TypeError(`${t} must be an absolute HTTP(S) URL`);return i.origin}function n(){if(!e)throw Error("Core AR widget runtime is not configured");return e}function o(){return"u"<typeof navigator?"":navigator.userAgent||navigator.vendor||""}function a(){if("u"<typeof window||"u"<typeof navigator)return!1;let e="MacIntel"===navigator.platform&&navigator.maxTouchPoints>1;return(/iPad|iPhone|iPod/.test(o())||e)&&!("MSStream"in window)}function s(){if("u"<typeof window||"u"<typeof navigator)return!1;let e=navigator.maxTouchPoints>1,t=window.matchMedia?.("(pointer: coarse)").matches??!1,i=/Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone|Opera Mini|IEMobile|Mobile/i.test(o());return e&&t&&(i||a())}function d(){let e=o();return[[/edg/i,"Microsoft Edge"],[/trident/i,"Microsoft Internet Explorer"],[/firefox|fxios/i,"Mozilla Firefox"],[/opr\//i,"Opera"],[/ucbrowser/i,"UC Browser"],[/samsungbrowser/i,"Samsung Browser"],[/chrome|chromium|crios/i,"Google Chrome"],[/safari/i,"Apple Safari"]].find(([t])=>t.test(e))?.[1]??"Other"}function l(){let e=function(){let e=o(),t=e.match(/\bOS (\d+)/)?.[1]??e.match(/Version\/(\d+)/)?.[1];if(!t)return null;let i=Number.parseInt(t,10);return Number.isNaN(i)?null:i}();return null!==e&&e>=17}function c(e){let t;try{t=new URL(e)}catch{throw TypeError("Native AR asset URL must be absolute HTTP(S)")}if("http:"!==t.protocol&&"https:"!==t.protocol)throw TypeError("Native AR asset URL must be absolute HTTP(S)");return t.href}function u(e,t){let i=c(e.glbUrl),r=c(e.usdzUrl),n=encodeURIComponent(i),o=`intent://arvr.google.com/scene-viewer/1.0?file=${n}&resizable=false${"wall"===t||"ceiling"===t?"&enable_vertical_placement=true":""}&mode=ar_preferred#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;end;`,s=`${r}#allowsContentScaling=0`;return a()?s:o}function g(e,t=0){let i=document.createElement("a"),r=document.createElement("img");i.rel="ar",i.href=e,i.hidden=!0,r.alt="",r.hidden=!0,i.appendChild(r),document.body.appendChild(i),window.setTimeout(()=>{i.click(),i.remove()},t)}function m(e,t,i){let r=function(e,t,i){let{brand:r}=i??n();if(a()){let i=new URL("https://appclip.apple.com/id");return i.searchParams.set("p","com.us.vizbl.Clip"),i.searchParams.set("tinuuid",e),t&&i.searchParams.set("hid",t),i.searchParams.set("region","arizo"===r?"ru":"en"),i.toString()}return`intent:/${window.location.pathname}#Intent;scheme=open;package=com.us.vizbl;end`}(e,t,i);window.self===window.top||d().toLowerCase().includes("edge")?window.location.assign(r):window.open(r,"_top")}function h(e,t,i=!1,r){let{viewerOrigin:o}=r??n(),a=new URL("/ar/index.html",o);return a.searchParams.set("tinuuid",e),t&&a.searchParams.set("hid",t),i&&a.searchParams.set("appview","true"),a.toString()}function p(){let e=new WeakMap;return function(t){let i=e.get(t);i?.cleanup?.();let r={revision:(i?.revision??0)+1};return e.set(t,r),{isCurrent:()=>e.get(t)===r,register(i){let n=!1,o=()=>{n||(n=!0,i())};return e.get(t)!==r?(o(),o):(r.cleanup=o,()=>{e.get(t)===r&&e.delete(t),o()})}}}}let f=0,b={arizo:{conjunction:"и",privacyLabel:"Политика конфиденциальности",privacyUrl:"https://arizo.ru/privacy-policy/",termsLabel:"Условия использования",termsUrl:"https://arizo.ru/terms-of-use/"},vizbl:{conjunction:"and",privacyLabel:"Privacy Policy",privacyUrl:"https://vizbl.com/legal/privacy-policy",termsLabel:"Terms of Use",termsUrl:"https://vizbl.com/legal/terms-of-use"}};function v(){return window.QRCode}function w(e,t,i){let r=document.createElement("a");return r.dataset.vizblLegalLink=e,r.href=t,r.rel="noopener noreferrer",r.target="_blank",r.textContent=i,Object.assign(r.style,{color:"inherit",textDecoration:"underline",textUnderlineOffset:"2px",whiteSpace:"nowrap"}),r}async function y(e,r="vizblQrModal",o,a){let s,d=++f;i?.(),document.querySelectorAll("[data-vizbl-qr-modal]").forEach(e=>e.remove());let l=function(e){let{brand:t,viewerOrigin:i}=e??n(),r="arizo"===t,o=document.createElement("div");o.dataset.vizblQrModal="",o.setAttribute("aria-label","View object in augmented reality"),o.setAttribute("aria-modal","true"),o.setAttribute("role","dialog"),Object.assign(o.style,{alignItems:"center",backgroundColor:"rgba(0,0,0,0.25)",display:"none",height:"100%",justifyContent:"center",left:"0",position:"fixed",top:"0",width:"100%",zIndex:"9999"});let a=document.createElement("div");Object.assign(a.style,{backgroundColor:"#fff",borderRadius:"12px",boxSizing:"border-box",color:"#000",fontFamily:"Inter, sans-serif",minHeight:"372px",padding:"48px 52px 40px",position:"relative",width:"min(460px, calc(100vw - 32px))"});let s=document.createElement("button");s.type="button",s.dataset.vizblQrClose="",s.setAttribute("aria-label","Close QR code"),s.textContent="\xd7",Object.assign(s.style,{background:"none",border:"none",color:"#AEB1B7",cursor:"pointer",fontSize:"24px",position:"absolute",right:"20px",top:"20px"});let d=document.createElement("div");d.dataset.vizblQrCode="",d.style.margin="0 auto",d.style.width="fit-content";let l=document.createElement("p");l.textContent=r?"Отсканируйте этот QR-код камерой телефона, чтобы примерить объект в интерьере":"Scan this QR code with your phone camera to view the object in Augmented Reality",Object.assign(l.style,{fontSize:"16px",fontWeight:"500",lineHeight:"24px",margin:"24px 0 0",textAlign:"center"});let c=document.createElement("p");Object.assign(c.style,{color:"#93979F",fontSize:"12px",lineHeight:"16px",margin:"12px 0 0",textAlign:"center"});let u=b[t],g=w("terms",u.termsUrl,u.termsLabel),m=w("privacy",u.privacyUrl,u.privacyLabel);c.append(r?"*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 12 или новее с Safari либо Android 7.0 или новее с Chrome.":"*Requires an AR-compatible device and browser. We recommend iOS 12 or later with Safari, or Android 7.0 or later with Chrome.",document.createElement("br"),g,` ${u.conjunction} `,m);let h=document.createElement("p");h.textContent=`Powered by ${r?"Arizo":"Vizbl"}`,Object.assign(h.style,{color:"#93979F",fontSize:"11px",letterSpacing:"1.5px",margin:"24px 0 4px",textAlign:"center",textTransform:"uppercase"});let p=document.createElement("a");p.dataset.vizblBrandLink="",p.href=r?"https://arizo.ru":"https://vizbl.com",p.style.display="block",p.style.textAlign="center";let f=document.createElement("img");return f.alt=`${r?"Arizo":"Vizbl"} logo`,f.src=`${i}/${r?"logoArizo.svg":"logo.svg"}`,f.height=20,f.width=r?76:60,p.appendChild(f),a.append(s,d,l,c,h,p),o.appendChild(a),o}(a);l.id=r;let c=l.querySelector("[data-vizbl-qr-close]"),u=Array.from(l.querySelectorAll("button, a[href]")),g=!1,m=e=>{if("Escape"===e.key){e.preventDefault(),s();return}if("Tab"!==e.key||0===u.length)return;let t=u[0],i=u.at(-1)??t;e.shiftKey&&(document.activeElement===t||!l.contains(document.activeElement))?(e.preventDefault(),i.focus()):e.shiftKey||document.activeElement!==i||(e.preventDefault(),t.focus())};i=s=()=>{g||(g=!0,document.removeEventListener("keydown",m),l.remove(),i===s&&(i=void 0),o?.focus({preventScroll:!0}))},c?.addEventListener("click",s),l.addEventListener("click",e=>{e.target===l&&s()}),document.body.appendChild(l),document.addEventListener("keydown",m),function(){let e="https://fonts.googleapis.com/css2?family=Inter&display=swap";if(Array.from(document.querySelectorAll('link[rel="stylesheet"]')).some(t=>t.href===e||t.getAttribute("href")===e))return;let t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}();try{let i=await function(e){let i=v();if(i)return Promise.resolve(i);if(t)return t;let{qrCodeScriptUrl:r}=e??n();return t=new Promise((e,i)=>{let n,o=document.createElement("script"),a=()=>{n();let r=v();r?e(r):(o.remove(),t=void 0,i(Error("QR code runtime did not expose QRCode")))},s=()=>{n(),o.remove(),t=void 0,i(Error("Failed to load QR code runtime"))};n=()=>{o.removeEventListener("load",a),o.removeEventListener("error",s)},o.addEventListener("load",a,{once:!0}),o.addEventListener("error",s,{once:!0}),o.src=r,o.async=!0,o.dataset.vizblQrScript="true",document.head.appendChild(o)})}(a);if(d!==f||!l.isConnected)return s(),s;let r=l.querySelector("[data-vizbl-qr-code]");return r&&new i(r,{correctLevel:i.CorrectLevel.L,height:148,text:e,width:148}),l.style.display="flex",c?.focus({preventScroll:!0}),s}catch(e){throw s(),e}}class E extends Error{code;constructor(e){super(e),this.code=e,this.name="WidgetRuntimeError"}}function A(e){return e.runtimeConfig??n()}function C(e,t,i={}){let r=new URL(t,e);for(let[e,t]of Object.entries(i))t&&r.searchParams.set(e,t);return r.toString()}async function I(e,t,i){try{return await (i.fetchImpl??i.runtimeConfig?.fetchImpl??n().fetchImpl)(e,{...t,signal:i.signal})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw e;throw new E("NETWORK_ERROR")}}async function x(e){try{let t=await e.json();return[t.code,t.error,t.message].flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>"string"==typeof e).join(" ").toLowerCase()}catch{return""}}async function O(e,t){let i=await x(e);return new E(429===e.status?"RATE_LIMITED":e.status>=500?"API_UNAVAILABLE":404===e.status&&"object"===t?"OBJECT_NOT_FOUND":i.includes("domain")||i.includes("origin")?"DOMAIN_NOT_ALLOWED":i.includes("revoked")?"KEY_REVOKED":i.includes("expired")?"activation"===t?"KEY_EXPIRED":"SESSION_EXPIRED":i.includes("policy")||i.includes("not available for this object")?"POLICY_DENIED":401===e.status||403===e.status?"activation"===t?"INVALID_KEY":"SESSION_EXPIRED":"REQUEST_FAILED")}async function S(e){try{return await e.json()}catch{throw new E("INVALID_RESPONSE")}}function k(e){if(!e||"object"!=typeof e||"string"!=typeof e.token||!e.token.trim()||"string"!=typeof e.sid||!e.sid.trim()||"number"!=typeof e.expiresIn||!Number.isFinite(e.expiresIn)||e.expiresIn<=0)throw new E("INVALID_RESPONSE");return e}async function T(e,t={}){let{apiOrigin:i}=A(t),r=await I(C(i,"/public/widget/activate-core",{mode:t.mode}),{cache:"no-store",headers:{"x-api-key":e},method:"POST"},t);if(!r.ok)throw await O(r,"activation");let n=await S(r);if("string"!=typeof n.productType)throw new E("INVALID_RESPONSE");return{...k(n.widgetSession),productType:n.productType}}async function L(e,t,i={}){let{apiOrigin:r}=A(i),n=await I(`${r}/public/widget/token`,{body:JSON.stringify({token:t,...i.mode?{mode:i.mode}:{}}),cache:"no-store",headers:{"Content-Type":"application/json","x-api-key":e},method:"POST"},i);if(!n.ok)throw await O(n,"token");return k(await S(n))}async function z(e,t,i={}){let{apiOrigin:r}=A(i),n=await I(C(r,`/public/objects/by-tinuuid/${encodeURIComponent(e)}`,{variantId:i.variantId}),{cache:"no-store",headers:{"x-widget-session-token":t},method:"GET"},i);if(!n.ok)throw await O(n,"object");let o=await S(n);if(!o||"object"!=typeof o||Array.isArray(o))throw new E("INVALID_RESPONSE");return o}async function R(e,t,i,r={}){let{apiOrigin:n}=A(r),o=await I(`${n}/public/widget/events`,{body:JSON.stringify({event:e,...i?{objectId:i}:{},...r.variantId?{variantId:r.variantId}:{},timestamp:new Date().toISOString()}),cache:"no-store",headers:{"Content-Type":"application/json","x-widget-session-token":t},keepalive:!0,method:"POST"},r);if(!o.ok)throw await O(o,"event");let a=await S(o);if(!a||"object"!=typeof a||Array.isArray(a)||"boolean"!=typeof a.ok)throw new E("INVALID_RESPONSE")}async function N(e,t,i){let r=i??n(),{fetchImpl:o,legacyApiOrigin:a}=r,s=await I(`${a}/obj/Fetch`,{body:JSON.stringify({tinuuid:e}),headers:{"Content-Type":"application/json"},method:"POST"},{fetchImpl:o,runtimeConfig:r,signal:t});if(!s.ok)throw await O(s,"object");let d=await S(s);if(!d||"object"!=typeof d||Array.isArray(d))throw new E("INVALID_RESPONSE");return d}async function P(e,t){let{fetchImpl:i,legacyApiOrigin:r}=t??n();await i(`${r}/obj/IncrViews`,{body:JSON.stringify({tinuuid:e}),headers:{"Content-Type":"application/json"},method:"POST"})}function D(e){try{let t=e?.();t instanceof Promise&&t.catch(()=>void 0)}catch{}}let j=p();function _(e){if(e?.aborted)throw new DOMException("Aborted","AbortError")}async function U(e,t={}){let i,r,n=j(e),o=e.getAttribute("data-native-link"),c=e.dataset.objectTinuuid?.trim(),p=e.dataset.objectHid?.trim()||void 0;if(!c)throw Error("Object ID is required");_(t.signal);let f=t.loadObject??((e,i)=>N(e,i,t.runtimeConfig)),b=t.object??await f(c,t.signal);if(_(t.signal),!n.isCurrent())return()=>void 0;let v=p?b.materials.find(e=>e.hid===p):b.materials[0];if(!v?.native?.glbUrl||!v.native.usdzUrl)throw Error("Native AR assets are unavailable");let w=u(v.native,b.type),E=s(),A=!1,C=0;e.querySelector("img")||((i=document.createElement("img")).alt="",i.hidden=!0,e.appendChild(i));let I=()=>t.trackView?t.trackView():P(c,t.runtimeConfig),x=i=>{i.preventDefault();let o=++C;r?.(),r=void 0,Promise.resolve(t.getDesktopQrUrl?.()??h(c,p,!0,t.runtimeConfig)).then(i=>{if(o===C&&n.isCurrent())return D(()=>t.onAction?.("interacted")),y(i,`vizbl-${c}`,e,t.runtimeConfig)}).then(e=>{if(e){if(o!==C||!n.isCurrent())return void e();r=e}}).catch(()=>void 0)},O=async e=>{let i;if(i=d().toLowerCase(),["firefox","edge","opera"].some(e=>i.includes(e))){if(e.preventDefault(),A)return;A=!0,D(()=>t.onAction?.("ar_launched"));try{await Promise.resolve(I()).catch(()=>void 0)}finally{A=!1,a()&&l()?m(c,p,t.runtimeConfig):g(w)}return}D(()=>t.onAction?.("ar_launched")),D(I),a()&&l()?(e.preventDefault(),m(c,p,t.runtimeConfig)):g(w)};return E?(e.dataset.nativeLink=w,e.addEventListener("click",O)):e.addEventListener("click",x),n.register(()=>{C+=1,e.removeEventListener("click",x),e.removeEventListener("click",O),r?.(),i?.remove(),null===o?e.removeAttribute("data-native-link"):e.setAttribute("data-native-link",o)})}var V=!1;if("u">typeof window){var M={get passive(){V=!0;return}};window.addEventListener("testPassive",null,M),window.removeEventListener("testPassive",null,M)}var $="u">typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),B=[],q=!1,H=-1,W=void 0,F=void 0,K=void 0,Q=function(e){return B.some(function(t){return!!(t.options.allowTouchMove&&t.options.allowTouchMove(e))})},Y=function(e){var t=e||window.event;return!!Q(t.target)||t.touches.length>1||(t.preventDefault&&t.preventDefault(),!1)},X=function(e){if(void 0===K){var t=!!e&&!0===e.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(t&&i>0){var r=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);K=document.body.style.paddingRight,document.body.style.paddingRight=r+i+"px"}}void 0===W&&(W=document.body.style.overflow,document.body.style.overflow="hidden")},J=function(){void 0!==K&&(document.body.style.paddingRight=K,K=void 0),void 0!==W&&(document.body.style.overflow=W,W=void 0)},Z=function(){if(void 0!==F){var e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);document.body.style.position=F.position,document.body.style.top=F.top,document.body.style.left=F.left,window.scrollTo(t,e),F=void 0}},G=function(e,t){var i=e.targetTouches[0].clientY-H;return!Q(e.target)&&(t&&0===t.scrollTop&&i>0?Y(e):t&&t.scrollHeight-t.scrollTop<=t.clientHeight&&i<0?Y(e):(e.stopPropagation(),!0))},ee=function(e,t){e?!B.some(function(t){return t.targetElement===e})&&(B=[].concat(function(e){if(!Array.isArray(e))return Array.from(e);for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}(B),[{targetElement:e,options:t||{}}]),$?window.requestAnimationFrame(function(){if(void 0===F){F={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var e=window,t=e.scrollY,i=e.scrollX,r=e.innerHeight;document.body.style.position="fixed",document.body.style.top=-t,document.body.style.left=-i,setTimeout(function(){return window.requestAnimationFrame(function(){var e=r-window.innerHeight;e&&t>=r&&(document.body.style.top=-(t+e))})},300)}}):X(t),$&&(e.ontouchstart=function(e){1===e.targetTouches.length&&(H=e.targetTouches[0].clientY)},e.ontouchmove=function(t){1===t.targetTouches.length&&G(t,e)},q||(document.addEventListener("touchmove",Y,V?{passive:!1}:void 0),q=!0))):console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},et=function(e){e?(B=B.filter(function(t){return t.targetElement!==e}),$&&(e.ontouchstart=null,e.ontouchmove=null,q&&0===B.length&&(document.removeEventListener("touchmove",Y,V?{passive:!1}:void 0),q=!1)),$?Z():J()):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};let ei=["cm","inch"],er=["x","y","z"],en=[...er],eo="vizbl_viewer",ea=p();function es(e){return e&&ei.includes(e)?e:"inch"}function ed(e){if(!e)return en;let t=Array.from(new Set(e.split(",").map(e=>e.trim().toLowerCase()).filter(e=>er.includes(e))));return t.length>0?t:en}function el(e){let t=new URL("/model-viewer",e.modelViewerOrigin??n().modelViewerOrigin),i=e.dimensionAxes??en;t.searchParams.set("tinuuid",e.tinuuid),e.hid&&t.searchParams.set("hid",e.hid),t.searchParams.set("size-type",e.sizeType),i.length<en.length&&t.searchParams.set("dimension-axes",i.join(",")),e.cameraOrbit&&t.searchParams.set("camera-orbit",e.cameraOrbit),e.minCameraOrbit&&t.searchParams.set("min-camera-orbit",e.minCameraOrbit),e.maxCameraOrbit&&t.searchParams.set("max-camera-orbit",e.maxCameraOrbit),e.lang&&t.searchParams.set("lang",e.lang);let r=new URLSearchParams;return e.apiKey&&r.set("api-key",e.apiKey),e.mode&&r.set("mode",e.mode),e.widgetSessionToken&&r.set("widget-session-token",e.widgetSessionToken),t.hash=r.toString(),t.toString()}let ec=p();function eu(e){if(e?.aborted)throw new DOMException("Aborted","AbortError")}async function eg(e,t={}){let i,r,n=ec(e),o=e.getAttribute("href"),a=e.getAttribute("rel"),d=e.dataset.objectTinuuid?.trim(),l=e.dataset.objectHid?.trim()||void 0;if(!d)throw Error("Object ID is required");eu(t.signal);let c=t.loadObject??((e,i)=>N(e,i,t.runtimeConfig)),g=t.object??await c(d,t.signal);if(eu(t.signal),!n.isCurrent())return()=>void 0;let m=l?g.materials.find(e=>e.hid===l):g.materials[0];if(!m?.native?.glbUrl||!m.native.usdzUrl)throw Error("Native AR assets are unavailable");let p=u(m.native,g.type),f=s(),b=0;e.rel="ar",e.querySelector("img")||((i=document.createElement("img")).alt="",i.hidden=!0,e.appendChild(i));let v=i=>{i.preventDefault();let o=++b;r?.(),r=void 0,Promise.resolve(t.getDesktopQrUrl?.()??h(d,l,!1,t.runtimeConfig)).then(i=>{if(o===b&&n.isCurrent())return D(()=>t.onAction?.("interacted")),y(i,`vizbl-${d}`,e,t.runtimeConfig)}).then(e=>{if(e){if(o!==b||!n.isCurrent())return void e();r=e}}).catch(()=>void 0)},w=()=>{D(t.trackView??(()=>P(d,t.runtimeConfig))),D(()=>t.onAction?.("ar_launched"))};return f?(e.href=p,e.addEventListener("click",w)):(e.href="#",e.addEventListener("click",v)),n.register(()=>{b+=1,e.removeEventListener("click",v),e.removeEventListener("click",w),r?.(),i?.remove(),null===o?e.removeAttribute("href"):e.setAttribute("href",o),null===a?e.removeAttribute("rel"):e.setAttribute("rel",a)})}let em=["advanced-ar","ar-one-click","ar-viewer"],eh={arizo:"arizo-core",vizbl:"vizbl-core"},ep=new Set(["core-ar","core-ar-shopify"]),ef={"advanced-ar":"View in advanced AR","ar-one-click":"View in AR","ar-viewer":"View in 3D & AR"},eb={"advanced-ar":"advanced-ar-view","ar-one-click":"ar-view","ar-viewer":"ar-viewer"},ev=["api-key","camera-orbit","dev","dimension-axes","max-camera-orbit","min-camera-orbit","object-id","size-type","trigger-class","type","variant-id"],ew=new Set(["API_UNAVAILABLE","INVALID_RESPONSE","NETWORK_ERROR","REQUEST_FAILED","SESSION_EXPIRED"]),ey="core-ar-widget-styles";class eE extends Error{code;constructor(e){super(e),this.code=e,this.name="CoreArWidgetComponentError"}}function eA(e){return em.includes(e)}function eC(e,t){let i=Array.isArray(e.materials)?e.materials:[],r=t?i.find(e=>e.hid===t):i[0];if(!r)throw new eE(t?"VARIANT_NOT_FOUND":"MODEL_UNAVAILABLE");return r}function eI(e,t){if("ar-one-click"===e&&t.policy?.instantArView===!1)throw new eE("POLICY_DENIED")}let ex="u"<typeof HTMLElement?class{}:HTMLElement;class eO extends ex{static get observedAttributes(){return[...ev]}get triggerClass(){return this.getAttribute("trigger-class")??""}set triggerClass(e){let t="string"==typeof e?e.trim():"";t?this.setAttribute("trigger-class",t):this.removeAttribute("trigger-class")}get unstyled(){return this.hasAttribute("unstyled")}set unstyled(e){this.toggleAttribute("unstyled",!!e)}abortController;actionResetTimer;cleanup;customLabelNodes=null;initializationRevision=0;object;queued=!1;session;trigger;variantId;widgetMode;connectedCallback(){!function(){if(document.getElementById(ey))return;let e=document.createElement("style");e.id=ey,e.textContent=`
|
|
2
2
|
:where(vizbl-core, arizo-core) {
|
|
3
3
|
display: inline-block;
|
|
4
4
|
--core-ar-widget-background: #3556f0;
|
|
@@ -65,4 +65,4 @@
|
|
|
65
65
|
:where(vizbl-core, arizo-core)[data-state="error"] [data-core-ar-widget-trigger] {
|
|
66
66
|
cursor: not-allowed;
|
|
67
67
|
}
|
|
68
|
-
`,document.head.appendChild(e)}(),this.captureCustomLabel(),this.queueInitialization()}disconnectedCallback(){this.initializationRevision+=1,this.abortController?.abort(),this.abortController=void 0,this.cleanup?.(),this.cleanup=void 0,this.clearActionResetTimer()}attributeChangedCallback(e,t,i){if(t!==i){if("trigger-class"===e)return void this.applyTriggerClass();("api-key"===e||"dev"===e)&&(this.session=void 0),this.isConnected&&(this.abortController?.abort(),this.cleanup?.(),this.cleanup=void 0,this.setState("loading"),this.queueInitialization())}}captureCustomLabel(){if(null!==this.customLabelNodes)return;let e=Array.from(this.childNodes),t=e.some(e=>e.nodeType!==Node.TEXT_NODE||!!e.textContent?.trim());this.customLabelNodes=t?e:[]}queueInitialization(){this.queued||(this.queued=!0,queueMicrotask(()=>{this.queued=!1,this.isConnected&&this.initialize()}))}async initialize(){let e=++this.initializationRevision;this.abortController?.abort(),this.cleanup?.(),this.cleanup=void 0,this.object=void 0,this.variantId=void 0,this.widgetMode=void 0,this.clearActionResetTimer();let t=new AbortController;this.abortController=t;let i=this.getAttribute("type")?.trim()??"",r=eA(i)?i:"ar-viewer",n=this.getAttribute("object-id")?.trim()??"",o=this.getAttribute("variant-id")?.trim()||void 0,a=this.getAttribute("api-key")?.trim()??"",l=this.getAttribute("size-type")?.trim()||void 0,d=this.getAttribute("dimension-axes")?.trim()||void 0;this.removeAttribute("data-error-code"),this.setState("loading"),this.renderTrigger(r);try{let r,c=this.resolveRuntimeConfig();if(!a)throw new eE("MISSING_API_KEY");if(!n)throw new eE("MISSING_OBJECT_ID");if(!eA(i))throw new eE("INVALID_TYPE");if("ar-viewer"===i&&l&&"cm"!==l&&"inch"!==l)throw new eE("INVALID_SIZE_TYPE");let u=ev[i],g=await this.ensureSession(a,c,u,t.signal);if(this.assertCurrent(e,t.signal),this.variantId=o,this.widgetMode=u,this.applyIntegrationData(n,o,l,d),"ar-viewer"===i)r=await N(n,t.signal,c),this.assertCurrent(e,t.signal),eI(r,o),eC(i,r),this.object=r;else{r=s()?await this.fetchObjectWithSession(n,a,g,c,t.signal,o):await N(n,t.signal,c),this.assertCurrent(e,t.signal);let l=eI(r,o);if(eC(i,r),!l.native?.glbUrl||!l.native.usdzUrl)throw new eE("MODEL_UNAVAILABLE");this.object=r}let h=await this.initializeTrigger(i,r,c,t.signal,a,g);try{this.assertCurrent(e,t.signal)}catch(e){throw h(),e}this.cleanup=h,this.setState("ready"),this.dispatchWidgetEvent("core-ar-ready",{objectId:n,type:i})}catch(o){if(e!==this.initializationRevision||t.signal.aborted||o instanceof DOMException&&"AbortError"===o.name)return;let r=o instanceof eE||o instanceof E?o.code:"INITIALIZATION_FAILED";this.setAttribute("data-error-code",r),this.setState("error"),this.dispatchWidgetEvent("core-ar-error",{code:r,objectId:n,type:i})}}async ensureSession(e,t,i,r,n=!1){let o=`${t.apiOrigin}|${t.viewerOrigin}|${t.modelViewerOrigin}|${i}`,a=this.session?.publicKey===e&&this.session.runtimeKey===o?this.session:void 0;if(a&&!n&&a.expiresAt-Date.now()>3e4)return a;if(a)try{let i=await z(e,a.token,{mode:a.mode,runtimeConfig:t,signal:r}),n={...a,...i,expiresAt:Date.now()+1e3*i.expiresIn};return this.session=n,n}catch(e){if(!(e instanceof E)||!eb.has(e.code))throw e;this.session=void 0}let s=await L(e,{mode:i,runtimeConfig:t,signal:r});if(!ep.has(s.productType))throw new eE("POLICY_DENIED");let l={expiresAt:Date.now()+1e3*s.expiresIn,mode:i,productType:s.productType,publicKey:e,runtimeKey:o,sid:s.sid,token:s.token};return this.session=l,l}async fetchObjectWithSession(e,t,i,r,n,o){try{return await O(e,i.token,{runtimeConfig:r,signal:n,variantId:o})}catch(a){if(!(a instanceof E)||"SESSION_EXPIRED"!==a.code)throw a;return O(e,(await this.ensureSession(t,r,i.mode,n,!0)).token,{runtimeConfig:r,signal:n,variantId:o})}}assertCurrent(e,t){if(e!==this.initializationRevision||t.aborted)throw new DOMException("Aborted","AbortError")}renderTrigger(e){let t="ar-one-click"===e?document.createElement("a"):document.createElement("button");if(t.dataset.coreArWidgetTrigger="",t.setAttribute("part","trigger"),t.addEventListener("click",e=>{"ready"!==this.dataset.state&&(e.preventDefault(),e.stopImmediatePropagation())}),t instanceof HTMLButtonElement&&(t.type="button"),t instanceof HTMLAnchorElement&&(t.href="#",t.rel="ar"),"ar-viewer"===e&&t.setAttribute("aria-haspopup","dialog"),"ar-viewer"!==e){let e=document.createElement("img");e.alt="",e.hidden=!0,t.appendChild(e)}let i=document.createElement("span");i.dataset.coreArWidgetLabel="",this.customLabelNodes?.length?i.append(...this.customLabelNodes):i.textContent=ef[e],t.appendChild(i),this.trigger=t,this.applyTriggerClass(),this.replaceChildren(t),this.updateTriggerAccessibility(this.dataset.state)}applyTriggerClass(){if(!this.trigger)return;let e=this.triggerClass.trim();e?this.trigger.className=e:this.trigger.removeAttribute("class")}applyIntegrationData(e,t,i,r){this.trigger&&(this.trigger.dataset.objectTinuuid=e,t?this.trigger.dataset.objectHid=t:delete this.trigger.dataset.objectHid,i?this.trigger.dataset.sizeType=i:delete this.trigger.dataset.sizeType,r?this.trigger.dataset.dimensionAxes=r:delete this.trigger.dataset.dimensionAxes)}async initializeTrigger(e,t,i,r,n,o){if(!this.trigger)throw new eE("INITIALIZATION_FAILED");if("ar-viewer"===e)return function(e,t={}){let i,r=ea(e),n=!1,o=async()=>{if(i||n)return;let o=e.dataset.objectTinuuid?.trim();if(!o)return;n=!0;let a=t.widgetSessionToken;try{t.getWidgetSessionToken&&(a=await t.getWidgetSessionToken())}catch{n=!1;return}if(n=!1,i||!r.isCurrent())return;let s=function(e){var t,i,r,n;let o,a,s;if(document.getElementById(eo))return null;let l=document.createElement("div"),d=document.createElement("div"),c=document.createElement("div"),u=e.containerClassName?document.getElementsByClassName(e.containerClassName)[0]:null,g=!!u,h=g?d:l,m=!1,p=e=>{"Escape"===e.key&&o()};o=()=>{m||(m=!0,document.removeEventListener("keydown",p),et(h),(g?d:l).remove(),e.onClose?.(),e.restoreFocusTo?.focus({preventScroll:!0}))},l.id=eo,Object.assign(l.style,{inset:"0",overflow:"auto",position:"fixed",zIndex:"11111"}),l.style.webkitOverflowScrolling="touch",d.setAttribute("role","dialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-label","3D model viewer"),Object.assign(c.style,{animation:"vex-fadein 0.5s",background:"#fff",inset:"0",position:"fixed",zIndex:"11111"}),c.addEventListener("click",o),(e.width||e.height)&&(c.style.background="rgba(0, 0, 0, 0.8)",Object.assign(d.style,{borderRadius:"12px",height:e.height??"100%",left:"50%",overflow:"hidden",position:"absolute",top:"50%",transform:"translate(-50%, -50%)",width:e.width??"100%",zIndex:"11112"}));let f=(t=e.crossClassName,i=o,(a=document.createElement("button")).type="button",a.setAttribute("aria-label","Close 3D model viewer"),t&&(a.className=t),Object.assign(a.style,{alignItems:"center",background:"#fff",border:"1px solid #E3E7E7",borderRadius:"4px",boxSizing:"border-box",cursor:"pointer",display:"flex",height:"40px",inset:"24px 24px auto auto",justifyContent:"center",padding:"8px 16px",position:"absolute",width:"56px",zIndex:"11113"}),a.innerHTML='<svg aria-hidden="true" style="flex-shrink:0" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z" fill="#484D50"/></svg>',a.addEventListener("click",i),a);return d.append((r=ed(e),n=e.backgroundColor,(s=document.createElement("iframe")).src=r,s.title="3D model viewer",s.allow="fullscreen; xr-spatial-tracking",Object.assign(s.style,{backgroundColor:n??"white",border:"none",height:"100%",inset:"0",position:"absolute",width:"100%",zIndex:"11112"}),s),f),u?(d.id=eo,u.appendChild(d)):(l.append(c,d),document.body.appendChild(l)),document.addEventListener("keydown",p),ee(h),f.focus({preventScroll:!0}),o}({apiKey:t.apiKey,backgroundColor:e.dataset.background,buttonBgColor:e.dataset.buttonBgColor,buttonBorderColor:e.dataset.buttonBorderColor,buttonTextColor:e.dataset.buttonTextColor,containerClassName:e.dataset.container,crossClassName:e.dataset.crossClassName,dimensionAxes:el(e.dataset.dimensionAxes),height:e.dataset.height?.trim(),hid:e.dataset.objectHid,hidePreview:e.dataset.hidePreview,hideTitle:e.dataset.hideTitle,mode:t.mode,modelViewerOrigin:t.modelViewerOrigin,onClose:()=>{i=void 0,t.onClose?.()},restoreFocusTo:e,sizeType:es(e.dataset.sizeType),tinuuid:o,widgetSessionToken:a,width:e.dataset.width?.trim()});s&&(i=s,t.onOpen?.(),P(()=>t.onAction?.("widget_opened")))};return e.addEventListener("click",o),r.register(()=>{e.removeEventListener("click",o),i?.(),i=void 0})}(this.trigger,{apiKey:n,getWidgetSessionToken:async()=>(await this.ensureSession(n,i,o.mode)).token,mode:o.mode,modelViewerOrigin:i.modelViewerOrigin,onAction:e=>this.handleAction(e,i),onClose:()=>{this.isConnected&&this.setState("ready")},onOpen:()=>this.setState("opening"),widgetSessionToken:o.token});if(!t)throw new eE("INITIALIZATION_FAILED");let a={getDesktopQrUrl:async()=>{let e=await this.ensureSession(n,i,o.mode);return ed({apiKey:n,dimensionAxes:el(this.trigger?.dataset.dimensionAxes),hid:this.variantId,mode:e.mode,modelViewerOrigin:i.modelViewerOrigin,sizeType:es(this.trigger?.dataset.sizeType),tinuuid:this.trigger?.dataset.objectTinuuid??"",widgetSessionToken:e.token})},object:t,onAction:e=>this.handleAction(e,i),runtimeConfig:i,signal:r,trackView:()=>this.trackEvent("ar_launched",i)};if("ar-one-click"===e){if(!(this.trigger instanceof HTMLAnchorElement))throw new eE("INITIALIZATION_FAILED");return eg(this.trigger,a)}return U(this.trigger,a)}handleAction(e,t){this.setState("opening"),("interacted"===e||"widget_opened"===e)&&"ar-viewer"!==this.getAttribute("type")&&this.trackEvent(e,t),"ar-viewer"!==this.getAttribute("type")&&(this.clearActionResetTimer(),this.actionResetTimer=window.setTimeout(()=>{this.isConnected&&this.setState("ready")},300))}async trackEvent(e,t){let i=this.getAttribute("api-key")?.trim(),r=this.widgetMode;if(i&&r&&this.isConnected)try{let n=await this.ensureSession(i,t,r);await R(e,n.token,this.object?.uuid,{runtimeConfig:t,variantId:this.variantId})}catch{}}clearActionResetTimer(){void 0!==this.actionResetTimer&&(window.clearTimeout(this.actionResetTimer),this.actionResetTimer=void 0)}setState(e){this.dataset.state=e,this.updateTriggerAccessibility(e)}updateTriggerAccessibility(e){if(!this.trigger)return;let t="ready"===e;this.trigger.setAttribute("aria-busy",String("loading"===e)),this.trigger.setAttribute("aria-disabled",String(!t)),this.trigger.tabIndex=t?0:-1,this.trigger instanceof HTMLButtonElement&&(this.trigger.disabled=!t)}dispatchWidgetEvent(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}}function ex(e){if("u"<typeof customElements)return;let t=em[e],i=customElements.get(t);if(i)return i;class n extends ek{resolveRuntimeConfig(){return function(e,t="prod"){var i,n;let o,a,s,l,d,c,u,g,h="arizo"===e?"arizo.ru":"vizbl.com",m="dev"===t?"-dev":"";return o=r((i={apiOrigin:`https://api${m}.${h}`,modelViewerOrigin:`https://integrations${m}.${h}`,viewerOrigin:`https://viewer${m}.${h}`}).apiOrigin,"apiOrigin"),a=r(i.viewerOrigin,"viewerOrigin"),d=i.modelViewerOrigin?r(i.modelViewerOrigin,"modelViewerOrigin"):(l=(s=new URL(a)).hostname.match(/^viewer(-dev)?\.(vizbl\.com|arizo\.ru)$/))?`${s.protocol}//integrations${l[1]??""}.${l[2]}`:a,g=i.legacyApiOrigin?(c=r(n=i.legacyApiOrigin,"legacyApiOrigin"),(u=new URL(n).pathname.replace(/\/+$/,""))?`${c}${u}`:c):`${o}/v1`,{apiOrigin:o,brand:new URL(a).hostname.endsWith("arizo.ru")?"arizo":"vizbl",fetchImpl:i.fetchImpl??fetch,legacyApiOrigin:g,modelViewerOrigin:d,qrCodeScriptUrl:i.qrCodeScriptUrl??`${a}/vendor/qrcode.min.js`,viewerOrigin:a}}(e,this.hasAttribute("dev")?"dev":"prod")}}return customElements.define(t,n),n}ex("arizo"),ex("vizbl")})();
|
|
68
|
+
`,document.head.appendChild(e)}(),this.captureCustomLabel(),this.queueInitialization()}disconnectedCallback(){this.initializationRevision+=1,this.abortController?.abort(),this.abortController=void 0,this.cleanup?.(),this.cleanup=void 0,this.clearActionResetTimer()}attributeChangedCallback(e,t,i){if(t!==i){if("trigger-class"===e)return void this.applyTriggerClass();("api-key"===e||"dev"===e)&&(this.session=void 0),this.isConnected&&(this.abortController?.abort(),this.cleanup?.(),this.cleanup=void 0,this.setState("loading"),this.queueInitialization())}}captureCustomLabel(){if(null!==this.customLabelNodes)return;let e=Array.from(this.childNodes),t=e.some(e=>e.nodeType!==Node.TEXT_NODE||!!e.textContent?.trim());this.customLabelNodes=t?e:[]}queueInitialization(){this.queued||(this.queued=!0,queueMicrotask(()=>{this.queued=!1,this.isConnected&&this.initialize()}))}async initialize(){let e=++this.initializationRevision;this.abortController?.abort(),this.cleanup?.(),this.cleanup=void 0,this.object=void 0,this.variantId=void 0,this.widgetMode=void 0,this.clearActionResetTimer();let t=new AbortController;this.abortController=t;let i=this.getAttribute("type")?.trim()??"",r=eA(i)?i:"ar-viewer",n=this.getAttribute("object-id")?.trim()??"",o=this.getAttribute("variant-id")?.trim()||void 0,a=this.getAttribute("api-key")?.trim()??"",d=this.getAttribute("size-type")?.trim()||void 0,l=this.getAttribute("dimension-axes")?.trim()||void 0,c=this.getAttribute("camera-orbit")?.trim()||void 0,u=this.getAttribute("min-camera-orbit")?.trim()||void 0,g=this.getAttribute("max-camera-orbit")?.trim()||void 0;this.removeAttribute("data-error-code"),this.setState("loading"),this.renderTrigger(r);try{let r,m=this.resolveRuntimeConfig();if(!a)throw new eE("MISSING_API_KEY");if(!n)throw new eE("MISSING_OBJECT_ID");if(!eA(i))throw new eE("INVALID_TYPE");if("ar-viewer"===i&&d&&"cm"!==d&&"inch"!==d)throw new eE("INVALID_SIZE_TYPE");let h=eb[i],p=await this.ensureSession(a,m,h,t.signal);if(this.assertCurrent(e,t.signal),this.variantId=o,this.widgetMode=h,this.applyIntegrationData(n,o,d,l,c,u,g),"ar-viewer"===i)r=await N(n,t.signal,m),this.assertCurrent(e,t.signal),eC(r,o),eI(i,r),this.object=r;else{r=s()?await this.fetchObjectWithSession(n,a,p,m,t.signal,o):await N(n,t.signal,m),this.assertCurrent(e,t.signal);let d=eC(r,o);if(eI(i,r),!d.native?.glbUrl||!d.native.usdzUrl)throw new eE("MODEL_UNAVAILABLE");this.object=r}let f=await this.initializeTrigger(i,r,m,t.signal,a,p);try{this.assertCurrent(e,t.signal)}catch(e){throw f(),e}this.cleanup=f,this.setState("ready"),this.dispatchWidgetEvent("core-ar-ready",{objectId:n,type:i})}catch(o){if(e!==this.initializationRevision||t.signal.aborted||o instanceof DOMException&&"AbortError"===o.name)return;let r=o instanceof eE||o instanceof E?o.code:"INITIALIZATION_FAILED";this.setAttribute("data-error-code",r),this.setState("error"),this.dispatchWidgetEvent("core-ar-error",{code:r,objectId:n,type:i})}}async ensureSession(e,t,i,r,n=!1){let o=`${t.apiOrigin}|${t.viewerOrigin}|${t.modelViewerOrigin}|${i}`,a=this.session?.publicKey===e&&this.session.runtimeKey===o?this.session:void 0;if(a&&!n&&a.expiresAt-Date.now()>3e4)return a;if(a)try{let i=await L(e,a.token,{mode:a.mode,runtimeConfig:t,signal:r}),n={...a,...i,expiresAt:Date.now()+1e3*i.expiresIn};return this.session=n,n}catch(e){if(!(e instanceof E)||!ew.has(e.code))throw e;this.session=void 0}let s=await T(e,{mode:i,runtimeConfig:t,signal:r});if(!ep.has(s.productType))throw new eE("POLICY_DENIED");let d={expiresAt:Date.now()+1e3*s.expiresIn,mode:i,productType:s.productType,publicKey:e,runtimeKey:o,sid:s.sid,token:s.token};return this.session=d,d}async fetchObjectWithSession(e,t,i,r,n,o){try{return await z(e,i.token,{runtimeConfig:r,signal:n,variantId:o})}catch(a){if(!(a instanceof E)||"SESSION_EXPIRED"!==a.code)throw a;return z(e,(await this.ensureSession(t,r,i.mode,n,!0)).token,{runtimeConfig:r,signal:n,variantId:o})}}assertCurrent(e,t){if(e!==this.initializationRevision||t.aborted)throw new DOMException("Aborted","AbortError")}renderTrigger(e){let t="ar-one-click"===e?document.createElement("a"):document.createElement("button");if(t.dataset.coreArWidgetTrigger="",t.setAttribute("part","trigger"),t.addEventListener("click",e=>{"ready"!==this.dataset.state&&(e.preventDefault(),e.stopImmediatePropagation())}),t instanceof HTMLButtonElement&&(t.type="button"),t instanceof HTMLAnchorElement&&(t.href="#",t.rel="ar"),"ar-viewer"===e&&t.setAttribute("aria-haspopup","dialog"),"ar-viewer"!==e){let e=document.createElement("img");e.alt="",e.hidden=!0,t.appendChild(e)}let i=document.createElement("span");i.dataset.coreArWidgetLabel="",this.customLabelNodes?.length?i.append(...this.customLabelNodes):i.textContent=ef[e],t.appendChild(i),this.trigger=t,this.applyTriggerClass(),this.replaceChildren(t),this.updateTriggerAccessibility(this.dataset.state)}applyTriggerClass(){if(!this.trigger)return;let e=this.triggerClass.trim();e?this.trigger.className=e:this.trigger.removeAttribute("class")}applyIntegrationData(e,t,i,r,n,o,a){this.trigger&&(this.trigger.dataset.objectTinuuid=e,t?this.trigger.dataset.objectHid=t:delete this.trigger.dataset.objectHid,i?this.trigger.dataset.sizeType=i:delete this.trigger.dataset.sizeType,r?this.trigger.dataset.dimensionAxes=r:delete this.trigger.dataset.dimensionAxes,n?this.trigger.dataset.cameraOrbit=n:delete this.trigger.dataset.cameraOrbit,o?this.trigger.dataset.minCameraOrbit=o:delete this.trigger.dataset.minCameraOrbit,a?this.trigger.dataset.maxCameraOrbit=a:delete this.trigger.dataset.maxCameraOrbit)}async initializeTrigger(e,t,i,r,n,o){if(!this.trigger)throw new eE("INITIALIZATION_FAILED");if("ar-viewer"===e)return function(e,t={}){let i,r=ea(e),n=!1,o=async()=>{if(i||n)return;let o=e.dataset.objectTinuuid?.trim();if(!o)return;n=!0;let a=t.widgetSessionToken;try{t.getWidgetSessionToken&&(a=await t.getWidgetSessionToken())}catch{n=!1;return}if(n=!1,i||!r.isCurrent())return;let s=function(e){var t,i;let r,n;if(document.getElementById(eo))return null;let o=document.createElement("div"),a=document.createElement("div"),s=document.createElement("div"),d=e.containerClassName?document.getElementsByClassName(e.containerClassName)[0]:null,l=!!d,c=l?a:o,u=!1,g=e=>{"Escape"===e.key&&r()};r=()=>{u||(u=!0,document.removeEventListener("keydown",g),et(c),(l?a:o).remove(),e.onClose?.(),e.restoreFocusTo?.focus({preventScroll:!0}))},o.id=eo,Object.assign(o.style,{inset:"0",overflow:"auto",position:"fixed",zIndex:"11111"}),o.style.webkitOverflowScrolling="touch",a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.setAttribute("aria-label","ru"===e.lang?"Просмотр 3D-модели":"3D model viewer"),Object.assign(s.style,{animation:"vex-fadein 0.5s",background:"#fff",inset:"0",position:"fixed",zIndex:"11111"}),s.addEventListener("click",r),(e.width||e.height)&&(s.style.background="rgba(0, 0, 0, 0.8)",Object.assign(a.style,{borderRadius:"12px",height:e.height??"100%",left:"50%",overflow:"hidden",position:"absolute",top:"50%",transform:"translate(-50%, -50%)",width:e.width??"100%",zIndex:"11112"}));let m=function(e,t,i="en"){let r=document.createElement("button");return r.type="button",r.setAttribute("aria-label","ru"===i?"Закрыть просмотр 3D-модели":"Close 3D model viewer"),e&&(r.className=e),Object.assign(r.style,{alignItems:"center",background:"#fff",border:"1px solid #E3E7E7",borderRadius:"4px",boxSizing:"border-box",cursor:"pointer",display:"flex",height:"40px",inset:"24px 24px auto auto",justifyContent:"center",padding:"8px 16px",position:"absolute",width:"56px",zIndex:"11113"}),r.innerHTML='<svg aria-hidden="true" style="flex-shrink:0" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z" fill="#484D50"/></svg>',r.addEventListener("click",t),r}(e.crossClassName,r,e.lang);return a.append((t=el(e),i=e.backgroundColor,(n=document.createElement("iframe")).src=t,n.title="3D model viewer",n.allow="fullscreen; xr-spatial-tracking",Object.assign(n.style,{backgroundColor:i??"white",border:"none",height:"100%",inset:"0",position:"absolute",width:"100%",zIndex:"11112"}),n),m),d?(a.id=eo,d.appendChild(a)):(o.append(s,a),document.body.appendChild(o)),document.addEventListener("keydown",g),ee(c),m.focus({preventScroll:!0}),r}({apiKey:t.apiKey,backgroundColor:e.dataset.background,buttonBgColor:e.dataset.buttonBgColor,buttonBorderColor:e.dataset.buttonBorderColor,buttonTextColor:e.dataset.buttonTextColor,cameraOrbit:e.dataset.cameraOrbit,containerClassName:e.dataset.container,crossClassName:e.dataset.crossClassName,dimensionAxes:ed(e.dataset.dimensionAxes),height:e.dataset.height?.trim(),hid:e.dataset.objectHid,hidePreview:e.dataset.hidePreview,hideTitle:e.dataset.hideTitle,lang:t.lang,maxCameraOrbit:e.dataset.maxCameraOrbit,minCameraOrbit:e.dataset.minCameraOrbit,mode:t.mode,modelViewerOrigin:t.modelViewerOrigin,onClose:()=>{i=void 0,t.onClose?.()},restoreFocusTo:e,sizeType:es(e.dataset.sizeType),tinuuid:o,widgetSessionToken:a,width:e.dataset.width?.trim()});s&&(i=s,t.onOpen?.(),D(()=>t.onAction?.("widget_opened")))};return e.addEventListener("click",o),r.register(()=>{e.removeEventListener("click",o),i?.(),i=void 0})}(this.trigger,{apiKey:n,getWidgetSessionToken:async()=>(await this.ensureSession(n,i,o.mode)).token,lang:"arizo"===i.brand?"ru":"en",mode:o.mode,modelViewerOrigin:i.modelViewerOrigin,onAction:e=>this.handleAction(e,i),onClose:()=>{this.isConnected&&this.setState("ready")},onOpen:()=>this.setState("opening"),widgetSessionToken:o.token});if(!t)throw new eE("INITIALIZATION_FAILED");let a={getDesktopQrUrl:async()=>{let e=await this.ensureSession(n,i,o.mode);return el({apiKey:n,cameraOrbit:this.trigger?.dataset.cameraOrbit,dimensionAxes:ed(this.trigger?.dataset.dimensionAxes),hid:this.variantId,lang:"arizo"===i.brand?"ru":"en",maxCameraOrbit:this.trigger?.dataset.maxCameraOrbit,minCameraOrbit:this.trigger?.dataset.minCameraOrbit,mode:e.mode,modelViewerOrigin:i.modelViewerOrigin,sizeType:es(this.trigger?.dataset.sizeType),tinuuid:this.trigger?.dataset.objectTinuuid??"",widgetSessionToken:e.token})},object:t,onAction:e=>this.handleAction(e,i),runtimeConfig:i,signal:r,trackView:()=>this.trackEvent("ar_launched",i)};if("ar-one-click"===e){if(!(this.trigger instanceof HTMLAnchorElement))throw new eE("INITIALIZATION_FAILED");return eg(this.trigger,a)}return U(this.trigger,a)}handleAction(e,t){this.setState("opening"),("interacted"===e||"widget_opened"===e)&&"ar-viewer"!==this.getAttribute("type")&&this.trackEvent(e,t),"ar-viewer"!==this.getAttribute("type")&&(this.clearActionResetTimer(),this.actionResetTimer=window.setTimeout(()=>{this.isConnected&&this.setState("ready")},300))}async trackEvent(e,t){let i=this.getAttribute("api-key")?.trim(),r=this.widgetMode;if(i&&r&&this.isConnected)try{let n=await this.ensureSession(i,t,r);await R(e,n.token,this.object?.uuid,{runtimeConfig:t,variantId:this.variantId})}catch{}}clearActionResetTimer(){void 0!==this.actionResetTimer&&(window.clearTimeout(this.actionResetTimer),this.actionResetTimer=void 0)}setState(e){this.dataset.state=e,this.updateTriggerAccessibility(e)}updateTriggerAccessibility(e){if(!this.trigger)return;let t="ready"===e;this.trigger.setAttribute("aria-busy",String("loading"===e)),this.trigger.setAttribute("aria-disabled",String(!t)),this.trigger.tabIndex=t?0:-1,this.trigger instanceof HTMLButtonElement&&(this.trigger.disabled=!t)}dispatchWidgetEvent(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}}function eS(e){if("u"<typeof customElements)return;let t=eh[e],i=customElements.get(t);if(i)return i;class n extends eO{resolveRuntimeConfig(){return function(e,t="prod"){var i,n;let o,a,s,d,l,c,u,g,m="arizo"===e?"arizo.ru":"vizbl.com",h="dev"===t?"-dev":"";return o=r((i={apiOrigin:`https://api${h}.${m}`,modelViewerOrigin:`https://integrations${h}.${m}`,viewerOrigin:`https://viewer${h}.${m}`}).apiOrigin,"apiOrigin"),a=r(i.viewerOrigin,"viewerOrigin"),l=i.modelViewerOrigin?r(i.modelViewerOrigin,"modelViewerOrigin"):(d=(s=new URL(a)).hostname.match(/^viewer(-dev)?\.(vizbl\.com|arizo\.ru)$/))?`${s.protocol}//integrations${d[1]??""}.${d[2]}`:a,g=i.legacyApiOrigin?(c=r(n=i.legacyApiOrigin,"legacyApiOrigin"),(u=new URL(n).pathname.replace(/\/+$/,""))?`${c}${u}`:c):`${o}/v1`,{apiOrigin:o,brand:new URL(a).hostname.endsWith("arizo.ru")?"arizo":"vizbl",fetchImpl:i.fetchImpl??fetch,legacyApiOrigin:g,modelViewerOrigin:l,qrCodeScriptUrl:i.qrCodeScriptUrl??`${a}/vendor/qrcode.min.js`,viewerOrigin:a}}(e,this.hasAttribute("dev")?"dev":"prod")}}return customElements.define(t,n),n}eS("arizo"),eS("vizbl")})();
|
package/dist/index.js
CHANGED
|
@@ -763,6 +763,10 @@ function createModalViewerUrl(params) {
|
|
|
763
763
|
if (params.hid) url.searchParams.set('hid', params.hid);
|
|
764
764
|
url.searchParams.set('size-type', params.sizeType);
|
|
765
765
|
if (dimensionAxes.length < ALL_DIMENSION_AXES.length) url.searchParams.set('dimension-axes', dimensionAxes.join(','));
|
|
766
|
+
if (params.cameraOrbit) url.searchParams.set('camera-orbit', params.cameraOrbit);
|
|
767
|
+
if (params.minCameraOrbit) url.searchParams.set('min-camera-orbit', params.minCameraOrbit);
|
|
768
|
+
if (params.maxCameraOrbit) url.searchParams.set('max-camera-orbit', params.maxCameraOrbit);
|
|
769
|
+
if (params.lang) url.searchParams.set('lang', params.lang);
|
|
766
770
|
const fragment = new URLSearchParams();
|
|
767
771
|
if (params.apiKey) fragment.set('api-key', params.apiKey);
|
|
768
772
|
if (params.mode) fragment.set('mode', params.mode);
|
|
@@ -786,10 +790,10 @@ function createFrame(src, backgroundColor) {
|
|
|
786
790
|
});
|
|
787
791
|
return frame;
|
|
788
792
|
}
|
|
789
|
-
function createCloseButton(className, close) {
|
|
793
|
+
function createCloseButton(className, close, lang = 'en') {
|
|
790
794
|
const button = document.createElement('button');
|
|
791
795
|
button.type = 'button';
|
|
792
|
-
button.setAttribute('aria-label', 'Close 3D model viewer');
|
|
796
|
+
button.setAttribute('aria-label', 'ru' === lang ? 'Закрыть просмотр 3D-модели' : 'Close 3D model viewer');
|
|
793
797
|
if (className) button.className = className;
|
|
794
798
|
Object.assign(button.style, {
|
|
795
799
|
alignItems: 'center',
|
|
@@ -845,7 +849,7 @@ function openModal(options) {
|
|
|
845
849
|
root.style.webkitOverflowScrolling = 'touch';
|
|
846
850
|
viewer.setAttribute('role', 'dialog');
|
|
847
851
|
viewer.setAttribute('aria-modal', 'true');
|
|
848
|
-
viewer.setAttribute('aria-label', '3D model viewer');
|
|
852
|
+
viewer.setAttribute('aria-label', 'ru' === options.lang ? 'Просмотр 3D-модели' : '3D model viewer');
|
|
849
853
|
Object.assign(overlay.style, {
|
|
850
854
|
animation: 'vex-fadein 0.5s',
|
|
851
855
|
background: '#fff',
|
|
@@ -868,7 +872,7 @@ function openModal(options) {
|
|
|
868
872
|
zIndex: '11112'
|
|
869
873
|
});
|
|
870
874
|
}
|
|
871
|
-
const closeButton = createCloseButton(options.crossClassName, close);
|
|
875
|
+
const closeButton = createCloseButton(options.crossClassName, close, options.lang);
|
|
872
876
|
viewer.append(createFrame(createModalViewerUrl(options), options.backgroundColor), closeButton);
|
|
873
877
|
if (targetContainer) {
|
|
874
878
|
viewer.id = VIEWER_CONTAINER_ID;
|
|
@@ -908,6 +912,7 @@ function initializeModalTrigger(trigger, options = {}) {
|
|
|
908
912
|
buttonBgColor: trigger.dataset.buttonBgColor,
|
|
909
913
|
buttonBorderColor: trigger.dataset.buttonBorderColor,
|
|
910
914
|
buttonTextColor: trigger.dataset.buttonTextColor,
|
|
915
|
+
cameraOrbit: trigger.dataset.cameraOrbit,
|
|
911
916
|
containerClassName: trigger.dataset.container,
|
|
912
917
|
crossClassName: trigger.dataset.crossClassName,
|
|
913
918
|
dimensionAxes: resolveDimensionAxes(trigger.dataset.dimensionAxes),
|
|
@@ -915,6 +920,9 @@ function initializeModalTrigger(trigger, options = {}) {
|
|
|
915
920
|
hid: trigger.dataset.objectHid,
|
|
916
921
|
hidePreview: trigger.dataset.hidePreview,
|
|
917
922
|
hideTitle: trigger.dataset.hideTitle,
|
|
923
|
+
lang: options.lang,
|
|
924
|
+
maxCameraOrbit: trigger.dataset.maxCameraOrbit,
|
|
925
|
+
minCameraOrbit: trigger.dataset.minCameraOrbit,
|
|
918
926
|
mode: options.mode,
|
|
919
927
|
modelViewerOrigin: options.modelViewerOrigin,
|
|
920
928
|
onClose: ()=>{
|
|
@@ -1032,8 +1040,11 @@ const BACKEND_WIDGET_MODES = {
|
|
|
1032
1040
|
};
|
|
1033
1041
|
const OBSERVED_ATTRIBUTES = [
|
|
1034
1042
|
'api-key',
|
|
1043
|
+
'camera-orbit',
|
|
1035
1044
|
'dev',
|
|
1036
1045
|
'dimension-axes',
|
|
1046
|
+
'max-camera-orbit',
|
|
1047
|
+
'min-camera-orbit',
|
|
1037
1048
|
'object-id',
|
|
1038
1049
|
'size-type',
|
|
1039
1050
|
'trigger-class',
|
|
@@ -1237,6 +1248,9 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1237
1248
|
const publicKey = this.getAttribute('api-key')?.trim() ?? '';
|
|
1238
1249
|
const sizeType = this.getAttribute('size-type')?.trim() || void 0;
|
|
1239
1250
|
const dimensionAxes = this.getAttribute('dimension-axes')?.trim() || void 0;
|
|
1251
|
+
const cameraOrbit = this.getAttribute('camera-orbit')?.trim() || void 0;
|
|
1252
|
+
const minCameraOrbit = this.getAttribute('min-camera-orbit')?.trim() || void 0;
|
|
1253
|
+
const maxCameraOrbit = this.getAttribute('max-camera-orbit')?.trim() || void 0;
|
|
1240
1254
|
this.removeAttribute('data-error-code');
|
|
1241
1255
|
this.setState('loading');
|
|
1242
1256
|
this.renderTrigger(renderType);
|
|
@@ -1251,7 +1265,7 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1251
1265
|
this.assertCurrent(revision, abortController.signal);
|
|
1252
1266
|
this.variantId = variantId;
|
|
1253
1267
|
this.widgetMode = mode;
|
|
1254
|
-
this.applyIntegrationData(objectId, variantId, sizeType, dimensionAxes);
|
|
1268
|
+
this.applyIntegrationData(objectId, variantId, sizeType, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit);
|
|
1255
1269
|
let object;
|
|
1256
1270
|
if ('ar-viewer' === rawType) {
|
|
1257
1271
|
object = await fetchLegacyObject(objectId, abortController.signal, runtimeConfig);
|
|
@@ -1388,7 +1402,7 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1388
1402
|
if (className) this.trigger.className = className;
|
|
1389
1403
|
else this.trigger.removeAttribute('class');
|
|
1390
1404
|
}
|
|
1391
|
-
applyIntegrationData(objectId, variantId, sizeType, dimensionAxes) {
|
|
1405
|
+
applyIntegrationData(objectId, variantId, sizeType, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit) {
|
|
1392
1406
|
if (!this.trigger) return;
|
|
1393
1407
|
this.trigger.dataset.objectTinuuid = objectId;
|
|
1394
1408
|
if (variantId) this.trigger.dataset.objectHid = variantId;
|
|
@@ -1397,6 +1411,12 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1397
1411
|
else delete this.trigger.dataset.sizeType;
|
|
1398
1412
|
if (dimensionAxes) this.trigger.dataset.dimensionAxes = dimensionAxes;
|
|
1399
1413
|
else delete this.trigger.dataset.dimensionAxes;
|
|
1414
|
+
if (cameraOrbit) this.trigger.dataset.cameraOrbit = cameraOrbit;
|
|
1415
|
+
else delete this.trigger.dataset.cameraOrbit;
|
|
1416
|
+
if (minCameraOrbit) this.trigger.dataset.minCameraOrbit = minCameraOrbit;
|
|
1417
|
+
else delete this.trigger.dataset.minCameraOrbit;
|
|
1418
|
+
if (maxCameraOrbit) this.trigger.dataset.maxCameraOrbit = maxCameraOrbit;
|
|
1419
|
+
else delete this.trigger.dataset.maxCameraOrbit;
|
|
1400
1420
|
}
|
|
1401
1421
|
async initializeTrigger(type, object, runtimeConfig, signal, publicKey, session) {
|
|
1402
1422
|
if (!this.trigger) throw new CoreArWidgetComponentError('INITIALIZATION_FAILED');
|
|
@@ -1406,6 +1426,7 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1406
1426
|
const currentSession = await this.ensureSession(publicKey, runtimeConfig, session.mode);
|
|
1407
1427
|
return currentSession.token;
|
|
1408
1428
|
},
|
|
1429
|
+
lang: 'arizo' === runtimeConfig.brand ? 'ru' : 'en',
|
|
1409
1430
|
mode: session.mode,
|
|
1410
1431
|
modelViewerOrigin: runtimeConfig.modelViewerOrigin,
|
|
1411
1432
|
onAction: (action)=>this.handleAction(action, runtimeConfig),
|
|
@@ -1421,8 +1442,12 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1421
1442
|
const currentSession = await this.ensureSession(publicKey, runtimeConfig, session.mode);
|
|
1422
1443
|
return createModalViewerUrl({
|
|
1423
1444
|
apiKey: publicKey,
|
|
1445
|
+
cameraOrbit: this.trigger?.dataset.cameraOrbit,
|
|
1424
1446
|
dimensionAxes: resolveDimensionAxes(this.trigger?.dataset.dimensionAxes),
|
|
1425
1447
|
hid: this.variantId,
|
|
1448
|
+
lang: 'arizo' === runtimeConfig.brand ? 'ru' : 'en',
|
|
1449
|
+
maxCameraOrbit: this.trigger?.dataset.maxCameraOrbit,
|
|
1450
|
+
minCameraOrbit: this.trigger?.dataset.minCameraOrbit,
|
|
1426
1451
|
mode: currentSession.mode,
|
|
1427
1452
|
modelViewerOrigin: runtimeConfig.modelViewerOrigin,
|
|
1428
1453
|
sizeType: resolveSizeType(this.trigger?.dataset.sizeType),
|