UNPKG

@onirix/webar-debug-module

Version:

Help debugging errors in WebAR experiences running in Onirix Studio

2 lines (1 loc) 29.3 kB
function t(){return t=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},t.apply(this,arguments)}function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},e.apply(this,arguments)}var n={READY:"READY",SCENE_LOAD_START:"SCENE_LOAD_START",SCENE_LOAD_END:"SCENE_LOAD_END",SCENE_LOST:"SCENE_LOST",SCENE_RADIUS_ENTER:"SCENE_RADIUS_ENTER",SCENE_RADIUS_EXIT:"SCENE_RADIUS_EXIT",ELEMENT_CLICK:"ELEMENT_CLICK",OPEN_MARKERS_PANEL:"OPEN_MARKERS_PANEL",CLOSE_MARKERS_PANEL:"CLOSE_MARKERS_PANEL",MAP_READY:"MAP_READY",SCENE_LOCATION_CLICK:"SCENE_LOCATION_CLICK",BACK_TO_MAP:"BACK_TO_MAP",ON_TOUCH_START:"ON_TOUCH_START",ON_TOUCH_END:"ON_TOUCH_END",ON_POSE:"ON_POSE",SCENE_CLICK:"SCENE_CLICK",ON_SCENE_TOUCH_START:"ON_SCENE_TOUCH_START",ON_SCENE_TOUCH_END:"ON_SCENE_TOUCH_END",SESSION_ENDED:"SESSION_ENDED",SCENE_DETECTED:"SCENE_DETECTED",LAZY_LOAD_END:"LAZY_LOAD_END"},i={ENABLE_ELEMENT:"ENABLE_ELEMENT",DISABLE_ELEMENT:"DISABLE_ELEMENT",TOGGLE_ELEMENT:"TOGGLE_ELEMENT",ENABLE_ALL:"ENABLE_ALL",DISABLE_ALL:"DISABLE_ALL",PLAY:"PLAY",PAUSE:"PAUSE",STOP:"STOP",TRANSLATE_ELEMENT:"TRANSLATE_ELEMENT",ROTATE_ELEMENT:"ROTATE_ELEMENT",SCALE_ELEMENT:"SCALE_ELEMENT",SET_ELEMENT_POSITION:"SET_ELEMENT_POSITION",SET_ELEMENT_ROTATION:"SET_ELEMENT_ROTATION",SET_ELEMENT_SCALE:"SET_ELEMENT_SCALE",PLAY_ANIMATION:"PLAY_ANIMATION",STOP_ANIMATION:"STOP_ANIMATION",SET_LABEL_TEXT:"SET_LABEL_TEXT",RESET_SCENES:"RESET_SCENES",PLAY_PAUSE:"PLAY_PAUSE",SET_CAMERA_RIG_TRANSFORM:"SET_CAMERA_RIG_TRANSFORM",SET_CAMERA_RIG_POSITION:"SET_CAMERA_RIG_POSITION",SET_CAMERA_RIG_ROTATION:"SET_CAMERA_RIG_ROTATION",SET_CAMERA_RIG_QUATERNION:"SET_CAMERA_RIG_QUATERNION",DISABLE_CAMERA_CONTROLS:"DISABLE_CAMERA_CONTROLS",LOAD_ELEMENT:"LOAD_ELEMENT",CREATE_ELEMENT:"CREATE_ELEMENT",SET_VARIANT:"SET_VARIANT",CAPTURE_SCREEN_FRAME:"CAPTURE_SCREEN_FRAME",START_SCREEN_CAPTURE:"START_SCREEN_CAPTURE",STOP_SCREEN_CAPTURE:"STOP_SCREEN_CAPTURE",GET_ASSET_IMAGE:"GET_ASSET_IMAGE",LOAD_SURFACE_PLACEHOLDER:"LOAD_SURFACE_PLACEHOLDER",SET_TRANSFORM_CONTROLS_ALLOWLIST:"SET_TRANSFORM_CONTROLS_ALLOWLIST",SET_TRANSFORM_CONTROLS_BLOCKLIST:"SET_TRANSFORM_CONTROLS_BLOCKLIST"},o="v1",r="studio",s=function(){function t(){this.eventListeners={},this.eventListenersCount=0}var e=t.prototype;return e.addEventListener=function(t,e){this.eventListeners[t]||(this.eventListeners[t]=[]);var n=this.eventListenersCount++;return this.eventListeners[t].push({id:n,func:e}),n},e.triggerEvent=function(t,e){this.eventListeners[t]&&this.eventListeners[t].map(function(t){return t.func(e)})},e.removeEventListener=function(t){for(var e=0,n=Object.keys(this.eventListeners);e<n.length;e++)for(var i=n[e],o=0;o<i.length;o++)if(i[o].id===t){i.splice(o,1);break}},t}();let a;const c=new Uint8Array(16);function d(){if(!a&&(a="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!a))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a(c)}const E=[];for(let t=0;t<256;++t)E.push((t+256).toString(16).slice(1));var h={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function l(t,e,n){if(h.randomUUID&&!e&&!t)return h.randomUUID();const i=(t=t||{}).random||(t.rng||d)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e){n=n||0;for(let t=0;t<16;++t)e[n+t]=i[t];return e}return function(t,e=0){return E[t[e+0]]+E[t[e+1]]+E[t[e+2]]+E[t[e+3]]+"-"+E[t[e+4]]+E[t[e+5]]+"-"+E[t[e+6]]+E[t[e+7]]+"-"+E[t[e+8]]+E[t[e+9]]+"-"+E[t[e+10]]+E[t[e+11]]+E[t[e+12]]+E[t[e+13]]+E[t[e+14]]+E[t[e+15]]}(i)}var u=function(){function t(t){this.iframe=t,this.targetWindow=t?t.contentWindow:window,this.id=l(),this.eventManager=new s,this.onMessageReceived=this.onMessageReceived.bind(this),this.pendingActions=new Map}var a=t.prototype;return a.connect=function(){try{var t=function(){e.origin.match(/\.onirix\.com$/)||(e.iframe?console.warn("The Onirix Embed SDK is trying to connect to the origin `"+e.origin+"`, but that is not a recognised Onirix origin. The iframe provided to the Onirix Embed SDK constructor is not pointing to an Onirix Experience."):console.warn("The Onirix Embed SDK is trying to connect to the origin `"+e.origin+"`, but that is not a recognised Onirix origin. You may need to provide an iframe in the Onirix Embed SDK constructor."));var t=new Promise(function(t,n){e.onConnect=t});return window.addEventListener("message",e.onMessageReceived),e.sendHandshake(),Promise.resolve(t).then(function(){})},e=this;try{e.origin=e.targetWindow.location.origin}catch(t){e.origin=new URL(e.iframe.src).origin}var n=function(){if("null"===e.origin)return Promise.resolve(new Promise(function(t){return e.iframe.addEventListener("load",t,{once:!0})})).then(function(){e.origin=new URL(e.iframe.src).origin})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(t){return Promise.reject(t)}},a.disconnect=function(){try{var t=this;return t.sendDisconnect(),window.removeEventListener("message",t.onMessageReceived),t.pendingActions.clear(),Promise.resolve()}catch(t){return Promise.reject(t)}},a.sendMessage=function(t){t=e({oxEmbedSdk:o,source:this.id,destination:r},t),this.targetWindow.postMessage(t,this.origin)},a.sendHandshake=function(){this.targetWindow.postMessage({oxEmbedSdk:o,source:this.id,destination:r,type:"HANDSHAKE"},this.origin)},a.sendDisconnect=function(){this.sendMessage({type:"DISCONNECT"})},a.triggerAction=function(t,e){var n=this,i=l(),o=new Error,r=new Promise(function(t,e){n.pendingActions.set(i,{resolve:t,reject:function(t){var n,i=null!=(n=null==t?void 0:t.message)?n:t;o.message=i,e(o)}})});return this.sendMessage({type:"TRIGGER_ACTION",thread:i,action:t,args:e}),r},a.onMessageReceived=function(t){var e;if(t.origin===this.origin){var n=t.data;if(n.oxEmbedSdk===o&&n.destination===this.id)switch(n.type){case"CONNECT":null==(e=this.onConnect)||e.call(this),this.onConnect=void 0;break;case"RAISE_EVENT":this.eventManager.triggerEvent(n.event,n.args);break;case"REJECT_ACTION":this.onActionRejected(n.thread,n.error);break;case"RESOLVE_ACTION":this.onActionResolved(n.thread,n.value)}}},a.onActionResolved=function(t,e){var n=this.pendingActions.get(t);n?(n.resolve(e),this.pendingActions.delete(t)):console.warn("[Embed SDK] Resolving an already resolved action: "+t)},a.onActionRejected=function(t,e){var n=this.pendingActions.get(t);n?(n.reject(new Error(e)),this.pendingActions.delete(t)):console.warn("[Embed SDK] Rejecting an already resolved action: "+t)},a.subscribe=function(t,e){if(!(t in n))throw new Error('event "'+t+'" does not exists');return this.eventManager.addEventListener(t,e)},a.unsubscribe=function(t){this.eventManager.removeEventListener(t)},a.enable=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=1),this.triggerAction(i.ENABLE_ELEMENT,{oid:t,transition:e,time:n})},a.disable=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=1),this.triggerAction(i.DISABLE_ELEMENT,{oid:t,transition:e,time:n})},a.toggle=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=1),this.triggerAction(i.TOGGLE_ELEMENT,{oid:t,transition:e,time:n})},a.enableAll=function(){return this.triggerAction(i.ENABLE_ALL)},a.disableAll=function(){return this.triggerAction(i.DISABLE_ALL)},a.play=function(t){return this.triggerAction(i.PLAY,{oid:t})},a.pause=function(t){return this.triggerAction(i.PAUSE,{oid:t})},a.stop=function(t){return this.triggerAction(i.STOP,{oid:t})},a.playPause=function(t){return this.triggerAction(i.PLAY_PAUSE,{oid:t})},a.translate=function(t,e,n,o,r,s){return this.triggerAction(i.TRANSLATE_ELEMENT,{oid:t,x:e,y:n,z:o,time:r,loop:s})},a.translateToPosition=function(t,e,n,o,r,s){return this.triggerAction(i.SET_ELEMENT_POSITION,{oid:t,target:{x:e,y:n,z:o},time:r,lookAt:s})},a.translateToElement=function(t,e,n,o,r){return this.triggerAction(i.SET_ELEMENT_POSITION,{oid:t,target:e,time:n,lookAt:o,loop:r})},a.rotate=function(t,e,n,o,r,s){return this.triggerAction(i.ROTATE_ELEMENT,{oid:t,x:e,y:n,z:o,time:r,loop:s})},a.rotateTo=function(t,e,n,o,r){return this.triggerAction(i.SET_ELEMENT_ROTATION,{oid:t,x:e,y:n,z:o,time:r})},a.rotateToQuaternion=function(t,e,n,o,r,s){return this.triggerAction(i.SET_ELEMENT_ROTATION,{oid:t,x:e,y:n,z:o,w:r,time:s})},a.scale=function(t,e,n,o,r,s){return this.triggerAction(i.SCALE_ELEMENT,{oid:t,x:e,y:n,z:o,time:r,loop:s})},a.playAnimation=function(t,e,n,o,r){return void 0===o&&(o=!1),void 0===r&&(r=void 0),this.triggerAction(i.PLAY_ANIMATION,{oid:t,animation:e,time:r,loop:n,autoStop:o})},a.stopAnimation=function(t,e){return this.triggerAction(i.STOP_ANIMATION,{oid:t,animation:e})},a.setLabelText=function(t,e){return this.triggerAction(i.SET_LABEL_TEXT,{oid:t,text:e})},a.resetScenes=function(){return this.triggerAction(i.RESET_SCENES,{})},a.setCameraRigTransform=function(t){return this.triggerAction(i.SET_CAMERA_RIG_TRANSFORM,{matrix:t.flat()})},a.setCameraRigPosition=function(t,e,n){return this.triggerAction(i.SET_CAMERA_RIG_POSITION,{x:t,y:e,z:n})},a.setCameraRigRotation=function(t,e,n){return this.triggerAction(i.SET_CAMERA_RIG_ROTATION,{x:t,y:e,z:n})},a.setCameraRigQuaternion=function(t,e,n,o){return this.triggerAction(i.SET_CAMERA_RIG_QUATERNION,{x:t,y:e,z:n,w:o})},a.disableCameraControls=function(){return this.triggerAction(i.DISABLE_CAMERA_CONTROLS,{})},a.loadElement=function(t,n){return this.triggerAction(i.LOAD_ELEMENT,e({},n,{oid:t}))},a.createElement=function(t,n){return this.triggerAction(i.CREATE_ELEMENT,e({},n,{newOid:t}))},a.setVariant=function(t,e){return this.triggerAction(i.SET_VARIANT,{oid:t,variant:e})},a.captureScreenFrame=function(){return this.triggerAction(i.CAPTURE_SCREEN_FRAME,{})},a.startScreenCapture=function(){return this.triggerAction(i.START_SCREEN_CAPTURE,{})},a.stopScreenCapture=function(){return this.triggerAction(i.STOP_SCREEN_CAPTURE,{})},a.getAssetImage=function(t,e){return void 0===e&&(e=!0),this.triggerAction(i.GET_ASSET_IMAGE,{assetOid:t,thumb:e})},a.loadSurfacePlaceholder=function(t){return this.triggerAction(i.LOAD_SURFACE_PLACEHOLDER,{placeholderUrl:t})},a.setTransformControlsAllowlist=function(t){if(!(t&&t[Symbol.iterator]||void 0===t))throw new Error("`allowlist` must be an iterable or `undefined`.");return void 0===t||t instanceof Set||(t=new Set(t)),this.triggerAction(i.SET_TRANSFORM_CONTROLS_ALLOWLIST,{allowlist:t})},a.setTransformControlsBlocklist=function(t){if(!(t&&t[Symbol.iterator]||void 0===t))throw new Error("`blocklist` must be an iterable or `undefined`.");return void 0===t||t instanceof Set||(t=new Set(t)),this.triggerAction(i.SET_TRANSFORM_CONTROLS_BLOCKLIST,{blocklist:t})},t}();u.Events=n,u.Actions=i;var g="\n .ox-webar-debug .ox-session-id:before {\n content: 'Debug id:';\n margin-right: 5px;\n }\n\n select {\n height: 30px;\n margin-right: 10px;\n width: 100%;\n margin-left: 10px;\n margin-top: auto;\n margin-bottom: auto;\n max-width: 200px;\n }\n\n div.ox-debug-panel {\n position: absolute;\n bottom: 0px;\n right: 0px;\n margin: 0px;\n left: 0px;\n min-height: 20px;\n }\n\n div.ox-debug-topbar {\n display: flex;\n justify-content: space-between;\n }\n\n div.ox-debug-topbar > div {\n display: flex;\n width: fit-content;\n font-size: 14px;\n font-weight: 600;\n text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);\n line-height: 1.5;\n color: #000;\n border: 2px solid #580088;\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n border-bottom: none;\n border-bottom: none;\n }\n\n div.ox-debug-handle {\n height: 7px;\n background: white;\n width: 35px;\n position: absolute;\n right: 50vw;\n cursor: pointer;\n transform: translate(50%, 0);\n border-radius: 4px;\n top: 50px;\n }\n\n div.ox-debug-topbar div div {\n padding: 15px;\n cursor: pointer;\n background-color: #58008844;\n text-align: center;\n display: flex;\n align-items: center;\n }\n\n div.ox-debug-topbar div div:first-child {\n border-top-left-radius: 5px;\n }\n\n div.ox-debug-topbar div div:last-child {\n border-top-right-radius: 5px;\n }\n\n div.ox-debug-topbar div div.ox-debug-selected {\n background: #580088;\n color: white;\n }\n\n div.ox-debug-topbar div div:not(:last-child) {\n border-right: 1px solid #580088;\n }\n\n div.ox-debug-topbar > div:last-child {\n align-items: center;\n padding: 10px;\n background-color: #58008844;\n }\n\n div.ox-debug-topbar > div:last-child > svg {\n cursor: pointer;\n }\n\n div.ox-debug-topbar > div:last-child > svg:first-child {\n margin-right: 20px;\n }\n\n pre.ox-show-trace {\n margin: 0;\n max-height: 50vh;\n min-height: 20px;\n padding: 5px;\n padding-bottom: calc(30px + var(--sab));\n background-color: #58008844;\n color: #000;\n font-size: 14px;\n font-weight: 600;\n text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);\n line-height: 1.5;\n border: 2px solid #580088;\n border-top-right-radius: 4px;\n border-bottom: none;\n overflow: scroll;\n white-space: pre-wrap;\n display: block;\n }\n\n pre.ox-show-trace::-webkit-scrollbar {\n display: none; \n }\n\n body:not(.ox-show-trace) .ox-copy-current-trace {\n display: none;\n }\n\n span.info {\n color: #0000FF;\n }\n\n span.warn {\n color: #f5a623;\n }\n\n span.error {\n color: #e90e0e;\n }\n\n .ox-debug-toast {\n position: absolute;\n left: 50%;\n transform: translate(-50%, 0px);\n background: #e90e0e0f;\n border-radius: 10px;\n top: calc(10px + var(--sat));\n display: flex;\n border: 1px solid #e90e0e;\n max-width: calc(100% - 40px);\n width: max-content;\n }\n\n .ox-debug-toast > div {\n width: 10px;\n background: #e90e0e;\n border-top-left-radius: 8px;\n border-bottom-left-radius: 8px;\n }\n \n .ox-debug-toast.info {\n border: 1px solid #0000FF;\n background: #0000FF0F;\n }\n\n .ox-debug-toast.info > div {\n background: #0000FF;\n }\n\n .ox-debug-toast > span {\n padding: 10px;\n width: 100%;\n }\n",T="Engine SDK",p="Embed SDK",A="Other",L=/*#__PURE__*/function(){function t(){this.OX_WEBAR_DEBUG="ox-webar-debug",this.SHOW_TRACE="ox-show-trace",this.DOWNLOAD_TRACE="ox-download-trace",this.COPY_CURRENT_TRACE="ox-copy-current-trace",this.PANEL="ox-debug-panel",this.TOP_BAR="ox-debug-topbar",this.SELECTED="ox-debug-selected",this.HANDLE="ox-debug-handle",this.TOAST="ox-debug-toast",this.isDragging=!1,this.MAX_TOP=0,this.MIN_TOP=590,this.importCss(),document.body.classList.add(this.OX_WEBAR_DEBUG),this.addPanel();var t=parseInt(document.defaultView.getComputedStyle(document.documentElement).getPropertyValue("--sat").split("px")[0]);this.MAX_TOP=0+t}var e=t.prototype;return e.addPanel=function(){this.panel=document.createElement("div"),this.panel.classList.add(this.PANEL),this.panel.id=this.PANEL;var t=this.addTopBar();this.panel.appendChild(t),this.createHandle(),this.panel.appendChild(this.handle),this.creaceTrace(),this.panel.appendChild(this.tracePre),document.body.appendChild(this.panel),this.addListeners(),this.minTopDesktop=window.innerHeight-this.panel.clientHeight,null!=this.isMobile()?this.initDragMobile():this.initDragDesktop()},e.addListeners=function(){var t=this;document.getElementById(T).addEventListener("click",function(){t.updateSelected(T),t.onTabChange(T)}),document.getElementById(p).addEventListener("click",function(){t.updateSelected(p),t.onTabChange(p)}),document.getElementById(A).addEventListener("click",function(){t.updateSelected(A),t.onTabChange(A)}),document.getElementById(this.DOWNLOAD_TRACE).addEventListener("click",function(){t.onShare()}),document.getElementById(this.COPY_CURRENT_TRACE).addEventListener("click",function(){t.copyToClipboard(JSON.stringify(t.data))})},e.createHandle=function(){this.handle=document.createElement("div"),this.handle.classList.add(this.HANDLE),this.handle.id=this.HANDLE},e.isMobile=function(){return navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/iPad/i)},e.preventTranform=function(t){t.addEventListener("touchmove",function(t){t.stopPropagation()})},e.initDragMobile=function(){var t=this,e={};this.handle.addEventListener("touchstart",function(n){t.isDragging=!0,e={offset:t.panel.offsetTop,init:Math.ceil(n.changedTouches[0].pageY),current:Math.ceil(n.changedTouches[0].pageY)}}),this.preventTranform(this.panel),this.handle.addEventListener("touchmove",function(n){t.controlMovement(n,e)}),this.handle.addEventListener("touchend",function(e){t.isDragging=!1})},e.controlMovement=function(t,e,n){if(void 0===n&&(n=!1),this.isDragging){n&&t.preventDefault();var i=""==this.panel.style.top?e.offset:parseInt(this.panel.style.top.replace("px","")),o=n?this.minTopDesktop:this.MIN_TOP;if(i>=this.MAX_TOP&&i<=o){e.current=n?Math.ceil(t.clientY):Math.ceil(t.changedTouches[0].pageY);var r=e.offset+(e.current-e.init);r>=this.MAX_TOP&&r<=o&&(this.panel.style.top=r+"px")}var s=this.panel.clientHeight,a=document.getElementById(this.TOP_BAR).clientHeight,c=parseInt(document.defaultView.getComputedStyle(document.documentElement).getPropertyValue("--sab").split("px")[0]);this.tracePre.style.maxHeight=s-a-37+c+"px",this.tracePre.style.height="100%"}},e.initDragDesktop=function(){var t=this;this.handle.addEventListener("mousedown",function(e){t.isDragging=!0;var n={offset:t.panel.offsetTop,init:Math.ceil(e.clientY),current:Math.ceil(e.clientY)};document.addEventListener("mousemove",function(e){t.controlMovement(e,n,!0)}),document.addEventListener("mouseup",function(){t.isDragging=!1})})},e.updateSelected=function(t){var e=document.getElementById(T),n=document.getElementById(p),i=document.getElementById(A);switch(t){case T:e.classList.add(this.SELECTED),n.classList.remove(this.SELECTED),i.classList.remove(this.SELECTED);break;case p:e.classList.remove(this.SELECTED),n.classList.add(this.SELECTED),i.classList.remove(this.SELECTED);break;case A:e.classList.remove(this.SELECTED),n.classList.remove(this.SELECTED),i.classList.add(this.SELECTED)}},e.addTopBar=function(){var t=document.createElement("div");t.classList.add(this.TOP_BAR),t.id=this.TOP_BAR;var e=navigator.canShare?'<svg id="'+this.DOWNLOAD_TRACE+'" width="18" height="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">\n <path d="M14.333 0C15.806 0 17 1.209 17 2.7s-1.194 2.7-2.667 2.7a2.649 2.649 0 0 1-2.064-.99L6.126 7.954c.134.321.207.674.207 1.045 0 .371-.074.725-.207 1.046l6.143 3.545a2.649 2.649 0 0 1 2.064-.991c1.473 0 2.667 1.209 2.667 2.7S15.806 18 14.333 18c-1.472 0-2.666-1.209-2.666-2.7 0-.322.055-.63.157-.916L5.62 10.839a2.644 2.644 0 0 1-1.952.861C2.194 11.7 1 10.491 1 9s1.194-2.7 2.667-2.7c.77 0 1.465.331 1.952.861l6.205-3.545a2.725 2.725 0 0 1-.157-.916c0-1.491 1.194-2.7 2.666-2.7z" fill="#211F1F" fill-rule="evenodd"/>\n </svg>':'<svg id="'+this.DOWNLOAD_TRACE+'" width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">\n <g fill="none" fill-rule="evenodd">\n <path d="M0 0h20v20H0z"/>\n <path d="m4.243 9.686 4.983 5.006a1.13 1.13 0 0 0 1.413.111l.12-.096 4.97-4.992a.868.868 0 0 0 .06-1.198l-.106-.106-.016-.013a1.108 1.108 0 0 0-1.465.069l-3.05 3.053V3.076C11.153 2.482 10.638 2 10 2c-.637 0-1.153.482-1.153 1.076v8.444L5.798 8.467a1.108 1.108 0 0 0-1.465-.069.87.87 0 0 0-.09 1.288zM17 16.992a.993.993 0 0 1-.992.993l-12.016.014a.99.99 0 1 1 0-1.984l12.016-.014a.99.99 0 0 1 .992.99z" fill="#580088"/>\n </g>\n </svg>\n ';return t.innerHTML='\n <div>\n <div id="'+T+'" class="'+this.SELECTED+'">'+T+'</div>\n <div id="'+p+'">'+p+'</div>\n <div id="'+A+'">'+A+"</div>\n </div>\n <div>\n "+e+'\n <svg id="'+this.COPY_CURRENT_TRACE+'" width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n <path id="copy" fill="#211f1f" fill-rule="nonzero" d="M8.45576471,7.42404706 C7.90982149,7.42404706 7.46724706,7.86662149 7.46724706,8.41256471 L7.46724706,14.8798588 C7.46724706,15.4262118 7.90941176,15.8696471 8.45576471,15.8696471 L14.9230588,15.8696471 C15.4694118,15.8696471 15.9128471,15.4262118 15.9128471,14.8811294 L15.9128471,8.41129412 C15.9128471,7.8653509 15.4702726,7.42277647 14.9243294,7.42277647 L8.45576471,7.42277647 L8.45576471,7.42404706 Z M8.45576471,5.44828235 L14.9230588,5.44828235 C15.7094555,5.44760813 16.4638927,5.75944347 17.0203166,6.31515253 C17.5767406,6.87086157 17.8895455,7.62489724 17.8898824,8.41129412 L17.8898824,14.8785882 C17.8902194,15.6649849 17.5780608,16.4192882 17.0221135,16.9754738 C16.4661662,17.5316594 15.7119967,17.8441413 14.9256,17.8441412 L8.45576471,17.8441412 C6.81863676,17.8441412 5.49148235,16.5169868 5.49148235,14.8798588 L5.49148235,8.41129412 C5.49148235,6.77416618 6.81863676,5.44701176 8.45576471,5.44701176 L8.45576471,5.44828235 Z M2.9376,4.16333634e-17 L3.68724706,4.16333634e-17 L3.68724706,0.988517647 L2.9376,0.988517647 L2.9376,4.16333634e-17 Z M4.77995294,4.16333634e-17 L5.7672,4.16333634e-17 L5.7672,0.988517647 L4.77995294,0.988517647 L4.77995294,4.16333634e-17 Z M6.83195294,4.16333634e-17 L7.82047059,4.16333634e-17 L7.82047059,0.988517647 L6.83195294,0.988517647 L6.83195294,4.16333634e-17 Z M8.81788235,4.16333634e-17 L9.80512941,4.16333634e-17 L9.80512941,0.988517647 L8.81788235,0.988517647 L8.81788235,4.16333634e-17 Z M11.7237176,0.640376471 L11.1100235,1.41543529 C10.9369182,1.27794848 10.7419139,1.17056724 10.5331765,1.09778824 L10.8584471,0.163905882 C11.1748235,0.274447059 11.4670588,0.435811765 11.7237176,0.640376471 Z M12.4517647,1.48150588 C12.6144,1.76484706 12.7325647,2.07614118 12.7960941,2.40903529 L11.8253647,2.592 C11.7842857,2.37560032 11.7069637,2.16768982 11.5966588,1.97703529 L12.4517647,1.48150588 Z M12.8481882,3.36832941 L12.8481882,4.35557647 L11.8596706,4.35557647 L11.8596706,3.36832941 L12.8481882,3.36832941 Z M2.96555294,12.8469176 C2.68983529,12.8469176 2.42174118,12.8088 2.16762353,12.7376471 L2.43317647,11.7859765 C2.60470588,11.8342588 2.78258824,11.8584 2.96682353,11.8584 L3.14851765,11.8584 L3.14851765,12.8469176 L2.96555294,12.8469176 Z M0.553976471,11.6080941 L1.35698824,11.0325176 C1.48531765,11.2116706 1.64414118,11.3692235 1.82583529,11.4975529 L1.25407059,12.3043765 C0.983435294,12.1137882 0.745835294,11.8774588 0.553976471,11.6080941 Z M0,9.93218824 L0,9.66282353 L0.988517647,9.66028235 L0.988517647,9.91694118 C0.991058824,10.0897412 1.01647059,10.26 1.06221176,10.4226353 L0.193129412,10.9359529 C0.0709406422,10.6151218 0.00558687345,10.2754542 3.3796495e-16,9.93218824 Z M-1.38777878e-17,7.68451765 L0.988517647,7.68451765 L0.988517647,8.67303529 L-1.38777878e-17,8.67303529 L-1.38777878e-17,7.68451765 Z M-1.38777878e-17,5.70875294 L0.988517647,5.70875294 L0.988517647,6.69727059 L-1.38777878e-17,6.69727059 L-1.38777878e-17,5.70875294 Z M-1.38777878e-17,3.73171765 L0.988517647,3.73171765 L0.988517647,4.72023529 L-1.38777878e-17,4.72023529 L-1.38777878e-17,3.73171765 Z M0.243952941,1.78390588 L1.15115294,2.17778824 C1.06221176,2.37981176 1.01011765,2.59454118 0.9936,2.81689412 L0.0139764706,2.74447059 L0.00762352941,2.74447059 C0.0330352941,2.40522353 0.114352941,2.08249412 0.243952941,1.78390588 Z M1.60348235,0.330352941 L2.05835294,1.20705882 C1.86141176,1.30870588 1.68352941,1.44338824 1.53105882,1.60475294 L0.813176471,0.923717647 C1.04188235,0.686117647 1.30870588,0.482823529 1.60348235,0.330352941 Z M2.9376,-4.51028104e-17 L2.94649412,0.988517647 C2.86390588,0.988517647 2.78258824,0.994870588 2.70254118,1.00503529 L2.57421176,0.0266823529 C2.69237647,0.0101647059 2.81435294,0.00127058824 2.9376,0.00127058824 L2.9376,-4.51028104e-17 Z" id="Shape"></path> \n </svg>\n </div>\n ',t},e.creaceTrace=function(){this.tracePre=document.createElement("pre"),this.tracePre.classList.add(this.SHOW_TRACE),this.tracePre.id=this.SHOW_TRACE},e.setTraceContent=function(t){this.data=t,this.tracePre.innerHTML=this.getContentData(t),this.tracePre.scrollTop=this.tracePre.scrollHeight},e.getContentData=function(t){var e="";return t.forEach(function(t){var n=JSON.stringify(t.args,null,2);e+="info"==t.type?'<span class="info">'+n+"</span><br>":"warn"==t.type?'<span class="warn">'+n+"</span><br>":"error"==t.type?'<span class="error">'+n+"</span><br>":"<span>"+n+"</span><br>"}),e},e.showTrace=function(t){t?document.body.classList.add(this.SHOW_TRACE):document.body.classList.remove(this.SHOW_TRACE)},e.copyToClipboard=function(t){var e=this;navigator.clipboard?navigator.clipboard.writeText(t).then(function(){e.showAlertInformation("Text copied to clipboard.")}).catch(function(n){e.fallbackCopyToClipboard(t)}):this.fallbackCopyToClipboard(t)},e.fallbackCopyToClipboard=function(t){var e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),e.setSelectionRange(0,99999);try{document.execCommand("copy"),this.showAlertInformation("Text copied to clipboard.")}catch(t){this.showAlertInformation("Error when copying text to clipboard. "+t,"error")}document.body.removeChild(e)},e.showAlertInformation=function(t,e){var n=this;void 0===e&&(e="info");var i=document.createElement("div");i.id=this.TOAST,i.classList.add(this.TOAST),"error"!=e&&i.classList.add("info"),i.innerHTML="\n <div></div>\n <span>"+t+"</span>\n ",document.body.appendChild(i),setTimeout(function(){document.body.removeChild(document.getElementById(n.TOAST))},1e3)},e.importCss=function(){var t=document.createElement("style");t.styleSheet?t.styleSheet.cssText=g:t.appendChild(document.createTextNode(g)),document.head.appendChild(t)},t}(),_=/*#__PURE__*/function(){function e(){var e=this;this.MAX_TRACE_SIZE=999,this.traceEngine=[],this.traceEmbed=[],this.traceOther=[],this.tab=T,this.originalConsole=t({},console),this.wrapConsoleMethods(),this.sessionId=(new Date).getTime(),this.uiService=new L,this.uiService.onShare=function(){return e.shareTrace()},this.uiService.onTabChange=function(t){e.tab=t,e.uiService.setTraceContent(e.filterByTab())}}var n=e.prototype;return n.showTrace=function(t){this.uiService.showTrace(t)},n.wrapConsoleMethods=function(){var t=this;["log","warn","info","error"].forEach(function(e){console[e]=t.createWrappedMethod(e).bind(t)})},n.createWrappedMethod=function(t){return function(){var e,n=[].slice.call(arguments),i=(new Error).stack.split("\n").slice(2);this.customTrace.apply(this,[t,i.join("\n")].concat(n)),(e=this.originalConsole)[t].apply(e,n)}},n.customTrace=function(t,e){var n={type:t,args:[].slice.call(arguments,2),origin:e,timestamp:(new Date).getTime()};this.pushTrace(n),this.uiService.setTraceContent(this.filterByTab())},n.filterByTab=function(){return(this.tab==T?this.traceEngine:this.tab==p?this.traceEmbed:this.traceOther).map(function(t){return{type:t.type,args:t.args}})},n.pushTrace=function(t){var e,n,i=this.traceEngine.length+this.traceEmbed.length+this.traceOther.length;i==this.MAX_TRACE_SIZE&&this.traceOther.push("The maximum trace size has been reached."),null!=(e=t.origin)&&e.includes("run@https://")?(i>this.MAX_TRACE_SIZE&&this.traceEngine.shift(),this.traceEngine.push(t)):null!=(n=JSON.stringify(t.args))&&n.includes("embed_skd_event")?(i>this.MAX_TRACE_SIZE&&this.traceEmbed.shift(),this.traceEmbed.push(t)):(i>this.MAX_TRACE_SIZE&&this.traceOther.shift(),this.traceOther.push(t))},n.setEmbedSDK=function(t){console.log("Listen OnirixEmbedSDK.Events"),Object.keys(u.Events).forEach(function(e){t.subscribe(e,function(t){console.log({embed_skd_event:e,params:t})})})},n.shareTrace=function(){try{var t=this,e=JSON.stringify(t.filterByTab(),null,2),n=function(){if(navigator.canShare){var n=new Blob([e],{type:"text/plain"}),i=new File([n],"ox_webar_debug_"+t.sessionId+".txt",{type:n.type});return Promise.resolve(navigator.share({files:[i]})).then(function(){})}var o=new Blob([e],{type:"application/json"}),r=URL.createObjectURL(o),s=document.createElement("a");s.href=r,s.download="ox_webar_debug_"+t.sessionId+".json",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r)}();return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(t){return Promise.reject(t)}},n.restoreConsole=function(){console=this.originalConsole,this.originalConsole=null},e}();export{_ as default};