@graphen.ai/aiia-sdk 1.0.18 → 1.0.19

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/LICENSE CHANGED
@@ -37,7 +37,7 @@ Development dependencies:
37
37
  - @rollup/* (MIT License)
38
38
  - @types/* (MIT License)
39
39
  - rollup (MIT License)
40
- - rollup-plugin-javascript-obfuscator (MIT License)
40
+ - rollup-plugin-obfuscator (MIT License)
41
41
  - tslib (MIT License)
42
42
  - typescript (Apache License 2.0)
43
43
 
@@ -1,2 +1,2 @@
1
- /** @license AiiaVad Released: 2025-12-8 */
2
- !function(){"use strict";var t;!function(t){t[t.unknow=0]="unknow",t[t.allowed=1]="allowed",t[t.rejected=2]="rejected"}(t||(t={}));class e extends AudioWorkletProcessor{inputBuffer;inputBufferLength;processChunkSize;outputSampleRate;originalSampleRate;constructor(t){super(),this.inputBuffer=[],this.inputBufferLength=0;const{outputSampleRate:e,chunkTimeInSeconds:n}=Object.assign({outputSampleRate:16e3,chunkTimeInSeconds:1},t?.processorOptions);this.originalSampleRate=sampleRate,this.outputSampleRate=e,this.processChunkSize=function(t,e,n=1){const s=e*n,u=t/e;return Math.ceil(s*u)}(this.originalSampleRate,this.outputSampleRate,n)}process(t,e,n){const s=t[0][0];if(!s)return!0;const u=new Float32Array(s);if(this.inputBuffer.push(u),this.inputBufferLength+=s.length,this.inputBufferLength>=this.processChunkSize){const t=function(t){const e=t.reduce((t,e)=>t+e.length,0),n=new Float32Array(e);let s=0;for(const e of t)n.set(e,s),s+=e.length;return n}(this.inputBuffer);this.inputBuffer=[],this.inputBufferLength=0;const e=function(t,e,n){if(e===n)return t;const s=n/e,u=Math.ceil(t.length*s),i=new Float32Array(u);for(let e=0;e<u;e++){const n=e/s,u=Math.floor(n),o=n-u,r=t[u],a=t[Math.min(u+1,t.length-1)];i[e]=r+(a-r)*o}return i}(t,this.originalSampleRate,this.outputSampleRate);this.port.postMessage({float32:e,outputSampleRate:this.outputSampleRate},[e.buffer])}return!0}}registerProcessor("aiia-vad",e)}();
1
+ /** @license AiiaVad Released: 2025-12-22 */
2
+ !function(){"use strict";function t(){const e=["2042184YXZFHw","18HKUeef","getInt16","sampleRate","getUserMedia","all","mediaDevices","length","6CKzhxj","random","forEach","allowed","getFloat32","12612ogqlIj","unknow","push","33nkEXkn","ceil","getChannelData","7ULJFed","1695580sHXvby","1116670wEZoGR","createBuffer","1060134UEcgVr","816816yfbxWw","min","195trdMIC","26893gTuhVI","rejected","buffer"];return(t=function(){return e})()}var e;function n(e,n){e-=254;return t()[e]}!function(t){const e=n,s=t();for(;;)try{if(169651===parseInt(e(256))/1*(parseInt(e(267))/2)+-parseInt(e(255))/3*(-parseInt(e(272))/4)+-parseInt(e(280))/5+-parseInt(e(282))/6*(-parseInt(e(278))/7)+parseInt(e(283))/8+parseInt(e(260))/9*(parseInt(e(279))/10)+-parseInt(e(275))/11*(parseInt(e(259))/12))break;s.push(s.shift())}catch(t){s.push(s.shift())}}(t),function(t){const e=n;t[t.unknow=0]=e(273),t[t[e(270)]=1]=e(270),t[t[e(257)]=2]=e(257)}(e||(e={}));const s=r;function r(t,e){t-=108;return o()[t]}function o(){const t=["postMessage","originalSampleRate","length","152yJRvsQ","3159219oWLtCy","process","push","ceil","reduce","155dxigFX","inputBuffer","inputBufferLength","port","76827AzHvIr","135TrVqEA","set","431410GMyazI","aiia-vad","341364jdyVRP","processorOptions","20946596xEQngT","193422eYUopB","processChunkSize","outputSampleRate","assign","1XUywph","903232YTAXNm"];return(o=function(){return t})()}!function(t){const e=r,n=t();for(;;)try{if(547637===-parseInt(e(132))/1*(-parseInt(e(125))/2)+parseInt(e(120))/3*(parseInt(e(110))/4)+parseInt(e(116))/5*(parseInt(e(128))/6)+-parseInt(e(111))/7+parseInt(e(133))/8+parseInt(e(121))/9*(parseInt(e(123))/10)+-parseInt(e(127))/11)break;n.push(n.shift())}catch(t){n.push(n.shift())}}(o);class a extends AudioWorkletProcessor{[s(117)];[s(118)];processChunkSize;[s(130)];[s(108)];constructor(t){const e=s;super(),this[e(117)]=[],this[e(118)]=0;const{outputSampleRate:n,chunkTimeInSeconds:o}=Object[e(131)]({outputSampleRate:16e3,chunkTimeInSeconds:1},t?.[e(126)]);this.originalSampleRate=sampleRate,this[e(130)]=n,this[e(129)]=function(t,e,n=1){const s=e*n,o=t/e;return Math[r(114)](s*o)}(this[e(108)],this[e(130)],o)}[s(112)](t,e,o){const a=s,i=t[0][0];if(!i)return!0;const u=new Float32Array(i);if(this[a(117)][a(113)](u),this[a(118)]+=i[a(109)],this[a(118)]>=this.processChunkSize){const t=function(t){const e=r,n=t[e(115)]((t,n)=>t+n[e(109)],0),s=new Float32Array(n);let o=0;for(const n of t)s[e(122)](n,o),o+=n.length;return s}(this[a(117)]);this.inputBuffer=[],this[a(118)]=0;const e=function(t,e,s){const r=n;if(e===s)return t;const o=s/e,a=Math[r(276)](t[r(266)]*o),i=new Float32Array(a);for(let e=0;e<a;e++){const n=e/o,s=Math.floor(n),a=n-s,u=t[s],c=t[Math.min(s+1,t[r(266)]-1)];i[e]=u+(c-u)*a}return i}(t,this[a(108)],this.outputSampleRate);this[a(119)][a(134)]({float32:e,outputSampleRate:this[a(130)]},[e.buffer])}return!0}}registerProcessor(s(124),a)}();
package/dist/browser.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("lodash-es"),t=require("moment");require("mathjs");var s,i=require("rxjs"),a=require("socket.io-client"),n=require("@mediapipe/tasks-vision");!function(e){e["網絡錯誤"]="ERROR CODE: 500",e["環境錯誤(browser)"]="ERROR CODE: 1001",e["Worklet模組載入失敗"]="ERROR CODE: 1002",e["未獲得媒體裝置權限"]="ERROR CODE: 1003",e["實例已摧毀"]="ERROR CODE: 1004",e["環境錯誤(nodejs)"]="ERROR CODE: 2001",e["未提供憑證"]="ERROR CODE: 2002",e["獲取權杖失敗"]="ERROR CODE: 2003",e["沒有可用專案"]="ERROR CODE: 2004",e["重複初始化"]="ERROR CODE: 2005"}(s||(s={}));const o="undefined"!=typeof window;"undefined"!=typeof process&&null!=process.versions&&process.versions.node;class r{config;get webserver(){return this.safeRead("webserver")}get environment(){const e=this.safeRead("env");return"string"==typeof e?e:"developement"}get license(){return this.safeRead("license")??""}get port(){return function(e,t){const s="number"==typeof t?t:NaN;if(e){const t=Number(e);return isNaN(t)?s:t}return s}(process.env.PORT,this.safeRead("port")??3e3)}get ws_url(){const e=this.safeRead("ws_url");return"string"==typeof e?e:""}get worklet_url(){const e=this.safeRead("worklet_url");return"string"==typeof e?e:""}get project(){const t=this.safeRead("project");if(void 0===t)return{specific:!1};if("string"==typeof t)return{name:t,id:t,specific:!1};{const s=e.get(t,"id",void 0),i=e.get(t,"name",void 0);return{id:"string"==typeof s?s:void 0,name:"string"==typeof i?i:void 0,specific:!0}}}get endPoint(){let e="dev";switch(this.environment){case"production":e="prod";break;case"test":e="test"}const t=`graphen-agentic-workflow-${e}-21193779403.asia-east1.run.app`;return{api:`https://${t}`,socket:`wss://${t}`}}get debug(){return this.safeRead("debug")??!0}get mediaStream(){return this.safeRead("mediaStream")}get chunkTimeInSeconds(){const e=this.safeRead("chunkTimeInSeconds");return"number"==typeof e&&e>0?e:.3}get llmSampleRate(){const e=this.safeRead("llmSampleRate");return"number"==typeof e&&e>0?e:16e3}get detection(){return e.assign({perSecond:3,confidence:80},this.safeRead("faceDetection"),this.safeRead("cameraDetection"))}get autoClearSubtitle(){const e=this.safeRead("autoClearUserSubtitle"),t=this.safeRead("autoClearAiiaSubtitle");return{userDelayTime:"number"==typeof e?e:5e3,aiiaDelayTime:"number"==typeof t?t:NaN}}get eyeTrackEnable(){return Boolean(this.safeRead("eyeTrackEnable"))}get eyeTrackCorrection(){return e.assign({x_axis_px:0,y_axis_px:0},this.safeRead("correction"))}constructor(e){this.config=e}safeRead(t){return e.get(this.config,t,void 0)}}var c;!function(e){e["通道、雲端服務、麥克風都已就緒"]="CODE: 1000",e["未取得媒體裝置權限,請重新設定或忽略此訊息"]="CODE: 1001",e["請訂閱專案列表"]="CODE: 1002",e["初始化必要依賴"]="CODE: 1010",e["指定依賴已完成"]="CODE: 1011",e["啟動SDK"]="CODE: 1012",e["結束SDK"]="CODE: 1013",e["已啟動SDK"]="CODE: 1014",e["安全的關閉連線"]="CODE: 2000",e["無副作用的關閉連線"]="CODE: 2001",e["與雲端的服務中斷"]="CODE: 2002",e["沒有授權,請聯繫Graphen"]="CODE: 2003",e["自動重新連線雲端服務"]="CODE: 2004",e["未預期的斷線,請聯繫Graphen"]="CODE: 2005",e["開始初始化必要模組"]="CODE: 2010",e["指定模組初始化完成"]="CODE: 2011",e["啟動服務"]="CODE: 2012",e["服務結束"]="CODE: 2013"}(c||(c={}));const u={code:console.log,debug:console.log,info:console.log,warn:console.warn,error:console.error,fatal:console.error},d=[];const h=new Proxy(u,{get(s,i,a){if("string"==typeof i)switch(i){case"debug":case"info":case"error":case"warn":case"fatal":case"code":return(...a)=>{const n=t().format("yyyy-MM-DD[T]HH:mm:ss:sss");e.forEach(d,e=>{e.next(i,n,...a)}),s[i](`[Aiia::${i}_${n}_]`,...a)};default:return}},set:(e,t,s,i)=>!0});class l{socket;messageSub;destorySub;get message(){return this.messageSub.asObservable()}constructor(t){this.destorySub=new i.Subject,this.messageSub=new i.Subject;const{specific:s,id:n}=t.project;this.socket=a.io(t.ws_url,e.assign({autoConnect:!1},s&&void 0!==n?{query:{uuid:n}}:{}))}start(){const e="list",t="cloud",s="channel";i.fromEvent(this.socket,"connect").pipe(i.takeUntil(this.destorySub)).subscribe(()=>{h.debug("Client ID: ",this.socket.id)}),i.fromEvent(this.socket,e).pipe(i.take(1),i.takeUntil(this.destorySub)).subscribe(t=>{this.messageSub.next({event:e,data:t})}),i.fromEvent(this.socket,t).pipe(i.takeUntil(this.destorySub)).subscribe(e=>{this.messageSub.next({event:t,data:e})}),i.fromEvent(this.socket,s).pipe(i.takeUntil(this.destorySub)).subscribe(e=>{this.messageSub.next({event:s,data:e})}),this.socket.connect()}send(e,t){this.socket.emit(e,t)}sendToCloud(e){this.send("cloud",e)}onDestroy(){this.destorySub.next(),this.destorySub.complete(),this.messageSub.complete(),this.socket.disconnect()}}var b,p;function m(e,t,s){return Math.max(s,Math.min(e,t))}function g(e){const t=new DataView(e.buffer),s=[];for(let i=0;i<e.length;i++){const e=t.getInt16(2*i,!0)/32768;s.push(e)}return new Float32Array(s)}function S(e){const t=new DataView(e.buffer),s=[];for(let i=0;i<e.length;i++){const e=m(32768*t.getFloat32(4*i,!0),32767,-32768);s.push(e)}return s}!function(e){e[e.unknow=0]="unknow",e[e.allowed=1]="allowed",e[e.rejected=2]="rejected"}(b||(b={}));class f{audioContext;type="audio";currentNode;bufferQueue;gainNode;set volume(e){e<0&&(e=0),e>100&&(e=100),this.gainNode.gain.value=e/100}get volume(){return Math.round(100*this.gainNode.gain.value)}constructor(e){this.audioContext=e,this.bufferQueue=[],this.currentNode=null,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}addBuffer(e){this.bufferQueue.push(e)}addBufferByFloat32(e,t=1){const s=e.length,i=this.audioContext.sampleRate,a=this.audioContext.createBuffer(t,s,i),n=e.slice();for(let e=0;e<t;e++)a.copyToChannel(n,e);this.addBuffer(a)}addBufferByInt16(e,t=1){this.addBufferByFloat32(g(e),t)}startSpeech(){null===this.currentNode&&this.continue()}pauseSpeech(){this.audioContext.suspend().catch(e=>{h.error("pause speech fail",e)})}resumeSpeech(){this.audioContext.resume().catch(e=>{h.error("resume speech fail",e)})}nextSpeech(){this.bufferQueue.length>0&&(this.clearNode(),this.continue())}stopSpeech(){this.bufferQueue=[],this.clearNode()}clearNode(){this.currentNode&&(this.currentNode.onended=function(){},this.currentNode.stop(),this.currentNode.disconnect(),this.currentNode=null)}continue(){const e=this.bufferQueue.shift();if(e){this.currentNode=this.audioContext.createBufferSource(),this.currentNode.buffer=e,this.currentNode.connect(this.gainNode);const t=this.continue.bind(this);this.currentNode.onended=t,this.currentNode.start()}else this.clearNode()}}class _{stream;audioContext;type="vad";workletNode;source;isRecording=!1;outputSampleRate;chunkTimeInSeconds;pcmSub;get pcm(){return this.pcmSub.asObservable()}constructor(e,t,s){this.stream=e,this.audioContext=t,this.outputSampleRate=s?.llmSampleRate??16e3,this.chunkTimeInSeconds=s?.chunkTimeInSeconds??1,this.pcmSub=new i.Subject}async startRecord(){this.isRecording||(this.source=this.audioContext.createMediaStreamSource(this.stream),this.workletNode=new AudioWorkletNode(this.audioContext,"aiia-vad",{processorOptions:{outputSampleRate:this.outputSampleRate,chunkTimeInSeconds:this.chunkTimeInSeconds}}),this.source.connect(this.workletNode),this.workletNode.port.onmessage=e=>{const{float32:t}=e.data;t&&this.pcmSub.next(new Float32Array(t))},this.isRecording=!0)}stopRecord(){this.isRecording&&(this.workletNode&&(this.workletNode.port.onmessage=null,this.workletNode.disconnect()),this.source&&this.source.disconnect(),this.isRecording=!1)}}class y{type="camera";aiiaCamera;get detections(){return this.aiiaCamera.detections}get landmarks(){return this.aiiaCamera.landmarks}get videoSize(){return this.aiiaCamera.videoSize}constructor(t){const{perSecond:s}=e.assign({perSecond:3},t);this.aiiaCamera=new C,this.aiiaCamera.setFrequency(s),document.body.append(this.aiiaCamera)}async init(e){try{const t=await n.FilesetResolver.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.0/wasm"),[s,i]=await Promise.all([n.FaceDetector.createFromOptions(t,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/1/blaze_face_short_range.tflite",delegate:"GPU"},runningMode:"VIDEO"}),n.PoseLandmarker.createFromOptions(t,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_lite/float16/1/pose_landmarker_lite.task",delegate:"GPU"},runningMode:"VIDEO",numPoses:5})]);this.aiiaCamera.setStream(e),this.aiiaCamera.setFaceDetector(s),this.aiiaCamera.setPoseLandmarker(i)}catch(e){h.error("Camera init fail",e)}}startCapture(){this.aiiaCamera.startCapture()}stopCapture(){this.aiiaCamera.stopCapture()}onDestroy(){this.aiiaCamera.remove()}}class C extends HTMLElement{static get observedAttributes(){return["debug"]}_shadow;_containerEl;_styleEl;_videoEl;_canvasEl;_canvasCtx;_isDebug;_debugElements;_interval;_lastTimestamp;_loopFrameID;_faceDetector;_detectionsSub;_poseLandmarker;_landmarksSub;_isReady;_drawingUtils;landmarkColors=["gray","lightgray","gray","gray","lightgray"];connectorColors=["green","blue","red","yellow","purple"];get detections(){return this._detectionsSub.asObservable()}get landmarks(){return this._landmarksSub.asObservable()}get videoSize(){return{width:this._videoEl.videoWidth,height:this._videoEl.videoHeight}}constructor(){super(),this.id="AiiaCamera",this._isDebug=!1,this._isReady=!1,this._shadow=this.attachShadow({mode:"open"}),this._containerEl=document.createElement("div"),this._videoEl=document.createElement("video"),this._styleEl=document.createElement("style"),this._canvasEl=document.createElement("canvas"),this._debugElements=[],this._loopFrameID=null,this._detectionsSub=new i.Subject,this._landmarksSub=new i.Subject,this._interval=Math.ceil(1e3/3),this._lastTimestamp=0,this.predictWebcam=this.predictWebcam.bind(this),this._settingContainer(),this._settingStyle(),this._settingVideo(),this._containerEl.appendChild(this._videoEl),this._shadow.appendChild(this._styleEl),this._shadow.appendChild(this._containerEl),this._containerEl.appendChild(this._canvasEl);const e=this._canvasEl.getContext("2d");e?(this._canvasCtx=e,this._drawingUtils=new n.DrawingUtils(this._canvasCtx)):(this._canvasCtx=null,this._drawingUtils=null)}connectedCallback(){this.startCapture()}disconnectedCallback(){this.stopCapture()}attributeChangedCallback(e,t,s){"debug"===e&&(this._isDebug=null!==s&&("true"===s||""===s),this._containerEl.style.visibility=this._isDebug?"visible":"hidden")}setStream(e){this._videoEl.onloadedmetadata=()=>{this._isReady=!0},this._videoEl.srcObject=e}setFaceDetector(e){this._faceDetector=e}setPoseLandmarker(e){this._poseLandmarker=e}setFrequency(e){this._interval=Math.ceil(1e3/e)}_settingStyle(){this._styleEl.textContent="\n .aiia_container {\n visibility: hidden;\n position: fixed;\n top: 0;\n left: 0;\n\n > canvas {\n position: absolute;\n top: 0;\n left: 0;\n width: 640px;\n height: 480px;\n }\n }\n .aiia_container .highlighter {\n background: rgba(0, 255, 0, 0.25);\n border: 1px dashed #fff;\n z-index: 1;\n position: absolute;\n }\n .aiia_container .confidence {\n position: absolute;\n padding-bottom: 5px;\n padding-top: 5px;\n background-color: #007f8b;\n color: #fff;\n border: 1px dashed rgba(255, 255, 255, 0.7);\n z-index: 2;\n font-size: 12px;\n margin: 0;\n }\n "}_settingContainer(){this._containerEl.classList.add("aiia_container")}_settingVideo(){this._videoEl.autoplay=!0,this._videoEl.playsInline=!0,this._videoEl.muted=!0}getVideo(){return this._videoEl}startCapture(){null===this._loopFrameID&&(this._videoEl.play(),this._loopFrameID=window.requestAnimationFrame(this.predictWebcam))}stopCapture(){null!==this._loopFrameID&&(window.cancelAnimationFrame(this._loopFrameID),this._loopFrameID=null),this._videoEl.pause()}async predictWebcam(){if(this._isReady){const e=performance.now();if(this._lastTimestamp+this._interval<=e){this._lastTimestamp=e;const t=this._faceDetector?.detectForVideo(this._videoEl,e).detections,s=this._poseLandmarker?.detectForVideo(this._videoEl,e).landmarks;t&&(this._isDebug&&this._drawRect(t),this._detectionsSub.next(t)),s&&(this._isDebug&&this._drawRect2(s),this._landmarksSub.next(s))}}this._loopFrameID=window.requestAnimationFrame(this.predictWebcam)}_drawRect(t){e.forEach(t,(e,t)=>{const{categories:s,boundingBox:i}=e;if(i){let e=this._debugElements[2*t],a=this._debugElements[2*t+1];e&&a||(e=document.createElement("div"),e.classList.add("highlighter"),a=document.createElement("p"),a.classList.add("confidence"),this._containerEl.append(a,e),this._debugElements.push(e,a)),e.style.display="block",a.style.display="block";const n=100*s[0].score;a.innerText=`Confidence: ${Math.round(n)} %`,a.style.right=this._videoEl.offsetWidth-i.width-i.originX+"px",a.style.top=i.originY-30+"px",a.style.width=i.width-10+"px",e.style.right=this._videoEl.offsetWidth-i.width-i.originX+"px",e.style.top=`${i.originY}px`,e.style.width=i.width-10+"px",e.style.height=`${i.height}px`}});for(let e=2*t.length;e<this._debugElements.length;e++)this._debugElements[e].style.display="none"}_drawRect2(t){this._canvasCtx&&this._drawingUtils&&(this._canvasCtx.save(),this._canvasCtx.clearRect(0,0,640,480),e.forEach(t,(e,t)=>{this._canvasCtx?.save(),this._drawingUtils?.drawLandmarks(e,{radius:e=>n.DrawingUtils.lerp(e.from.z,-.15,.1,5,1),color:this.landmarkColors[t]}),this._drawingUtils?.drawConnectors(e,n.PoseLandmarker.POSE_CONNECTIONS,{color:this.connectorColors[t],lineWidth:2})}),this._canvasCtx.restore())}destroy(){this._detectionsSub.complete(),this.remove()}}customElements.define("aiia-camera",C),function(e){e[e.padding=0]="padding",e[e.rejected=1]="rejected",e[e.loadfail=2]="loadfail",e[e.allowed=3]="allowed"}(p||(p={}));class v{stream;_state;stateSub;audioCtx;audioManager;vadManager;camManager;destroy;pcmSub;detectionsSub;landmarksSub;get sampleRate(){return this.audioCtx?this.audioCtx.sampleRate:16e3}get pcm(){return this.pcmSub.asObservable()}get detections(){return this.detectionsSub.asObservable()}get landmarks(){return this.landmarksSub.asObservable()}get state(){return this._state}set state(e){e!==this._state&&(this._state=e,this.stateSub.next(e))}get stateObs(){return this.stateSub.asObservable()}constructor(e){this.stream=e,this.stateSub=new i.ReplaySubject(1),this.pcmSub=new i.Subject,this.destroy=new i.Subject,this.detectionsSub=new i.Subject,this.landmarksSub=new i.Subject,this.state=p.padding}async init(e,t){const a=this.stream??await async function(e){try{return await navigator.mediaDevices.getUserMedia(e)}catch(e){return null}}({audio:{echoCancellation:!0,noiseSuppression:!0},video:!0});if(null===a)throw this.state=p.rejected,new Error(s["未獲得媒體裝置權限"]);this.stream=a,this.audioCtx=new AudioContext;try{await this.audioCtx.audioWorklet.addModule(e)}catch(e){throw h.fatal(e),this.state=p.loadfail,new Error(s["Worklet模組載入失敗"])}this.state=p.allowed,this.audioManager=new f(this.audioCtx),this.vadManager=new _(a,this.audioCtx,t),this.vadManager.pcm.pipe(i.takeUntil(this.destroy)).subscribe(e=>{this.pcmSub.next(e)});const n=new y(t?.cameraDetection);n.detections.pipe(i.takeUntil(this.destroy)).subscribe(e=>{const{width:t,height:s}=n.videoSize;this.detectionsSub.next({detections:e,clientWidth:t,clientHeight:s})}),n.landmarks.pipe(i.takeUntil(this.destroy)).subscribe(e=>{this.landmarksSub.next(e)}),n.init(a),this.camManager=n}addAudioQueue(t){const s=e.get(t,"buffer",void 0),i=e.get(t,"float32",void 0),a=e.get(t,"int16",void 0),n=e.get(t,"numberOfChannels",void 0);s?this.audioManager?.addBuffer(s):i?this.audioManager?.addBufferByFloat32(i,n):a&&this.audioManager?.addBufferByInt16(a,n)}playAudio(){this.audioManager?.startSpeech()}stopAudio(){this.audioManager?.stopSpeech()}startRecord(){this.vadManager?.startRecord()}stopRecord(){this.vadManager?.stopRecord()}setVolume(e){this.audioManager&&(this.audioManager.volume=e)}getVolume(){return this.audioManager?this.audioManager.volume:0}startCapture(){this.camManager?.startCapture()}stopCapture(){this.camManager?.stopCapture()}onDestroy(){this.camManager?.onDestroy(),this.audioCtx?.close(),this.destroy.next(),this.destroy.complete()}}class w{config;media;chat;destroySub;projectsSub;layoutSub;aiiaSubtitleSub;userSubtitleSub;sampleRateOfWhisper;channelState;stateSub;_currentState;isMuteAiia;aiiaSubtitleClearSub;userSubtitleClearSub;_lastProjects;guestSub;_hasGuest;mediaEventReady;isStart;get state(){return this.stateSub.asObservable()}get currentState(){return this._currentState}get layout(){return this.layoutSub.asObservable()}get projects(){return this.projectsSub.asObservable()}get lastProjects(){return e.cloneDeep(this._lastProjects)}get aiiaSubtitle(){return this.aiiaSubtitleSub.asObservable()}get userSubtitle(){return this.userSubtitleSub.asObservable()}get guest(){return this.guestSub.asObservable()}get hasGuest(){return this._hasGuest}set volume(e){this.media.setVolume(e)}get volume(){return this.media.getVolume()}constructor(e,t){this.config=e,this.media=t,this.layoutSub=new i.Subject,this.projectsSub=new i.ReplaySubject(1),this.destroySub=new i.Subject,this.aiiaSubtitleSub=new i.Subject,this.userSubtitleSub=new i.Subject,this.aiiaSubtitleClearSub=new i.Subject,this.userSubtitleClearSub=new i.Subject,this.stateSub=new i.BehaviorSubject("NotStart"),this.sampleRateOfWhisper={input:e.llmSampleRate,output:16e3},this.channelState={proxy:!1,cloud:!1},this.isMuteAiia=!1,this._lastProjects=[],this.guestSub=new i.ReplaySubject(1),this._hasGuest=!1,this.mediaEventReady=!1,this.isStart=!1,this.chat=new l(e),h.code(c["指定依賴已完成"],"chat"),this.close=this.onDestroy,this.behavior=this.behavior.bind(this);const{userDelayTime:s,aiiaDelayTime:a}=e.autoClearSubtitle;isNaN(a)||this.aiiaSubtitleClearSub.pipe(i.debounceTime(a),i.takeUntil(this.destroySub)).subscribe(()=>{this.aiiaSubtitleSub.next("")}),isNaN(s)||this.userSubtitleClearSub.pipe(i.debounceTime(s),i.takeUntil(this.destroySub)).subscribe(()=>{this.userSubtitleSub.next("")}),this.stateSub.pipe(i.takeUntil(this.destroySub)).subscribe(e=>{this._currentState=e}),this.projectsSub.pipe(i.takeUntil(this.destroySub)).subscribe(e=>{this._lastProjects=e}),this.guestSub.pipe(i.takeUntil(this.destroySub)).subscribe(e=>{this._hasGuest=e}),t.stateObs.pipe(i.takeUntil(this.destroySub)).subscribe(e=>{p.allowed===e&&this.channelCheck()})}start(){this.isStart?h.code(c["已啟動SDK"]):(this.isStart=!0,this.chat.message.pipe(i.takeUntil(this.destroySub)).subscribe(({event:t,data:s})=>{switch(t){case"cloud":e.map(s,this.behavior);break;case"list":{const{id:t,name:i,specific:a}=this.config.project;let n=null;if(a&&void 0!==t)n=t;else{const a=e.find(s,e=>e.name===i||e.id===t);a&&(n=a.id)}null!==n?this.chooseProject(n):null===s?(this.stateSub.next("CloseService"),h.error("No project ready or lose network")):(this.projectsSub.next(s),this.stateSub.next("WaitingProjectID"),h.code(c["請訂閱專案列表"]));break}case"channel":switch(this.channelState.proxy=!0,s){case"open":this.channelCheck();break;case"close":this.channelState.cloud=!1,this.media.stopRecord(),this.media.stopCapture(),this.stateSub.next("CloseService");break;case"no_permissions":this.channelState.cloud=!1,this.media.stopRecord(),this.media.stopCapture(),this.stateSub.next("NoPermissions");break;case"reconnect":this.channelState.cloud=!1,this.media.stopRecord(),this.media.stopCapture(),this.stateSub.next("ReconnectingCloud");break;case"net_error":this.channelState.cloud=!1,this.media.stopRecord(),this.media.stopCapture(),this.stateSub.next("CloseService"),h.error("Please check network status")}}}),this.chat.start(),this.stateSub.next("ConnectingCloud"),h.code(c["啟動SDK"]))}close;skip(){this.chat.sendToCloud({request:"skip"})}reset(){this.chat.sendToCloud({request:"reset"})}chooseProject(e){this.chat.send("uuid",e),this.stateSub.next("ConnectingCloud")}mute(){this.isMuteAiia=!0,this.media.stopAudio(),this.media.stopRecord()}unmute(){this.isMuteAiia=!1,this.media.startRecord()}behavior(t){switch(t.signal){case"layout":this.layoutSub.next(t.content);break;case"audio":if("sampleRate"===t.command)this.sampleRateOfWhisper.output=t.content;else switch(t.command){case"pcm":if(!this.isMuteAiia){const e=function(e,t,s){if(t===s)return e;const i=s/t,a=Math.ceil(e.length*i),n=new Float32Array(a);for(let t=0;t<a;t++){const s=t/i,a=Math.floor(s),o=s-a,r=e[a],c=e[Math.min(a+1,e.length-1)];n[t]=r+(c-r)*o}return n}(g(new Int16Array(t.content)),this.sampleRateOfWhisper.output,this.media.sampleRate);this.media.addAudioQueue({float32:e}),this.media.playAudio()}break;case"interrupted":this.media.stopAudio(),this.aiiaSubtitleSub.next("")}break;case"status":"Connected"===e.get(t,"content")&&(this.channelState.cloud=!0,this.channelCheck(),this.layoutSub.next({type:"resetLayout"}));break;case"agent":if(!this.isMuteAiia){const s=e.get(t,"content.function_result.response");void 0!==s&&(this.aiiaSubtitleSub.next(s),this.aiiaSubtitleClearSub.next())}break;case"asr":if(!this.isMuteAiia&&"ASR"===e.get(t,"content.function_type")){const s=e.get(t,"content.function_result.result");void 0!==s&&(this.userSubtitleSub.next(s),this.userSubtitleClearSub.next())}break;case"cv":{const s=e.get(t,"content.status");"user present"===s?this.guestSub.next(!0):"user leave"===s?this.guestSub.next(!1):h.warn("Unexpect value",e.get(t,"content"));break}default:h.debug(t.signal)}}channelCheck(){const{proxy:t,cloud:s}=this.channelState;if(t&&s&&this.media.state===p.allowed){if(this.chat.sendToCloud({request:"audio",command:"sampleRate",content:this.sampleRateOfWhisper.input}),!this.mediaEventReady){this.mediaEventReady=!0,this.media.pcm.pipe(i.takeUntil(this.destroySub)).subscribe(e=>{this.chat.sendToCloud({request:"audio",command:"pcm",content:S(e)})});const t=(a=this.config.detection.confidence,function(t,s){const{width:i,height:n}=s,o=e.filter(t,e=>100*(e.categories[0]?.score??0)>=a),r=e.compact(e.map(o,e=>{if(void 0!==e.boundingBox){const t=e.boundingBox,s=t.width*t.height,a=e.categories[0]?.score??0;return{...t,area:s,score:100*a,clientWidth:i,clientHeight:n}}return null}));return e.sortBy(r,["area","score"])[0]??null});this.media.detections.pipe(i.takeUntil(this.destroySub),i.map(({detections:e,clientHeight:s,clientWidth:i})=>t(e,{width:i,height:s}))).subscribe(e=>{this.chat.send("face",e)}),this.media.landmarks.pipe(i.takeUntil(this.destroySub)).subscribe(e=>{this.chat.sendToCloud({request:"pose_detect",content:e})})}this.media.startRecord(),this.media.startCapture(),this.stateSub.next("InService"),h.code(c["通道、雲端服務、麥克風都已就緒"])}else t&&s&&this.media.state!==p.allowed&&(this.stateSub.next("InServiceNoMedia"),h.code(c["未取得媒體裝置權限,請重新設定或忽略此訊息"]));var a}onDestroy(){this.chat.onDestroy(),this.media.onDestroy(),this.destroySub.next(),this.destroySub.complete(),this.stateSub.next("Destroy"),this.stateSub.complete(),h.code(c["結束SDK"])}}exports.initSdk=function(t){if(o){!function(e){const{info:t,error:s,warn:i,debug:a,fatal:n,code:o}=function(e){if(void 0===e||"all"===e)return{code:!0,error:!0,warn:!0,info:!0,debug:!0,fatal:!0};if("none"===e)return{error:!1,code:!1,warn:!1,info:!1,debug:!1,fatal:!1};if("boolean"==typeof e)return{code:e,error:e,warn:e,info:e,debug:e,fatal:e};{const t=new Set(e);return{code:t.has("code"),debug:t.has("debug"),fatal:t.has("fatal"),error:t.has("error"),warn:t.has("warn"),info:t.has("info")}}}(e);o||(u.code=()=>{}),a||(u.debug=()=>{}),t||(u.info=()=>{}),i||(u.warn=()=>{}),s||(u.error=()=>{}),n||(u.fatal=()=>{})}(e.get(t,"debug",!0)),h.code(c["初始化必要依賴"]);const s=new r(e.assign({},t));h.code(c["指定依賴已完成"],"config");const i=new v(s.mediaStream);h.code(c["指定依賴已完成"],"config");const a=new w(s,i);return h.code(c["指定依賴已完成"],"sdk"),""!==s.worklet_url&&i.init(s.worklet_url,s),a}throw new Error(s["環境錯誤(browser)"])};
1
+ "use strict";var t=require("lodash-es"),e=require("moment");require("mathjs");var s,n,i,r,a,o,c,h,u,p=require("rxjs"),d=require("socket.io-client"),l=require("@mediapipe/tasks-vision");function f(){var t=["ERROR CODE: 2001","100vQzVjL","2619328xANAXk","ERROR CODE: 1004","959336AlhFfc","3STsxhl","2206304lUgcBN","環境錯誤(browser)","ERROR CODE: 2004","ERROR CODE: 1002","579104GqLuFJ","未提供憑證","未獲得媒體裝置權限","ERROR CODE: 1001","ERROR CODE: 2002","沒有可用專案","ERROR CODE: 2003","211959SyWwrS","2488092hjGsFS","830150IHtdHk","ERROR CODE: 2005","實例已摧毀","Worklet模組載入失敗","10GfAmjO"];return(f=function(){return t})()}function m(t,e){return t-=265,f()[t]}function b(t,e){return t-=134,I()[t]}function I(){var t=["無服務","可正常使用","等待授權","缺失該裝置","246222XXGItB","沒有服務","1221031dIkIqT","VAD模組載入失敗","6xMbVGK","120zvBojo","3vFpsxo","75742bGHYFe","1435196gOwmGa","可使用","非預期的狀態","85472jNfyzH","未啟動","未響應","未授權控制","3484270ZFcDLf","359925LMSVuS"];return(I=function(){return t})()}!function(){for(var t=m,e=f();;)try{if(667343===-parseInt(t(287))/1+-parseInt(t(272))/2+parseInt(t(282))/3*(parseInt(t(279))/4)+-parseInt(t(276))/5*(-parseInt(t(271))/6)+parseInt(t(281))/7+parseInt(t(283))/8+parseInt(t(270))/9*(-parseInt(t(278))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),n=s||(s={}),i=m,n["網絡錯誤"]="ERROR CODE: 500",n[i(284)]=i(266),n[i(275)]=i(286),n[i(265)]="ERROR CODE: 1003",n[i(274)]=i(280),n["環境錯誤(nodejs)"]=i(277),n[i(288)]=i(267),n["獲取權杖失敗"]=i(269),n[i(268)]=i(285),n["重複初始化"]=i(273),function(){for(var t=b,e=I();;)try{if(270693===-parseInt(t(139))/1+parseInt(t(135))/2*(parseInt(t(134))/3)+parseInt(t(136))/4+-parseInt(t(144))/5*(-parseInt(t(153))/6)+-parseInt(t(151))/7+-parseInt(t(154))/8*(-parseInt(t(149))/9)+-parseInt(t(143))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),(a=r||(r={}))[a[(o=b)(141)]=1]=o(141),a[a["等待授權"]=2]=o(147),a[a["已被拒絕"]=3]="已被拒絕",a[a[o(152)]=4]="VAD模組載入失敗",a[a[o(146)]=5]=o(146),a[a[o(148)]=6]=o(148),a[a[o(150)]=7]=o(150),(h=c||(c={}))[h[(u=b)(138)]=1]="非預期的狀態",h[h["未授權控制"]=2]=u(142),h[h[u(140)]=3]=u(140),h[h["無服務"]=4]=u(145),h[h[u(137)]=5]=u(137);const g=S;function S(t,e){t-=305;return y()[t]}!function(){const t=S,e=y();for(;;)try{if(209035===-parseInt(t(311))/1+parseInt(t(309))/2+-parseInt(t(308))/3*(-parseInt(t(318))/4)+-parseInt(t(306))/5+parseInt(t(310))/6+parseInt(t(315))/7*(-parseInt(t(314))/8)+-parseInt(t(317))/9*(-parseInt(t(305))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();function y(){const t=["251118JZucSh","1136388BOWAej","31455hiNPMQ","number","node","5912LaTxkS","3486cysdQp","undefined","141507WGklij","2344HaITKM","230NpOcOh","384320UWqeQr","versions","45SfcDcO"];return(y=function(){return t})()}const w=typeof window!==g(316);typeof process!==g(316)&&null!=process[g(307)]&&process.versions[g(313)];const k=C;function v(){const t=["webserver","config","-21193779403.asia-east1.run.app","safeRead","detection","developement","project","chunkTimeInSeconds","https://","wss://","1054128TtBwLj","endPoint","llmSampleRate","eyeTrackEnable","114983fARIVW","environment","1194697tzXdhC","PORT","ws_url","note","worklet_url","faceDetection","port","autoClearSubtitle","debug","autoClearUserSubtitle","4AqEzeT","production","string","correction","2277880gfqBWm","autoClearAiiaSubtitle","test","prod","env","number","3465596PJHVgM","100098gnldjH","923382qBTtpw","mediaStream","cameraDetection","license"];return(v=function(){return t})()}function C(t,e){t-=447;return v()[t]}!function(){const t=C,e=v();for(;;)try{if(511112===-parseInt(t(461))/1+parseInt(t(473))/2*(parseInt(t(484))/3)+parseInt(t(483))/4+-parseInt(t(477))/5+-parseInt(t(485))/6+parseInt(t(463))/7+parseInt(t(457))/8)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class _{[k(448)];get[k(447)](){return this[k(450)]("webserver")}get environment(){const t=k,e=this[t(450)](t(481));return typeof e===t(475)?e:t(452)}get[k(488)](){const t=k;return this[t(450)](t(488))??""}get[k(466)](){const t=k;return this.safeRead(t(466))}get[k(469)](){const t=k;return function(t,e){const s=typeof e===g(312)?e:NaN;if(t){const e=Number(t);return isNaN(e)?s:e}return s}(process[t(481)][t(464)],this[t(450)](t(469))??3e3)}get[k(465)](){const t=k,e=this[t(450)]("ws_url");return typeof e===t(475)?e:""}get[k(467)](){const t=k,e=this[t(450)](t(467));return typeof e===t(475)?e:""}get[k(453)](){const e=k,s=this.safeRead("project");if(void 0===s)return{specific:!1};if(typeof s===e(475))return{name:s,id:s,specific:!1};{const n=t.get(s,"id",void 0),i=t.get(s,"name",void 0);return{id:"string"==typeof n?n:void 0,name:typeof i===e(475)?i:void 0,specific:!0}}}get[k(458)](){const t=k;let e="dev";switch(this[t(462)]){case t(474):e=t(480);break;case t(479):e="test"}const s="graphen-agentic-workflow-"+e+t(449);return{api:t(455)+s,socket:t(456)+s}}get[k(471)](){const t=k;return this[t(450)](t(471))??!0}get[k(486)](){const t=k;return this[t(450)](t(486))}get chunkTimeInSeconds(){const t=k,e=this[t(450)](t(454));return typeof e===t(482)&&e>0?e:.3}get[k(459)](){const t=k,e=this.safeRead(t(459));return typeof e===t(482)&&e>0?e:16e3}get[k(451)](){const e=k;return t.assign({perSecond:3,confidence:80},this[e(450)](e(468)),this[e(450)](e(487)))}get[k(470)](){const t=k,e=this[t(450)](t(472)),s=this[t(450)](t(478));return{userDelayTime:typeof e===t(482)?e:5e3,aiiaDelayTime:typeof s===t(482)?s:NaN}}get[k(460)](){return Boolean(this[k(450)]("eyeTrackEnable"))}get eyeTrackCorrection(){const e=k;return t.assign({x_axis_px:0,y_axis_px:0},this[e(450)](e(476)))}constructor(t){this[k(448)]=t}[k(450)](e){return t.get(this.config,e,void 0)}}const E=T;var D;function R(){const t=["CODE: 1012","warn","285464XQUBiB","CODE: 1011","與雲端的服務中斷","已啟動SDK","string","自動重新連線雲端服務","fatal","CODE: 2012","error","2yxxpJS","未取得媒體裝置權限,請重新設定或忽略此訊息","_](","format","670629jEamlZ","log","CODE: 2004","[Aiia::","2076221sfAZCu","CODE: 1013","9eHDpPm","未預期的斷線,請聯繫Graphen","CODE: 2002","push","none","debug","189605nUHwJE","CODE: 2005","CODE: 1002","category","CODE: 2001","沒有授權,請聯繫Graphen","yyyy-MM-DD[T]HH:mm:ss:sss","無副作用的關閉連線","includes","啟動SDK","CODE: 2000","請訂閱專案列表","has","163701SOjnlN","24ZEzgSh","all","default","code","2325852pTTOrA","CODE: 1014","指定模組初始化完成","啟動服務","服務結束","2390120YKohEv","結束SDK","CODE: 1001","CODE: 2003","boolean","next","info","通道、雲端服務、麥克風都已就緒"];return(R=function(){return t})()}!function(){const t=T,e=R();for(;;)try{if(198050===-parseInt(t(500))/1+parseInt(t(529))/2*(parseInt(t(533))/3)+parseInt(t(501))/4*(-parseInt(t(545))/5)+parseInt(t(505))/6+-parseInt(t(537))/7+parseInt(t(520))/8+parseInt(t(539))/9*(parseInt(t(510))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(t){const e=T;t[e(517)]="CODE: 1000",t[e(530)]=e(512),t[e(498)]=e(547),t["初始化必要依賴"]="CODE: 1010",t["指定依賴已完成"]=e(521),t[e(496)]=e(518),t[e(511)]=e(538),t[e(523)]=e(506),t["安全的關閉連線"]=e(497),t[e(494)]=e(491),t[e(522)]=e(541),t[e(492)]=e(513),t[e(525)]=e(535),t[e(540)]=e(546),t["開始初始化必要模組"]="CODE: 2010",t[e(507)]="CODE: 2011",t[e(508)]=e(527),t[e(509)]="CODE: 2013"}(D||(D={}));const x={code:console[E(534)],debug:console.log,info:console.log,warn:console[E(519)],error:console.error,fatal:console[E(528)]},O=[];function T(t,e){t-=491;return R()[t]}const A=(j=E(503),new Proxy(x,{get(s,n,i){const r=T;if(typeof n===r(524))switch(n){case r(544):case r(516):case r(528):case r(519):case r(526):case r(504):return(...i)=>{const a=r,o=e()[a(532)](a(493));t.forEach(O,t=>{const e=a;(void 0===t[e(548)]||t.category[e(495)](j))&&t[e(515)](n,o,j,...i)}),s[n](a(536)+n+"_"+o+a(531)+j+")",...i)};default:return}},set:(t,e,s,n)=>!0}));var j;function M(t,e){t-=117;return N()[t]}function N(){const t=["2353512woxspR","boundingBox","219264grnWvT","180wuKHKK","8337952zMHggo","4187358TDvlad","3616700PGJAai","get","2374TqcHHo","area","69423JqBNiE","categories","score","1686UNkNfE"];return(N=function(){return t})()}function U(){var t=["456132kMZEcF","78pamjzu","285848xStkvt","5746040rsvztS","19803AygsZQ","919290ogGCMs","139080HqHDNi","35mKAysE","55dQxUch","4687812Qkstoy","7RuxfrN","99YQkHBH"];return(U=function(){return t})()}function P(t,e){return t-=429,U()[t]}!function(){const t=M,e=N();for(;;)try{if(630118===-parseInt(t(121))/1+-parseInt(t(119))/2*(parseInt(t(124))/3)+parseInt(t(125))/4+parseInt(t(117))/5+parseInt(t(130))/6+-parseInt(t(129))/7+parseInt(t(127))/8*(parseInt(t(128))/9))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(){for(var t=P,e=U();;)try{if(335274===-parseInt(t(434))/1+parseInt(t(435))/2*(parseInt(t(438))/3)+parseInt(t(436))/4*(-parseInt(t(429))/5)+parseInt(t(439))/6*(-parseInt(t(432))/7)+parseInt(t(440))/8*(-parseInt(t(433))/9)+-parseInt(t(437))/10+parseInt(t(430))/11*(parseInt(t(431))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const q=B;function B(t,e){t-=239;return G()[t]}!function(){const t=B,e=G();for(;;)try{if(733753===parseInt(t(256))/1*(-parseInt(t(262))/2)+parseInt(t(251))/3*(-parseInt(t(243))/4)+-parseInt(t(245))/5+-parseInt(t(257))/6*(parseInt(t(253))/7)+parseInt(t(255))/8+parseInt(t(239))/9*(-parseInt(t(268))/10)+parseInt(t(246))/11)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class V{[q(250)];messageSub;[q(265)];get[q(241)](){return this.messageSub.asObservable()}constructor(e){const s=q;this[s(265)]=new p.Subject,this.messageSub=new p.Subject;const{specific:n,id:i}=e.project;this[s(250)]=d.io(e[s(254)],t.assign({autoConnect:!1},n&&void 0!==i?{query:{uuid:i}}:{}))}start(){const t=q,e=t(266),s=t(242),n=t(258),i=t(260);p.fromEvent(this.socket,t(252))[t(244)](p.takeUntil(this.destorySub))[t(264)](()=>{const e=t;A[e(267)](e(249),this[e(250)].id)}),p.fromEvent(this[t(250)],e)[t(244)](p.take(1),p.takeUntil(this[t(265)]))[t(264)](s=>{this[t(269)].next({event:e,data:s})}),p.fromEvent(this[t(250)],s).pipe(p.takeUntil(this[t(265)]))[t(264)](e=>{const n=t;this[n(269)][n(270)]({event:s,data:e})}),p.fromEvent(this.socket,n).pipe(p.takeUntil(this[t(265)])).subscribe(e=>{const s=t;this[s(269)][s(270)]({event:n,data:e})}),p.fromEvent(this[t(250)],i).pipe(p.takeUntil(this[t(265)]))[t(264)](e=>{this[t(269)].next({event:i,data:e})}),this[t(250)].connect()}[q(263)](t,e){const s=q;this[s(250)][s(240)](t,e)}[q(261)](t){const e=q;this[e(263)](e(242),t)}[q(248)](){const t=q;this.destorySub[t(270)](),this[t(265)][t(247)](),this[t(269)][t(247)](),this.socket[t(259)]()}}function G(){const t=["116GhiYIs","pipe","6481540ZDncAB","43960356IGrjCS","complete","onDestroy","Client ID: ","socket","1965IwzRWU","connect","7dBgWOQ","ws_url","8284568tPgKDd","9eYYqEb","5000052PLtrnu","channel","disconnect","monitor","sendToCloud","288866gkuDtE","send","subscribe","destorySub","list","debug","4248360fEJMNP","messageSub","next","18TuTXdb","emit","message","cloud"];return(G=function(){return t})()}function W(t,e){t-=316;return H()[t]}function H(){const t=["unknow","max","forEach","all","getTracks","32AMqWLy","502878tqdqIh","rejected","createBuffer","getInt16","106134zisxrZ","291320AMViTr","14tHqykK","length","push","36sdWrML","2692270BgHBrP","buffer","filter","stop","240bdOHUv","4iFZecw","enumerateDevices","177463ubGrSb","getChannelData","then","984560maIRdA","getUserMedia","ceil","9091GHSJqw","sampleRate","min","allowed","mediaDevices"];return(H=function(){return t})()}var L;function K(t,e,s){const n=W;return Math[n(346)](s,Math[n(342)](t,e))}function z(t){const e=W,s=new DataView(t[e(328)]),n=[];for(let i=0;i<t.length;i++){const t=s[e(320)](2*i,!0)/32768;n[e(325)](t)}return new Float32Array(n)}function F(t){const e=W,s=new DataView(t[e(328)]),n=[];for(let i=0;i<t[e(324)];i++){const t=K(32768*s.getFloat32(4*i,!0),32767,-32768);n.push(t)}return n}!function(){const t=W,e=H();for(;;)try{if(173019===-parseInt(t(340))/1*(-parseInt(t(316))/2)+-parseInt(t(317))/3*(-parseInt(t(332))/4)+-parseInt(t(337))/5+parseInt(t(321))/6*(-parseInt(t(323))/7)+parseInt(t(322))/8*(parseInt(t(326))/9)+parseInt(t(327))/10+parseInt(t(334))/11*(-parseInt(t(331))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(t){const e=W;t[t[e(345)]=0]=e(345),t[t[e(343)]=1]=e(343),t[t[e(318)]=2]=e(318)}(L||(L={}));const Q=Z;function J(){const t=["connect","type","createBufferSource","destination","nextSpeech","96438eyOLBI","217fjVghZ","gainNode","961390lgXcRj","stopSpeech","startSpeech","154368luqsue","clearNode","round","audio","addBuffer","start","catch","volume","bufferQueue","disconnect","buffer","962810nRihku","onended","shift","createGain","length","suspend","bind","26056vTPycK","error","continue","gain","8zaTJrv","createBuffer","addBufferByFloat32","value","currentNode","audioContext","250296bRJKXD","pauseSpeech","10892696YGqzxs","stop","143UhNKYb","slice","465mPVIpQ"];return(J=function(){return t})()}function Z(t,e){t-=432;return J()[t]}!function(){const t=Z,e=J();for(;;)try{if(768774===parseInt(t(465))/1*(parseInt(t(437))/2)+parseInt(t(477))/3*(-parseInt(t(461))/4)+parseInt(t(440))/5+-parseInt(t(471))/6*(-parseInt(t(438))/7)+-parseInt(t(473))/8+parseInt(t(443))/9+parseInt(t(454))/10*(parseInt(t(475))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class X{[Q(470)];[Q(433)]=Q(446);currentNode;bufferQueue;[Q(439)];set[Q(450)](t){const e=Q;t<0&&(t=0),t>100&&(t=100),this[e(439)][e(464)][e(468)]=t/100}get[Q(450)](){const t=Q;return Math[t(445)](100*this[t(439)][t(464)][t(468)])}constructor(t){const e=Q;this.audioContext=t,this[e(451)]=[],this[e(469)]=null,this[e(439)]=this[e(470)][e(457)](),this.gainNode[e(432)](this[e(470)][e(435)])}[Q(447)](t){this[Q(451)].push(t)}[Q(467)](t,e=1){const s=Q,n=t.length,i=this[s(470)].sampleRate,r=this.audioContext[s(466)](e,n,i),a=t[s(476)]();for(let t=0;t<e;t++)r.copyToChannel(a,t);this[s(447)](r)}addBufferByInt16(t,e=1){this[Q(467)](z(t),e)}[Q(442)](){const t=Q;null===this.currentNode&&this[t(463)]()}[Q(472)](){const t=Q;this[t(470)][t(459)]()[t(449)](e=>{A[t(462)]("pause speech fail",e)})}resumeSpeech(){this[Q(470)].resume().catch(t=>{A.error("resume speech fail",t)})}[Q(436)](){const t=Q;this[t(451)][t(458)]>0&&(this[t(444)](),this[t(463)]())}[Q(441)](){const t=Q;this[t(451)]=[],this[t(444)]()}[Q(444)](){const t=Q;this[t(469)]&&(this[t(469)][t(455)]=function(){},this[t(469)][t(474)](),this[t(469)][t(452)](),this[t(469)]=null)}[Q(463)](){const t=Q,e=this[t(451)][t(456)]();if(e){this.currentNode=this[t(470)][t(434)](),this[t(469)][t(453)]=e,this[t(469)][t(432)](this[t(439)]);const s=this[t(463)][t(460)](this);this[t(469)][t(455)]=s,this[t(469)][t(448)]()}else this.clearNode()}}const Y=tt;!function(){const t=tt,e=et();for(;;)try{if(930935===parseInt(t(378))/1*(-parseInt(t(377))/2)+parseInt(t(393))/3*(parseInt(t(389))/4)+parseInt(t(398))/5*(parseInt(t(399))/6)+parseInt(t(392))/7+-parseInt(t(388))/8*(parseInt(t(382))/9)+parseInt(t(401))/10*(-parseInt(t(394))/11)+parseInt(t(375))/12)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class ${stream;[Y(395)];[Y(384)]="vad";[Y(403)];[Y(376)];[Y(387)]=!1;[Y(383)];[Y(379)];[Y(386)];get[Y(374)](){const t=Y;return this[t(386)][t(381)]()}constructor(t,e,s){const n=Y;this[n(397)]=t,this.audioContext=e,this[n(383)]=s?.[n(400)]??16e3,this[n(379)]=s?.chunkTimeInSeconds??1,this[n(386)]=new p.Subject}async[Y(405)](){const t=Y;this[t(387)]||(this.source=this[t(395)][t(385)](this[t(397)]),this[t(403)]=new AudioWorkletNode(this.audioContext,t(390),{processorOptions:{outputSampleRate:this.outputSampleRate,chunkTimeInSeconds:this.chunkTimeInSeconds}}),this[t(376)].connect(this[t(403)]),this[t(403)][t(380)][t(404)]=e=>{const s=t,{float32:n}=e[s(391)];n&&this[s(386)][s(402)](new Float32Array(n))},this[t(387)]=!0)}[Y(396)](){const t=Y;this[t(387)]&&(this[t(403)]&&(this.workletNode.port[t(404)]=null,this[t(403)].disconnect()),this[t(376)]&&this[t(376)].disconnect(),this[t(387)]=!1)}}function tt(t,e){t-=374;return et()[t]}function et(){const t=["startRecord","pcm","35507844NzviKT","source","130UEePtQ","15463cQQuHP","chunkTimeInSeconds","port","asObservable","9uyIQIB","outputSampleRate","type","createMediaStreamSource","pcmSub","isRecording","13732792gImYnJ","246808WVcqlM","aiia-vad","data","7538986gsKGnw","36umrRPJ","17497700tlRqRP","audioContext","stopRecord","stream","600oELPgk","23346CbVRYn","llmSampleRate","10WwBgPk","next","workletNode","onmessage"];return(et=function(){return t})()}const st=at;function nt(){const t=["770520ObLbob","_loopFrameID","MediaPipeTools","_interval","_videoEl","aiia_container","top","predictWebcam","Confidence: ","right","highlighter","lightgray","srcObject","camera","_landmarksSub","_settingContainer","_poseLandmarker","_drawRect","setStream","style","16fOHIKC","clearElement","setFrequency","aiiaCamera","height","aiia-camera#AiiaCamera","_isDebug","all","body","remove","div","originY","_drawingUtils","getVideo","7atDhXJ","canvas","\n .aiia_container {\n visibility: hidden;\n position: fixed;\n top: 0;\n left: 0;\n\n > canvas {\n position: absolute;\n top: 0;\n left: 0;\n width: 640px;\n height: 480px;\n }\n }\n .aiia_container .highlighter {\n background: rgba(0, 255, 0, 0.25);\n border: 1px dashed #fff;\n z-index: 1;\n position: absolute;\n }\n .aiia_container .confidence {\n position: absolute;\n padding-bottom: 5px;\n padding-top: 5px;\n background-color: #007f8b;\n color: #fff;\n border: 1px dashed rgba(255, 255, 255, 0.7);\n z-index: 2;\n font-size: 12px;\n margin: 0;\n }\n ","appendChild","_shadow","green","score","none","querySelectorAll","yellow","createFromOptions","69zLkAkh","GPU","visibility","forVisionTasks","complete","setFaceDetector","textContent","add","open","165UDspeX","lerp","_canvasEl","5326395mgERGv","landmarkColors","_detectionsSub","2144664lYvJIR","AiiaCamera","_lastTimestamp","onloadedmetadata","visible","now","display","connectorColors","block","https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/1/blaze_face_short_range.tflite","_faceDetector","purple","detections","_styleEl","classList","207904LUFQLx","originX","from","stopCapture","aiia-camera","disconnectedCallback","debug","_settingStyle","true","asObservable","define","pause","confidence","onDestroy","_drawRect2","videoSize","_isReady","connectedCallback","gray","video","landmarks","startCapture","cancelAnimationFrame","1819899uzTRHh","next","requestAnimationFrame","offsetWidth","observedAttributes","videoWidth","setPoseLandmarker","width","61468sTpGAr","play","getContext","1696206lmzDon","_canvasCtx","detectForVideo","type","drawConnectors","destroy","ceil","blue","_settingVideo","init","createElement","attachShadow","_containerEl","_debugElements"];return(nt=function(){return t})()}!function(){const t=at,e=nt();for(;;)try{if(559434===-parseInt(t(371))/1+-parseInt(t(402))/2*(-parseInt(t(341))/3)+-parseInt(t(356))/4+parseInt(t(353))/5+-parseInt(t(405))/6*(-parseInt(t(330))/7)+parseInt(t(316))/8*(parseInt(t(394))/9)+-parseInt(t(419))/10*(parseInt(t(350))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class it{static MediaPipeTools=null;[st(408)]=st(309);[st(319)];get[st(368)](){const t=st;return this[t(319)][t(368)]}get[st(391)](){return this[st(319)].landmarks}get[st(386)](){const t=st;return this[t(319)][t(386)]}constructor(e){const s=st,{perSecond:n}=t.assign({perSecond:3},e);this[s(317)](),this[s(319)]=new rt,document[s(324)].append(this[s(319)]),this[s(319)][s(318)](n)}async[st(414)](t){const e=st;try{if(null===it.MediaPipeTools){const t=await l.FilesetResolver[e(344)]("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.0/wasm");it.MediaPipeTools=await Promise[e(323)]([l.FaceDetector[e(340)](t,{baseOptions:{modelAssetPath:e(365),delegate:e(342)},runningMode:"VIDEO"}),l.PoseLandmarker[e(340)](t,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_lite/float16/1/pose_landmarker_lite.task",delegate:e(342)},runningMode:"VIDEO",numPoses:5})])}const[s,n]=it[e(421)];this.aiiaCamera[e(346)](s),this.aiiaCamera[e(400)](n),this[e(319)][e(314)](t)}catch(t){A.error("Camera init fail",t)}}clearElement(){const e=st;t.forEach(document[e(338)](e(321)),t=>{const s=e;this[s(319)]!==t&&t[s(410)]()})}startCapture(){this[st(319)].startCapture()}stopCapture(){const t=st;this[t(319)][t(374)]()}[st(384)](){const t=st;this[t(319)][t(410)]()}}class rt extends HTMLElement{static get[st(398)](){return[st(377)]}_shadow;_containerEl;[st(369)];[st(423)];[st(352)];[st(406)];[st(322)];[st(418)];[st(422)];_lastTimestamp;[st(420)];_faceDetector;[st(355)];[st(312)];[st(310)];[st(387)];_drawingUtils;[st(354)]=["gray",st(307),st(389),st(389),st(307)];[st(363)]=[st(335),st(412),"red",st(339),st(367)];get detections(){const t=st;return this._detectionsSub[t(380)]()}get[st(391)](){const t=st;return this[t(310)][t(380)]()}get[st(386)](){const t=st;return{width:this._videoEl[t(399)],height:this[t(423)].videoHeight}}constructor(){const t=st;super(),this.id=t(357),this._isDebug=!1,this[t(387)]=!1,this._shadow=this[t(416)]({mode:t(349)}),this[t(417)]=document[t(415)](t(326)),this[t(423)]=document.createElement(t(390)),this[t(369)]=document[t(415)](t(315)),this[t(352)]=document[t(415)](t(331)),this[t(418)]=[],this[t(420)]=null,this[t(355)]=new p.Subject,this[t(310)]=new p.Subject,this[t(422)]=Math[t(411)](1e3/3),this[t(358)]=0,this[t(426)]=this[t(426)].bind(this),this[t(311)](),this[t(378)](),this[t(413)](),this[t(417)].appendChild(this[t(423)]),this[t(334)].appendChild(this._styleEl),this._shadow[t(333)](this._containerEl),this[t(417)].appendChild(this[t(352)]);const e=this._canvasEl[t(404)]("2d");e?(this._canvasCtx=e,this._drawingUtils=new l.DrawingUtils(this[t(406)])):(this[t(406)]=null,this._drawingUtils=null)}[st(388)](){}[st(376)](){this[st(374)]()}attributeChangedCallback(t,e,s){const n=st;"debug"===t&&(this[n(322)]=null!==s&&(s===n(379)||""===s),this[n(417)][n(315)][n(343)]=this[n(322)]?n(360):"hidden")}[st(314)](t){const e=st;this[e(423)][e(359)]=()=>{this[e(387)]=!0},this[e(423)][e(308)]=t}[st(346)](t){this[st(366)]=t}[st(400)](t){this._poseLandmarker=t}[st(318)](t){const e=st;this[e(422)]=Math[e(411)](1e3/t)}_settingStyle(){const t=st;this[t(369)][t(347)]=t(332)}_settingContainer(){const t=st;this._containerEl.classList[t(348)](t(424))}[st(413)](){const t=st;this[t(423)].autoplay=!0,this[t(423)].playsInline=!0,this._videoEl.muted=!0}[st(329)](){return this[st(423)]}[st(392)](){const t=st;null===this._loopFrameID&&(this[t(423)][t(403)](),this[t(420)]=window[t(396)](this.predictWebcam))}[st(374)](){const t=st;null!==this[t(420)]&&(window[t(393)](this._loopFrameID),this[t(420)]=null),this[t(423)][t(382)]()}async[st(426)](){const t=st;if(this[t(387)]){const e=performance[t(361)]();if(this._lastTimestamp+this[t(422)]<=e){this._lastTimestamp=e;const s=this[t(366)]?.[t(407)](this[t(423)],e).detections,n=this[t(312)]?.[t(407)](this[t(423)],e)[t(391)];s&&(this[t(322)]&&this[t(313)](s),this._detectionsSub[t(395)](s)),n&&(this[t(322)]&&this[t(385)](n),this[t(310)][t(395)](n))}}this[t(420)]=window.requestAnimationFrame(this.predictWebcam)}[st(313)](e){const s=st;t.forEach(e,(t,e)=>{const s=at,{categories:n,boundingBox:i}=t;if(i){let t=this[s(418)][2*e],r=this._debugElements[2*e+1];(!t||!r)&&(t=document[s(415)](s(326)),t[s(370)][s(348)](s(306)),r=document[s(415)]("p"),r[s(370)][s(348)](s(383)),this[s(417)].append(r,t),this[s(418)].push(t,r)),t[s(315)][s(362)]=s(364),r[s(315)][s(362)]=s(364);const a=100*n[0][s(336)];r.innerText=s(304)+Math.round(a)+" %",r[s(315)][s(305)]=this[s(423)][s(397)]-i[s(401)]-i[s(372)]+"px",r.style[s(425)]=i[s(327)]-30+"px",r[s(315)][s(401)]=i[s(401)]-10+"px",t[s(315)].right=this._videoEl.offsetWidth-i[s(401)]-i.originX+"px",t[s(315)][s(425)]=i[s(327)]+"px",t[s(315)].width=i[s(401)]-10+"px",t[s(315)][s(320)]=i[s(320)]+"px"}});for(let t=2*e.length;t<this[s(418)].length;t++)this[s(418)][t][s(315)][s(362)]=s(337)}[st(385)](e){const s=st;this._canvasCtx&&this[s(328)]&&(this._canvasCtx.save(),this[s(406)].clearRect(0,0,640,480),t.forEach(e,(t,e)=>{const n=s;this[n(406)]?.save(),this._drawingUtils?.drawLandmarks(t,{radius:t=>l.DrawingUtils[n(351)](t[n(373)].z,-.15,.1,5,1),color:this[n(354)][e]}),this[n(328)]?.[n(409)](t,l.PoseLandmarker.POSE_CONNECTIONS,{color:this[n(363)][e],lineWidth:2})}),this[s(406)].restore())}[st(410)](){const t=st;this._detectionsSub[t(345)](),this[t(310)].complete(),this[t(325)]()}}function at(t,e){t-=304;return nt()[t]}customElements[st(381)](st(375),rt);const ot=ht;function ct(){const t=["float32","landmarks","allowed","asObservable","addBufferByInt16","audioManager","volume","state","detections","10048100LGtpCJ","vadManager","camManager","可正常使用","1190100SuRWwt","VAD模組載入失敗","沒有服務","12siIhEs","getVolume","等待授權","addModule","stateObs","loadfail","startCapture","playAudio","init","stream","destroy","872123XiVUzB","stopCapture","缺失該裝置","12vTjZLm","pipe","135012UoiAgH","onDestroy","complete","fatal","已被拒絕","cameraDetection","sampleRate","pcm","next","rejected","getVideoTracks","enabled","subscribe","stopRecord","Worklet模組載入失敗","2564536ybaRNZ","stopSpeech","detectionsSub","landmarksSub","_state","32440YVpwem","stateSub","addBuffer","pcmSub","startRecord","9vMDuOd","videoSize","未獲得媒體裝置權限","padding","numberOfChannels","stopAudio","buffer","408344cVDzXc","audioWorklet","length","audioCtx"];return(ct=function(){return t})()}function ht(t,e){t-=253;return ct()[t]}var ut;!function(){const t=ht,e=ct();for(;;)try{if(165091===parseInt(t(307))/1+-parseInt(t(259))/2*(parseInt(t(305))/3)+-parseInt(t(271))/4+-parseInt(t(288))/5+parseInt(t(291))/6*(-parseInt(t(302))/7)+parseInt(t(254))/8*(-parseInt(t(264))/9)+parseInt(t(284))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(t){const e=ht;t[t.padding=0]=e(267),t[t[e(316)]=1]=e(316),t[t[e(296)]=2]=e(296),t[t[e(277)]=3]=e(277)}(ut||(ut={}));class pt{stream;[ot(258)];[ot(260)];audioCtx;audioManager;[ot(285)];camManager;[ot(301)];pcmSub;[ot(256)];[ot(257)];get[ot(313)](){const t=ot;return this[t(274)]?this[t(274)][t(313)]:16e3}get[ot(314)](){const t=ot;return this[t(262)][t(278)]()}get[ot(283)](){const t=ot;return this[t(256)][t(278)]()}get[ot(276)](){return this[ot(257)].asObservable()}get[ot(282)](){return this._state}set[ot(282)](t){const e=ot;t!==this[e(258)]&&(this[e(258)]=t,this[e(260)][e(315)](t))}get[ot(295)](){const t=ot;return this[t(260)][t(278)]()}constructor(t){const e=ot;this.stream=t,this[e(260)]=new p.ReplaySubject(1),this[e(262)]=new p.Subject,this[e(301)]=new p.Subject,this.detectionsSub=new p.Subject,this.landmarksSub=new p.Subject,this[e(282)]=ut.padding}async init(t,e){const n=ot,i=this.stream??await async function(t){const e=W;try{return await navigator[e(344)][e(338)](t)}catch(t){return null}}({audio:{echoCancellation:!0,noiseSuppression:!0},video:!0});if(null===i)throw this[n(282)]=ut[n(316)],new Error(s[n(266)]);this[n(300)]=i,this[n(274)]=new AudioContext;try{await this[n(274)][n(272)][n(294)](t)}catch(t){throw A[n(310)](t),this[n(282)]=ut[n(296)],new Error(s[n(253)])}this[n(282)]=ut[n(277)],this[n(280)]=new X(this[n(274)]),this[n(285)]=new $(i,this[n(274)],e),this[n(285)][n(314)][n(306)](p.takeUntil(this[n(301)])).subscribe(t=>{this.pcmSub.next(t)});const r=new it(e?.[n(312)]);r[n(283)][n(306)](p.takeUntil(this[n(301)]))[n(319)](t=>{const e=n,{width:s,height:i}=r[e(265)];this[e(256)][e(315)]({detections:t,clientWidth:s,clientHeight:i})}),r[n(276)].pipe(p.takeUntil(this[n(301)])).subscribe(t=>{const e=n;this.landmarksSub[e(315)](t)}),r[n(299)](i),this[n(286)]=r}addAudioQueue(e){const s=ot,n=t.get(e,s(270),void 0),i=t.get(e,s(275),void 0),r=t.get(e,"int16",void 0),a=t.get(e,s(268),void 0);n?this[s(280)]?.[s(261)](n):i?this.audioManager?.addBufferByFloat32(i,a):r&&this.audioManager?.[s(279)](r,a)}[ot(298)](){const t=ot;this[t(280)]?.startSpeech()}[ot(269)](){const t=ot;this[t(280)]?.[t(255)]()}[ot(263)](){const t=ot;this[t(285)]?.startRecord()}stopRecord(){const t=ot;this[t(285)]?.[t(320)]()}setVolume(t){const e=ot;this[e(280)]&&(this[e(280)][e(281)]=t)}[ot(292)](){const t=ot;return this[t(280)]?this[t(280)].volume:0}startCapture(){const t=ot;this[t(286)]?.[t(297)]()}[ot(303)](){const t=ot;this[t(286)]?.[t(303)]()}getInfo(){const e=ot;switch(this[e(282)]){case ut[e(267)]:return{mic:r[e(293)],camera:r[e(293)]};case ut.rejected:return{mic:r["已被拒絕"],camera:r[e(311)]};case ut[e(296)]:return{mic:r[e(289)],camera:r[e(289)]};case ut.allowed:if(this[e(300)]){const{hasAudio:s,hasVideo:n}=function(e){const s=ht,n=e.getAudioTracks(),i=n[s(273)]>0&&t.some(n,t=>t.enabled),r=e[s(317)]();return{hasAudio:i,hasVideo:r[s(273)]>0&&t.some(r,t=>t[s(318)])}}(this[e(300)]);return{mic:s?r[e(287)]:r[e(304)],camera:n?r[e(287)]:r[e(304)]}}return{mic:r[e(290)],camera:r[e(290)]}}}[ot(308)](){const t=ot;this[t(286)]?.[t(308)](),this.audioCtx?.close(),this[t(301)][t(315)](),this[t(301)][t(309)]()}}function dt(){var t=["3VCNAgv","2624280qncviz","8050294dqxdrd","4567604dnGsJo","153787GYAADE","2874100PTPcCG","2012877InjYkX","8PAZGFl","10437400GcCOMy","10XZSsTD"];return(dt=function(){return t})()}function lt(t,e){return t-=306,dt()[t]}function ft(t,e){t-=124;return bt()[t]}!function(){for(var t=lt,e=dt();;)try{if(584963===-parseInt(t(306))/1*(-parseInt(t(311))/2)+parseInt(t(312))/3*(-parseInt(t(315))/4)+-parseInt(t(307))/5+-parseInt(t(313))/6+parseInt(t(314))/7*(parseInt(t(309))/8)+-parseInt(t(308))/9+parseInt(t(310))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const mt=ft;function bt(){const t=["clear","94324RKYTCt","4sReTnG","12BuzbgT","11396473QvdDNq","2915590zVKIKZ","8HPmAWD","8928030bQOONK","5936iQOKrM","removeItemSync","4248711NWRNfX","4437981gitbug","setItemSync","browser","32agOPHj","removeItem","setItem","getItem","clearSync","getItemSync"];return(bt=function(){return t})()}!function(){const t=ft,e=bt();for(;;)try{if(908466===parseInt(t(135))/1*(parseInt(t(128))/2)+parseInt(t(124))/3*(-parseInt(t(136))/4)+parseInt(t(139))/5*(parseInt(t(137))/6)+-parseInt(t(142))/7+parseInt(t(140))/8*(-parseInt(t(125))/9)+-parseInt(t(141))/10+parseInt(t(138))/11)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();mt(131),mt(130),mt(129),mt(134),mt(133),mt(126),mt(143),mt(132);function It(){var t=["961611TyEAQc","736308LCtCyy","366595UnDpJt","2NNSiTq","4365882OVyXqA","1166hcvlJG","91908YTKDbN","1477AsVrPn","223390hpnipr","13576agaWkj","108vyAjpe"];return(It=function(){return t})()}function gt(t,e){return t-=238,It()[t]}function St(t,e){t-=160;return kt()[t]}!function(){for(var t=gt,e=It();;)try{if(793600===-parseInt(t(247))/1*(parseInt(t(239))/2)+-parseInt(t(242))/3*(parseInt(t(246))/4)+-parseInt(t(238))/5+parseInt(t(240))/6+-parseInt(t(243))/7*(parseInt(t(245))/8)+-parseInt(t(248))/9+parseInt(t(244))/10*(parseInt(t(241))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const yt=St;!function(){const t=St,e=kt();for(;;)try{if(165260===-parseInt(t(218))/1*(-parseInt(t(226))/2)+-parseInt(t(245))/3+parseInt(t(248))/4*(-parseInt(t(194))/5)+parseInt(t(179))/6*(parseInt(t(237))/7)+parseInt(t(163))/8+parseInt(t(205))/9+parseInt(t(234))/10*(parseInt(t(235))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class wt{[yt(243)];[yt(231)];[yt(220)];destroySub;[yt(198)];layoutSub;[yt(167)];[yt(211)];sampleRateOfWhisper;stateSub;[yt(225)];[yt(169)];[yt(232)];[yt(221)];_lastProjects;[yt(168)];[yt(254)];[yt(201)];get[yt(202)](){const t=yt;return this.stateSub[t(216)]()}get currentState(){return this[yt(225)]}get[yt(256)](){return this[yt(184)].asObservable()}get projects(){const t=yt;return this[t(198)][t(216)]()}get lastProjects(){const e=yt;return t.cloneDeep(this[e(172)])}get[yt(253)](){const t=yt;return this[t(167)][t(216)]()}get userSubtitle(){const t=yt;return this[t(211)][t(216)]()}get guest(){const t=yt;return this[t(168)][t(216)]()}get[yt(165)](){return this[yt(254)]}set volume(t){this.media.setVolume(t)}get[yt(266)](){const t=yt;return this[t(231)][t(204)]()}constructor(e,s){const n=yt;this[n(243)]=e,this[n(231)]=s,this[n(184)]=new p.Subject,this.projectsSub=new p.ReplaySubject(1),this[n(181)]=new p.Subject,this[n(167)]=new p.Subject,this[n(211)]=new p.Subject,this[n(232)]=new p.Subject,this[n(221)]=new p.Subject,this.stateSub=new p.BehaviorSubject(n(259)),this[n(257)]={input:e[n(255)],output:16e3},this[n(169)]=!1,this[n(172)]=[],this[n(168)]=new p.ReplaySubject(1),this._hasGuest=!1,this[n(201)]=!1,this.chat=new V(e),A.code(D["指定依賴已完成"],n(220)),this[n(174)]=this[n(210)],this[n(258)]=this[n(258)].bind(this);const{userDelayTime:i,aiiaDelayTime:r}=e[n(189)];!isNaN(r)&&this[n(232)].pipe(p.debounceTime(r),p.takeUntil(this.destroySub))[n(170)](()=>{const t=n;this[t(167)][t(242)]("")}),!isNaN(i)&&this[n(221)][n(197)](p.debounceTime(i),p.takeUntil(this[n(181)])).subscribe(()=>{const t=n;this[t(211)][t(242)]("")}),this[n(182)][n(197)](p.takeUntil(this[n(181)])).subscribe(t=>{this[n(225)]=t}),this.projectsSub.pipe(p.takeUntil(this[n(181)]))[n(170)](t=>{this[n(172)]=t}),this[n(168)][n(197)](p.takeUntil(this[n(181)]))[n(170)](t=>{this._hasGuest=t}),p.combineLatest([this[n(182)],this[n(231)][n(190)]])[n(197)](p.takeUntil(this.destroySub))[n(170)](([t,e])=>{const s=n;if(e===ut.allowed)switch(t){case"InServiceNoMedia":this[s(231)][s(228)](),this[s(231)].startRecord(),this[s(182)].next(s(206));break;case s(206):break;default:this[s(231)].stopCapture(),this[s(231)][s(236)]()}});const a=(o=this[n(243)][n(195)][n(160)],function(e,s){const n=M,{width:i,height:r}=s,a=t.filter(e,t=>{const e=M;return 100*(t[e(122)][0]?.[e(123)]??0)>=o}),c=t.compact(t.map(a,t=>{const e=M;if(void 0!==t[e(126)]){const s=t[e(126)],n=s.width*s.height,a=t[e(122)][0]?.[e(123)]??0;return{...s,area:n,score:100*a,clientWidth:i,clientHeight:r}}return null}));return t.sortBy(c,[n(120),n(123)])[0]??null});var o;this.media[n(264)].pipe(p.takeUntil(this[n(181)])).subscribe(t=>{const e=n;this.chat.sendToCloud({request:e(265),command:"pcm",content:F(t)})}),this[n(231)][n(229)].pipe(p.takeUntil(this[n(181)]))[n(170)](({detections:t,clientHeight:e,clientWidth:s})=>{const i=n;this[i(220)][i(192)]("face",a(t,{width:s,height:e}))}),this[n(231)].landmarks[n(197)](p.takeUntil(this[n(181)]))[n(170)](t=>{const e=n;this[e(220)][e(222)]({request:e(178),content:t})})}start(){const e=yt;this[e(201)]?A.code(D["已啟動SDK"]):(this[e(201)]=!0,this.chat[e(261)][e(197)](p.takeUntil(this[e(181)])).subscribe(({event:s,data:n})=>{const i=e;switch(s){case i(191):t.map(n,this[i(258)]);break;case"list":{const{id:e,name:s,specific:r}=this[i(243)][i(161)];let a=null;if(r&&void 0!==e)a=e;else{const r=t.find(n,t=>t[i(262)]===s||t.id===e);r&&(a=r.id)}null!==a?this[i(166)](a):null===n?(this[i(182)].next("CloseService"),A[i(246)](i(263))):(this[i(198)][i(242)](n),this[i(182)].next(i(186)),A.code(D["請訂閱專案列表"]));break}case i(207):switch(n){case i(241):A[i(246)](i(224));case i(174):case"no_permissions":this[i(182)].next("CloseService");break;case i(196):this.stateSub[i(242)](i(175));case i(252):}break;case i(171):{const t=this.media[i(209)]();this[i(220)][i(192)](i(171),t);break}}}),this[e(220)][e(217)](),this.stateSub.next(e(227)),A[e(239)](D[e(260)]))}[yt(174)];[yt(183)](){const t=yt;this[t(220)][t(222)]({request:t(183)})}reset(){const t=yt;this.chat.sendToCloud({request:t(164)})}chooseProject(t){const e=yt;this[e(220)][e(192)](e(176),t),this[e(182)].next(e(227))}mute(){const t=yt;this[t(169)]=!0,this.media.stopAudio(),this.media[t(236)]()}unmute(){const t=yt;this.isMuteAiia=!1,this[t(231)][t(213)]()}[yt(258)](e){const s=yt;switch(e.signal){case s(256):this[s(184)][s(242)](e[s(208)]);break;case s(265):if("sampleRate"===e.command)this[s(257)].output=e.content;else switch(e[s(212)]){case s(264):if(!this.isMuteAiia){const t=function(t,e,s){const n=W;if(e===s)return t;const i=s/e,r=Math[n(339)](t.length*i),a=new Float32Array(r);for(let e=0;e<r;e++){const s=e/i,r=Math.floor(s),o=s-r,c=t[r],h=t[Math[n(342)](r+1,t[n(324)]-1)];a[e]=c+(h-c)*o}return a}(z(new Int16Array(e.content)),this[s(257)].output,this.media[s(199)]);this[s(231)][s(251)]({float32:t}),this.media.playAudio()}break;case"interrupted":this[s(231)][s(173)](),this.aiiaSubtitleSub[s(242)]("")}break;case"status":t.get(e,s(208))===s(180)&&this[s(214)]();break;case"agent":if(!this.isMuteAiia){const n=t.get(e,s(249));void 0!==n&&(this[s(167)][s(242)](n),this[s(232)][s(242)]())}break;case s(238):if(!this[s(169)]&&t.get(e,s(250))===s(188)){const n=t.get(e,"content.function_result.result");void 0!==n&&(this.userSubtitleSub.next(n),this[s(221)].next())}break;case"cv":{const n=t.get(e,s(215));n===s(193)?this[s(168)].next(!0):"user leave"===n?this[s(168)].next(!1):A[s(230)](s(223),t.get(e,"content"));break}case s(247):case s(200):case"transcribe":case s(240):default:A[s(219)](e[s(244)])}}proxyIsStable(){const t=yt;this[t(220)][t(222)]({request:t(265),command:t(199),content:this[t(257)].input}),this[t(231)].state===ut[t(177)]?(this.media[t(213)](),this[t(231)].startCapture(),this[t(182)].next(t(206)),A[t(239)](D[t(187)])):(this[t(182)][t(242)]("InServiceNoMedia"),A[t(239)](D[t(185)])),this[t(184)].next({type:"resetLayout"})}[yt(210)](){const t=yt;this[t(220)][t(210)](),this[t(231)][t(210)](),this[t(181)][t(242)](),this[t(181)][t(233)](),this[t(182)].next(t(203)),this[t(182)].complete(),A[t(239)](D[t(162)])}}function kt(){const t=["getInfo","onDestroy","userSubtitleSub","command","startRecord","proxyIsStable","content.status","asObservable","start","1LdKktu","debug","chat","userSubtitleClearSub","sendToCloud","Unexpect value","Please check network status","_currentState","207356MLtefT","ConnectingCloud","startCapture","detections","warn","media","aiiaSubtitleClearSub","complete","422690UVcfWB","11cYRTRM","stopRecord","638463Blgfoj","asr","code","response","net_error","next","config","signal","241740iUUWrM","error","tts","20XCJqsp","content.function_result.response","content.function_type","addAudioQueue","open","aiiaSubtitle","_hasGuest","llmSampleRate","layout","sampleRateOfWhisper","behavior","NotStart","啟動SDK","message","name","No project ready or lose network","pcm","audio","volume","confidence","project","結束SDK","1688080KgxKMZ","reset","hasGuest","chooseProject","aiiaSubtitleSub","guestSub","isMuteAiia","subscribe","monitor","_lastProjects","stopAudio","close","ReconnectingCloud","uuid","allowed","pose_detect","12ZPZACE","Connected","destroySub","stateSub","skip","layoutSub","未取得媒體裝置權限,請重新設定或忽略此訊息","WaitingProjectID","通道、雲端服務、麥克風都已就緒","ASR","autoClearSubtitle","stateObs","cloud","send","user present","302300pbXMfZ","detection","reconnect","pipe","projectsSub","sampleRate","mic","isStart","state","Destroy","getVolume","78885rSGMtI","InService","channel","content"];return(kt=function(){return t})()}function vt(){const t=["sdk","6883920fbZiVu","4UnakHb","config","22360000MVVyAO","1773906GnbfkK","指定依賴已完成","init","4697495xFAIgm","debug","3JmdvLC","環境錯誤(browser)","701924UkUrae","1374831UMhJOC","1355872QFjMqs","初始化必要依賴","7YgShki","code"];return(vt=function(){return t})()}function Ct(t,e){t-=420;return vt()[t]}!function(){const t=Ct,e=vt();for(;;)try{if(634646===parseInt(t(420))/1*(parseInt(t(422))/2)+-parseInt(t(433))/3*(parseInt(t(430))/4)+parseInt(t(436))/5+parseInt(t(429))/6+parseInt(t(426))/7*(parseInt(t(424))/8)+parseInt(t(423))/9+-parseInt(t(432))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),exports.initSdk=function(e){const n=Ct;if(w){(function(t){const e=E,{info:s,error:n,warn:i,debug:r,fatal:a,code:o}=function(t){const e=T;if(void 0===t||t===e(502))return{code:!0,error:!0,warn:!0,info:!0,debug:!0,fatal:!0};if(t===e(543))return{error:!1,code:!1,warn:!1,info:!1,debug:!1,fatal:!1};if(typeof t===e(514))return{code:t,error:t,warn:t,info:t,debug:t,fatal:t};{const s=new Set(t);return{code:s[e(499)](e(504)),debug:s[e(499)](e(544)),fatal:s[e(499)](e(526)),error:s[e(499)](e(528)),warn:s[e(499)](e(519)),info:s.has(e(516))}}}(t);!o&&(x.code=()=>{}),!r&&(x[e(544)]=()=>{}),!s&&(x[e(516)]=()=>{}),!i&&(x[e(519)]=()=>{}),!n&&(x[e(528)]=()=>{}),!a&&(x[e(526)]=()=>{})})(t.get(e,n(437),!0)),A.code(D[n(425)]);const s=new _(t.assign({},e));A[n(427)](D[n(434)],n(431));const i=new pt(s.mediaStream);A[n(427)](D[n(434)],"config");const r=new wt(s,i);return A[n(427)](D[n(434)],n(428)),""!==s.worklet_url&&i[n(435)](s.worklet_url,s),r}throw new Error(s[n(421)])};
package/dist/browser.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { BoundingBox } from '@mediapipe/tasks-vision';
1
2
  import type { Detection } from '@mediapipe/tasks-vision';
2
3
  import { Http2SecureServer } from 'http2';
3
4
  import { Http2Server } from 'http2';
@@ -77,6 +78,7 @@ declare class AiiaConfig {
77
78
  get webserver(): (Server<any, any> | Server_2<any, any> | Http2SecureServer<any, any, any, any> | Http2Server<any, any, any, any>) | undefined;
78
79
  get environment(): string;
79
80
  get license(): string;
81
+ get note(): string | undefined;
80
82
  get port(): number;
81
83
  get ws_url(): string;
82
84
  get worklet_url(): string;
@@ -130,7 +132,6 @@ declare class AiiaSdk {
130
132
  private aiiaSubtitleSub;
131
133
  private userSubtitleSub;
132
134
  private sampleRateOfWhisper;
133
- private channelState;
134
135
  private stateSub;
135
136
  private _currentState;
136
137
  private isMuteAiia;
@@ -139,7 +140,6 @@ declare class AiiaSdk {
139
140
  private _lastProjects;
140
141
  private guestSub;
141
142
  private _hasGuest;
142
- private mediaEventReady;
143
143
  private isStart;
144
144
  /**
145
145
  * [zh]
@@ -293,7 +293,7 @@ declare class AiiaSdk {
293
293
  */
294
294
  unmute(): void;
295
295
  private behavior;
296
- private channelCheck;
296
+ private proxyIsStable;
297
297
  /**
298
298
  * [zh]
299
299
  * 停止所有服務,釋放資源
@@ -306,6 +306,8 @@ declare class AiiaSdk {
306
306
 
307
307
  export declare type AiiaState = "NotStart" | "WaitingProjectID" | "ConnectingCloud" | "ReconnectingCloud" | "InService" | "InServiceNoMedia" | "NoPermissions" | "CloseService" | "Destroy";
308
308
 
309
+ declare type AnalysisResult = Result | null;
310
+
309
311
  declare interface ASR {
310
312
  signal: "asr";
311
313
  content: {
@@ -339,7 +341,7 @@ declare type AUDIO = {
339
341
  command: "interrupted";
340
342
  };
341
343
 
342
- export declare type BrowserInitOptions = Omit<InitOptions, "webserver" | "port" | "license" | "eyeTrackEnable" | "correction">;
344
+ export declare type BrowserInitOptions = Omit<InitOptions, "webserver" | "port" | "license" | "eyeTrackEnable" | "correction" | "note">;
343
345
 
344
346
  declare type CLOUD_SOCKET_MSG = TTS | MIC | ASR | AGENT | OLD_ASR | OLD_AGENT | RATINGS | QUESTIONNAIRE | LAYOUT_2 | AUDIO | CV | MovementToUE;
345
347
 
@@ -351,6 +353,14 @@ declare interface CV {
351
353
  }
352
354
 
353
355
  declare interface InitOptions {
356
+ /**
357
+ * [zh]
358
+ * 簡易的機台資訊備註,於管理系統查看
359
+ *
360
+ * [en]
361
+ * Simple machine information notes, viewable in the management system.
362
+ */
363
+ note?: string;
354
364
  /**
355
365
  * [zh]
356
366
  * 請從 Aiia platform 取得授權
@@ -597,6 +607,7 @@ declare class MediaManager {
597
607
  getVolume(): number;
598
608
  startCapture(): void;
599
609
  stopCapture(): void;
610
+ getInfo(): MSG_TO_SERVER["monitor"];
600
611
  onDestroy(): void;
601
612
  }
602
613
 
@@ -614,6 +625,21 @@ declare interface MIC {
614
625
  };
615
626
  }
616
627
 
628
+ declare enum MonitorDeviceState {
629
+ 未響應 = 1,// 瀏覽器未在時間內回應狀態
630
+ 等待授權 = 2,
631
+ 已被拒絕 = 3,
632
+ VAD模組載入失敗 = 4,
633
+ 可正常使用 = 5,
634
+ 缺失該裝置 = 6,
635
+ 沒有服務 = 7
636
+ }
637
+
638
+ declare interface MonitorResult {
639
+ mic: MonitorDeviceState;
640
+ camera: MonitorDeviceState;
641
+ }
642
+
617
643
  declare interface MovementToUE {
618
644
  signal: "osc";
619
645
  content: {
@@ -623,6 +649,14 @@ declare interface MovementToUE {
623
649
  };
624
650
  }
625
651
 
652
+ declare interface MSG_TO_SERVER {
653
+ uuid: string;
654
+ cloud: SendMessage;
655
+ debug: null;
656
+ face: AnalysisResult;
657
+ monitor: MonitorResult;
658
+ }
659
+
626
660
  /** @deprecated */
627
661
  declare interface OLD_AGENT {
628
662
  signal: "response";
@@ -671,6 +705,13 @@ declare interface RATINGS {
671
705
  };
672
706
  }
673
707
 
708
+ declare interface Result extends BoundingBox {
709
+ area: number;
710
+ score: number;
711
+ clientWidth: number;
712
+ clientHeight: number;
713
+ }
714
+
674
715
  declare type SendMessage = {
675
716
  request: "reset";
676
717
  } | {
package/dist/browser.mjs CHANGED
@@ -1 +1 @@
1
- import{get as e,assign as t,forEach as s,filter as i,compact as a,map as n,sortBy as o,cloneDeep as r,find as c}from"lodash-es";import u from"moment";import"mathjs";import{Subject as d,fromEvent as h,takeUntil as l,take as p,ReplaySubject as b,BehaviorSubject as m,debounceTime as g,map as f}from"rxjs";import{io as S}from"socket.io-client";import{DrawingUtils as _,PoseLandmarker as y,FilesetResolver as C,FaceDetector as w}from"@mediapipe/tasks-vision";var v;!function(e){e["網絡錯誤"]="ERROR CODE: 500",e["環境錯誤(browser)"]="ERROR CODE: 1001",e["Worklet模組載入失敗"]="ERROR CODE: 1002",e["未獲得媒體裝置權限"]="ERROR CODE: 1003",e["實例已摧毀"]="ERROR CODE: 1004",e["環境錯誤(nodejs)"]="ERROR CODE: 2001",e["未提供憑證"]="ERROR CODE: 2002",e["獲取權杖失敗"]="ERROR CODE: 2003",e["沒有可用專案"]="ERROR CODE: 2004",e["重複初始化"]="ERROR CODE: 2005"}(v||(v={}));const x="undefined"!=typeof window;"undefined"!=typeof process&&null!=process.versions&&process.versions.node;class k{config;get webserver(){return this.safeRead("webserver")}get environment(){const e=this.safeRead("env");return"string"==typeof e?e:"developement"}get license(){return this.safeRead("license")??""}get port(){return function(e,t){const s="number"==typeof t?t:NaN;if(e){const t=Number(e);return isNaN(t)?s:t}return s}(process.env.PORT,this.safeRead("port")??3e3)}get ws_url(){const e=this.safeRead("ws_url");return"string"==typeof e?e:""}get worklet_url(){const e=this.safeRead("worklet_url");return"string"==typeof e?e:""}get project(){const t=this.safeRead("project");if(void 0===t)return{specific:!1};if("string"==typeof t)return{name:t,id:t,specific:!1};{const s=e(t,"id",void 0),i=e(t,"name",void 0);return{id:"string"==typeof s?s:void 0,name:"string"==typeof i?i:void 0,specific:!0}}}get endPoint(){let e="dev";switch(this.environment){case"production":e="prod";break;case"test":e="test"}const t=`graphen-agentic-workflow-${e}-21193779403.asia-east1.run.app`;return{api:`https://${t}`,socket:`wss://${t}`}}get debug(){return this.safeRead("debug")??!0}get mediaStream(){return this.safeRead("mediaStream")}get chunkTimeInSeconds(){const e=this.safeRead("chunkTimeInSeconds");return"number"==typeof e&&e>0?e:.3}get llmSampleRate(){const e=this.safeRead("llmSampleRate");return"number"==typeof e&&e>0?e:16e3}get detection(){return t({perSecond:3,confidence:80},this.safeRead("faceDetection"),this.safeRead("cameraDetection"))}get autoClearSubtitle(){const e=this.safeRead("autoClearUserSubtitle"),t=this.safeRead("autoClearAiiaSubtitle");return{userDelayTime:"number"==typeof e?e:5e3,aiiaDelayTime:"number"==typeof t?t:NaN}}get eyeTrackEnable(){return Boolean(this.safeRead("eyeTrackEnable"))}get eyeTrackCorrection(){return t({x_axis_px:0,y_axis_px:0},this.safeRead("correction"))}constructor(e){this.config=e}safeRead(t){return e(this.config,t,void 0)}}var R;!function(e){e["通道、雲端服務、麥克風都已就緒"]="CODE: 1000",e["未取得媒體裝置權限,請重新設定或忽略此訊息"]="CODE: 1001",e["請訂閱專案列表"]="CODE: 1002",e["初始化必要依賴"]="CODE: 1010",e["指定依賴已完成"]="CODE: 1011",e["啟動SDK"]="CODE: 1012",e["結束SDK"]="CODE: 1013",e["已啟動SDK"]="CODE: 1014",e["安全的關閉連線"]="CODE: 2000",e["無副作用的關閉連線"]="CODE: 2001",e["與雲端的服務中斷"]="CODE: 2002",e["沒有授權,請聯繫Graphen"]="CODE: 2003",e["自動重新連線雲端服務"]="CODE: 2004",e["未預期的斷線,請聯繫Graphen"]="CODE: 2005",e["開始初始化必要模組"]="CODE: 2010",e["指定模組初始化完成"]="CODE: 2011",e["啟動服務"]="CODE: 2012",e["服務結束"]="CODE: 2013"}(R||(R={}));const E={code:console.log,debug:console.log,info:console.log,warn:console.warn,error:console.error,fatal:console.error},D=[];const O=new Proxy(E,{get(e,t,i){if("string"==typeof t)switch(t){case"debug":case"info":case"error":case"warn":case"fatal":case"code":return(...i)=>{const a=u().format("yyyy-MM-DD[T]HH:mm:ss:sss");s(D,e=>{e.next(t,a,...i)}),e[t](`[Aiia::${t}_${a}_]`,...i)};default:return}},set:(e,t,s,i)=>!0});class N{socket;messageSub;destorySub;get message(){return this.messageSub.asObservable()}constructor(e){this.destorySub=new d,this.messageSub=new d;const{specific:s,id:i}=e.project;this.socket=S(e.ws_url,t({autoConnect:!1},s&&void 0!==i?{query:{uuid:i}}:{}))}start(){const e="list",t="cloud",s="channel";h(this.socket,"connect").pipe(l(this.destorySub)).subscribe(()=>{O.debug("Client ID: ",this.socket.id)}),h(this.socket,e).pipe(p(1),l(this.destorySub)).subscribe(t=>{this.messageSub.next({event:e,data:t})}),h(this.socket,t).pipe(l(this.destorySub)).subscribe(e=>{this.messageSub.next({event:t,data:e})}),h(this.socket,s).pipe(l(this.destorySub)).subscribe(e=>{this.messageSub.next({event:s,data:e})}),this.socket.connect()}send(e,t){this.socket.emit(e,t)}sendToCloud(e){this.send("cloud",e)}onDestroy(){this.destorySub.next(),this.destorySub.complete(),this.messageSub.complete(),this.socket.disconnect()}}var M,T;function A(e,t,s){return Math.max(s,Math.min(e,t))}function j(e){const t=new DataView(e.buffer),s=[];for(let i=0;i<e.length;i++){const e=t.getInt16(2*i,!0)/32768;s.push(e)}return new Float32Array(s)}function I(e){const t=new DataView(e.buffer),s=[];for(let i=0;i<e.length;i++){const e=A(32768*t.getFloat32(4*i,!0),32767,-32768);s.push(e)}return s}!function(e){e[e.unknow=0]="unknow",e[e.allowed=1]="allowed",e[e.rejected=2]="rejected"}(M||(M={}));class F{audioContext;type="audio";currentNode;bufferQueue;gainNode;set volume(e){e<0&&(e=0),e>100&&(e=100),this.gainNode.gain.value=e/100}get volume(){return Math.round(100*this.gainNode.gain.value)}constructor(e){this.audioContext=e,this.bufferQueue=[],this.currentNode=null,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}addBuffer(e){this.bufferQueue.push(e)}addBufferByFloat32(e,t=1){const s=e.length,i=this.audioContext.sampleRate,a=this.audioContext.createBuffer(t,s,i),n=e.slice();for(let e=0;e<t;e++)a.copyToChannel(n,e);this.addBuffer(a)}addBufferByInt16(e,t=1){this.addBufferByFloat32(j(e),t)}startSpeech(){null===this.currentNode&&this.continue()}pauseSpeech(){this.audioContext.suspend().catch(e=>{O.error("pause speech fail",e)})}resumeSpeech(){this.audioContext.resume().catch(e=>{O.error("resume speech fail",e)})}nextSpeech(){this.bufferQueue.length>0&&(this.clearNode(),this.continue())}stopSpeech(){this.bufferQueue=[],this.clearNode()}clearNode(){this.currentNode&&(this.currentNode.onended=function(){},this.currentNode.stop(),this.currentNode.disconnect(),this.currentNode=null)}continue(){const e=this.bufferQueue.shift();if(e){this.currentNode=this.audioContext.createBufferSource(),this.currentNode.buffer=e,this.currentNode.connect(this.gainNode);const t=this.continue.bind(this);this.currentNode.onended=t,this.currentNode.start()}else this.clearNode()}}class P{stream;audioContext;type="vad";workletNode;source;isRecording=!1;outputSampleRate;chunkTimeInSeconds;pcmSub;get pcm(){return this.pcmSub.asObservable()}constructor(e,t,s){this.stream=e,this.audioContext=t,this.outputSampleRate=s?.llmSampleRate??16e3,this.chunkTimeInSeconds=s?.chunkTimeInSeconds??1,this.pcmSub=new d}async startRecord(){this.isRecording||(this.source=this.audioContext.createMediaStreamSource(this.stream),this.workletNode=new AudioWorkletNode(this.audioContext,"aiia-vad",{processorOptions:{outputSampleRate:this.outputSampleRate,chunkTimeInSeconds:this.chunkTimeInSeconds}}),this.source.connect(this.workletNode),this.workletNode.port.onmessage=e=>{const{float32:t}=e.data;t&&this.pcmSub.next(new Float32Array(t))},this.isRecording=!0)}stopRecord(){this.isRecording&&(this.workletNode&&(this.workletNode.port.onmessage=null,this.workletNode.disconnect()),this.source&&this.source.disconnect(),this.isRecording=!1)}}class W{type="camera";aiiaCamera;get detections(){return this.aiiaCamera.detections}get landmarks(){return this.aiiaCamera.landmarks}get videoSize(){return this.aiiaCamera.videoSize}constructor(e){const{perSecond:s}=t({perSecond:3},e);this.aiiaCamera=new B,this.aiiaCamera.setFrequency(s),document.body.append(this.aiiaCamera)}async init(e){try{const t=await C.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.0/wasm"),[s,i]=await Promise.all([w.createFromOptions(t,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/1/blaze_face_short_range.tflite",delegate:"GPU"},runningMode:"VIDEO"}),y.createFromOptions(t,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_lite/float16/1/pose_landmarker_lite.task",delegate:"GPU"},runningMode:"VIDEO",numPoses:5})]);this.aiiaCamera.setStream(e),this.aiiaCamera.setFaceDetector(s),this.aiiaCamera.setPoseLandmarker(i)}catch(e){O.error("Camera init fail",e)}}startCapture(){this.aiiaCamera.startCapture()}stopCapture(){this.aiiaCamera.stopCapture()}onDestroy(){this.aiiaCamera.remove()}}class B extends HTMLElement{static get observedAttributes(){return["debug"]}_shadow;_containerEl;_styleEl;_videoEl;_canvasEl;_canvasCtx;_isDebug;_debugElements;_interval;_lastTimestamp;_loopFrameID;_faceDetector;_detectionsSub;_poseLandmarker;_landmarksSub;_isReady;_drawingUtils;landmarkColors=["gray","lightgray","gray","gray","lightgray"];connectorColors=["green","blue","red","yellow","purple"];get detections(){return this._detectionsSub.asObservable()}get landmarks(){return this._landmarksSub.asObservable()}get videoSize(){return{width:this._videoEl.videoWidth,height:this._videoEl.videoHeight}}constructor(){super(),this.id="AiiaCamera",this._isDebug=!1,this._isReady=!1,this._shadow=this.attachShadow({mode:"open"}),this._containerEl=document.createElement("div"),this._videoEl=document.createElement("video"),this._styleEl=document.createElement("style"),this._canvasEl=document.createElement("canvas"),this._debugElements=[],this._loopFrameID=null,this._detectionsSub=new d,this._landmarksSub=new d,this._interval=Math.ceil(1e3/3),this._lastTimestamp=0,this.predictWebcam=this.predictWebcam.bind(this),this._settingContainer(),this._settingStyle(),this._settingVideo(),this._containerEl.appendChild(this._videoEl),this._shadow.appendChild(this._styleEl),this._shadow.appendChild(this._containerEl),this._containerEl.appendChild(this._canvasEl);const e=this._canvasEl.getContext("2d");e?(this._canvasCtx=e,this._drawingUtils=new _(this._canvasCtx)):(this._canvasCtx=null,this._drawingUtils=null)}connectedCallback(){this.startCapture()}disconnectedCallback(){this.stopCapture()}attributeChangedCallback(e,t,s){"debug"===e&&(this._isDebug=null!==s&&("true"===s||""===s),this._containerEl.style.visibility=this._isDebug?"visible":"hidden")}setStream(e){this._videoEl.onloadedmetadata=()=>{this._isReady=!0},this._videoEl.srcObject=e}setFaceDetector(e){this._faceDetector=e}setPoseLandmarker(e){this._poseLandmarker=e}setFrequency(e){this._interval=Math.ceil(1e3/e)}_settingStyle(){this._styleEl.textContent="\n .aiia_container {\n visibility: hidden;\n position: fixed;\n top: 0;\n left: 0;\n\n > canvas {\n position: absolute;\n top: 0;\n left: 0;\n width: 640px;\n height: 480px;\n }\n }\n .aiia_container .highlighter {\n background: rgba(0, 255, 0, 0.25);\n border: 1px dashed #fff;\n z-index: 1;\n position: absolute;\n }\n .aiia_container .confidence {\n position: absolute;\n padding-bottom: 5px;\n padding-top: 5px;\n background-color: #007f8b;\n color: #fff;\n border: 1px dashed rgba(255, 255, 255, 0.7);\n z-index: 2;\n font-size: 12px;\n margin: 0;\n }\n "}_settingContainer(){this._containerEl.classList.add("aiia_container")}_settingVideo(){this._videoEl.autoplay=!0,this._videoEl.playsInline=!0,this._videoEl.muted=!0}getVideo(){return this._videoEl}startCapture(){null===this._loopFrameID&&(this._videoEl.play(),this._loopFrameID=window.requestAnimationFrame(this.predictWebcam))}stopCapture(){null!==this._loopFrameID&&(window.cancelAnimationFrame(this._loopFrameID),this._loopFrameID=null),this._videoEl.pause()}async predictWebcam(){if(this._isReady){const e=performance.now();if(this._lastTimestamp+this._interval<=e){this._lastTimestamp=e;const t=this._faceDetector?.detectForVideo(this._videoEl,e).detections,s=this._poseLandmarker?.detectForVideo(this._videoEl,e).landmarks;t&&(this._isDebug&&this._drawRect(t),this._detectionsSub.next(t)),s&&(this._isDebug&&this._drawRect2(s),this._landmarksSub.next(s))}}this._loopFrameID=window.requestAnimationFrame(this.predictWebcam)}_drawRect(e){s(e,(e,t)=>{const{categories:s,boundingBox:i}=e;if(i){let e=this._debugElements[2*t],a=this._debugElements[2*t+1];e&&a||(e=document.createElement("div"),e.classList.add("highlighter"),a=document.createElement("p"),a.classList.add("confidence"),this._containerEl.append(a,e),this._debugElements.push(e,a)),e.style.display="block",a.style.display="block";const n=100*s[0].score;a.innerText=`Confidence: ${Math.round(n)} %`,a.style.right=this._videoEl.offsetWidth-i.width-i.originX+"px",a.style.top=i.originY-30+"px",a.style.width=i.width-10+"px",e.style.right=this._videoEl.offsetWidth-i.width-i.originX+"px",e.style.top=`${i.originY}px`,e.style.width=i.width-10+"px",e.style.height=`${i.height}px`}});for(let t=2*e.length;t<this._debugElements.length;t++)this._debugElements[t].style.display="none"}_drawRect2(e){this._canvasCtx&&this._drawingUtils&&(this._canvasCtx.save(),this._canvasCtx.clearRect(0,0,640,480),s(e,(e,t)=>{this._canvasCtx?.save(),this._drawingUtils?.drawLandmarks(e,{radius:e=>_.lerp(e.from.z,-.15,.1,5,1),color:this.landmarkColors[t]}),this._drawingUtils?.drawConnectors(e,y.POSE_CONNECTIONS,{color:this.connectorColors[t],lineWidth:2})}),this._canvasCtx.restore())}destroy(){this._detectionsSub.complete(),this.remove()}}customElements.define("aiia-camera",B),function(e){e[e.padding=0]="padding",e[e.rejected=1]="rejected",e[e.loadfail=2]="loadfail",e[e.allowed=3]="allowed"}(T||(T={}));class V{stream;_state;stateSub;audioCtx;audioManager;vadManager;camManager;destroy;pcmSub;detectionsSub;landmarksSub;get sampleRate(){return this.audioCtx?this.audioCtx.sampleRate:16e3}get pcm(){return this.pcmSub.asObservable()}get detections(){return this.detectionsSub.asObservable()}get landmarks(){return this.landmarksSub.asObservable()}get state(){return this._state}set state(e){e!==this._state&&(this._state=e,this.stateSub.next(e))}get stateObs(){return this.stateSub.asObservable()}constructor(e){this.stream=e,this.stateSub=new b(1),this.pcmSub=new d,this.destroy=new d,this.detectionsSub=new d,this.landmarksSub=new d,this.state=T.padding}async init(e,t){const s=this.stream??await async function(e){try{return await navigator.mediaDevices.getUserMedia(e)}catch(e){return null}}({audio:{echoCancellation:!0,noiseSuppression:!0},video:!0});if(null===s)throw this.state=T.rejected,new Error(v["未獲得媒體裝置權限"]);this.stream=s,this.audioCtx=new AudioContext;try{await this.audioCtx.audioWorklet.addModule(e)}catch(e){throw O.fatal(e),this.state=T.loadfail,new Error(v["Worklet模組載入失敗"])}this.state=T.allowed,this.audioManager=new F(this.audioCtx),this.vadManager=new P(s,this.audioCtx,t),this.vadManager.pcm.pipe(l(this.destroy)).subscribe(e=>{this.pcmSub.next(e)});const i=new W(t?.cameraDetection);i.detections.pipe(l(this.destroy)).subscribe(e=>{const{width:t,height:s}=i.videoSize;this.detectionsSub.next({detections:e,clientWidth:t,clientHeight:s})}),i.landmarks.pipe(l(this.destroy)).subscribe(e=>{this.landmarksSub.next(e)}),i.init(s),this.camManager=i}addAudioQueue(t){const s=e(t,"buffer",void 0),i=e(t,"float32",void 0),a=e(t,"int16",void 0),n=e(t,"numberOfChannels",void 0);s?this.audioManager?.addBuffer(s):i?this.audioManager?.addBufferByFloat32(i,n):a&&this.audioManager?.addBufferByInt16(a,n)}playAudio(){this.audioManager?.startSpeech()}stopAudio(){this.audioManager?.stopSpeech()}startRecord(){this.vadManager?.startRecord()}stopRecord(){this.vadManager?.stopRecord()}setVolume(e){this.audioManager&&(this.audioManager.volume=e)}getVolume(){return this.audioManager?this.audioManager.volume:0}startCapture(){this.camManager?.startCapture()}stopCapture(){this.camManager?.stopCapture()}onDestroy(){this.camManager?.onDestroy(),this.audioCtx?.close(),this.destroy.next(),this.destroy.complete()}}class L{config;media;chat;destroySub;projectsSub;layoutSub;aiiaSubtitleSub;userSubtitleSub;sampleRateOfWhisper;channelState;stateSub;_currentState;isMuteAiia;aiiaSubtitleClearSub;userSubtitleClearSub;_lastProjects;guestSub;_hasGuest;mediaEventReady;isStart;get state(){return this.stateSub.asObservable()}get currentState(){return this._currentState}get layout(){return this.layoutSub.asObservable()}get projects(){return this.projectsSub.asObservable()}get lastProjects(){return r(this._lastProjects)}get aiiaSubtitle(){return this.aiiaSubtitleSub.asObservable()}get userSubtitle(){return this.userSubtitleSub.asObservable()}get guest(){return this.guestSub.asObservable()}get hasGuest(){return this._hasGuest}set volume(e){this.media.setVolume(e)}get volume(){return this.media.getVolume()}constructor(e,t){this.config=e,this.media=t,this.layoutSub=new d,this.projectsSub=new b(1),this.destroySub=new d,this.aiiaSubtitleSub=new d,this.userSubtitleSub=new d,this.aiiaSubtitleClearSub=new d,this.userSubtitleClearSub=new d,this.stateSub=new m("NotStart"),this.sampleRateOfWhisper={input:e.llmSampleRate,output:16e3},this.channelState={proxy:!1,cloud:!1},this.isMuteAiia=!1,this._lastProjects=[],this.guestSub=new b(1),this._hasGuest=!1,this.mediaEventReady=!1,this.isStart=!1,this.chat=new N(e),O.code(R["指定依賴已完成"],"chat"),this.close=this.onDestroy,this.behavior=this.behavior.bind(this);const{userDelayTime:s,aiiaDelayTime:i}=e.autoClearSubtitle;isNaN(i)||this.aiiaSubtitleClearSub.pipe(g(i),l(this.destroySub)).subscribe(()=>{this.aiiaSubtitleSub.next("")}),isNaN(s)||this.userSubtitleClearSub.pipe(g(s),l(this.destroySub)).subscribe(()=>{this.userSubtitleSub.next("")}),this.stateSub.pipe(l(this.destroySub)).subscribe(e=>{this._currentState=e}),this.projectsSub.pipe(l(this.destroySub)).subscribe(e=>{this._lastProjects=e}),this.guestSub.pipe(l(this.destroySub)).subscribe(e=>{this._hasGuest=e}),t.stateObs.pipe(l(this.destroySub)).subscribe(e=>{T.allowed===e&&this.channelCheck()})}start(){this.isStart?O.code(R["已啟動SDK"]):(this.isStart=!0,this.chat.message.pipe(l(this.destroySub)).subscribe(({event:e,data:t})=>{switch(e){case"cloud":n(t,this.behavior);break;case"list":{const{id:e,name:s,specific:i}=this.config.project;let a=null;if(i&&void 0!==e)a=e;else{const i=c(t,t=>t.name===s||t.id===e);i&&(a=i.id)}null!==a?this.chooseProject(a):null===t?(this.stateSub.next("CloseService"),O.error("No project ready or lose network")):(this.projectsSub.next(t),this.stateSub.next("WaitingProjectID"),O.code(R["請訂閱專案列表"]));break}case"channel":switch(this.channelState.proxy=!0,t){case"open":this.channelCheck();break;case"close":this.channelState.cloud=!1,this.media.stopRecord(),this.media.stopCapture(),this.stateSub.next("CloseService");break;case"no_permissions":this.channelState.cloud=!1,this.media.stopRecord(),this.media.stopCapture(),this.stateSub.next("NoPermissions");break;case"reconnect":this.channelState.cloud=!1,this.media.stopRecord(),this.media.stopCapture(),this.stateSub.next("ReconnectingCloud");break;case"net_error":this.channelState.cloud=!1,this.media.stopRecord(),this.media.stopCapture(),this.stateSub.next("CloseService"),O.error("Please check network status")}}}),this.chat.start(),this.stateSub.next("ConnectingCloud"),O.code(R["啟動SDK"]))}close;skip(){this.chat.sendToCloud({request:"skip"})}reset(){this.chat.sendToCloud({request:"reset"})}chooseProject(e){this.chat.send("uuid",e),this.stateSub.next("ConnectingCloud")}mute(){this.isMuteAiia=!0,this.media.stopAudio(),this.media.stopRecord()}unmute(){this.isMuteAiia=!1,this.media.startRecord()}behavior(t){switch(t.signal){case"layout":this.layoutSub.next(t.content);break;case"audio":if("sampleRate"===t.command)this.sampleRateOfWhisper.output=t.content;else switch(t.command){case"pcm":if(!this.isMuteAiia){const e=function(e,t,s){if(t===s)return e;const i=s/t,a=Math.ceil(e.length*i),n=new Float32Array(a);for(let t=0;t<a;t++){const s=t/i,a=Math.floor(s),o=s-a,r=e[a],c=e[Math.min(a+1,e.length-1)];n[t]=r+(c-r)*o}return n}(j(new Int16Array(t.content)),this.sampleRateOfWhisper.output,this.media.sampleRate);this.media.addAudioQueue({float32:e}),this.media.playAudio()}break;case"interrupted":this.media.stopAudio(),this.aiiaSubtitleSub.next("")}break;case"status":"Connected"===e(t,"content")&&(this.channelState.cloud=!0,this.channelCheck(),this.layoutSub.next({type:"resetLayout"}));break;case"agent":if(!this.isMuteAiia){const s=e(t,"content.function_result.response");void 0!==s&&(this.aiiaSubtitleSub.next(s),this.aiiaSubtitleClearSub.next())}break;case"asr":if(!this.isMuteAiia&&"ASR"===e(t,"content.function_type")){const s=e(t,"content.function_result.result");void 0!==s&&(this.userSubtitleSub.next(s),this.userSubtitleClearSub.next())}break;case"cv":{const s=e(t,"content.status");"user present"===s?this.guestSub.next(!0):"user leave"===s?this.guestSub.next(!1):O.warn("Unexpect value",e(t,"content"));break}default:O.debug(t.signal)}}channelCheck(){const{proxy:e,cloud:t}=this.channelState;if(e&&t&&this.media.state===T.allowed){if(this.chat.sendToCloud({request:"audio",command:"sampleRate",content:this.sampleRateOfWhisper.input}),!this.mediaEventReady){this.mediaEventReady=!0,this.media.pcm.pipe(l(this.destroySub)).subscribe(e=>{this.chat.sendToCloud({request:"audio",command:"pcm",content:I(e)})});const e=(s=this.config.detection.confidence,function(e,t){const{width:r,height:c}=t,u=i(e,e=>100*(e.categories[0]?.score??0)>=s),d=a(n(u,e=>{if(void 0!==e.boundingBox){const t=e.boundingBox,s=t.width*t.height,i=e.categories[0]?.score??0;return{...t,area:s,score:100*i,clientWidth:r,clientHeight:c}}return null}));return o(d,["area","score"])[0]??null});this.media.detections.pipe(l(this.destroySub),f(({detections:t,clientHeight:s,clientWidth:i})=>e(t,{width:i,height:s}))).subscribe(e=>{this.chat.send("face",e)}),this.media.landmarks.pipe(l(this.destroySub)).subscribe(e=>{this.chat.sendToCloud({request:"pose_detect",content:e})})}this.media.startRecord(),this.media.startCapture(),this.stateSub.next("InService"),O.code(R["通道、雲端服務、麥克風都已就緒"])}else e&&t&&this.media.state!==T.allowed&&(this.stateSub.next("InServiceNoMedia"),O.code(R["未取得媒體裝置權限,請重新設定或忽略此訊息"]));var s}onDestroy(){this.chat.onDestroy(),this.media.onDestroy(),this.destroySub.next(),this.destroySub.complete(),this.stateSub.next("Destroy"),this.stateSub.complete(),O.code(R["結束SDK"])}}function U(s){if(x){!function(e){const{info:t,error:s,warn:i,debug:a,fatal:n,code:o}=function(e){if(void 0===e||"all"===e)return{code:!0,error:!0,warn:!0,info:!0,debug:!0,fatal:!0};if("none"===e)return{error:!1,code:!1,warn:!1,info:!1,debug:!1,fatal:!1};if("boolean"==typeof e)return{code:e,error:e,warn:e,info:e,debug:e,fatal:e};{const t=new Set(e);return{code:t.has("code"),debug:t.has("debug"),fatal:t.has("fatal"),error:t.has("error"),warn:t.has("warn"),info:t.has("info")}}}(e);o||(E.code=()=>{}),a||(E.debug=()=>{}),t||(E.info=()=>{}),i||(E.warn=()=>{}),s||(E.error=()=>{}),n||(E.fatal=()=>{})}(e(s,"debug",!0)),O.code(R["初始化必要依賴"]);const i=new k(t({},s));O.code(R["指定依賴已完成"],"config");const a=new V(i.mediaStream);O.code(R["指定依賴已完成"],"config");const n=new L(i,a);return O.code(R["指定依賴已完成"],"sdk"),""!==i.worklet_url&&a.init(i.worklet_url,i),n}throw new Error(v["環境錯誤(browser)"])}export{U as initSdk};
1
+ import{get as t,assign as e,forEach as s,filter as n,compact as i,map as r,sortBy as a,some as o,cloneDeep as c,find as h}from"lodash-es";import u from"moment";import"mathjs";import{Subject as p,fromEvent as d,takeUntil as l,take as f,ReplaySubject as m,BehaviorSubject as I,debounceTime as b,combineLatest as g}from"rxjs";import{io as w}from"socket.io-client";import{FilesetResolver as y,FaceDetector as S,PoseLandmarker as v,DrawingUtils as k}from"@mediapipe/tasks-vision";function C(){var t=["ERROR CODE: 2001","100vQzVjL","2619328xANAXk","ERROR CODE: 1004","959336AlhFfc","3STsxhl","2206304lUgcBN","環境錯誤(browser)","ERROR CODE: 2004","ERROR CODE: 1002","579104GqLuFJ","未提供憑證","未獲得媒體裝置權限","ERROR CODE: 1001","ERROR CODE: 2002","沒有可用專案","ERROR CODE: 2003","211959SyWwrS","2488092hjGsFS","830150IHtdHk","ERROR CODE: 2005","實例已摧毀","Worklet模組載入失敗","10GfAmjO"];return(C=function(){return t})()}function _(t,e){return t-=265,C()[t]}var x,D,E,R,O,A,T,M,N;function j(t,e){return t-=134,P()[t]}function P(){var t=["無服務","可正常使用","等待授權","缺失該裝置","246222XXGItB","沒有服務","1221031dIkIqT","VAD模組載入失敗","6xMbVGK","120zvBojo","3vFpsxo","75742bGHYFe","1435196gOwmGa","可使用","非預期的狀態","85472jNfyzH","未啟動","未響應","未授權控制","3484270ZFcDLf","359925LMSVuS"];return(P=function(){return t})()}!function(){for(var t=_,e=C();;)try{if(667343===-parseInt(t(287))/1+-parseInt(t(272))/2+parseInt(t(282))/3*(parseInt(t(279))/4)+-parseInt(t(276))/5*(-parseInt(t(271))/6)+parseInt(t(281))/7+parseInt(t(283))/8+parseInt(t(270))/9*(-parseInt(t(278))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),D=x||(x={}),E=_,D["網絡錯誤"]="ERROR CODE: 500",D[E(284)]=E(266),D[E(275)]=E(286),D[E(265)]="ERROR CODE: 1003",D[E(274)]=E(280),D["環境錯誤(nodejs)"]=E(277),D[E(288)]=E(267),D["獲取權杖失敗"]=E(269),D[E(268)]=E(285),D["重複初始化"]=E(273),function(){for(var t=j,e=P();;)try{if(270693===-parseInt(t(139))/1+parseInt(t(135))/2*(parseInt(t(134))/3)+parseInt(t(136))/4+-parseInt(t(144))/5*(-parseInt(t(153))/6)+-parseInt(t(151))/7+-parseInt(t(154))/8*(-parseInt(t(149))/9)+-parseInt(t(143))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),(O=R||(R={}))[O[(A=j)(141)]=1]=A(141),O[O["等待授權"]=2]=A(147),O[O["已被拒絕"]=3]="已被拒絕",O[O[A(152)]=4]="VAD模組載入失敗",O[O[A(146)]=5]=A(146),O[O[A(148)]=6]=A(148),O[O[A(150)]=7]=A(150),(M=T||(T={}))[M[(N=j)(138)]=1]="非預期的狀態",M[M["未授權控制"]=2]=N(142),M[M[N(140)]=3]=N(140),M[M["無服務"]=4]=N(145),M[M[N(137)]=5]=N(137);const V=B;function B(t,e){t-=305;return q()[t]}!function(){const t=B,e=q();for(;;)try{if(209035===-parseInt(t(311))/1+parseInt(t(309))/2+-parseInt(t(308))/3*(-parseInt(t(318))/4)+-parseInt(t(306))/5+parseInt(t(310))/6+parseInt(t(315))/7*(-parseInt(t(314))/8)+-parseInt(t(317))/9*(-parseInt(t(305))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();function q(){const t=["251118JZucSh","1136388BOWAej","31455hiNPMQ","number","node","5912LaTxkS","3486cysdQp","undefined","141507WGklij","2344HaITKM","230NpOcOh","384320UWqeQr","versions","45SfcDcO"];return(q=function(){return t})()}const G=typeof window!==V(316);typeof process!==V(316)&&null!=process[V(307)]&&process.versions[V(313)];const W=K;function H(){const t=["webserver","config","-21193779403.asia-east1.run.app","safeRead","detection","developement","project","chunkTimeInSeconds","https://","wss://","1054128TtBwLj","endPoint","llmSampleRate","eyeTrackEnable","114983fARIVW","environment","1194697tzXdhC","PORT","ws_url","note","worklet_url","faceDetection","port","autoClearSubtitle","debug","autoClearUserSubtitle","4AqEzeT","production","string","correction","2277880gfqBWm","autoClearAiiaSubtitle","test","prod","env","number","3465596PJHVgM","100098gnldjH","923382qBTtpw","mediaStream","cameraDetection","license"];return(H=function(){return t})()}function K(t,e){t-=447;return H()[t]}!function(){const t=K,e=H();for(;;)try{if(511112===-parseInt(t(461))/1+parseInt(t(473))/2*(parseInt(t(484))/3)+parseInt(t(483))/4+-parseInt(t(477))/5+-parseInt(t(485))/6+parseInt(t(463))/7+parseInt(t(457))/8)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class U{[W(448)];get[W(447)](){return this[W(450)]("webserver")}get environment(){const t=W,e=this[t(450)](t(481));return typeof e===t(475)?e:t(452)}get[W(488)](){const t=W;return this[t(450)](t(488))??""}get[W(466)](){const t=W;return this.safeRead(t(466))}get[W(469)](){const t=W;return function(t,e){const s=typeof e===V(312)?e:NaN;if(t){const e=Number(t);return isNaN(e)?s:e}return s}(process[t(481)][t(464)],this[t(450)](t(469))??3e3)}get[W(465)](){const t=W,e=this[t(450)]("ws_url");return typeof e===t(475)?e:""}get[W(467)](){const t=W,e=this[t(450)](t(467));return typeof e===t(475)?e:""}get[W(453)](){const e=W,s=this.safeRead("project");if(void 0===s)return{specific:!1};if(typeof s===e(475))return{name:s,id:s,specific:!1};{const n=t(s,"id",void 0),i=t(s,"name",void 0);return{id:"string"==typeof n?n:void 0,name:typeof i===e(475)?i:void 0,specific:!0}}}get[W(458)](){const t=W;let e="dev";switch(this[t(462)]){case t(474):e=t(480);break;case t(479):e="test"}const s="graphen-agentic-workflow-"+e+t(449);return{api:t(455)+s,socket:t(456)+s}}get[W(471)](){const t=W;return this[t(450)](t(471))??!0}get[W(486)](){const t=W;return this[t(450)](t(486))}get chunkTimeInSeconds(){const t=W,e=this[t(450)](t(454));return typeof e===t(482)&&e>0?e:.3}get[W(459)](){const t=W,e=this.safeRead(t(459));return typeof e===t(482)&&e>0?e:16e3}get[W(451)](){const t=W;return e({perSecond:3,confidence:80},this[t(450)](t(468)),this[t(450)](t(487)))}get[W(470)](){const t=W,e=this[t(450)](t(472)),s=this[t(450)](t(478));return{userDelayTime:typeof e===t(482)?e:5e3,aiiaDelayTime:typeof s===t(482)?s:NaN}}get[W(460)](){return Boolean(this[W(450)]("eyeTrackEnable"))}get eyeTrackCorrection(){const t=W;return e({x_axis_px:0,y_axis_px:0},this[t(450)](t(476)))}constructor(t){this[W(448)]=t}[W(450)](e){return t(this.config,e,void 0)}}const z=Z;var L;function F(){const t=["CODE: 1012","warn","285464XQUBiB","CODE: 1011","與雲端的服務中斷","已啟動SDK","string","自動重新連線雲端服務","fatal","CODE: 2012","error","2yxxpJS","未取得媒體裝置權限,請重新設定或忽略此訊息","_](","format","670629jEamlZ","log","CODE: 2004","[Aiia::","2076221sfAZCu","CODE: 1013","9eHDpPm","未預期的斷線,請聯繫Graphen","CODE: 2002","push","none","debug","189605nUHwJE","CODE: 2005","CODE: 1002","category","CODE: 2001","沒有授權,請聯繫Graphen","yyyy-MM-DD[T]HH:mm:ss:sss","無副作用的關閉連線","includes","啟動SDK","CODE: 2000","請訂閱專案列表","has","163701SOjnlN","24ZEzgSh","all","default","code","2325852pTTOrA","CODE: 1014","指定模組初始化完成","啟動服務","服務結束","2390120YKohEv","結束SDK","CODE: 1001","CODE: 2003","boolean","next","info","通道、雲端服務、麥克風都已就緒"];return(F=function(){return t})()}!function(){const t=Z,e=F();for(;;)try{if(198050===-parseInt(t(500))/1+parseInt(t(529))/2*(parseInt(t(533))/3)+parseInt(t(501))/4*(-parseInt(t(545))/5)+parseInt(t(505))/6+-parseInt(t(537))/7+parseInt(t(520))/8+parseInt(t(539))/9*(parseInt(t(510))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(t){const e=Z;t[e(517)]="CODE: 1000",t[e(530)]=e(512),t[e(498)]=e(547),t["初始化必要依賴"]="CODE: 1010",t["指定依賴已完成"]=e(521),t[e(496)]=e(518),t[e(511)]=e(538),t[e(523)]=e(506),t["安全的關閉連線"]=e(497),t[e(494)]=e(491),t[e(522)]=e(541),t[e(492)]=e(513),t[e(525)]=e(535),t[e(540)]=e(546),t["開始初始化必要模組"]="CODE: 2010",t[e(507)]="CODE: 2011",t[e(508)]=e(527),t[e(509)]="CODE: 2013"}(L||(L={}));const Q={code:console[z(534)],debug:console.log,info:console.log,warn:console[z(519)],error:console.error,fatal:console[z(528)]},J=[];function Z(t,e){t-=491;return F()[t]}const X=(Y=z(503),new Proxy(Q,{get(t,e,n){const i=Z;if(typeof e===i(524))switch(e){case i(544):case i(516):case i(528):case i(519):case i(526):case i(504):return(...n)=>{const r=i,a=u()[r(532)](r(493));s(J,t=>{const s=r;(void 0===t[s(548)]||t.category[s(495)](Y))&&t[s(515)](e,a,Y,...n)}),t[e](r(536)+e+"_"+a+r(531)+Y+")",...n)};default:return}},set:(t,e,s,n)=>!0}));var Y;function $(t,e){t-=117;return tt()[t]}function tt(){const t=["2353512woxspR","boundingBox","219264grnWvT","180wuKHKK","8337952zMHggo","4187358TDvlad","3616700PGJAai","get","2374TqcHHo","area","69423JqBNiE","categories","score","1686UNkNfE"];return(tt=function(){return t})()}function et(){var t=["456132kMZEcF","78pamjzu","285848xStkvt","5746040rsvztS","19803AygsZQ","919290ogGCMs","139080HqHDNi","35mKAysE","55dQxUch","4687812Qkstoy","7RuxfrN","99YQkHBH"];return(et=function(){return t})()}function st(t,e){return t-=429,et()[t]}!function(){const t=$,e=tt();for(;;)try{if(630118===-parseInt(t(121))/1+-parseInt(t(119))/2*(parseInt(t(124))/3)+parseInt(t(125))/4+parseInt(t(117))/5+parseInt(t(130))/6+-parseInt(t(129))/7+parseInt(t(127))/8*(parseInt(t(128))/9))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(){for(var t=st,e=et();;)try{if(335274===-parseInt(t(434))/1+parseInt(t(435))/2*(parseInt(t(438))/3)+parseInt(t(436))/4*(-parseInt(t(429))/5)+parseInt(t(439))/6*(-parseInt(t(432))/7)+parseInt(t(440))/8*(-parseInt(t(433))/9)+-parseInt(t(437))/10+parseInt(t(430))/11*(parseInt(t(431))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const nt=it;function it(t,e){t-=239;return at()[t]}!function(){const t=it,e=at();for(;;)try{if(733753===parseInt(t(256))/1*(-parseInt(t(262))/2)+parseInt(t(251))/3*(-parseInt(t(243))/4)+-parseInt(t(245))/5+-parseInt(t(257))/6*(parseInt(t(253))/7)+parseInt(t(255))/8+parseInt(t(239))/9*(-parseInt(t(268))/10)+parseInt(t(246))/11)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class rt{[nt(250)];messageSub;[nt(265)];get[nt(241)](){return this.messageSub.asObservable()}constructor(t){const s=nt;this[s(265)]=new p,this.messageSub=new p;const{specific:n,id:i}=t.project;this[s(250)]=w(t[s(254)],e({autoConnect:!1},n&&void 0!==i?{query:{uuid:i}}:{}))}start(){const t=nt,e=t(266),s=t(242),n=t(258),i=t(260);d(this.socket,t(252))[t(244)](l(this.destorySub))[t(264)](()=>{const e=t;X[e(267)](e(249),this[e(250)].id)}),d(this[t(250)],e)[t(244)](f(1),l(this[t(265)]))[t(264)](s=>{this[t(269)].next({event:e,data:s})}),d(this[t(250)],s).pipe(l(this[t(265)]))[t(264)](e=>{const n=t;this[n(269)][n(270)]({event:s,data:e})}),d(this.socket,n).pipe(l(this[t(265)])).subscribe(e=>{const s=t;this[s(269)][s(270)]({event:n,data:e})}),d(this[t(250)],i).pipe(l(this[t(265)]))[t(264)](e=>{this[t(269)].next({event:i,data:e})}),this[t(250)].connect()}[nt(263)](t,e){const s=nt;this[s(250)][s(240)](t,e)}[nt(261)](t){const e=nt;this[e(263)](e(242),t)}[nt(248)](){const t=nt;this.destorySub[t(270)](),this[t(265)][t(247)](),this[t(269)][t(247)](),this.socket[t(259)]()}}function at(){const t=["116GhiYIs","pipe","6481540ZDncAB","43960356IGrjCS","complete","onDestroy","Client ID: ","socket","1965IwzRWU","connect","7dBgWOQ","ws_url","8284568tPgKDd","9eYYqEb","5000052PLtrnu","channel","disconnect","monitor","sendToCloud","288866gkuDtE","send","subscribe","destorySub","list","debug","4248360fEJMNP","messageSub","next","18TuTXdb","emit","message","cloud"];return(at=function(){return t})()}function ot(t,e){t-=316;return ct()[t]}function ct(){const t=["unknow","max","forEach","all","getTracks","32AMqWLy","502878tqdqIh","rejected","createBuffer","getInt16","106134zisxrZ","291320AMViTr","14tHqykK","length","push","36sdWrML","2692270BgHBrP","buffer","filter","stop","240bdOHUv","4iFZecw","enumerateDevices","177463ubGrSb","getChannelData","then","984560maIRdA","getUserMedia","ceil","9091GHSJqw","sampleRate","min","allowed","mediaDevices"];return(ct=function(){return t})()}var ht;function ut(t,e,s){const n=ot;return Math[n(346)](s,Math[n(342)](t,e))}function pt(t){const e=ot,s=new DataView(t[e(328)]),n=[];for(let i=0;i<t.length;i++){const t=s[e(320)](2*i,!0)/32768;n[e(325)](t)}return new Float32Array(n)}function dt(t){const e=ot,s=new DataView(t[e(328)]),n=[];for(let i=0;i<t[e(324)];i++){const t=ut(32768*s.getFloat32(4*i,!0),32767,-32768);n.push(t)}return n}!function(){const t=ot,e=ct();for(;;)try{if(173019===-parseInt(t(340))/1*(-parseInt(t(316))/2)+-parseInt(t(317))/3*(-parseInt(t(332))/4)+-parseInt(t(337))/5+parseInt(t(321))/6*(-parseInt(t(323))/7)+parseInt(t(322))/8*(parseInt(t(326))/9)+parseInt(t(327))/10+parseInt(t(334))/11*(-parseInt(t(331))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(t){const e=ot;t[t[e(345)]=0]=e(345),t[t[e(343)]=1]=e(343),t[t[e(318)]=2]=e(318)}(ht||(ht={}));const lt=mt;function ft(){const t=["connect","type","createBufferSource","destination","nextSpeech","96438eyOLBI","217fjVghZ","gainNode","961390lgXcRj","stopSpeech","startSpeech","154368luqsue","clearNode","round","audio","addBuffer","start","catch","volume","bufferQueue","disconnect","buffer","962810nRihku","onended","shift","createGain","length","suspend","bind","26056vTPycK","error","continue","gain","8zaTJrv","createBuffer","addBufferByFloat32","value","currentNode","audioContext","250296bRJKXD","pauseSpeech","10892696YGqzxs","stop","143UhNKYb","slice","465mPVIpQ"];return(ft=function(){return t})()}function mt(t,e){t-=432;return ft()[t]}!function(){const t=mt,e=ft();for(;;)try{if(768774===parseInt(t(465))/1*(parseInt(t(437))/2)+parseInt(t(477))/3*(-parseInt(t(461))/4)+parseInt(t(440))/5+-parseInt(t(471))/6*(-parseInt(t(438))/7)+-parseInt(t(473))/8+parseInt(t(443))/9+parseInt(t(454))/10*(parseInt(t(475))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class It{[lt(470)];[lt(433)]=lt(446);currentNode;bufferQueue;[lt(439)];set[lt(450)](t){const e=lt;t<0&&(t=0),t>100&&(t=100),this[e(439)][e(464)][e(468)]=t/100}get[lt(450)](){const t=lt;return Math[t(445)](100*this[t(439)][t(464)][t(468)])}constructor(t){const e=lt;this.audioContext=t,this[e(451)]=[],this[e(469)]=null,this[e(439)]=this[e(470)][e(457)](),this.gainNode[e(432)](this[e(470)][e(435)])}[lt(447)](t){this[lt(451)].push(t)}[lt(467)](t,e=1){const s=lt,n=t.length,i=this[s(470)].sampleRate,r=this.audioContext[s(466)](e,n,i),a=t[s(476)]();for(let t=0;t<e;t++)r.copyToChannel(a,t);this[s(447)](r)}addBufferByInt16(t,e=1){this[lt(467)](pt(t),e)}[lt(442)](){const t=lt;null===this.currentNode&&this[t(463)]()}[lt(472)](){const t=lt;this[t(470)][t(459)]()[t(449)](e=>{X[t(462)]("pause speech fail",e)})}resumeSpeech(){this[lt(470)].resume().catch(t=>{X.error("resume speech fail",t)})}[lt(436)](){const t=lt;this[t(451)][t(458)]>0&&(this[t(444)](),this[t(463)]())}[lt(441)](){const t=lt;this[t(451)]=[],this[t(444)]()}[lt(444)](){const t=lt;this[t(469)]&&(this[t(469)][t(455)]=function(){},this[t(469)][t(474)](),this[t(469)][t(452)](),this[t(469)]=null)}[lt(463)](){const t=lt,e=this[t(451)][t(456)]();if(e){this.currentNode=this[t(470)][t(434)](),this[t(469)][t(453)]=e,this[t(469)][t(432)](this[t(439)]);const s=this[t(463)][t(460)](this);this[t(469)][t(455)]=s,this[t(469)][t(448)]()}else this.clearNode()}}const bt=wt;!function(){const t=wt,e=yt();for(;;)try{if(930935===parseInt(t(378))/1*(-parseInt(t(377))/2)+parseInt(t(393))/3*(parseInt(t(389))/4)+parseInt(t(398))/5*(parseInt(t(399))/6)+parseInt(t(392))/7+-parseInt(t(388))/8*(parseInt(t(382))/9)+parseInt(t(401))/10*(-parseInt(t(394))/11)+parseInt(t(375))/12)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class gt{stream;[bt(395)];[bt(384)]="vad";[bt(403)];[bt(376)];[bt(387)]=!1;[bt(383)];[bt(379)];[bt(386)];get[bt(374)](){const t=bt;return this[t(386)][t(381)]()}constructor(t,e,s){const n=bt;this[n(397)]=t,this.audioContext=e,this[n(383)]=s?.[n(400)]??16e3,this[n(379)]=s?.chunkTimeInSeconds??1,this[n(386)]=new p}async[bt(405)](){const t=bt;this[t(387)]||(this.source=this[t(395)][t(385)](this[t(397)]),this[t(403)]=new AudioWorkletNode(this.audioContext,t(390),{processorOptions:{outputSampleRate:this.outputSampleRate,chunkTimeInSeconds:this.chunkTimeInSeconds}}),this[t(376)].connect(this[t(403)]),this[t(403)][t(380)][t(404)]=e=>{const s=t,{float32:n}=e[s(391)];n&&this[s(386)][s(402)](new Float32Array(n))},this[t(387)]=!0)}[bt(396)](){const t=bt;this[t(387)]&&(this[t(403)]&&(this.workletNode.port[t(404)]=null,this[t(403)].disconnect()),this[t(376)]&&this[t(376)].disconnect(),this[t(387)]=!1)}}function wt(t,e){t-=374;return yt()[t]}function yt(){const t=["startRecord","pcm","35507844NzviKT","source","130UEePtQ","15463cQQuHP","chunkTimeInSeconds","port","asObservable","9uyIQIB","outputSampleRate","type","createMediaStreamSource","pcmSub","isRecording","13732792gImYnJ","246808WVcqlM","aiia-vad","data","7538986gsKGnw","36umrRPJ","17497700tlRqRP","audioContext","stopRecord","stream","600oELPgk","23346CbVRYn","llmSampleRate","10WwBgPk","next","workletNode","onmessage"];return(yt=function(){return t})()}const St=_t;function vt(){const t=["770520ObLbob","_loopFrameID","MediaPipeTools","_interval","_videoEl","aiia_container","top","predictWebcam","Confidence: ","right","highlighter","lightgray","srcObject","camera","_landmarksSub","_settingContainer","_poseLandmarker","_drawRect","setStream","style","16fOHIKC","clearElement","setFrequency","aiiaCamera","height","aiia-camera#AiiaCamera","_isDebug","all","body","remove","div","originY","_drawingUtils","getVideo","7atDhXJ","canvas","\n .aiia_container {\n visibility: hidden;\n position: fixed;\n top: 0;\n left: 0;\n\n > canvas {\n position: absolute;\n top: 0;\n left: 0;\n width: 640px;\n height: 480px;\n }\n }\n .aiia_container .highlighter {\n background: rgba(0, 255, 0, 0.25);\n border: 1px dashed #fff;\n z-index: 1;\n position: absolute;\n }\n .aiia_container .confidence {\n position: absolute;\n padding-bottom: 5px;\n padding-top: 5px;\n background-color: #007f8b;\n color: #fff;\n border: 1px dashed rgba(255, 255, 255, 0.7);\n z-index: 2;\n font-size: 12px;\n margin: 0;\n }\n ","appendChild","_shadow","green","score","none","querySelectorAll","yellow","createFromOptions","69zLkAkh","GPU","visibility","forVisionTasks","complete","setFaceDetector","textContent","add","open","165UDspeX","lerp","_canvasEl","5326395mgERGv","landmarkColors","_detectionsSub","2144664lYvJIR","AiiaCamera","_lastTimestamp","onloadedmetadata","visible","now","display","connectorColors","block","https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/1/blaze_face_short_range.tflite","_faceDetector","purple","detections","_styleEl","classList","207904LUFQLx","originX","from","stopCapture","aiia-camera","disconnectedCallback","debug","_settingStyle","true","asObservable","define","pause","confidence","onDestroy","_drawRect2","videoSize","_isReady","connectedCallback","gray","video","landmarks","startCapture","cancelAnimationFrame","1819899uzTRHh","next","requestAnimationFrame","offsetWidth","observedAttributes","videoWidth","setPoseLandmarker","width","61468sTpGAr","play","getContext","1696206lmzDon","_canvasCtx","detectForVideo","type","drawConnectors","destroy","ceil","blue","_settingVideo","init","createElement","attachShadow","_containerEl","_debugElements"];return(vt=function(){return t})()}!function(){const t=_t,e=vt();for(;;)try{if(559434===-parseInt(t(371))/1+-parseInt(t(402))/2*(-parseInt(t(341))/3)+-parseInt(t(356))/4+parseInt(t(353))/5+-parseInt(t(405))/6*(-parseInt(t(330))/7)+parseInt(t(316))/8*(parseInt(t(394))/9)+-parseInt(t(419))/10*(parseInt(t(350))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class kt{static MediaPipeTools=null;[St(408)]=St(309);[St(319)];get[St(368)](){const t=St;return this[t(319)][t(368)]}get[St(391)](){return this[St(319)].landmarks}get[St(386)](){const t=St;return this[t(319)][t(386)]}constructor(t){const s=St,{perSecond:n}=e({perSecond:3},t);this[s(317)](),this[s(319)]=new Ct,document[s(324)].append(this[s(319)]),this[s(319)][s(318)](n)}async[St(414)](t){const e=St;try{if(null===kt.MediaPipeTools){const t=await y[e(344)]("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.0/wasm");kt.MediaPipeTools=await Promise[e(323)]([S[e(340)](t,{baseOptions:{modelAssetPath:e(365),delegate:e(342)},runningMode:"VIDEO"}),v[e(340)](t,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_lite/float16/1/pose_landmarker_lite.task",delegate:e(342)},runningMode:"VIDEO",numPoses:5})])}const[s,n]=kt[e(421)];this.aiiaCamera[e(346)](s),this.aiiaCamera[e(400)](n),this[e(319)][e(314)](t)}catch(t){X.error("Camera init fail",t)}}clearElement(){const t=St;s(document[t(338)](t(321)),e=>{const s=t;this[s(319)]!==e&&e[s(410)]()})}startCapture(){this[St(319)].startCapture()}stopCapture(){const t=St;this[t(319)][t(374)]()}[St(384)](){const t=St;this[t(319)][t(410)]()}}class Ct extends HTMLElement{static get[St(398)](){return[St(377)]}_shadow;_containerEl;[St(369)];[St(423)];[St(352)];[St(406)];[St(322)];[St(418)];[St(422)];_lastTimestamp;[St(420)];_faceDetector;[St(355)];[St(312)];[St(310)];[St(387)];_drawingUtils;[St(354)]=["gray",St(307),St(389),St(389),St(307)];[St(363)]=[St(335),St(412),"red",St(339),St(367)];get detections(){const t=St;return this._detectionsSub[t(380)]()}get[St(391)](){const t=St;return this[t(310)][t(380)]()}get[St(386)](){const t=St;return{width:this._videoEl[t(399)],height:this[t(423)].videoHeight}}constructor(){const t=St;super(),this.id=t(357),this._isDebug=!1,this[t(387)]=!1,this._shadow=this[t(416)]({mode:t(349)}),this[t(417)]=document[t(415)](t(326)),this[t(423)]=document.createElement(t(390)),this[t(369)]=document[t(415)](t(315)),this[t(352)]=document[t(415)](t(331)),this[t(418)]=[],this[t(420)]=null,this[t(355)]=new p,this[t(310)]=new p,this[t(422)]=Math[t(411)](1e3/3),this[t(358)]=0,this[t(426)]=this[t(426)].bind(this),this[t(311)](),this[t(378)](),this[t(413)](),this[t(417)].appendChild(this[t(423)]),this[t(334)].appendChild(this._styleEl),this._shadow[t(333)](this._containerEl),this[t(417)].appendChild(this[t(352)]);const e=this._canvasEl[t(404)]("2d");e?(this._canvasCtx=e,this._drawingUtils=new k(this[t(406)])):(this[t(406)]=null,this._drawingUtils=null)}[St(388)](){}[St(376)](){this[St(374)]()}attributeChangedCallback(t,e,s){const n=St;"debug"===t&&(this[n(322)]=null!==s&&(s===n(379)||""===s),this[n(417)][n(315)][n(343)]=this[n(322)]?n(360):"hidden")}[St(314)](t){const e=St;this[e(423)][e(359)]=()=>{this[e(387)]=!0},this[e(423)][e(308)]=t}[St(346)](t){this[St(366)]=t}[St(400)](t){this._poseLandmarker=t}[St(318)](t){const e=St;this[e(422)]=Math[e(411)](1e3/t)}_settingStyle(){const t=St;this[t(369)][t(347)]=t(332)}_settingContainer(){const t=St;this._containerEl.classList[t(348)](t(424))}[St(413)](){const t=St;this[t(423)].autoplay=!0,this[t(423)].playsInline=!0,this._videoEl.muted=!0}[St(329)](){return this[St(423)]}[St(392)](){const t=St;null===this._loopFrameID&&(this[t(423)][t(403)](),this[t(420)]=window[t(396)](this.predictWebcam))}[St(374)](){const t=St;null!==this[t(420)]&&(window[t(393)](this._loopFrameID),this[t(420)]=null),this[t(423)][t(382)]()}async[St(426)](){const t=St;if(this[t(387)]){const e=performance[t(361)]();if(this._lastTimestamp+this[t(422)]<=e){this._lastTimestamp=e;const s=this[t(366)]?.[t(407)](this[t(423)],e).detections,n=this[t(312)]?.[t(407)](this[t(423)],e)[t(391)];s&&(this[t(322)]&&this[t(313)](s),this._detectionsSub[t(395)](s)),n&&(this[t(322)]&&this[t(385)](n),this[t(310)][t(395)](n))}}this[t(420)]=window.requestAnimationFrame(this.predictWebcam)}[St(313)](t){const e=St;s(t,(t,e)=>{const s=_t,{categories:n,boundingBox:i}=t;if(i){let t=this[s(418)][2*e],r=this._debugElements[2*e+1];(!t||!r)&&(t=document[s(415)](s(326)),t[s(370)][s(348)](s(306)),r=document[s(415)]("p"),r[s(370)][s(348)](s(383)),this[s(417)].append(r,t),this[s(418)].push(t,r)),t[s(315)][s(362)]=s(364),r[s(315)][s(362)]=s(364);const a=100*n[0][s(336)];r.innerText=s(304)+Math.round(a)+" %",r[s(315)][s(305)]=this[s(423)][s(397)]-i[s(401)]-i[s(372)]+"px",r.style[s(425)]=i[s(327)]-30+"px",r[s(315)][s(401)]=i[s(401)]-10+"px",t[s(315)].right=this._videoEl.offsetWidth-i[s(401)]-i.originX+"px",t[s(315)][s(425)]=i[s(327)]+"px",t[s(315)].width=i[s(401)]-10+"px",t[s(315)][s(320)]=i[s(320)]+"px"}});for(let s=2*t.length;s<this[e(418)].length;s++)this[e(418)][s][e(315)][e(362)]=e(337)}[St(385)](t){const e=St;this._canvasCtx&&this[e(328)]&&(this._canvasCtx.save(),this[e(406)].clearRect(0,0,640,480),s(t,(t,s)=>{const n=e;this[n(406)]?.save(),this._drawingUtils?.drawLandmarks(t,{radius:t=>k[n(351)](t[n(373)].z,-.15,.1,5,1),color:this[n(354)][s]}),this[n(328)]?.[n(409)](t,v.POSE_CONNECTIONS,{color:this[n(363)][s],lineWidth:2})}),this[e(406)].restore())}[St(410)](){const t=St;this._detectionsSub[t(345)](),this[t(310)].complete(),this[t(325)]()}}function _t(t,e){t-=304;return vt()[t]}customElements[St(381)](St(375),Ct);const xt=Et;function Dt(){const t=["float32","landmarks","allowed","asObservable","addBufferByInt16","audioManager","volume","state","detections","10048100LGtpCJ","vadManager","camManager","可正常使用","1190100SuRWwt","VAD模組載入失敗","沒有服務","12siIhEs","getVolume","等待授權","addModule","stateObs","loadfail","startCapture","playAudio","init","stream","destroy","872123XiVUzB","stopCapture","缺失該裝置","12vTjZLm","pipe","135012UoiAgH","onDestroy","complete","fatal","已被拒絕","cameraDetection","sampleRate","pcm","next","rejected","getVideoTracks","enabled","subscribe","stopRecord","Worklet模組載入失敗","2564536ybaRNZ","stopSpeech","detectionsSub","landmarksSub","_state","32440YVpwem","stateSub","addBuffer","pcmSub","startRecord","9vMDuOd","videoSize","未獲得媒體裝置權限","padding","numberOfChannels","stopAudio","buffer","408344cVDzXc","audioWorklet","length","audioCtx"];return(Dt=function(){return t})()}function Et(t,e){t-=253;return Dt()[t]}var Rt;!function(){const t=Et,e=Dt();for(;;)try{if(165091===parseInt(t(307))/1+-parseInt(t(259))/2*(parseInt(t(305))/3)+-parseInt(t(271))/4+-parseInt(t(288))/5+parseInt(t(291))/6*(-parseInt(t(302))/7)+parseInt(t(254))/8*(-parseInt(t(264))/9)+parseInt(t(284))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(t){const e=Et;t[t.padding=0]=e(267),t[t[e(316)]=1]=e(316),t[t[e(296)]=2]=e(296),t[t[e(277)]=3]=e(277)}(Rt||(Rt={}));class Ot{stream;[xt(258)];[xt(260)];audioCtx;audioManager;[xt(285)];camManager;[xt(301)];pcmSub;[xt(256)];[xt(257)];get[xt(313)](){const t=xt;return this[t(274)]?this[t(274)][t(313)]:16e3}get[xt(314)](){const t=xt;return this[t(262)][t(278)]()}get[xt(283)](){const t=xt;return this[t(256)][t(278)]()}get[xt(276)](){return this[xt(257)].asObservable()}get[xt(282)](){return this._state}set[xt(282)](t){const e=xt;t!==this[e(258)]&&(this[e(258)]=t,this[e(260)][e(315)](t))}get[xt(295)](){const t=xt;return this[t(260)][t(278)]()}constructor(t){const e=xt;this.stream=t,this[e(260)]=new m(1),this[e(262)]=new p,this[e(301)]=new p,this.detectionsSub=new p,this.landmarksSub=new p,this[e(282)]=Rt.padding}async init(t,e){const s=xt,n=this.stream??await async function(t){const e=ot;try{return await navigator[e(344)][e(338)](t)}catch(t){return null}}({audio:{echoCancellation:!0,noiseSuppression:!0},video:!0});if(null===n)throw this[s(282)]=Rt[s(316)],new Error(x[s(266)]);this[s(300)]=n,this[s(274)]=new AudioContext;try{await this[s(274)][s(272)][s(294)](t)}catch(t){throw X[s(310)](t),this[s(282)]=Rt[s(296)],new Error(x[s(253)])}this[s(282)]=Rt[s(277)],this[s(280)]=new It(this[s(274)]),this[s(285)]=new gt(n,this[s(274)],e),this[s(285)][s(314)][s(306)](l(this[s(301)])).subscribe(t=>{this.pcmSub.next(t)});const i=new kt(e?.[s(312)]);i[s(283)][s(306)](l(this[s(301)]))[s(319)](t=>{const e=s,{width:n,height:r}=i[e(265)];this[e(256)][e(315)]({detections:t,clientWidth:n,clientHeight:r})}),i[s(276)].pipe(l(this[s(301)])).subscribe(t=>{const e=s;this.landmarksSub[e(315)](t)}),i[s(299)](n),this[s(286)]=i}addAudioQueue(e){const s=xt,n=t(e,s(270),void 0),i=t(e,s(275),void 0),r=t(e,"int16",void 0),a=t(e,s(268),void 0);n?this[s(280)]?.[s(261)](n):i?this.audioManager?.addBufferByFloat32(i,a):r&&this.audioManager?.[s(279)](r,a)}[xt(298)](){const t=xt;this[t(280)]?.startSpeech()}[xt(269)](){const t=xt;this[t(280)]?.[t(255)]()}[xt(263)](){const t=xt;this[t(285)]?.startRecord()}stopRecord(){const t=xt;this[t(285)]?.[t(320)]()}setVolume(t){const e=xt;this[e(280)]&&(this[e(280)][e(281)]=t)}[xt(292)](){const t=xt;return this[t(280)]?this[t(280)].volume:0}startCapture(){const t=xt;this[t(286)]?.[t(297)]()}[xt(303)](){const t=xt;this[t(286)]?.[t(303)]()}getInfo(){const t=xt;switch(this[t(282)]){case Rt[t(267)]:return{mic:R[t(293)],camera:R[t(293)]};case Rt.rejected:return{mic:R["已被拒絕"],camera:R[t(311)]};case Rt[t(296)]:return{mic:R[t(289)],camera:R[t(289)]};case Rt.allowed:if(this[t(300)]){const{hasAudio:e,hasVideo:s}=function(t){const e=Et,s=t.getAudioTracks(),n=s[e(273)]>0&&o(s,t=>t.enabled),i=t[e(317)]();return{hasAudio:n,hasVideo:i[e(273)]>0&&o(i,t=>t[e(318)])}}(this[t(300)]);return{mic:e?R[t(287)]:R[t(304)],camera:s?R[t(287)]:R[t(304)]}}return{mic:R[t(290)],camera:R[t(290)]}}}[xt(308)](){const t=xt;this[t(286)]?.[t(308)](),this.audioCtx?.close(),this[t(301)][t(315)](),this[t(301)][t(309)]()}}function At(){var t=["3VCNAgv","2624280qncviz","8050294dqxdrd","4567604dnGsJo","153787GYAADE","2874100PTPcCG","2012877InjYkX","8PAZGFl","10437400GcCOMy","10XZSsTD"];return(At=function(){return t})()}function Tt(t,e){return t-=306,At()[t]}function Mt(t,e){t-=124;return jt()[t]}!function(){for(var t=Tt,e=At();;)try{if(584963===-parseInt(t(306))/1*(-parseInt(t(311))/2)+parseInt(t(312))/3*(-parseInt(t(315))/4)+-parseInt(t(307))/5+-parseInt(t(313))/6+parseInt(t(314))/7*(parseInt(t(309))/8)+-parseInt(t(308))/9+parseInt(t(310))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const Nt=Mt;function jt(){const t=["clear","94324RKYTCt","4sReTnG","12BuzbgT","11396473QvdDNq","2915590zVKIKZ","8HPmAWD","8928030bQOONK","5936iQOKrM","removeItemSync","4248711NWRNfX","4437981gitbug","setItemSync","browser","32agOPHj","removeItem","setItem","getItem","clearSync","getItemSync"];return(jt=function(){return t})()}!function(){const t=Mt,e=jt();for(;;)try{if(908466===parseInt(t(135))/1*(parseInt(t(128))/2)+parseInt(t(124))/3*(-parseInt(t(136))/4)+parseInt(t(139))/5*(parseInt(t(137))/6)+-parseInt(t(142))/7+parseInt(t(140))/8*(-parseInt(t(125))/9)+-parseInt(t(141))/10+parseInt(t(138))/11)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();Nt(131),Nt(130),Nt(129),Nt(134),Nt(133),Nt(126),Nt(143),Nt(132);function Pt(){var t=["961611TyEAQc","736308LCtCyy","366595UnDpJt","2NNSiTq","4365882OVyXqA","1166hcvlJG","91908YTKDbN","1477AsVrPn","223390hpnipr","13576agaWkj","108vyAjpe"];return(Pt=function(){return t})()}function Vt(t,e){return t-=238,Pt()[t]}function Bt(t,e){t-=160;return Wt()[t]}!function(){for(var t=Vt,e=Pt();;)try{if(793600===-parseInt(t(247))/1*(parseInt(t(239))/2)+-parseInt(t(242))/3*(parseInt(t(246))/4)+-parseInt(t(238))/5+parseInt(t(240))/6+-parseInt(t(243))/7*(parseInt(t(245))/8)+-parseInt(t(248))/9+parseInt(t(244))/10*(parseInt(t(241))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const qt=Bt;!function(){const t=Bt,e=Wt();for(;;)try{if(165260===-parseInt(t(218))/1*(-parseInt(t(226))/2)+-parseInt(t(245))/3+parseInt(t(248))/4*(-parseInt(t(194))/5)+parseInt(t(179))/6*(parseInt(t(237))/7)+parseInt(t(163))/8+parseInt(t(205))/9+parseInt(t(234))/10*(parseInt(t(235))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class Gt{[qt(243)];[qt(231)];[qt(220)];destroySub;[qt(198)];layoutSub;[qt(167)];[qt(211)];sampleRateOfWhisper;stateSub;[qt(225)];[qt(169)];[qt(232)];[qt(221)];_lastProjects;[qt(168)];[qt(254)];[qt(201)];get[qt(202)](){const t=qt;return this.stateSub[t(216)]()}get currentState(){return this[qt(225)]}get[qt(256)](){return this[qt(184)].asObservable()}get projects(){const t=qt;return this[t(198)][t(216)]()}get lastProjects(){return c(this[qt(172)])}get[qt(253)](){const t=qt;return this[t(167)][t(216)]()}get userSubtitle(){const t=qt;return this[t(211)][t(216)]()}get guest(){const t=qt;return this[t(168)][t(216)]()}get[qt(165)](){return this[qt(254)]}set volume(t){this.media.setVolume(t)}get[qt(266)](){const t=qt;return this[t(231)][t(204)]()}constructor(t,e){const s=qt;this[s(243)]=t,this[s(231)]=e,this[s(184)]=new p,this.projectsSub=new m(1),this[s(181)]=new p,this[s(167)]=new p,this[s(211)]=new p,this[s(232)]=new p,this[s(221)]=new p,this.stateSub=new I(s(259)),this[s(257)]={input:t[s(255)],output:16e3},this[s(169)]=!1,this[s(172)]=[],this[s(168)]=new m(1),this._hasGuest=!1,this[s(201)]=!1,this.chat=new rt(t),X.code(L["指定依賴已完成"],s(220)),this[s(174)]=this[s(210)],this[s(258)]=this[s(258)].bind(this);const{userDelayTime:o,aiiaDelayTime:c}=t[s(189)];!isNaN(c)&&this[s(232)].pipe(b(c),l(this.destroySub))[s(170)](()=>{const t=s;this[t(167)][t(242)]("")}),!isNaN(o)&&this[s(221)][s(197)](b(o),l(this[s(181)])).subscribe(()=>{const t=s;this[t(211)][t(242)]("")}),this[s(182)][s(197)](l(this[s(181)])).subscribe(t=>{this[s(225)]=t}),this.projectsSub.pipe(l(this[s(181)]))[s(170)](t=>{this[s(172)]=t}),this[s(168)][s(197)](l(this[s(181)]))[s(170)](t=>{this._hasGuest=t}),g([this[s(182)],this[s(231)][s(190)]])[s(197)](l(this.destroySub))[s(170)](([t,e])=>{const n=s;if(e===Rt.allowed)switch(t){case"InServiceNoMedia":this[n(231)][n(228)](),this[n(231)].startRecord(),this[n(182)].next(n(206));break;case n(206):break;default:this[n(231)].stopCapture(),this[n(231)][n(236)]()}});const h=(u=this[s(243)][s(195)][s(160)],function(t,e){const s=$,{width:o,height:c}=e,h=n(t,t=>{const e=$;return 100*(t[e(122)][0]?.[e(123)]??0)>=u}),p=i(r(h,t=>{const e=$;if(void 0!==t[e(126)]){const s=t[e(126)],n=s.width*s.height,i=t[e(122)][0]?.[e(123)]??0;return{...s,area:n,score:100*i,clientWidth:o,clientHeight:c}}return null}));return a(p,[s(120),s(123)])[0]??null});var u;this.media[s(264)].pipe(l(this[s(181)])).subscribe(t=>{const e=s;this.chat.sendToCloud({request:e(265),command:"pcm",content:dt(t)})}),this[s(231)][s(229)].pipe(l(this[s(181)]))[s(170)](({detections:t,clientHeight:e,clientWidth:n})=>{const i=s;this[i(220)][i(192)]("face",h(t,{width:n,height:e}))}),this[s(231)].landmarks[s(197)](l(this[s(181)]))[s(170)](t=>{const e=s;this[e(220)][e(222)]({request:e(178),content:t})})}start(){const t=qt;this[t(201)]?X.code(L["已啟動SDK"]):(this[t(201)]=!0,this.chat[t(261)][t(197)](l(this[t(181)])).subscribe(({event:e,data:s})=>{const n=t;switch(e){case n(191):r(s,this[n(258)]);break;case"list":{const{id:t,name:e,specific:i}=this[n(243)][n(161)];let r=null;if(i&&void 0!==t)r=t;else{const i=h(s,s=>s[n(262)]===e||s.id===t);i&&(r=i.id)}null!==r?this[n(166)](r):null===s?(this[n(182)].next("CloseService"),X[n(246)](n(263))):(this[n(198)][n(242)](s),this[n(182)].next(n(186)),X.code(L["請訂閱專案列表"]));break}case n(207):switch(s){case n(241):X[n(246)](n(224));case n(174):case"no_permissions":this[n(182)].next("CloseService");break;case n(196):this.stateSub[n(242)](n(175));case n(252):}break;case n(171):{const t=this.media[n(209)]();this[n(220)][n(192)](n(171),t);break}}}),this[t(220)][t(217)](),this.stateSub.next(t(227)),X[t(239)](L[t(260)]))}[qt(174)];[qt(183)](){const t=qt;this[t(220)][t(222)]({request:t(183)})}reset(){const t=qt;this.chat.sendToCloud({request:t(164)})}chooseProject(t){const e=qt;this[e(220)][e(192)](e(176),t),this[e(182)].next(e(227))}mute(){const t=qt;this[t(169)]=!0,this.media.stopAudio(),this.media[t(236)]()}unmute(){const t=qt;this.isMuteAiia=!1,this[t(231)][t(213)]()}[qt(258)](e){const s=qt;switch(e.signal){case s(256):this[s(184)][s(242)](e[s(208)]);break;case s(265):if("sampleRate"===e.command)this[s(257)].output=e.content;else switch(e[s(212)]){case s(264):if(!this.isMuteAiia){const t=function(t,e,s){const n=ot;if(e===s)return t;const i=s/e,r=Math[n(339)](t.length*i),a=new Float32Array(r);for(let e=0;e<r;e++){const s=e/i,r=Math.floor(s),o=s-r,c=t[r],h=t[Math[n(342)](r+1,t[n(324)]-1)];a[e]=c+(h-c)*o}return a}(pt(new Int16Array(e.content)),this[s(257)].output,this.media[s(199)]);this[s(231)][s(251)]({float32:t}),this.media.playAudio()}break;case"interrupted":this[s(231)][s(173)](),this.aiiaSubtitleSub[s(242)]("")}break;case"status":t(e,s(208))===s(180)&&this[s(214)]();break;case"agent":if(!this.isMuteAiia){const n=t(e,s(249));void 0!==n&&(this[s(167)][s(242)](n),this[s(232)][s(242)]())}break;case s(238):if(!this[s(169)]&&t(e,s(250))===s(188)){const n=t(e,"content.function_result.result");void 0!==n&&(this.userSubtitleSub.next(n),this[s(221)].next())}break;case"cv":{const n=t(e,s(215));n===s(193)?this[s(168)].next(!0):"user leave"===n?this[s(168)].next(!1):X[s(230)](s(223),t(e,"content"));break}case s(247):case s(200):case"transcribe":case s(240):default:X[s(219)](e[s(244)])}}proxyIsStable(){const t=qt;this[t(220)][t(222)]({request:t(265),command:t(199),content:this[t(257)].input}),this[t(231)].state===Rt[t(177)]?(this.media[t(213)](),this[t(231)].startCapture(),this[t(182)].next(t(206)),X[t(239)](L[t(187)])):(this[t(182)][t(242)]("InServiceNoMedia"),X[t(239)](L[t(185)])),this[t(184)].next({type:"resetLayout"})}[qt(210)](){const t=qt;this[t(220)][t(210)](),this[t(231)][t(210)](),this[t(181)][t(242)](),this[t(181)][t(233)](),this[t(182)].next(t(203)),this[t(182)].complete(),X[t(239)](L[t(162)])}}function Wt(){const t=["getInfo","onDestroy","userSubtitleSub","command","startRecord","proxyIsStable","content.status","asObservable","start","1LdKktu","debug","chat","userSubtitleClearSub","sendToCloud","Unexpect value","Please check network status","_currentState","207356MLtefT","ConnectingCloud","startCapture","detections","warn","media","aiiaSubtitleClearSub","complete","422690UVcfWB","11cYRTRM","stopRecord","638463Blgfoj","asr","code","response","net_error","next","config","signal","241740iUUWrM","error","tts","20XCJqsp","content.function_result.response","content.function_type","addAudioQueue","open","aiiaSubtitle","_hasGuest","llmSampleRate","layout","sampleRateOfWhisper","behavior","NotStart","啟動SDK","message","name","No project ready or lose network","pcm","audio","volume","confidence","project","結束SDK","1688080KgxKMZ","reset","hasGuest","chooseProject","aiiaSubtitleSub","guestSub","isMuteAiia","subscribe","monitor","_lastProjects","stopAudio","close","ReconnectingCloud","uuid","allowed","pose_detect","12ZPZACE","Connected","destroySub","stateSub","skip","layoutSub","未取得媒體裝置權限,請重新設定或忽略此訊息","WaitingProjectID","通道、雲端服務、麥克風都已就緒","ASR","autoClearSubtitle","stateObs","cloud","send","user present","302300pbXMfZ","detection","reconnect","pipe","projectsSub","sampleRate","mic","isStart","state","Destroy","getVolume","78885rSGMtI","InService","channel","content"];return(Wt=function(){return t})()}function Ht(){const t=["sdk","6883920fbZiVu","4UnakHb","config","22360000MVVyAO","1773906GnbfkK","指定依賴已完成","init","4697495xFAIgm","debug","3JmdvLC","環境錯誤(browser)","701924UkUrae","1374831UMhJOC","1355872QFjMqs","初始化必要依賴","7YgShki","code"];return(Ht=function(){return t})()}function Kt(t,e){t-=420;return Ht()[t]}function Ut(s){const n=Kt;if(G){(function(t){const e=z,{info:s,error:n,warn:i,debug:r,fatal:a,code:o}=function(t){const e=Z;if(void 0===t||t===e(502))return{code:!0,error:!0,warn:!0,info:!0,debug:!0,fatal:!0};if(t===e(543))return{error:!1,code:!1,warn:!1,info:!1,debug:!1,fatal:!1};if(typeof t===e(514))return{code:t,error:t,warn:t,info:t,debug:t,fatal:t};{const s=new Set(t);return{code:s[e(499)](e(504)),debug:s[e(499)](e(544)),fatal:s[e(499)](e(526)),error:s[e(499)](e(528)),warn:s[e(499)](e(519)),info:s.has(e(516))}}}(t);!o&&(Q.code=()=>{}),!r&&(Q[e(544)]=()=>{}),!s&&(Q[e(516)]=()=>{}),!i&&(Q[e(519)]=()=>{}),!n&&(Q[e(528)]=()=>{}),!a&&(Q[e(526)]=()=>{})})(t(s,n(437),!0)),X.code(L[n(425)]);const i=new U(e({},s));X[n(427)](L[n(434)],n(431));const r=new Ot(i.mediaStream);X[n(427)](L[n(434)],"config");const a=new Gt(i,r);return X[n(427)](L[n(434)],n(428)),""!==i.worklet_url&&r[n(435)](i.worklet_url,i),a}throw new Error(x[n(421)])}!function(){const t=Kt,e=Ht();for(;;)try{if(634646===parseInt(t(420))/1*(parseInt(t(422))/2)+-parseInt(t(433))/3*(parseInt(t(430))/4)+parseInt(t(436))/5+parseInt(t(429))/6+parseInt(t(426))/7*(parseInt(t(424))/8)+parseInt(t(423))/9+-parseInt(t(432))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();export{Ut as initSdk};
package/dist/node.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("lodash-es"),t=require("moment"),s=require("mathjs"),r=require("socket.io"),o=require("rxjs"),n=require("axios"),i=require("ws"),a=require("fs"),c=require("os"),h=require("path"),l=require("node-osc"),u=require("child_process"),d=require("systeminformation"),p=require("@nut-tree-fork/nut-js"),f=require("readline"),g=require("net");function y(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(s){if("default"!==s){var r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:function(){return e[s]}})}}),t.default=e,Object.freeze(t)}var m,b=y(f);!function(e){e["網絡錯誤"]="ERROR CODE: 500",e["環境錯誤(browser)"]="ERROR CODE: 1001",e["Worklet模組載入失敗"]="ERROR CODE: 1002",e["未獲得媒體裝置權限"]="ERROR CODE: 1003",e["實例已摧毀"]="ERROR CODE: 1004",e["環境錯誤(nodejs)"]="ERROR CODE: 2001",e["未提供憑證"]="ERROR CODE: 2002",e["獲取權杖失敗"]="ERROR CODE: 2003",e["沒有可用專案"]="ERROR CODE: 2004",e["重複初始化"]="ERROR CODE: 2005"}(m||(m={}));const S="access_token",_="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node;function w(e){return new Promise(t=>{setTimeout(t,e)})}class E{config;get webserver(){return this.safeRead("webserver")}get environment(){const e=this.safeRead("env");return"string"==typeof e?e:"developement"}get license(){return this.safeRead("license")??""}get port(){return function(e,t){const s="number"==typeof t?t:NaN;if(e){const t=Number(e);return isNaN(t)?s:t}return s}(process.env.PORT,this.safeRead("port")??3e3)}get ws_url(){const e=this.safeRead("ws_url");return"string"==typeof e?e:""}get worklet_url(){const e=this.safeRead("worklet_url");return"string"==typeof e?e:""}get project(){const t=this.safeRead("project");if(void 0===t)return{specific:!1};if("string"==typeof t)return{name:t,id:t,specific:!1};{const s=e.get(t,"id",void 0),r=e.get(t,"name",void 0);return{id:"string"==typeof s?s:void 0,name:"string"==typeof r?r:void 0,specific:!0}}}get endPoint(){let e="dev";switch(this.environment){case"production":e="prod";break;case"test":e="test"}const t=`graphen-agentic-workflow-${e}-21193779403.asia-east1.run.app`;return{api:`https://${t}`,socket:`wss://${t}`}}get debug(){return this.safeRead("debug")??!0}get mediaStream(){return this.safeRead("mediaStream")}get chunkTimeInSeconds(){const e=this.safeRead("chunkTimeInSeconds");return"number"==typeof e&&e>0?e:.3}get llmSampleRate(){const e=this.safeRead("llmSampleRate");return"number"==typeof e&&e>0?e:16e3}get detection(){return e.assign({perSecond:3,confidence:80},this.safeRead("faceDetection"),this.safeRead("cameraDetection"))}get autoClearSubtitle(){const e=this.safeRead("autoClearUserSubtitle"),t=this.safeRead("autoClearAiiaSubtitle");return{userDelayTime:"number"==typeof e?e:5e3,aiiaDelayTime:"number"==typeof t?t:NaN}}get eyeTrackEnable(){return Boolean(this.safeRead("eyeTrackEnable"))}get eyeTrackCorrection(){return e.assign({x_axis_px:0,y_axis_px:0},this.safeRead("correction"))}constructor(e){this.config=e}safeRead(t){return e.get(this.config,t,void 0)}}var k;!function(e){e["通道、雲端服務、麥克風都已就緒"]="CODE: 1000",e["未取得媒體裝置權限,請重新設定或忽略此訊息"]="CODE: 1001",e["請訂閱專案列表"]="CODE: 1002",e["初始化必要依賴"]="CODE: 1010",e["指定依賴已完成"]="CODE: 1011",e["啟動SDK"]="CODE: 1012",e["結束SDK"]="CODE: 1013",e["已啟動SDK"]="CODE: 1014",e["安全的關閉連線"]="CODE: 2000",e["無副作用的關閉連線"]="CODE: 2001",e["與雲端的服務中斷"]="CODE: 2002",e["沒有授權,請聯繫Graphen"]="CODE: 2003",e["自動重新連線雲端服務"]="CODE: 2004",e["未預期的斷線,請聯繫Graphen"]="CODE: 2005",e["開始初始化必要模組"]="CODE: 2010",e["指定模組初始化完成"]="CODE: 2011",e["啟動服務"]="CODE: 2012",e["服務結束"]="CODE: 2013"}(k||(k={}));const D={code:console.log,debug:console.log,info:console.log,warn:console.warn,error:console.error,fatal:console.error},O=[];function N(e){return O.push(e),N}const R=new Proxy(D,{get(s,r,o){if("string"==typeof r)switch(r){case"debug":case"info":case"error":case"warn":case"fatal":case"code":return(...o)=>{const n=t().format("yyyy-MM-DD[T]HH:mm:ss:sss");e.forEach(O,e=>{e.next(r,n,...o)}),s[r](`[Aiia::${r}_${n}_]`,...o)};default:return}},set:(e,t,s,r)=>!0});class C{config;server;memberSub;get port(){return this.config.port}get webserver(){return this.config.webserver}get memberChange(){return this.memberSub.asObservable()}constructor(e){this.config=e,this.memberSub=new o.Subject}start(){if(this.server=new r.Server(this.webserver,{cors:{origin:"*"}}),this.server.on("connection",e=>{R.debug("client on",e.id),this.memberSub.next({type:"in",socket:e}),e.on("disconnect",t=>{R.debug("client off",e.id,"reason",t),this.memberSub.next({type:"out",socket:e})})}),void 0===this.webserver){const e=this.port;this.server.listen(e),R.info("Websocket server run on",e)}else R.info("Websocket server rely your webserver.")}onDestroy(){this.server&&this.server.close()}}class A{instance;controller;constructor(e){this.controller=new AbortController,this.instance=n.create({baseURL:e,signal:this.controller.signal})}async getAccessToken(t,s){const r=performance.now(),o={license_number:t,token_value:s??""},n=await this.instance.post("/api/v1/license/agent_token",o).then(t=>e.get(t.data,"token_value","")).catch(()=>null);if(R.debug("Complete certification",`Took ${performance.now()-r} milliseconds.`),null===n)throw new Error(m["網絡錯誤"]);if(""===n)throw new Error(m["獲取權杖失敗"]);return n}async getProjectList(t){const s=performance.now(),r=await this.instance.post("/api/v1/license/projects",{license_number:t}).then(t=>e.map(e.get(t,"data.projects",[]),({id:e,sub_project_name:t,avatar:s})=>{const{name:r,url:o}=s;return{avatar:{name:r,url:o},id:e,name:t}})).catch(e=>null);if(R.debug("Got Project List",`Took ${performance.now()-s} milliseconds.`),null===r)throw new Error(m["網絡錯誤"]);if(0===r.length)throw new Error(m["沒有可用專案"]);return r}onDestroy(){this.controller.abort()}}var M;!function(e){e[e.MDN_NORMAL_CLOSURE=1e3]="MDN_NORMAL_CLOSURE",e[e.MDN_GOING_AWAY=1001]="MDN_GOING_AWAY",e[e.MDN_PROTOCOL_ERROR=1002]="MDN_PROTOCOL_ERROR",e[e.MDN_UNSUPPORTED_DATA=1003]="MDN_UNSUPPORTED_DATA",e[e.MDN_RESERVED_1004=1004]="MDN_RESERVED_1004",e[e.MDN_NO_STATUS_RECEIVED=1005]="MDN_NO_STATUS_RECEIVED",e[e.MDN_ABNORMAL_CLOSURE=1006]="MDN_ABNORMAL_CLOSURE",e[e.MDN_INVALID_FRAME_PAYLOAD=1007]="MDN_INVALID_FRAME_PAYLOAD",e[e.MDN_POLICY_VIOLATION=1008]="MDN_POLICY_VIOLATION",e[e.MDN_MESSAGE_TOO_BIG=1009]="MDN_MESSAGE_TOO_BIG",e[e.MDN_MANDATORY_EXTENSION=1010]="MDN_MANDATORY_EXTENSION",e[e.MDN_INTERNAL_ERROR=1011]="MDN_INTERNAL_ERROR",e[e.MDN_SERVICE_RESTART=1012]="MDN_SERVICE_RESTART",e[e.MDN_TRY_AGAIN_LATER=1013]="MDN_TRY_AGAIN_LATER",e[e.MDN_BAD_GATEWAY=1014]="MDN_BAD_GATEWAY",e[e.MDN_TLS_HANDSHAKE=1015]="MDN_TLS_HANDSHAKE",e[e.WHEN_BROWSER_CLOSE=4001]="WHEN_BROWSER_CLOSE",e[e.WS_4100_NORAML_CLOSURE=4100]="WS_4100_NORAML_CLOSURE",e[e.WS_4101_UNAUTHORIZED=4101]="WS_4101_UNAUTHORIZED",e[e.WS_4102_LICENSE_EXPIRED=4102]="WS_4102_LICENSE_EXPIRED",e[e.WS_4103_TOKEN_EXPIRED=4103]="WS_4103_TOKEN_EXPIRED",e[e.WS_4104_LLM_SESSION_ERROR=4104]="WS_4104_LLM_SESSION_ERROR",e[e.WS_4105_TOO_MANY_CONNECTIONS=4105]="WS_4105_TOO_MANY_CONNECTIONS"}(M||(M={}));class P{id;uuid;socket;messageSub;linkStartSub;destorySub;closeSub;isFinished;debugInfo;lastCloseLog;get message(){return this.messageSub.asObservable()}get close(){return this.closeSub.asObservable()}get linkStart(){return this.linkStartSub.asObservable()}get isConnected(){return this.socket?.readyState===i.OPEN}constructor(e){this.id=e,this.messageSub=new o.Subject,this.linkStartSub=new o.Subject,this.closeSub=new o.Subject,this.destorySub=new o.Subject,this.isFinished=!1,this.uuid=crypto.randomUUID(),this.debugInfo=`browser(${this.id}), proxy(${this.uuid})`,R.debug(`create proxy for browser(${this.id})`)}start(e){this.socket=new i(e,{autoPong:!0}),o.fromEvent(this.socket,"open").pipe(o.takeUntil(this.destorySub)).subscribe(()=>{R.code(k["啟動服務"],"proxy",this.debugInfo),this.linkStartSub.next()}),o.fromEvent(this.socket,"message").pipe(o.takeUntil(this.destorySub)).subscribe(e=>{const{data:t}=e;this.messageSub.next(t)}),o.fromEvent(this.socket,"error").pipe(o.takeUntil(this.destorySub)).subscribe(e=>{const{error:t}=e;R.error(this.debugInfo,"Proxy has some problem",t)}),o.fromEvent(this.socket,"close").pipe(o.takeUntil(this.destorySub)).subscribe(e=>{const{code:t,reason:s,type:r,wasClean:o}=e;switch(this.lastCloseLog=`最近一次關閉原因: ${s}, 錯誤碼: ${t}, Type: ${r}`,t){case M.WHEN_BROWSER_CLOSE:R.code(k["無副作用的關閉連線"],this.debugInfo),this.onDestroy();break;case M.MDN_NORMAL_CLOSURE:case M.MDN_GOING_AWAY:this.closeSub.next("close"),R.code(k["安全的關閉連線"],this.debugInfo);break;case M.MDN_NO_STATUS_RECEIVED:case M.MDN_ABNORMAL_CLOSURE:this.closeSub.next("close"),R.code(k["與雲端的服務中斷"],this.debugInfo,{code:t,reason:s,type:r,wasClean:o});break;case M.WS_4100_NORAML_CLOSURE:case M.WS_4103_TOKEN_EXPIRED:case M.WS_4104_LLM_SESSION_ERROR:case M.WS_4105_TOO_MANY_CONNECTIONS:this.closeSub.next("reconnect"),R.code(k["自動重新連線雲端服務"],this.debugInfo,`socket code: ${t}`);break;case M.WS_4101_UNAUTHORIZED:case M.WS_4102_LICENSE_EXPIRED:this.closeSub.next("no_permissions"),R.code(k["沒有授權,請聯繫Graphen"],this.debugInfo,`socket code: ${t}`);break;default:this.closeSub.next("close"),R.code(k["未預期的斷線,請聯繫Graphen"],this.debugInfo,{code:t,reason:s,type:r,wasClean:o})}})}reconnect(e){this.isFinished||(this.destorySub.next(),this.destorySub.complete(),this.destorySub=new o.Subject,this.start(e))}send(e){const s=`currentTime: ${t().format("yyyy-MM-DD[T]HH:mm:ss:sss")}`;this.isConnected?this.socket.send(e,t=>{t&&R.error("send message fail",this.debugInfo,s,e.slice(0,100),t)}):R.warn("The socket is not connected",this.debugInfo,s,e.slice(0,100))}sendToCloud(e){this.send(JSON.stringify(e))}onClose(){if(this.socket)switch(this.socket.readyState){case 0:R.debug("Once the cloud connection is complete, the connection will be disconnected."),this.linkStart.pipe(o.takeUntil(this.destorySub),o.take(1)).subscribe(()=>{this.socket?.close(M.WHEN_BROWSER_CLOSE)});break;case 1:R.debug("Close safely, no side effects"),this.socket.close(M.WHEN_BROWSER_CLOSE);break;case 2:case 3:R.debug("The connection have been lost.")}}getStatusInfo(){const e=(()=>{if(!this.socket)return"雲端服務尚未啟動";{const e=this.socket.readyState;switch(e){case 0:return"正在連線雲端服務中";case 1:return"雲端服務正常運作";case 2:return"正在關閉雲端服務";case 3:return"雲端服務已關閉";default:return`未知的 Websocket 狀態: ${e}`}}})(),t=this.lastCloseLog?`${e}, ${this.lastCloseLog}`:e;return`瀏覽器(${this.id}) - 雲端代理(${this.uuid}), ${t}`}onDestroy(){this.isFinished=!0,this.destorySub.next(),this.destorySub.complete(),R.debug(`Destroy cloud channel(${this.debugInfo})`)}}const T=new class{AppName;platform;isMAC;isWIN;isLINUX;saveFolder;homedir;appFolder;EOL;constructor(e){switch(this.AppName=e,this.platform=process.platform,this.homedir=c.homedir(),this.EOL=c.EOL,this.platform){case"darwin":this.isMAC=!0,this.isWIN=!1,this.isLINUX=!1,this.saveFolder=h.join(this.homedir,"Library","Application Support");break;case"win32":this.isMAC=!1,this.isWIN=!0,this.isLINUX=!1,this.saveFolder=process.env.APPDATA||h.join(this.homedir,"AppData","Roaming");break;case"linux":this.isMAC=!1,this.isWIN=!1,this.isLINUX=!0,this.saveFolder=process.env.XDG_CONFIG_HOME||h.join(this.homedir,".config");break;default:console.log(`當前系統是未知的平台: ${this.platform}`),this.isMAC=!1,this.isWIN=!1,this.isLINUX=!1,this.saveFolder=this.homedir}this.appFolder=h.join(this.saveFolder,this.AppName),this.folderCheck(this.appFolder)}addPath(...e){return h.join(...e)}folderCheck(e){a.mkdirSync(e,{recursive:!0})}createFolder(e){const t=this.addPath(this.appFolder,e);return this.folderCheck(t),t}fileCheck(e,t=""){a.existsSync(e)||a.writeFileSync(e,t,{encoding:"utf8"})}}("aiia-sdk");class v{type="node";filePath;fileName;constructor(){this.fileName="storage.json",this.filePath=T.addPath(T.appFolder,this.fileName),T.fileCheck(this.filePath)}getFileDataSync(){const e=a.readFileSync(this.filePath,"utf8");try{return JSON.parse(e)}catch(e){return{}}}setFileDataSync(e){try{const t=JSON.stringify(e);a.writeFileSync(this.filePath,t,"utf8")}catch(e){}}async getFileData(){return new Promise(e=>{a.readFile(this.filePath,"utf8",(t,s)=>{if(t)e({});else try{e(JSON.parse(s))}catch(t){e({})}})})}async setFileData(e){return new Promise(t=>{try{const s=JSON.stringify(e);a.writeFile(this.filePath,s,"utf8",e=>{t()})}catch(e){}})}async getItem(e){return(await this.getFileData())[e]??null}async setItem(e,t){const s=await this.getFileData();s[e]=t,await this.setFileData(s)}async removeItem(t){const s=await this.getFileData(),r=e.omit(s,t);await this.setFileData(r)}async clear(){await this.setFileData({})}getItemSync(e){return this.getFileDataSync()[e]??null}setItemSync(e,t){const s=this.getFileDataSync();s[e]=t,this.setFileDataSync(s)}removeItemSync(t){const s=e.omit(this.getFileDataSync(),t);this.setFileDataSync(s)}clearSync(){this.setFileDataSync({})}}const x={[k["通道、雲端服務、麥克風都已就緒"]]:"通道、雲端服務、麥克風都已就緒",[k["未取得媒體裝置權限,請重新設定或忽略此訊息"]]:"未取得媒體裝置權限,請重新設定或忽略此訊息",[k["請訂閱專案列表"]]:"請訂閱專案列表",[k["初始化必要依賴"]]:"初始化必要依賴",[k["指定依賴已完成"]]:"指定依賴已完成",[k["啟動SDK"]]:"啟動SDK",[k["結束SDK"]]:"結束SDK",[k["已啟動SDK"]]:"已啟動SDK",[k["安全的關閉連線"]]:"安全的關閉連線",[k["無副作用的關閉連線"]]:"無副作用的關閉連線",[k["與雲端的服務中斷"]]:"與雲端的服務中斷",[k["沒有授權,請聯繫Graphen"]]:"沒有授權,請聯繫Graphen",[k["自動重新連線雲端服務"]]:"自動重新連線雲端服務",[k["未預期的斷線,請聯繫Graphen"]]:"未預期的斷線,請聯繫Graphen",[k["開始初始化必要模組"]]:"開始初始化必要模組",[k["指定模組初始化完成"]]:"指定模組初始化完成",[k["啟動服務"]]:"啟動服務",[k["服務結束"]]:"服務結束",[m["網絡錯誤"]]:"網絡錯誤",[m["環境錯誤(browser)"]]:"環境錯誤",[m["Worklet模組載入失敗"]]:"Worklet模組載入失敗",[m["未獲得媒體裝置權限"]]:"未獲得媒體裝置權限",[m["實例已摧毀"]]:"實例已摧毀",[m["環境錯誤(nodejs)"]]:"nodejs",[m["未提供憑證"]]:"未提供憑證",[m["獲取權杖失敗"]]:"獲取權杖失敗",[m["沒有可用專案"]]:"沒有可用專案",[m["重複初始化"]]:"重複初始化"},I=new RegExp(/^(ERROR )?CODE: [0-9]{3,4}$/);class L{path;constructor(e){this.path=e?T.createFolder(e):T.appFolder}next(e,s,...r){const o=`log_${t().format("yyyy-MM-DD")}.txt`,n=T.addPath(this.path,o),i="code"===e?e=>I.test(e)?`${e}(${x[e]})`:e:e=>e;try{const t=r.reduce((e,t)=>{if(t instanceof Error){let s=`Error[${t.message??"No Message"}]${T.EOL}`;return s+=t.stack??"unknow stack","string"==typeof t.cause&&(s+=`${T.EOL}cause: ${t.cause}`),`${e}${T.EOL}${s}${T.EOL}`}switch(typeof t){case"string":return`${e} ${i(t)}`;case"number":case"bigint":return`${e} ${t.toString()}`;case"boolean":return`${e} ${t?"true":"false"}`;case"object":try{return`${e} ${JSON.stringify(t)}`}catch(t){return e}case"symbol":case"undefined":case"function":return`${e} [${typeof t}]`}},"");a.appendFileSync(n,`LOG(${e})__${s}__::${t}${T.EOL}`,{encoding:"utf8"})}catch(e){}}}const $="127.0.0.1",U={AvatarPort:"9876",ActionPort:"6969",LocationPort:"4060",LookPort:"6745",BackGroundPort:"2400"},W={StreamAudioPort:"8080",CleanAudioPort:"8081"};function F(){return{...U,...W}}class j{clientMap;eyeBallUdp;x_axis_px;y_axis_px;defPortMap;constructor(){this.clientMap=new Map,this.x_axis_px=0,this.y_axis_px=0,this.defPortMap={};const t=e.pick(U,"AvatarPort","ActionPort","LocationPort","BackGroundPort");e.forEach(e.keys(t),e=>{const s=e,r=t[s];this.defPortMap[r]=s})}enableUDPClient(t){e.forEach(e.keys(t),e=>{const s=new l.Client($,t[e]);this.clientMap.set(e,s)})}enableEyeTrack(e){this.eyeBallUdp=new l.Client($,e.port),this.x_axis_px=e.x_axis_px,this.y_axis_px=e.y_axis_px}eyeTrack(t){if(void 0!==this.eyeBallUdp){const r=null!==t,{x:o,y:n}=(()=>{if(r){const{x:r,y:o}=function(t,r){const{maxX:o,maxY:n,minX:i,minY:a}=e.assign({maxX:25,minX:-25,maxY:50,minY:-50},r),c=s.abs(o)+s.abs(i),h=s.abs(n)+s.abs(a),{clientHeight:l,clientWidth:u,originX:d,originY:p,width:f,height:g}=t,y=s.matrix([[c/u,0,i],[0,h/l,a],[0,0,1]]),m=d+f/2,b=l-(p+g/2),S=s.matrix([[m],[b],[1]]),_=s.multiply(y,S);return{x:_.get([0,0]),y:_.get([1,0])}}(t);return{x:this.toFloat(r+this.x_axis_px),y:this.toFloat(o+this.y_axis_px)}}return{x:this.toFloat(7),y:this.toFloat(20)}})();this.eyeBallUdp.send(["/",o,n],e=>{null!=e&&R.error("Eye track error:",e)})}}movement(t){e.map(t,({content:t})=>{const s=e.get(t,"port",""),r=e.get(t,"message"),o=this.defPortMap[s.toString()];this.clientMap.has(o)&&this.clientMap.get(o).send(r,e=>{null!=e&&R.error("Occur error when send message to UE",e)})})}toFloat(t){return e.isInteger(t)?t+1e-5:t}onDestroy(){e.forEach(Array.from(this.clientMap),([e,t])=>{t.close()}),R.info("Close all UnrealEngine's UDP")}}class G{destroy;speechWS;interruptWS;get speechIsConnected(){return this.speechWS?.readyState===i.OPEN}get intrIsConnected(){return this.interruptWS?.readyState===i.OPEN}constructor(){this.destroy=new o.Subject}connectSocket(e){this.speechWS=this.getSocket(e.speech,"speech"),this.interruptWS=this.getSocket(e.interrupt,"interrupt")}getSocket(e,t){const s=new i(`ws://${$}:${e}`);return s.onerror=s=>{const{message:r,error:o,type:n}=s;R.error(`UE Tool(${t}) fail: ${r}`,o,{port:e,type:n})},s.onclose=s=>{const{code:r,reason:o,type:n}=s;R.debug(`UE Tool(${t}) close`,{code:r,reason:o,type:n,port:e})},s}interrupted(){this.intrIsConnected&&this.interruptWS.send("interrupted")}speech(e){if(this.speechIsConnected){const t=Buffer.allocUnsafe(2*e.length);for(let s=0;s<e.length;s++)t.writeInt16LE(e[s],2*s);this.speechWS.send(t)}}onDestroy(){this.speechWS?.close(),this.interruptWS?.close(),this.destroy.next(),this.destroy.complete(),R.info("Close all UnrealEngine's WebSocket")}}class B{config;udpManager;socketManager;movement;eyeTrack;interrupted;speech;constructor(e){this.config=e,this.udpManager=new j,this.socketManager=new G,this.movement=()=>{},this.eyeTrack=()=>{},this.interrupted=()=>{},this.speech=()=>{}}onStart(t){const s={},r=F(),o=e.assign(F(),t);e.forEach(e.keys(r),e=>{const t=o[e],n=Number(t);s[e]=isNaN(n)?Number(r[e]):n});const{StreamAudioPort:n,CleanAudioPort:i,LookPort:a,...c}=s;this.udpManager.enableUDPClient(c),this.socketManager.connectSocket({speech:n,interrupt:i}),this.movement=this.udpManager.movement.bind(this.udpManager),this.eyeTrack=this.udpManager.eyeTrack.bind(this.udpManager),this.interrupted=this.socketManager.interrupted.bind(this.socketManager),this.speech=this.socketManager.speech.bind(this.socketManager),this.config.eyeTrackEnable&&this.udpManager.enableEyeTrack({...this.config.eyeTrackCorrection,port:a})}onDestroy(){this.udpManager.onDestroy(),this.socketManager.onDestroy(),R.info("UE tools destroy")}}async function Y(e){return new Promise(t=>{a.stat(e,e=>{t(e?[!1,e]:[!0])})})}async function H(e,t,...s){return T.isWIN?new Promise(r=>{const o=[`cd ${e} && ${t} `,...s].join(" "),n=u.exec(o);n.once("error",e=>{r([!1,e])}),n.once("spawn",()=>{n.unref(),r([!0])})}):Promise.resolve([!1,new Error("The function isn't implement in this system")])}async function K(){try{return await d.networkConnections()}catch(e){return console.error("檢查 Port 時發生錯誤:",e),[]}}async function X(t){const s=t.toString(),r=await K();return e.some(r,e=>e.localPort===s)}async function q(e){const t=await p.getWindows();let s=null;const r=new RegExp(e.toLocaleLowerCase());for(const e of t){const t=await e.title;if(r.test(t.toLocaleLowerCase())){s=e;break}}return s}function V(e){return[2e3,2e3,2e3,1e3,1e3,2e3,3e3,5e3][e]??[6e3,4e3][e%2]}function J(){if(T.isWIN){const e="UEProject_5_6";return{proc:e,name:`${e}.exe`}}return null}class Z{config;ueConfig;destroySub;constructor(t){this.destroySub=new o.Subject;const s={isKiosk:!1,browserKeeping:!1},{unrealFolder:r,openUrl:n,mode:i,foreground:a,remoteDebug:c}=e.assign({},t);if("string"==typeof r&&""!==r.trim()){s.path=r;const e=J();e&&(this.ueConfig=new z(r,e.proc))}"string"==typeof n&&""!==n.trim()&&(s.url=n),"string"==typeof i&&""!==i.trim()&&(s.isKiosk="kiosk"===i),"string"==typeof a&&""!==a.trim()&&(s.browserKeeping="always"===a),"number"==typeof c&&(s.remoteDebug=c),this.config=s}async exec(){let e=!1,t=await this.isUnrealRunning();t||(this.ueConfig&&await this.ueConfig.getSafePortTable(),t=await this.openUnreal()),t&&(e=await this.isUnrealInService()),e&&await this.openBrowser();return this.ueConfig?await this.ueConfig.getPortTable():F()}async isUnrealRunning(){const t=J();if(null===t)return!1;const{proc:s}=t,r=await async function(...e){const t=e.length>0?e.join(", "):"*";return await d.processLoad(t).catch(()=>[])}(s);if(r.length<=0)return!1;const o=s.toLocaleLowerCase(),n=e.find(r,e=>e.proc.toLocaleLowerCase()===o);return!!(n&&"number"==typeof n.pid&&n.pids.length>=2)}async isUnrealInService(e=12){let t=!1,s=0;const{StreamAudioPort:r}=this.ueConfig?await this.ueConfig.getPortTable():F();for(;!t&&s<e;)t=await X(r),await w(V(s)),s++;return t}async openUnreal(){const e=J();if(null===e)return!1;const{path:t}=this.config;if(void 0===t)return!1;const s=T.addPath(t,e.name),[r,o]=await Y(s);if(!r)return R.error(o),!1;const[n,i]=await async function(e,...t){return T.isWIN?new Promise(s=>{const r=u.spawn(e,t,{detached:!0,stdio:"ignore"});r.once("error",e=>{s([!1,e])}),r.once("spawn",()=>{r.unref(),s([!0])})}):Promise.resolve([!1,new Error("The function isn't implement in this system")])}(s);return i&&R.error(i),n}async openBrowser(){const{url:e,isKiosk:t,remoteDebug:s}=this.config;if(void 0===e)return!1;const r=T.isWIN?{edge:["C:/Program Files (x86)/Microsoft/Edge/Application","msedge.exe"],chrome:["C:/Program Files/Google/Chrome/Application","chrome.exe"],chrome2:[`${T.homedir}/AppData/Local/Google/Chrome/Application`,"chrome.exe"]}:null;if(null===r)return!1;const{proc:o}=J(),{chrome:n,chrome2:i,edge:a}=r,[[c],[h],[l]]=await Promise.all([Y(T.addPath(...n)),Y(T.addPath(...a)),Y(T.addPath(...i))]);if(c||l){const r=[];if(t&&(r.push("--kiosk"),r.push(`--auto-select-desktop-capture-source="${o}"`)),void 0!==s){r.push(`--remote-debugging-port=${s}`);const e=T.createFolder("google");r.push(`--user-data-dir=${e}`)}r.push(e);const[a,h]=c?n:i,[l,u]=await H(a,h,...r);return l?(this.setAppInForeground("chrome"),!0):(R.error(u),!1)}if(h){const r=[];if(t&&(r.push("--kiosk"),r.push(`--auto-select-desktop-capture-source="${o}"`)),void 0!==s){r.push(`--remote-debugging-port=${s}`);const e=T.createFolder("edge");r.push(`--user-data-dir=${e}`)}r.push(e);const[n,i]=a,[c,h]=await H(n,i,...r);return c?(this.setAppInForeground("edge"),!0):(R.error(h),!1)}return R.info("Can't find browser"),!1}async setAppInForeground(e){await w(3e3);const t=await q(e);t?.focus(),this.config.browserKeeping&&o.interval(1e4).pipe(o.takeUntil(this.destroySub)).subscribe(()=>{q(e).then(e=>{e?.focus()})})}async getStateInfo(){const e=await this.isUnrealRunning();return{isOpen:e,isReady:!!e&&await this.isUnrealInService(1)}}onDestroy(){this.destroySub.next(),this.destroySub.complete()}}class z{folder;file;constructor(e,t){this.folder=T.addPath(e,t,"config"),this.file=T.addPath(this.folder,"config.json"),T.folderCheck(this.folder),T.fileCheck(this.file,JSON.stringify(F()))}async getSafePortTable(){const t=F(),s=await K(),r=await async function(t,s){const r=s??await K(),o={};return e.forEach(e.keys(t),s=>{const n=e.some(r,({localPort:e})=>e===t[s]);o[s]=n}),o}(t,s);if(e.some(e.values(r),e=>e)){const o=new Set(e.filter(e.map(s,e=>Number(e.localPort)),e=>!isNaN(e)));e.forEach(e.keys(r),e=>{const s=e;if(r[s]){const e=Number(t[s]);let r=1,n=NaN;for(;isNaN(n)&&r<=200;){const t=e+r;o.has(t)?r++:(o.add(t),n=t)}isNaN(n)||(t[s]=n.toString())}})}await this.setPortTable(t)}getPortTable(){return new Promise(e=>{a.readFile(this.file,"utf8",(t,s)=>{if(t)e(F());else try{e(JSON.parse(s))}catch(t){e(F())}})})}async setPortTable(e){try{const t=JSON.stringify(e);await new Promise(e=>{a.writeFile(this.file,t,"utf8",t=>{e()})})}catch(e){}}}function Q(...e){switch(e[0]){case"--status":return"服務狀態確認\n 用法: status [額外參數]\n 範例:\n status\n";case"--log":return"日誌讀取(無參數時,會返回可用日誌)\n 用法: log [額外參數]\n\n 範例:\n log --y\n log --yesterday\n log --specific=2025-11-28\n 可用參數:\n today : 讀取今天的日誌\n t : 讀取今天的日誌\n yesterday : 讀取昨天的日誌\n y : 讀取昨天的日誌\n specific=<yyyy-MM-dd> : 讀取指定日期的日誌\n s=<yyyy-MM-dd> : 讀取指定日期的日誌\n";case"--exit":case"--close":return"安全離開\n 用法 1: exit\n 用法 2: close\n";default:return"用法: [可用指令] [額外參數]\n 範例:\n help\n help --log\n 可用指令列表:\n help : 獲得可用的指令,使用 [--可用指令] 獲得該指令的詳細說明。\n status : 顯示當前的服務狀態\n log : 讀取今天的日誌\n exit : 關閉連線\n close : exit 的別稱,關閉連線\n"}}function ee(e){return async(...t)=>{const{core:s,channel:r}=e.getStatusInfo(),o=r.reduce((e,t,s)=>e+` channel ${s+1} - ${t}\n`,"\n");let n=`服務狀態\n 核心狀態 : ${s}\n 通道列表 : ${0===r.length?"無服務通道":o}\n`;if(e.automaion){const{isOpen:t,isReady:s}=await e.automaion.getStateInfo();n+=" Unreal : ",n+=t?s?"已啟動,服務已就緒":"已啟動,但服務未就緒":"尚未啟動",n+="\n"}return n}}function te(...e){const s=e[0];if(!s)return new Promise(e=>{a.readdir(T.appFolder,(t,s)=>{e(t?"沒有可用日誌":s.filter(e=>e.endsWith(".txt")).join("\n"))})});{let e=null;switch(s){case"--today":case"--t":e=t();break;case"--yesterday":case"--y":e=t().add(-1);break;default:{const r=new RegExp(/^--(specific|s)=([0-9]{4}-[0-9]{1,2}-[0-9]{1,2})$/),o=s.match(r);if(o){const[s,r,n]=o[2].split("-");e=t(`${s}-${r.padStart(2,"0")}-${n.padStart(2,"0")}`);break}return"請使用 -- 開始,或使用 help --log 查看幫助"}}if(!e.isValid())return"指定了無效的日期,請再次確認";{const t=`log_${e.format("yyyy-MM-DD")}.txt`,s=T.addPath(T.appFolder,t);try{return a.readFileSync(s,"utf8")}catch(e){return"找不到日誌"}}}}class se{server;constructor(t,s){const r=function(e){return e?{help:Q,status:ee(e),log:te}:{}}(s),{port:o,host:n}=t;this.server=g.createServer(t=>{console.log(`⚙️ 新的連線來自: ${t.remoteAddress}`);const s=b.createInterface({input:t,output:t,prompt:"Aiia Admin > "});t.setEncoding("utf8"),t.write("歡迎使用Aiia Admin!\n"),t.write("使用 `help` 獲得幫助\n"),s.prompt(),s.on("line",async o=>{const[n,...i]=o.trim().split(/\s/),a=n.toLocaleLowerCase();if("exit"===a||"close"===a)t.write("👋 切斷連線...\n"),t.end();else{const o=e.get(r,a,null);if(o){const e=await o(...i);t.write("\n"+e+"\n")}else t.write(`"${n}"是無效的指令.\n`);s.prompt()}}),t.on("end",()=>{console.log(`⚙️ 切斷連線: ${t.remoteAddress}`)})}),this.server.listen(o,n,()=>{console.log(`連線指令: telnet 127.0.0.1 ${o}`)})}onDestroy(){this.server.close()}}class re{config;stroage;expiment;apiProxy;chat;ueTools;automaion;state;browserSocketMap;destorySub;access_token;timestamp;socketAddr;get accessToken(){return this.access_token}constructor(e,t,s){this.config=e,this.stroage=t,this.expiment=s,this.state=0,this.destorySub=new o.Subject,this.browserSocketMap=new Map,this.timestamp=0,this.access_token=t.getItemSync(S);const{api:r,socket:n}=e.endPoint;this.socketAddr=n,this.apiProxy=new A(r),R.code(k["指定模組初始化完成"],"api"),this.chat=new C(e),R.code(k["指定模組初始化完成"],"chat"),this.ueTools=new B(e),R.code(k["指定模組初始化完成"],"udp tools"),this.openChannel=this.openChannel.bind(this),this.initService()}async start(){if(this.state>=1)throw new Error(m["重複初始化"]);this.state=1,await this.replaceAccessToken(),this.chat.memberChange.pipe(o.takeUntil(this.destorySub)).subscribe(({type:t,socket:s})=>{const r=s;switch(t){case"in":{const t=new P(s.id),i=new o.Subject;r.__cloudProxy=t;const a=(n=s.handshake.query.uuid,e.isArray(n)?e.get(n,"[0]",void 0):n??void 0);void 0===a?(this.getProjectList().then(e=>{s.emit("list",e)}).catch(e=>{R.error(e),s.emit("list",null)}),o.fromEvent(s,"uuid").pipe(o.take(1),o.takeUntil(i)).subscribe(e=>{this.openChannel(e,r,t,i)})):this.openChannel(a,r,t,i),this.browserSocketMap.set(r,i);break}case"out":if(this.browserSocketMap.has(r)){const e=this.browserSocketMap.get(r);e.next(),e.complete(),this.browserSocketMap.delete(r)}}var n}),this.chat.start(),R.code(k["啟動服務"],"chat");const{interaction:t}=e.assign({},this.expiment);if(void 0!==t&&"number"==typeof t.port){const{port:e,host:s}=t,r=new se({port:e,host:s},this);this.destorySub.subscribe(()=>{r.onDestroy()})}}initService(){const{automaion:t}=e.assign({},this.expiment);if(void 0!==t){const e=new Z(t);e.exec().then(e=>{this.ueTools.onStart(e)}),this.destorySub.subscribe(()=>{e.onDestroy()}),this.automaion=e}else this.ueTools.onStart();o.interval(18e4).pipe(o.takeUntil(this.destorySub)).subscribe(()=>{this.inspectClientSocket()})}async replaceAccessToken(){try{const e=await this.apiProxy.getAccessToken(this.config.license,this.access_token),s=this.access_token;this.access_token=e,this.timestamp=0,this.stroage.setItemSync(S,e),this.stroage.setItemSync(t().format("yyyy-MM-DD[T]HH:mm:ss:sss"),s)}catch(e){throw R.error(e),e}}async getProjectList(){try{return await this.apiProxy.getProjectList(this.config.license)}catch(e){throw R.error(e),e}}async getProxySocketURL(e){const t=Date.now()-this.timestamp;return t<5e3&&await w(5100-t),this.timestamp=Date.now(),`${this.socketAddr}/v1/chat/project/${this.accessToken}/${e}`}async openChannel(t,s,r,n){o.fromEvent(s,"cloud").pipe(o.takeUntil(n)).subscribe(e=>{r.sendToCloud(e)}),o.fromEvent(s,"face").pipe(o.takeUntil(n)).subscribe(e=>{const t=e,s=null!==t;this.ueTools.eyeTrack(t),r.sendToCloud({request:"face_detect",content:s})}),r.message.pipe(o.takeUntil(n)).subscribe(t=>{const r=function(t){try{const s=JSON.parse(t);return e.get(s,"signal")?[s]:e.isArray(s)?s:e.values(s)}catch(e){return R.error("message transfer fail",e),[]}}(t),o=[],n=[];e.forEach(r,e=>{switch(e.signal){case"osc":n.push(e);break;case"audio":"pcm"===e.command?this.ueTools.speech(e.content):"interrupted"===e.command&&this.ueTools.interrupted();default:o.push(e)}}),o.length>0&&s.emit("cloud",o),n.length>0&&this.ueTools.movement(n)}),r.close.pipe(o.takeUntil(n)).subscribe(async e=>{switch(s.emit("channel",e),e){case"close":case"no_permissions":r.onDestroy();break;case"reconnect":try{await this.replaceAccessToken();const e=await this.getProxySocketURL(t);s.connected?r.reconnect(e):R.error(`The browser(${r.id}) leaves before reconnecting to the cloud`)}catch(e){r.onDestroy(),s.emit("channel","net_error"),R.error(e)}}}),r.linkStart.pipe(o.takeUntil(n)).subscribe(()=>{s.emit("channel","open")}),n.subscribe(()=>{r.onClose()});const i=await this.getProxySocketURL(t);s.connected?r.start(i):R.error(`The browser(${r.id}) leaves before connecting to the cloud`)}inspectClientSocket(){const t=Array.from(this.browserSocketMap);e.forEach(t,([e,t])=>{e.disconnected&&(t.next(),t.complete(),this.browserSocketMap.delete(e),R.info(`The browser(${e.id}) should be closed. Auto clean service.`))})}getStatusInfo(){return{core:0===this.state?"未啟動":1===this.state?"服務中":"已結束",channel:Array.from(this.browserSocketMap).map(([e])=>e.__cloudProxy.getStatusInfo())}}onDestroy(){this.state=2,this.apiProxy.onDestroy(),this.chat.onDestroy(),this.ueTools.onDestroy(),this.destorySub.next(),this.destorySub.complete(),R.code(k["服務結束"])}}exports.aiiaCore=function(t){if(_){if("string"!=typeof e.get(t,"license",void 0))throw new Error(m["未提供憑證"]);!function(e){const{info:t,error:s,warn:r,debug:o,fatal:n,code:i}=function(e){if(void 0===e||"all"===e)return{code:!0,error:!0,warn:!0,info:!0,debug:!0,fatal:!0};if("none"===e)return{error:!1,code:!1,warn:!1,info:!1,debug:!1,fatal:!1};if("boolean"==typeof e)return{code:e,error:e,warn:e,info:e,debug:e,fatal:e};{const t=new Set(e);return{code:t.has("code"),debug:t.has("debug"),fatal:t.has("fatal"),error:t.has("error"),warn:t.has("warn"),info:t.has("info")}}}(e);return i||(D.code=()=>{}),o||(D.debug=()=>{}),t||(D.info=()=>{}),r||(D.warn=()=>{}),s||(D.error=()=>{}),n||(D.fatal=()=>{}),N}(e.get(t,"debug",!0))(new L),R.code(k["開始初始化必要模組"]);const s=new E(e.assign({},t));R.code(k["指定模組初始化完成"],"config");const r=new v;R.code(k["指定模組初始化完成"],"storage");const o=new re(s,r,e.get(t,"experiment"));return R.code(k["指定模組初始化完成"],"core"),o.start(),R.code(k["啟動服務"],"main core"),()=>{o.onDestroy()}}throw new Error(m["環境錯誤(nodejs)"])};
1
+ "use strict";var t=require("lodash-es"),e=require("moment"),n=require("mathjs"),s=require("socket.io"),r=require("rxjs"),o=require("axios"),i=require("ws"),a=require("fs"),c=require("os"),u=require("path"),h=require("node-osc"),p=require("child_process"),l=require("systeminformation"),f=require("@nut-tree-fork/nut-js"),d=require("readline"),I=require("net");function y(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var g,m,b,w,S,k,E,O,N,D=y(d);function _(){var t=["3uNyNKK","11mfdsBH","ERROR CODE: 2001","未獲得媒體裝置權限","ERROR CODE: 1003","重複初始化","ERROR CODE: 1004","網絡錯誤","ERROR CODE: 1001","實例已摧毀","6PjEPOQ","2520YqFLXI","沒有可用專案","1583928HxMyGk","ERROR CODE: 500","3497809OtbvdR","97724ntfKUs","ERROR CODE: 2002","9613810XeusjT","1719eKeJvN","獲取權杖失敗","ERROR CODE: 1002","235182fVRlWj","2197105cpWvgV","ERROR CODE: 2004","Worklet模組載入失敗","ERROR CODE: 2005","環境錯誤(browser)"];return(_=function(){return t})()}function C(t,e){return t-=128,_()[t]}function v(t,e){return t-=374,R()[t]}function R(){var t=["9OFiJIn","未授權控制","沒有服務","等待授權","1494748pDmsHp","3767397MUHbLj","1536190Vdbbmh","VAD模組載入失敗","778027ugxlgV","3149540fInulT","8319031ZCVnBd","30nzGjsP","8IYDbqa","可正常使用","已被拒絕","可使用","非預期的狀態","無服務","缺失該裝置","1640850XXgHPI","未響應","未啟動"];return(R=function(){return t})()}!function(){for(var t=C,e=_();;)try{if(258648===-parseInt(t(138))/1+-parseInt(t(132))/2*(-parseInt(t(144))/3)+-parseInt(t(129))/4+parseInt(t(139))/5+parseInt(t(154))/6*(-parseInt(t(131))/7)+-parseInt(t(155))/8*(parseInt(t(135))/9)+parseInt(t(134))/10*(parseInt(t(145))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),(m=g||(g={}))[(b=C)(151)]=b(130),m[b(143)]=b(152),m[b(141)]=b(137),m[b(147)]=b(148),m[b(153)]=b(150),m["環境錯誤(nodejs)"]=b(146),m["未提供憑證"]=b(133),m[b(136)]="ERROR CODE: 2003",m[b(128)]=b(140),m[b(149)]=b(142),function(){for(var t=v,e=R();;)try{if(924377===parseInt(t(382))/1+-parseInt(t(393))/2+parseInt(t(379))/3+parseInt(t(378))/4+parseInt(t(380))/5*(-parseInt(t(385))/6)+-parseInt(t(384))/7*(-parseInt(t(386))/8)+parseInt(t(374))/9*(-parseInt(t(383))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),(S=w||(w={}))[S[(k=v)(394)]=1]=k(394),S[S["等待授權"]=2]=k(377),S[S[k(388)]=3]=k(388),S[S[k(381)]=4]=k(381),S[S[k(387)]=5]=k(387),S[S["缺失該裝置"]=6]=k(392),S[S[k(376)]=7]=k(376),(O=E||(E={}))[O[(N=v)(390)]=1]="非預期的狀態",O[O[N(375)]=2]="未授權控制",O[O[N(395)]=3]=N(395),O[O[N(391)]=4]=N(391),O[O[N(389)]=5]=N(389);const T=P;!function(){const t=P,e=M();for(;;)try{if(433699===-parseInt(t(300))/1+-parseInt(t(305))/2*(-parseInt(t(307))/3)+parseInt(t(308))/4+-parseInt(t(306))/5+-parseInt(t(304))/6*(parseInt(t(309))/7)+-parseInt(t(302))/8+parseInt(t(297))/9*(parseInt(t(299))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const A=T(301);function P(t,e){t-=297;return M()[t]}T(303);const x="undefined"!=typeof process&&null!=process[T(310)]&&null!=process.versions.node;function M(){const t=["3886008bwONeC","undefined","2251842EAGNdE","8ExagCX","4016195xBceqI","372522fjXHYk","2359072IcEnDA","14MdcuJB","versions","4574097VtjqLo","number","40nHnPwj","646093ZWwgiY","access_token"];return(M=function(){return t})()}function L(t){return new Promise(e=>{setTimeout(e,t)})}const U=j;function j(t,e){t-=163;return X()[t]}!function(){const t=j,e=X();for(;;)try{if(643213===-parseInt(t(186))/1*(parseInt(t(168))/2)+parseInt(t(164))/3+parseInt(t(169))/4+-parseInt(t(191))/5+-parseInt(t(173))/6+parseInt(t(196))/7+parseInt(t(179))/8*(parseInt(t(180))/9))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class W{[U(192)];get[U(203)](){const t=U;return this[t(170)](t(203))}get[U(172)](){const t=U,e=this[t(170)](t(189));return typeof e===t(194)?e:t(187)}get[U(165)](){const t=U;return this[t(170)](t(165))??""}get[U(174)](){const t=U;return this[t(170)](t(174))}get port(){const t=U;return function(t,e){const n=typeof e===T(298)?e:NaN;if(t){const e=Number(t);return isNaN(e)?n:e}return n}(process.env[t(184)],this[t(170)](t(182))??3e3)}get[U(176)](){const t=this[U(170)]("ws_url");return"string"==typeof t?t:""}get[U(177)](){const t=U,e=this[t(170)](t(177));return typeof e===t(194)?e:""}get[U(183)](){const e=U,n=this[e(170)]("project");if(void 0===n)return{specific:!1};if(typeof n===e(194))return{name:n,id:n,specific:!1};{const e=t.get(n,"id",void 0),s=t.get(n,"name",void 0);return{id:"string"==typeof e?e:void 0,name:"string"==typeof s?s:void 0,specific:!0}}}get[U(197)](){const t=U;let e=t(163);switch(this[t(172)]){case t(202):e=t(188);break;case"test":e="test"}const n="graphen-agentic-workflow-"+e+"-21193779403.asia-east1.run.app";return{api:t(204)+n,socket:"wss://"+n}}get[U(198)](){const t=U;return this[t(170)](t(198))??!0}get[U(195)](){const t=U;return this[t(170)](t(195))}get[U(199)](){const t=U,e=this[t(170)](t(199));return"number"==typeof e&&e>0?e:.3}get llmSampleRate(){const t=U,e=this[t(170)](t(200));return typeof e===t(178)&&e>0?e:16e3}get[U(171)](){const e=U;return t.assign({perSecond:3,confidence:80},this[e(170)](e(190)),this[e(170)](e(201)))}get[U(181)](){const t=U,e=this.safeRead(t(167)),n=this[t(170)](t(175));return{userDelayTime:typeof e===t(178)?e:5e3,aiiaDelayTime:typeof n===t(178)?n:NaN}}get[U(185)](){const t=U;return Boolean(this.safeRead(t(185)))}get[U(193)](){const e=U;return t.assign({x_axis_px:0,y_axis_px:0},this[e(170)](e(166)))}constructor(t){this.config=t}safeRead(e){const n=U;return t.get(this[n(192)],e,void 0)}}function X(){const t=["webserver","https://","dev","413811oNZoHz","license","correction","autoClearUserSubtitle","1331170ARafnj","1214712qEhGMX","safeRead","detection","environment","4162590XZOSBP","note","autoClearAiiaSubtitle","ws_url","worklet_url","number","431352Ljyprc","153ygYYyI","autoClearSubtitle","port","project","PORT","eyeTrackEnable","1BgsKZX","developement","prod","env","faceDetection","3109470RCovGg","config","eyeTrackCorrection","string","mediaStream","8863533YtgnNx","endPoint","debug","chunkTimeInSeconds","llmSampleRate","cameraDetection","production"];return(X=function(){return t})()}const G=V;var F;!function(){const t=V,e=H();for(;;)try{if(540782===-parseInt(t(502))/1*(parseInt(t(501))/2)+parseInt(t(489))/3*(parseInt(t(506))/4)+parseInt(t(468))/5*(-parseInt(t(476))/6)+parseInt(t(453))/7*(parseInt(t(493))/8)+parseInt(t(463))/9+parseInt(t(449))/10*(parseInt(t(473))/11)+-parseInt(t(471))/12)break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(t){const e=V;t["通道、雲端服務、麥克風都已就緒"]=e(486),t[e(465)]="CODE: 1001",t[e(457)]="CODE: 1002",t[e(492)]=e(503),t[e(467)]=e(485),t[e(496)]=e(479),t[e(455)]=e(466),t["已啟動SDK"]="CODE: 1014",t[e(505)]=e(499),t[e(483)]=e(494),t[e(472)]=e(450),t[e(454)]=e(495),t[e(488)]="CODE: 2004",t["未預期的斷線,請聯繫Graphen"]=e(469),t[e(451)]="CODE: 2010",t[e(497)]=e(478),t[e(452)]="CODE: 2012",t[e(460)]=e(480)}(F||(F={}));const Y={code:console[G(456)],debug:console.log,info:console[G(456)],warn:console.warn,error:console[G(490)],fatal:console[G(490)]},q=[];function V(t,e){t-=449;return H()[t]}function K(...t){return q[G(484)](...t),K}function H(){const t=["has","4014243kXGSPh","category","未取得媒體裝置權限,請重新設定或忽略此訊息","CODE: 1013","指定依賴已完成","3797740dJEowL","CODE: 2005","info","12253920NtvTeU","與雲端的服務中斷","561buLbZG","code","string","6fuueAk","debug","CODE: 2011","CODE: 1012","CODE: 2013","all","warn","無副作用的關閉連線","push","CODE: 1011","CODE: 1000","includes","自動重新連線雲端服務","39dPmmCA","error","boolean","初始化必要依賴","1400BNfynD","CODE: 2001","CODE: 2003","啟動SDK","指定模組初始化完成","yyyy-MM-DD[T]HH:mm:ss:sss","CODE: 2000","next","974aIcolo","134CbqOcV","CODE: 1010","fatal","安全的關閉連線","290024lxZqaU","6680jzQZWi","CODE: 2002","開始初始化必要模組","啟動服務","38563HXhbty","沒有授權,請聯繫Graphen","結束SDK","log","請訂閱專案列表","default","[Aiia::","服務結束","format"];return(H=function(){return t})()}function B(n){return new Proxy(Y,{get(s,r,o){const i=V;if(typeof r===i(475))switch(r){case i(477):case"info":case i(490):case"warn":case i(504):case i(474):return(...o)=>{const a=i,c=e()[a(461)](a(498));t.forEach(q,t=>{const e=a;(void 0===t[e(464)]||t[e(464)][e(487)](n))&&t[e(500)](r,c,n,...o)}),s[r](a(459)+r+"_"+c+"_]("+n+")",...o)};default:return}},set:(t,e,n,s)=>!0})}const J=B(G(458));function Z(t,e){t-=224;return z()[t]}function z(){const t=["boundingBox","7044Tmgcdj","8biSMSA","717786bWUdpp","score","307360XSROVs","7iVlxYg","44zzFmnm","22072IkqAwn","396544PcivuX","categories","343032RDhXzX","width","94tvuwUi","height","390230EkLRXI","get"];return(z=function(){return t})()}function Q(){var t=["19045960kmzEwy","842047PbegzN","3255875YUtnSU","321108lLQqaX","1292592iRELZd","3787272iaPspA","2OSZcXz","455336pPyvUp"];return(Q=function(){return t})()}function $(t,e){return t-=437,Q()[t]}!function(){const t=Z,e=z();for(;;)try{if(100772===parseInt(t(239))/1+-parseInt(t(227))/2*(-parseInt(t(232))/3)+-parseInt(t(240))/4+-parseInt(t(229))/5+parseInt(t(225))/6*(-parseInt(t(237))/7)+parseInt(t(233))/8*(parseInt(t(234))/9)+parseInt(t(236))/10*(parseInt(t(238))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(){for(var t=$,e=Q();;)try{if(434169===-parseInt(t(440))/1*(parseInt(t(437))/2)+parseInt(t(442))/3+-parseInt(t(438))/4+-parseInt(t(441))/5+-parseInt(t(444))/6+parseInt(t(443))/7+parseInt(t(439))/8)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const tt=nt;function et(){const t=["Websocket server run on","225qYNEHA","out","memberSub","client off","connection","start","1832UNjitF","debug","webserver","9414KftLNk","next","109984nyfIIJ","client on","port","config","3388xHEYoT","info","server","236674AgjjdN","asObservable","1249262hgloYg","595685GnIuQA","ChatModule","listen","156000gHHZsU","onDestroy"];return(et=function(){return t})()}function nt(t,e){t-=335;return et()[t]}!function(){const t=nt,e=et();for(;;)try{if(108067===-parseInt(t(343))/1+-parseInt(t(350))/2+-parseInt(t(359))/3*(-parseInt(t(347))/4)+-parseInt(t(353))/5+-parseInt(t(356))/6+parseInt(t(352))/7+parseInt(t(338))/8*(parseInt(t(341))/9))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const st=B(tt(354));class rt{[tt(346)];server;memberSub;get[tt(345)](){const t=tt;return this[t(346)][t(345)]}get[tt(340)](){const t=tt;return this[t(346)][t(340)]}get memberChange(){const t=tt;return this[t(361)][t(351)]()}constructor(t){this[tt(346)]=t,this.memberSub=new r.Subject}[tt(337)](){const t=tt;if(this[t(349)]=new s.Server(this.webserver,{cors:{origin:"*"}}),this[t(349)].on(t(336),e=>{const n=t;st[n(339)](n(344),e.id),this[n(361)][n(342)]({type:"in",socket:e}),e.on("disconnect",t=>{const s=n;st[s(339)](s(335),e.id,"reason",t),this.memberSub[s(342)]({type:s(360),socket:e})})}),void 0===this[t(340)]){const e=this[t(345)];this.server[t(355)](e),st[t(348)](t(358),e)}else st[t(348)]("Websocket server rely your webserver.")}[tt(357)](){const t=tt;this[t(349)]&&this[t(349)].close()}}const ot=it;function it(t,e){t-=406;return at()[t]}function at(){const t=["post","4277808kzqahM","/api/v1/license/projects","/api/v1/license/agent_token","catch","4084104VdBVAZ","6566651raWKmo","now","data","note","沒有可用專案","data.projects","1804444xrhYTt"," milliseconds.","then","1525353zDUHJV","onDestroy","debug","獲取權杖失敗","Complete certification","網絡錯誤","Took ","create","getAccessToken","instance","signal","4310GqjkHf","abort","Got Project List","8394YfnsrZ","105021fqeXXn","controller","token_value"];return(at=function(){return t})()}!function(){const t=it,e=at();for(;;)try{if(877029===-parseInt(t(435))/1+parseInt(t(417))/2+-parseInt(t(420))/3+-parseInt(t(410))/4+-parseInt(t(431))/5*(-parseInt(t(434))/6)+parseInt(t(411))/7+-parseInt(t(406))/8)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const ct=B("ApiProxyModule");class ut{[ot(429)];controller;constructor(t){const e=ot;this.controller=new AbortController,this.instance=o[e(427)]({baseURL:t,signal:this[e(436)][e(430)]})}async[ot(428)](e,n,s){const r=ot,o=performance[r(412)](),i={license_number:e,token_value:n??""};s&&(i[r(414)]=s);const a=await this[r(429)][r(438)](r(408),i)[r(419)](e=>t.get(e[r(413)],r(437),""))[r(409)](()=>null);if(ct[r(422)](r(424),r(426)+(performance[r(412)]()-o)+r(418)),null===a)throw new Error(g["網絡錯誤"]);if(""===a)throw new Error(g[r(423)]);return a}async getProjectList(e){const n=ot,s=performance[n(412)](),r=await this.instance[n(438)](n(407),{license_number:e})[n(419)](e=>{const s=n;return t.map(t.get(e,s(416),[]),({id:t,sub_project_name:e,avatar:n})=>{const{name:s,url:r}=n;return{avatar:{name:s,url:r},id:t,name:e}})})[n(409)](t=>null);if(ct[n(422)](n(433),n(426)+(performance[n(412)]()-s)+n(418)),null===r)throw new Error(g[n(425)]);if(0===r.length)throw new Error(g[n(415)]);return r}[ot(421)](){const t=ot;this[t(436)][t(432)]()}}function ht(){const t=["parse","79956qdKWvI","5023020tKvAyT","2054EdPkbq","stringify","pong","5276646ABgGRt","195SlVgyG","550LHavBA","53948seegzu","string","unknow","6mXMTGr","6662xipfvZ","beat","7xXThtT","3259912PBcbdk","280005VtKMPV","signal","message","253JCOjnK"];return(ht=function(){return t})()}const pt=ft;var lt;function ft(t,e){t-=332;return ht()[t]}!function(){const t=ft,e=ht();for(;;)try{if(883260===-parseInt(t(338))/1*(-parseInt(t(352))/2)+parseInt(t(346))/3*(parseInt(t(348))/4)+-parseInt(t(341))/5*(parseInt(t(351))/6)+-parseInt(t(333))/7*(-parseInt(t(334))/8)+-parseInt(t(345))/9+parseInt(t(347))/10*(parseInt(t(335))/11)+-parseInt(t(340))/12*(parseInt(t(342))/13))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(t){const e=ft;t[t.unknow=0]=e(350),t[t[e(332)]=1]="beat",t[t.message=2]=e(337)}(lt||(lt={}));const dt=JSON[pt(343)]({request:"ping",content:"2"}),It=yt;function yt(t,e){t-=214;return gt()[t]}function gt(){const t=["isConnected","與雲端的服務中斷","MDN_RESERVED_1004","180QfOcNW","), ",") - 雲端代理(","MDN_PROTOCOL_ERROR","closeSub","MDN_NO_STATUS_RECEIVED","Proxy has some problem","安全的關閉連線","2117421nciJNY","116488YNlmyc","沒有授權,請聯繫Graphen","WS_4104_LLM_SESSION_ERROR","SocketProxtModule","19674DDhZdg","WS_4103_TOKEN_EXPIRED","13268035AGXRTs","warn",", Type: ","7983209vYXMrV","readyState","averageLatency","slice","stringify","4iCvxHs","now","MDN_ABNORMAL_CLOSURE","WS_4100_NORAML_CLOSURE","socket","onDestroy","send","complete","正在關閉雲端服務","MDN_UNSUPPORTED_DATA",", 錯誤碼: ","21fIFdKb","MDN_MESSAGE_TOO_BIG","正在連線雲端服務中","shift","create proxy for browser(","瀏覽器(","lastCloseLog","10LHWPIi","最近一次關閉原因: ","2170BtvVOG","open","format","send message fail","pingSub","socket code: ","code","WHEN_BROWSER_CLOSE","reduce","length","MDN_INVALID_FRAME_PAYLOAD","currentTime: ","yyyy-MM-DD[T]HH:mm:ss:sss","push","uuid","getStatusInfo","setPing","pipe","MDN_MANDATORY_EXTENSION","no_permissions","MDN_POLICY_VIOLATION","59640qqpUuG","MDN_INTERNAL_ERROR","messageSub","linkStart","雲端服務尚未啟動","pingTime","24voxGgx","OPEN","beat","MDN_NORMAL_CLOSURE","url","subscribe","asObservable","MDN_BAD_GATEWAY","自動重新連線雲端服務","setPong","未知的 Websocket 狀態: ","The socket is not connected","Destroy cloud channel(","destorySub","reconnect","WS_4105_TOO_MANY_CONNECTIONS","proxy","雲端服務已關閉","close","type","MDN_SERVICE_RESTART","linkStartSub","next","message","WS_4102_LICENSE_EXPIRED","WS_4101_UNAUTHORIZED","MDN_TRY_AGAIN_LATER","error","2104496RSwrvu","MDN_TLS_HANDSHAKE","MDN_GOING_AWAY","_latency"];return(gt=function(){return t})()}!function(){const t=yt,e=gt();for(;;)try{if(637584===parseInt(t(227))/1*(parseInt(t(259))/2)+parseInt(t(226))/3*(parseInt(t(241))/4)+-parseInt(t(218))/5*(parseInt(t(282))/6)+-parseInt(t(252))/7*(parseInt(t(316))/8)+parseInt(t(231))/9*(parseInt(t(261))/10)+-parseInt(t(233))/11+parseInt(t(288))/12*(parseInt(t(236))/13))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const mt=B(It(230));var bt;!function(t){const e=It;t[t[e(291)]=1e3]=e(291),t[t[e(318)]=1001]=e(318),t[t[e(221)]=1002]="MDN_PROTOCOL_ERROR",t[t[e(250)]=1003]=e(250),t[t[e(217)]=1004]=e(217),t[t[e(223)]=1005]=e(223),t[t[e(243)]=1006]=e(243),t[t[e(271)]=1007]="MDN_INVALID_FRAME_PAYLOAD",t[t[e(281)]=1008]="MDN_POLICY_VIOLATION",t[t[e(253)]=1009]=e(253),t[t.MDN_MANDATORY_EXTENSION=1010]=e(279),t[t[e(283)]=1011]=e(283),t[t[e(308)]=1012]=e(308),t[t[e(314)]=1013]="MDN_TRY_AGAIN_LATER",t[t[e(295)]=1014]="MDN_BAD_GATEWAY",t[t[e(317)]=1015]=e(317),t[t[e(268)]=4001]=e(268),t[t[e(244)]=4100]=e(244),t[t[e(313)]=4101]=e(313),t[t[e(312)]=4102]=e(312),t[t.WS_4103_TOKEN_EXPIRED=4103]=e(232),t[t[e(229)]=4104]="WS_4104_LLM_SESSION_ERROR",t[t.WS_4105_TOO_MANY_CONNECTIONS=4105]=e(303)}(bt||(bt={}));class wt{id;uuid;[It(245)];[It(284)];[It(265)];[It(309)];[It(301)];[It(222)];[It(258)];_latency=[];pingTime=NaN;get[It(292)](){const t=It;return this[t(245)]?.[t(292)]}get[It(311)](){return this[It(284)].asObservable()}get[It(306)](){const t=It;return this.closeSub[t(294)]()}get[It(285)](){const t=It;return this[t(309)][t(294)]()}get[It(215)](){const t=It;return this[t(245)]?.[t(237)]===i[t(289)]}get latency(){const t=It,e=this[t(214)][t(270)];return e>1?this._latency[e-1]:NaN}get[It(238)](){const t=It,e=this[t(214)][t(270)];if(e>=1){return this[t(214)][t(269)]((t,e)=>t+e,0)/e}return NaN}constructor(t){const e=It;this.id=t,this.messageSub=new r.Subject,this[e(265)]=new r.Subject,this[e(309)]=new r.Subject,this.closeSub=new r.Subject,this[e(301)]=new r.Subject,this[e(275)]=crypto.randomUUID(),this.pingSub[e(278)](r.delay(2e4),r.takeUntil(this[e(301)]))[e(293)](()=>{const t=e;this[t(215)]&&(this[t(277)](),this[t(245)].send(dt))}),mt.debug(e(256)+this.id+")")}start(e){const n=It;this[n(245)]=new i(e,{autoPong:!0}),r.fromEvent(this.socket,n(262)).pipe(r.takeUntil(this[n(301)]))[n(293)](()=>{const t=n;mt[t(267)](F["啟動服務"],t(304)),this[t(309)][t(310)](),this[t(265)].next()}),r.fromEvent(this[n(245)],n(311))[n(278)](r.takeUntil(this[n(301)]))[n(293)](e=>{const s=n,{data:r}=e,o=function(e){const n=ft;if(typeof e!==n(349))return{type:lt.unknow};try{let s=[];const r=JSON[n(339)](e);return s=t.get(r,n(336))?[r]:t.isArray(r)?r:t.values(r),t.some(s,({signal:t})=>t===n(344))?{type:lt[n(332)]}:{type:lt.message,data:s}}catch(t){return{type:lt[n(350)]}}}(r);switch(o[s(307)]){case lt[s(290)]:this[s(297)](),this[s(265)][s(310)]();break;case lt[s(311)]:this[s(284)][s(310)](o.data);break;case lt.unknow:default:mt[s(234)]("Got a message, but failed",r)}}),r.fromEvent(this[n(245)],n(315))[n(278)](r.takeUntil(this[n(301)]))[n(293)](t=>{const e=n,{error:s}=t;mt[e(315)](e(224),s)}),r.fromEvent(this[n(245)],n(306)).pipe(r.takeUntil(this[n(301)])).subscribe(t=>{const e=n,{code:s,reason:r,type:o,wasClean:i}=t;switch(this[e(258)]=e(260)+r+e(251)+s+e(235)+o,s){case bt[e(268)]:mt[e(267)](F["無副作用的關閉連線"]),this[e(246)]();break;case bt[e(291)]:case bt[e(318)]:this[e(222)][e(310)](e(306)),mt[e(267)](F[e(225)]);break;case bt[e(223)]:case bt[e(243)]:this[e(222)].next(e(306)),mt[e(267)](F[e(216)],{code:s,reason:r,type:o,wasClean:i});break;case bt[e(244)]:case bt.WS_4103_TOKEN_EXPIRED:case bt[e(229)]:case bt[e(303)]:this[e(222)][e(310)](e(302)),mt.code(F[e(296)],"socket code: "+s);break;case bt.WS_4101_UNAUTHORIZED:case bt[e(312)]:this[e(222)][e(310)](e(280)),mt[e(267)](F[e(228)],e(266)+s);break;default:this[e(222)][e(310)](e(306)),mt[e(267)](F["未預期的斷線,請聯繫Graphen"],{code:s,reason:r,type:o,wasClean:i})}})}[It(277)](){const e=It;t.isNaN(this[e(287)])&&(this[e(287)]=Date[e(242)]())}[It(297)](){const e=It;if(!t.isNaN(this.pingTime)){const t=Date.now()-this[e(287)];this._latency[e(274)](t/2),this[e(287)]=NaN,this[e(214)].length>6&&this[e(214)][e(255)]()}}[It(247)](t){const n=It,s=n(272)+e()[n(263)](n(273));this[n(215)]?this[n(245)].send(t,e=>{const r=n;e&&mt[r(315)](r(264),s,t[r(239)](0,100),e)}):mt[n(234)](n(299),s,t[n(239)](0,100))}sendToCloud(t){const e=It;this.send(JSON[e(240)](t))}[It(276)](){const t=It,e=(()=>{const t=yt;if(!this[t(245)])return t(286);{const e=this[t(245)][t(237)];switch(e){case 0:return t(254);case 1:return"雲端服務正常運作";case 2:return t(249);case 3:return t(305);default:return t(298)+e}}})(),n=this.lastCloseLog?e+", "+this[t(258)]:e;return{proxy_id:this[t(275)],latency:this.latency,averageLatency:this[t(238)],proxy_state:this[t(245)]?.readyState??-1,msg:t(257)+this.id+t(220)+this[t(275)]+t(219)+n}}[It(246)](){const t=It;this.destorySub[t(310)](),this.destorySub[t(248)](),mt.debug(t(300)+this[t(275)]+")")}}function St(t,e){t-=408;return Et()[t]}const kt=St;function Et(){const t=["platform","當前系統是未知的平台: ","mkdirSync","saveFolder","aiia-sdk","1507344uDlzcG","linux","EOL","existsSync","217190dTQgzJ","7FyQaZu","fileCheck","1213415PsufEb","AppName","Application Support","userName","isWIN","addPath","7DrrexW","XDG_CONFIG_HOME","env","join","writeFileSync","homedir","AppData","167622tIYJNF","username","log","5764208oUPxyN","2595832vCViQl","darwin","isLINUX","appFolder","utf8","Library","18bSgdRC","folderCheck","1645400jxsaJZ","isMAC"];return(Et=function(){return t})()}!function(){const t=St,e=Et();for(;;)try{if(388618===parseInt(t(423))/1*(-parseInt(t(422))/2)+-parseInt(t(438))/3+parseInt(t(442))/4+-parseInt(t(425))/5+parseInt(t(418))/6*(-parseInt(t(431))/7)+parseInt(t(441))/8+-parseInt(t(409))/9*(-parseInt(t(411))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class Ot{[kt(426)];platform;[kt(412)];[kt(429)];[kt(444)];[kt(416)];[kt(436)];[kt(445)];[kt(428)];[kt(420)];constructor(t){const e=kt;switch(this[e(426)]=t,this[e(413)]=process[e(413)],this[e(436)]=c[e(436)](),this[e(428)]=c.userInfo()[e(439)],this[e(420)]=c[e(420)],this[e(413)]){case e(443):this[e(412)]=!0,this[e(429)]=!1,this[e(444)]=!1,this[e(416)]=u[e(434)](this[e(436)],e(408),e(427));break;case"win32":this[e(412)]=!1,this.isWIN=!0,this[e(444)]=!1,this.saveFolder=process[e(433)].APPDATA||u[e(434)](this[e(436)],e(437),"Roaming");break;case e(419):this[e(412)]=!1,this.isWIN=!1,this[e(444)]=!0,this[e(416)]=process[e(433)][e(432)]||u[e(434)](this[e(436)],".config");break;default:console[e(440)](e(414)+this[e(413)]),this[e(412)]=!1,this[e(429)]=!1,this[e(444)]=!1,this[e(416)]=this[e(436)]}this[e(445)]=u[e(434)](this[e(416)],this.AppName),this[e(410)](this[e(445)])}addPath(...t){return u[kt(434)](...t)}[kt(410)](t){a[kt(415)](t,{recursive:!0})}createFolder(t){const e=kt,n=this[e(430)](this[e(445)],t);return this[e(410)](n),n}[kt(424)](t,e=""){const n=kt;!a[n(421)](t)&&a[n(435)](t,e,{encoding:n(446)})}}const Nt=new Ot(kt(417));function Dt(){var t=["1794640SFdOmg","4163376tDekSM","2016296zHJWax","14muFtkV","126254aFeunp","3002229MduuDk","15cyenKe","697175ULsNfp","479398RFKdnD"];return(Dt=function(){return t})()}function _t(t,e){return t-=174,Dt()[t]}!function(){for(var t=_t,e=Dt();;)try{if(350697===parseInt(t(179))/1+-parseInt(t(175))/2*(-parseInt(t(177))/3)+-parseInt(t(180))/4+-parseInt(t(178))/5+-parseInt(t(181))/6+parseInt(t(174))/7*(parseInt(t(182))/8)+parseInt(t(176))/9)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const Ct=Tt;function vt(){const t=["2743572XTuVuY","20052WbcXGh","10415817kEIuRH","parse","1iELxCO","storage.json","205824MegpBH","26418tyEpGT","clearSync","getItem","setItemSyncByRecoord","setItemSync","writeFileSync","readFile","utf8","clear","appFolder","removeItemSync","fileCheck","node","stringify","112pVTadB","removeItem","fileName","110jwrXvu","35IKEwIX","107330luWGTN","1471340wCDQmW","getFileData","setFileData","352bXMmNb","filePath","getFileDataSync","setFileDataSync","setItem"];return(vt=function(){return t})()}!function(){const t=Tt,e=vt();for(;;)try{if(629130===parseInt(t(274))/1*(-parseInt(t(296))/2)+parseInt(t(306))/3*(-parseInt(t(291))/4)+-parseInt(t(295))/5*(parseInt(t(276))/6)+-parseInt(t(277))/7*(parseInt(t(300))/8)+-parseInt(t(272))/9+parseInt(t(297))/10+parseInt(t(294))/11*(parseInt(t(305))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class Rt{type=Ct(289);filePath;[Ct(293)];constructor(){const t=Ct;this.fileName=t(275),this[t(301)]=Nt.addPath(Nt[t(286)],this[t(293)]),Nt[t(288)](this[t(301)])}[Ct(302)](){const t=Ct,e=a.readFileSync(this[t(301)],t(284));try{return JSON[t(273)](e)}catch(t){return{}}}setFileDataSync(t){const e=Ct;try{const n=JSON[e(290)](t);a[e(282)](this[e(301)],n,e(284))}catch(t){}}async[Ct(298)](){return new Promise(t=>{const e=Tt;a[e(283)](this.filePath,e(284),(n,s)=>{const r=e;if(n)t({});else try{t(JSON[r(273)](s))}catch(e){t({})}})})}async setFileData(t){return new Promise(e=>{const n=Tt;try{const s=JSON[n(290)](t);a.writeFile(this[n(301)],s,"utf8",t=>{e()})}catch(t){}})}async[Ct(279)](t){const e=Ct;return(await this[e(298)]())[t]??null}async[Ct(304)](t,e){const n=Ct,s=await this.getFileData();s[t]=e,await this[n(299)](s)}async[Ct(292)](e){const n=Ct,s=await this[n(298)](),r=t.omit(s,e);await this[n(299)](r)}async[Ct(285)](){const t=Ct;await this[t(299)]({})}getItemSync(t){return this[Ct(302)]()[t]??null}[Ct(281)](t,e){const n=Ct,s=this[n(302)]();s[t]=e,this[n(303)](s)}[Ct(280)](e){const n=this[Ct(302)]();t.forEach(t.keys(e),t=>{n[t]=e[t]}),this.setFileDataSync(n)}[Ct(287)](e){const n=Ct,s=t.omit(this.getFileDataSync(),e);this[n(303)](s)}[Ct(278)](){this[Ct(303)]({})}}function Tt(t,e){t-=272;return vt()[t]}const At=Pt;function Pt(t,e){t-=468;return Ut()[t]}!function(){const t=Pt,e=Ut();for(;;)try{if(252291===parseInt(t(483))/1*(-parseInt(t(527))/2)+-parseInt(t(488))/3+parseInt(t(498))/4+parseInt(t(477))/5+parseInt(t(473))/6*(-parseInt(t(481))/7)+parseInt(t(475))/8+parseInt(t(480))/9)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const xt={[F[At(518)]]:At(518),[F[At(484)]]:At(484),[F[At(508)]]:"請訂閱專案列表",[F[At(486)]]:"初始化必要依賴",[F[At(494)]]:At(494),[F[At(492)]]:At(492),[F[At(510)]]:At(510),[F[At(526)]]:At(526),[F[At(476)]]:At(476),[F[At(487)]]:At(487),[F[At(509)]]:"與雲端的服務中斷",[F[At(505)]]:At(505),[F[At(468)]]:At(468),[F["未預期的斷線,請聯繫Graphen"]]:At(513),[F["開始初始化必要模組"]]:At(523),[F[At(482)]]:At(482),[F[At(474)]]:"啟動服務",[F[At(511)]]:At(511),[g[At(522)]]:At(522),[g[At(507)]]:At(516),[g["Worklet模組載入失敗"]]:At(499),[g["未獲得媒體裝置權限"]]:At(530),[g[At(495)]]:At(495),[g[At(517)]]:At(514),[g[At(497)]]:"未提供憑證",[g[At(469)]]:"獲取權杖失敗",[g[At(502)]]:At(502),[g[At(504)]]:At(504)},Mt=new RegExp(/^(ERROR )?CODE: [0-9]{3,4}$/);class Lt{path;constructor(t){const e=At;this[e(485)]=t?Nt[e(470)](t):Nt[e(493)]}next(t,n,s,...r){const o=At,i=e()[o(528)](o(520)),c=o(490)+i+o(496),u=Nt.addPath(this[o(485)],c),h=t===o(501)?t=>Mt[o(519)](t)?t+"("+xt[t]+")":t:t=>t;try{const e=r[o(478)]((t,e)=>{const n=o;if(e instanceof Error){let s=n(503)+(e[n(529)]??"No Message")+"]"+Nt[n(489)];return s+=e[n(535)]??n(471),typeof e[n(534)]===n(500)&&(s+=Nt.EOL+n(472)+e[n(534)]),""+t+Nt[n(489)]+s+Nt[n(489)]}switch(typeof e){case n(500):return t+" "+h(e);case n(479):case n(532):return t+" "+e[n(533)]();case"boolean":return t+" "+(e?n(521):"false");case n(524):try{return t+" "+JSON[n(531)](e)}catch(e){return t}case n(506):case n(525):case n(515):return t+" ["+typeof e+"]"}},"");a.appendFileSync(u,o(491)+t+")__"+n+"__"+s+"__::"+e+Nt[o(489)],{encoding:o(512)})}catch(t){}}}function Ut(){const t=["cause","stack","自動重新連線雲端服務","獲取權杖失敗","createFolder","unknow stack","cause: ","313638xkTeFT","啟動服務","3231984SLXJhh","安全的關閉連線","770660dimGls","reduce","number","5037435ZdadVx","63AcAzMf","指定模組初始化完成","98402dxAoSA","未取得媒體裝置權限,請重新設定或忽略此訊息","path","初始化必要依賴","無副作用的關閉連線","1200999bVzoZs","EOL","log_","LOG(","啟動SDK","appFolder","指定依賴已完成","實例已摧毀",".txt","未提供憑證","1988984IwbKaN","Worklet模組載入失敗","string","code","沒有可用專案","Error[","重複初始化","沒有授權,請聯繫Graphen","symbol","環境錯誤(browser)","請訂閱專案列表","與雲端的服務中斷","結束SDK","服務結束","utf8","未預期的斷線,請聯繫Graphen","nodejs","function","環境錯誤","環境錯誤(nodejs)","通道、雲端服務、麥克風都已就緒","test","yyyy-MM-DD","true","網絡錯誤","開始初始化必要模組","object","undefined","已啟動SDK","10LxISxg","format","message","未獲得媒體裝置權限","stringify","bigint","toString"];return(Ut=function(){return t})()}function jt(t,e){t-=166;return Yt()[t]}const Wt=jt;!function(){const t=jt,e=Yt();for(;;)try{if(745317===parseInt(t(169))/1+-parseInt(t(174))/2*(parseInt(t(176))/3)+parseInt(t(175))/4+-parseInt(t(179))/5+-parseInt(t(170))/6*(parseInt(t(173))/7)+-parseInt(t(182))/8*(-parseInt(t(166))/9)+-parseInt(t(171))/10*(-parseInt(t(181))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const Xt=Wt(178),Gt={AvatarPort:9876,ActionPort:6969,LocationPort:4060,LookPort:6745,BackGroundPort:2400},Ft={StreamAudioPort:8080,CleanAudioPort:8081};function Yt(){const t=["127.0.0.1","3155535vkSLBo","ShortHair","330XlQqHl","80caZaoW","1026576LmFxbw","keys","DoctorSuit","761453xbCbqK","6xCxblY","59610pOdCGc","reduce","1718465XnlaCi","2gOhzjS","3533568xCXkTc","4027188xCzmkz","toString"];return(Yt=function(){return t})()}function qt(){return{...Gt,...Ft}}function Vt(t){const e=Wt;return Object[e(167)](t)[e(172)]((n,s)=>{const r=e;return{...n,[s]:t[s][r(177)]()}},{})}function Kt(t){const e=Wt;return Object[e(167)](t)[e(172)]((e,n)=>({...e,[n]:Number(t[n])}),{})}Wt(168),Wt(180);const Ht=Bt;function Bt(t,e){t-=219;return zt()[t]}!function(){const t=Bt,e=zt();for(;;)try{if(262332===parseInt(t(223))/1*(parseInt(t(248))/2)+parseInt(t(247))/3+-parseInt(t(238))/4*(parseInt(t(258))/5)+-parseInt(t(231))/6*(parseInt(t(235))/7)+-parseInt(t(224))/8*(-parseInt(t(252))/9)+parseInt(t(257))/10*(-parseInt(t(249))/11)+-parseInt(t(240))/12*(parseInt(t(220))/13))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const Jt=B(Ht(237));class Zt{[Ht(255)];[Ht(233)];[Ht(221)];y_axis_px;[Ht(242)];constructor(){const e=Ht;this.udpClient=new Map,this.x_axis_px=0,this[e(244)]=0,this[e(242)]={};const n=t.pick(Gt,"AvatarPort",e(219),e(232),e(239));t.forEach(t.keys(n),t=>{const s=e,r=t,o=n[r][s(229)]();this[s(242)][o]=r})}[Ht(243)](e){t.forEach(t.keys(e),t=>{const n=Bt,s=new h.Client(Xt,e[t]);this[n(255)][n(227)](t,s)})}enableEyeTrack(t){const e=Ht;this[e(233)]=new h.Client(Xt,t[e(225)]),this[e(221)]=t[e(221)],this[e(244)]=t.y_axis_px}[Ht(251)](e){const s=Ht;if(void 0!==this[s(233)]){const r=null!==e,{x:o,y:i}=(()=>{const o=s;if(r){const{x:s,y:r}=function(e,s){const r=Z,{maxX:o,maxY:i,minX:a,minY:c}=t.assign({maxX:25,minX:-25,maxY:50,minY:-50},s),u=n.abs(o)+n.abs(a),h=n.abs(i)+n.abs(c),{clientHeight:p,clientWidth:l,originX:f,originY:d,width:I,height:y}=e,g=n.matrix([[u/l,0,a],[0,h/p,c],[0,0,1]]),m=f+I/2,b=p-(d+y/2),w=n.matrix([[m],[b],[1]]),S=n.multiply(g,w);return{x:S[r(230)]([0,0]),y:S[r(230)]([1,0])}}(e);return{x:this[o(253)](s+this[o(221)]),y:this.toFloat(r+this[o(244)])}}return{x:this[o(253)](7),y:this[o(253)](20)}})();this[s(233)][s(250)](["/",o,i],t=>{const e=s;null!=t&&Jt[e(222)](e(228),t)})}}[Ht(254)](e){t.map(e,({content:e})=>{const n=Bt,s=t.get(e,n(225),"")[n(229)](),r=this[n(242)][s];if(this.udpClient[n(241)](r)){const s=t.get(e,n(245));this[n(255)][n(236)](r)[n(250)](s,t=>{const e=n;t&&Jt[e(222)](e(226),t)})}})}toFloat(e){return t.isInteger(e)?e+1e-5:e}[Ht(246)](){const e=Ht;t.forEach(Array[e(234)](this.udpClient),([t,n])=>{n[e(230)]()}),Jt[e(256)]("Close all UnrealEngine's UDP")}}function zt(){const t=["BackGroundPort","852fuMBSC","has","mapping","enableUDPClient","y_axis_px","message","onDestroy","1257327aUFmKu","116562ZuPftF","77gfQaZE","send","eyeTrack","9EwnNjC","toFloat","movement","udpClient","debug","744220kKUyGQ","13315dQFKFe","ActionPort","12129QemQLo","x_axis_px","error","6EKOdyj","2404592nglqWt","port","Occur error when send message to UE","set","Eye track error:","toString","close","18mvcYcy","LocationPort","eyeBallUdp","from","158781IKcLKX","get","UnrealUdpModule","228pJbWXv"];return(zt=function(){return t})()}const Qt=ee;!function(){const t=ee,e=te();for(;;)try{if(464010===-parseInt(t(452))/1+-parseInt(t(467))/2+parseInt(t(477))/3+-parseInt(t(482))/4+-parseInt(t(460))/5*(-parseInt(t(447))/6)+-parseInt(t(448))/7+parseInt(t(470))/8)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const $t=B(Qt(463));function te(){const t=["Send to Unreal fail, type speech","debug","2172684BWwcKI","speechIsConnected","Unreal tools connection successful","interrupt","complete","1060036VpWvMZ","close","interruptWS","length","5473068ZDZCxz","5246080yQHPjU","speech","info","getSocket","615285mvRUqv","connectSocket","type ","intrIsConnected","speechWS","UE Tool(",") fail: ","onclose","5mFmrOz","onDestroy","send","UnrealSocketModule","interrupted","retrySub","readyState","849566STrNUw","next","onerror","7056968HPafho","error",") close, try reconnecting after a delay","destroy","allocUnsafe"];return(te=function(){return t})()}function ee(t,e){t-=446;return te()[t]}class ne{[Qt(473)];retrySub;speechWS;[Qt(484)];get speechIsConnected(){const t=Qt;return this[t(456)]?.[t(466)]===i.OPEN}get[Qt(455)](){const t=Qt;return this[t(484)]?.[t(466)]===i.OPEN}constructor(){const t=Qt;this[t(473)]=new r.Subject,this[t(465)]=new r.Subject}[Qt(453)](t){const e=Qt;this.speechWS=this[e(451)](t[e(449)],"speech"),this.interruptWS=this[e(451)](t[e(480)],e(480)),this[e(465)].pipe(r.delay(1e3),r.takeUntil(this[e(473)])).subscribe(n=>{const s=e;switch(n){case s(449):this.speechWS=this[s(451)](t[s(449)],s(449));break;case s(480):this[s(484)]=this[s(451)](t.interrupt,s(480))}})}[Qt(451)](t,e){const n=Qt,s=new i("ws://"+Xt+":"+t);return s.onopen=()=>{const t=ee;$t.debug(t(479),t(454)+e)},s[n(469)]=s=>{const r=n,{message:o,error:i,type:a}=s;$t[r(471)](r(457)+e+r(458)+o,i,{port:t,type:a})},s[n(459)]=s=>{const r=n,{code:o,reason:i,type:a}=s;$t[r(476)](r(457)+e+r(472),{code:o,reason:i,type:a,port:t})},s}[Qt(464)](){const t=Qt;this[t(455)]?this[t(484)][t(462)](t(464)):$t[t(471)]("Send to Unreal fail, type interrupt")}speech(t){const e=Qt;this[e(478)]?this[e(456)].send(function(t){const e=Qt,n=Buffer[e(474)](2*t.length);for(let s=0;s<t[e(446)];s++)n.writeInt16LE(t[s],2*s);return n}(t)):$t[e(471)](e(475))}[Qt(461)](){const t=Qt;this.speechWS?.[t(483)](),this[t(484)]?.[t(483)](),this[t(473)][t(468)](),this[t(473)][t(481)](),$t[t(450)]("Close all UnrealEngine's WebSocket")}}const se=re;function re(t,e){t-=110;return oe()[t]}function oe(){const t=["1470560jijaDf","2OWlbzg","bind","UnrealModule","onDestroy","1740928XcASnI","udpManager","19818RSzDlx","1581856qBzXpj","eyeTrack","config","enableEyeTrack","450488ZUGyXD","movement","enableUDPClient","UE tools destroy","370UJqqxL","socketManager","onStart","eyeTrackCorrection","speech","1228695OTkmoa","interrupted","debug","6318cSEuSh"];return(oe=function(){return t})()}!function(){const t=re,e=oe();for(;;)try{if(241261===-parseInt(t(114))/1*(parseInt(t(125))/2)+parseInt(t(134))/3+-parseInt(t(121))/4+-parseInt(t(129))/5*(-parseInt(t(120))/6)+parseInt(t(118))/7+parseInt(t(113))/8+parseInt(t(112))/9)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const ie=B(se(116));class ae{config;[se(119)];socketManager;[se(126)];[se(122)];[se(110)];[se(133)];constructor(t){const e=se;this[e(123)]=t,this[e(119)]=new Zt,this.socketManager=new ne,this.movement=()=>{},this[e(122)]=()=>{},this[e(110)]=()=>{},this[e(133)]=()=>{}}[se(131)](e){const n=se,s=t.assign(qt(),e);ie[n(111)]("指定的 ue port",s);const{StreamAudioPort:r,CleanAudioPort:o,LookPort:i,...a}=s;this.udpManager[n(127)](a),this[n(130)].connectSocket({speech:r,interrupt:o}),this[n(126)]=this.udpManager[n(126)].bind(this.udpManager),this[n(122)]=this.udpManager.eyeTrack[n(115)](this[n(119)]),this.interrupted=this[n(130)][n(110)].bind(this[n(130)]),this[n(133)]=this[n(130)][n(133)].bind(this[n(130)]),this[n(123)].eyeTrackEnable&&this.udpManager[n(124)]({...this.config[n(132)],port:i})}[se(117)](){const t=se;this[t(119)][t(117)](),this[t(130)].onDestroy(),ie.debug(t(128))}}function ce(t,e){return t-=278,ue()[t]}function ue(){var t=["3210810gFWTPj","3617710uRVIsm","8318871QTYDcV","3DErJmJ","80996jgkOuP","179972pHCRkc","2984940cxdrRu","10xskjep","11821720EasFME","8nVPzEf"];return(ue=function(){return t})()}!function(){for(var t=ce,e=ue();;)try{if(799246===-parseInt(t(287))/1*(parseInt(t(282))/2)+parseInt(t(281))/3*(-parseInt(t(283))/4)+parseInt(t(279))/5+-parseInt(t(278))/6+parseInt(t(284))/7+parseInt(t(286))/8+-parseInt(t(280))/9*(parseInt(t(285))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const he=pe;function pe(t,e){t-=210;return Ie()[t]}async function le(t){return new Promise(e=>{a[pe(282)](t,t=>{e(t?[!1,t]:[!0])})})}async function fe(t,e,...n){const s=pe;return Nt.isWIN?new Promise(s=>{const r=pe,o=[r(279)+t+r(238)+e+" ",...n][r(225)](" "),i=p.exec(o);i[r(254)]("error",t=>{s([!1,t])}),i.once(r(269),()=>{i[r(266)](),s([!0])})}):Promise[s(215)]([!1,new Error(s(239))])}async function de(){const t=pe;try{return await l[t(214)]()}catch(e){return console[t(235)](t(265),e),[]}}function Ie(){const t=["fileCheck","232xYlQJw","all","number","focus","cd ","proc","28330IeVrAg","stat","isUnrealInService","debug","ueConfig","msedge.exe","setPortTable","browserKeeping","createFolder","always","title","12ZsOSTN","folderCheck","test","isUnrealRunning","path","trim","edge","setAppInForeground","3yClIZv","exec","isKiosk","settingSafePort","parse",'--auto-select-desktop-capture-source="',"getStateInfo","isWIN","networkConnections","resolve","push","has","5735820pkcXCL","config","1359VamJam","getPortTable","addPath","toString","folder","join","onDestroy","length","2828815XBkljA","url","file","utf8","--user-data-dir=","string","pipe","error","name","pids"," && ","The function isn't implement in this system","無服務","--kiosk","1974724pcagwj","chrome.exe","openBrowser","非預期的狀態","toLocaleLowerCase","可使用","231931lzplhc","openUnreal","chrome","8910814cioVzr","62bssauj","homedir","once","C:/Program Files/Google/Chrome/Application","C:/Program Files (x86)/Microsoft/Edge/Application","next","Can't find browser","then","UEProject_5_6",".exe","stringify","destroySub","3578xrNZgE","檢查 Port 時發生錯誤:","unref","localPort","--remote-debugging-port=","spawn","remoteDebug","/AppData/Local/Google/Chrome/Application","config.json","catch"];return(Ie=function(){return t})()}async function ye(e){const n=pe,s=e[n(223)](),r=await de();return t.some(r,t=>t[n(267)]===s)}async function ge(t){const e=pe,n=await f.getWindows();let s=null;const r=new RegExp(t[e(246)]());for(const t of n){const n=await t[e(291)];if(r[e(294)](n[e(246)]())){s=t;break}}return s}function me(t){return[2e3,2e3,2e3,1e3,1e3,2e3,3e3,5e3][t]??[6e3,4e3][t%2]}function be(){const t=pe;if(Nt.isWIN){const e=t(260);return{proc:e,name:e+t(261)}}return null}!function(){const t=pe,e=Ie();for(;;)try{if(495970===-parseInt(t(252))/1*(parseInt(t(264))/2)+parseInt(t(300))/3*(parseInt(t(242))/4)+-parseInt(t(228))/5+parseInt(t(218))/6+-parseInt(t(248))/7*(-parseInt(t(275))/8)+-parseInt(t(220))/9*(parseInt(t(281))/10)+parseInt(t(251))/11*(-parseInt(t(292))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class we{[he(219)];[he(285)];[he(263)];constructor(e){const n=he;this[n(263)]=new r.Subject;const s={isKiosk:!1,browserKeeping:!1},{unrealFolder:o,openUrl:i,mode:a,foreground:c,remoteDebug:u}=t.assign({},e);if(typeof o===n(233)&&""!==o[n(297)]()){s[n(296)]=o;const t=be();t&&(this[n(285)]=new Se(o,t[n(280)]))}typeof i===n(233)&&""!==i[n(297)]()&&(s[n(229)]=i),typeof a===n(233)&&""!==a[n(297)]()&&(s[n(302)]="kiosk"===a),typeof c===n(233)&&""!==c.trim()&&(s[n(288)]=c===n(290)),"number"==typeof u&&(s[n(270)]=u),this[n(219)]=s}async[he(301)](e){const n=he,{blockPorts:s=[]}=t.assign({},e);let r=!1,o=await this[n(295)]();!o&&(this[n(285)]&&await this[n(285)][n(303)](...s),o=await this[n(249)]()),o&&(r=await this[n(283)]()),r&&await this.openBrowser();return this[n(285)]?await this[n(285)][n(221)]()[n(259)](Kt):qt()}async isUnrealRunning(){const e=he,n=be();if(null===n)return!1;const{proc:s}=n,r=await async function(...t){const e=pe,n=t[e(227)]>0?t[e(225)](", "):"*";return await l.processLoad(n)[e(273)](()=>[])}(s);if(r[e(227)]<=0)return!1;const o=s[e(246)](),i=t.find(r,t=>t[e(280)].toLocaleLowerCase()===o);return!!(i&&typeof i.pid===e(277)&&i[e(237)].length>=2)}async isUnrealInService(t=12){const e=he;let n=!1,s=0;const{StreamAudioPort:r}=this[e(285)]?await this[e(285)][e(221)]():qt();for(;!n&&s<t;)n=await ye(r),await L(me(s)),s++;return n}async[he(249)](){const t=he,e=be();if(null===e)return!1;const{path:n}=this[t(219)];if(void 0===n)return!1;const s=Nt.addPath(n,e[t(236)]),[r,o]=await le(s);if(!r)return J.error(o),!1;const[i,a]=await async function(t,...e){const n=pe;return Nt[n(213)]?new Promise(s=>{const r=n,o=p.spawn(t,e,{detached:!0,stdio:"ignore"});o.once(r(235),t=>{s([!1,t])}),o[r(254)]("spawn",()=>{o[r(266)](),s([!0])})}):Promise.resolve([!1,new Error("The function isn't implement in this system")])}(s);return a&&J[t(235)](a),i}async[he(244)](){const t=he,{url:e,isKiosk:n,remoteDebug:s}=this[t(219)];if(void 0===e)return!1;const r=function(){const t=pe;return Nt[t(213)]?{edge:[t(256),t(286)],chrome:[t(255),t(243)],chrome2:[Nt[t(253)]+t(271),t(243)]}:null}();if(null===r)return!1;const{proc:o}=be(),{chrome:i,chrome2:a,edge:c}=r,[[u],[h],[p]]=await Promise[t(276)]([le(Nt[t(222)](...i)),le(Nt[t(222)](...c)),le(Nt[t(222)](...a))]);if(u||p){const r=[];if(n&&(r[t(216)](t(241)),r[t(216)](t(211)+o+'"')),void 0!==s){r[t(216)](t(268)+s);const e=Nt[t(289)]("google");r.push("--user-data-dir="+e)}r[t(216)](e);const[c,h]=u?i:a,[p,l]=await fe(c,h,...r);return p?(this[t(299)](t(250)),!0):(J[t(235)](l),!1)}if(h){const r=[];if(n&&(r.push(t(241)),r[t(216)](t(211)+o+'"')),void 0!==s){r[t(216)](t(268)+s);const e=Nt[t(289)](t(298));r[t(216)](t(232)+e)}r[t(216)](e);const[i,a]=c,[u,h]=await fe(i,a,...r);return u?(this[t(299)](t(298)),!0):(J[t(235)](h),!1)}return J[t(284)](t(258)),!1}async[he(299)](t){const e=he;await L(3e3);const n=await ge(t);n?.[e(278)](),this[e(219)][e(288)]&&r.interval(1e4)[e(234)](r.takeUntil(this[e(263)])).subscribe(()=>{const n=e;ge(t)[n(259)](t=>{const e=n;t?.[e(278)]()})})}async[he(212)](){const t=he,e=await this[t(295)](),n=!!e&&await this[t(283)](1);switch(Number("0b"+(n?1:0)+(e?1:0))){case 0:return E["未啟動"];case 1:return E[t(240)];case 3:return E[t(247)];default:return E[t(245)]}}[he(226)](){const t=he;this.destroySub[t(257)](),this[t(263)].complete()}}class Se{[he(224)];[he(230)];constructor(t,e){const n=he;this.folder=Nt[n(222)](t,e,n(219)),this[n(230)]=Nt[n(222)](this[n(224)],n(272)),Nt[n(293)](this[n(224)]),Nt[n(274)](this.file,JSON[n(262)](qt()))}async[he(303)](...e){const n=he,s=qt(),r=await de(),o=await async function(e,n){const s=n??await de(),r={};return t.forEach(t.keys(e),n=>{const o=pe,i=t.some(s,({localPort:t})=>t===e[n][o(223)]());r[n]=i}),r}(s,r);if(t.some(t.values(o),t=>t)){const i=[...e,...t.filter(t.map(r,t=>Number(t[n(267)])),t=>!isNaN(t))],a=new Set(i);t.forEach(t.keys(o),t=>{const e=n,r=t;if(o[r]){const t=s[r];let n=1,o=NaN;for(;isNaN(o)&&n<=200;){const s=t+n;a[e(217)](s)?n++:(a.add(s),o=s)}!isNaN(o)&&(s[r]=o)}})}await this[n(287)](Vt(s))}getPortTable(){return new Promise(t=>{const e=pe;a.readFile(this.file,e(231),(n,s)=>{const r=e;if(n)t(Vt(qt()));else try{t(JSON[r(210)](s))}catch(e){t(Vt(qt()))}})})}async setPortTable(t){const e=he;try{const n=JSON[e(262)](t);await new Promise(t=>{const s=e;a.writeFile(this[s(230)],n,s(231),e=>{t()})})}catch(t){}}}const ke=Ee;function Ee(t,e){t-=183;return Oe()[t]}function Oe(){const t=["找不到日誌","prompt","endsWith","write","3061920AyJlDf","length",".txt","歡迎使用Aiia Admin!\n","👋 切斷連線...\n","server","exit","7036668ljNuuZ","15664XqrDKN","readdir","--yesterday","服務狀態\n 核心狀態 : "," - ","服務狀態確認\n 用法: status [額外參數]\n 範例:\n status\n","appFolder","log","getStatusInfo","--exit","remoteAddress","1180466bNkNQx","--today","yyyy-MM-DD","安全離開\n 用法 1: exit\n 用法 2: close\n"," Unreal : ","日誌讀取(無參數時,會返回可用日誌)\n 用法: log [額外參數]\n\n 範例:\n log --y\n log --yesterday\n log --specific=2025-11-28\n 可用參數:\n today : 讀取今天的日誌\n t : 讀取今天的日誌\n yesterday : 讀取昨天的日誌\n y : 讀取昨天的日誌\n specific=<yyyy-MM-dd> : 讀取指定日期的日誌\n s=<yyyy-MM-dd> : 讀取指定日期的日誌\n","296gUUkOL","19154mCzAOx","close","split","請使用 -- 開始,或使用 help --log 查看幫助","readFileSync","--y","用法: [可用指令] [額外參數]\n 範例:\n help\n help --log\n 可用指令列表:\n help : 獲得可用的指令,使用 [--可用指令] 獲得該指令的詳細說明。\n status : 顯示當前的服務狀態\n log : 讀取日誌\n exit : 關閉連線\n close : exit 的別稱,關閉連線\n","trim","167vXCRBo","isValid","--status","使用 `help` 獲得幫助\n","reduce","onDestroy","1827470GwQiDb","118584yXGTPT","630lMyyzo","padStart","沒有可用日誌"," channel ","--close","--t","join","format","\n 通道列表 : ","utf8","24gnxACt","⚙️ 新的連線來自: ","無服務通道","99uAmPXv","連線指令: telnet 127.0.0.1 ","createInterface"];return(Oe=function(){return t})()}function Ne(...t){const e=Ee;switch(t[0]){case e(202):return e(241);case"--log":return e(190);case e(183):case e(212):return e(188);default:return e(198)}}function De(...t){const n=Ee,s=t[0];if(!s)return new Promise(t=>{const e=n;a[e(237)](Nt[e(242)],(n,s)=>{const r=e;t(n?r(210):s.filter(t=>t[r(226)](r(230)))[r(214)]("\n"))})});{let t=null;switch(s){case n(186):case n(213):t=e();break;case n(238):case n(197):t=e().add(-1);break;default:{const r=new RegExp(/^--(specific|s)=([0-9]{4}-[0-9]{1,2}-[0-9]{1,2})$/),o=s.match(r);if(o){const[s,r,i]=o[2][n(194)]("-");t=e(s+"-"+r[n(209)](2,"0")+"-"+i[n(209)](2,"0"));break}return n(195)}}if(!t[n(201)]())return"指定了無效的日期,請再次確認";{const e="log_"+t[n(215)](n(187))+n(230),s=Nt.addPath(Nt.appFolder,e);try{return a[n(196)](s,n(217))}catch(t){return n(224)}}}}!function(){const t=Ee,e=Oe();for(;;)try{if(881209===-parseInt(t(200))/1*(-parseInt(t(192))/2)+parseInt(t(228))/3+parseInt(t(236))/4*(-parseInt(t(208))/5)+-parseInt(t(218))/6*(parseInt(t(185))/7)+parseInt(t(191))/8*(parseInt(t(207))/9)+-parseInt(t(206))/10*(parseInt(t(221))/11)+parseInt(t(235))/12)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class _e{[ke(233)];constructor(e,n){const s=ke,r=(a=n)?{help:Ne,status:(c=a,async(...t)=>{const e=Ee,{core:n,channel:s}=await c[e(244)](),r=s[e(204)]((t,n,s)=>{const r=e,o=n.msg;return t+(r(211)+(s+1)+r(240)+o+"}\n")},"\n");let o=e(239)+n+e(216)+(0===s[e(229)]?e(220):r)+"\n";if(c.automaion){const t=await c.automaion.getStateInfo();o+=e(189),o+=E[t],o+="\n"}return o}),log:De}:{},{port:o,host:i}=e;var a,c;this[s(233)]=I.createServer(e=>{const n=s;console.log(n(219)+e[n(184)]);const o=D[n(223)]({input:e,output:e,prompt:"Aiia Admin > "});e.setEncoding(n(217)),e[n(227)](n(231)),e[n(227)](n(203)),o.prompt(),o.on("line",async s=>{const i=n,[a,...c]=s[i(199)]()[i(194)](/\s/),u=a.toLocaleLowerCase();if(u===i(234)||u===i(193))e[i(227)](i(232)),e.end();else{const n=t.get(r,u,null);if(n){const t=await n(...c);e.write("\n"+t+"\n")}else e[i(227)]('"'+a+'"是無效的指令.\n');o[i(225)]()}}),e.on("end",()=>{console[n(243)]("⚙️ 切斷連線: "+e.remoteAddress)})}),this[s(233)].listen(o,i,()=>{const t=s;console[t(243)](t(222)+o)})}[ke(205)](){this[ke(233)].close()}}function Ce(){var t=["2rIWXEL","385595tHlWQe","4907529xOUlXD","10qYMAFA","4062784VutgKz","4579800pLLymY","8nBNujw","42642eJiiSS","5445620fCTxgv","2284329bZEOlq"];return(Ce=function(){return t})()}function ve(t,e){return t-=438,Ce()[t]}!function(){for(var t=ve,e=Ce();;)try{if(714579===parseInt(t(441))/1+-parseInt(t(444))/2*(-parseInt(t(443))/3)+-parseInt(t(438))/4+parseInt(t(442))/5+-parseInt(t(439))/6+-parseInt(t(445))/7*(-parseInt(t(440))/8)+parseInt(t(446))/9*(parseInt(t(447))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const Re=Te;function Te(t,e){t-=278;return Ae()[t]}function Ae(){const t=["browser"," --\x3e new cloud: ","30RmNArc","transition","JOIN","split","disconnect","reverse","complete","debug","emit","1168431qIvXbY","TO_DESTROY","[0]","transitionMap","pipe","getCloudProxy","subscribe","destroy","length","command","onChannelDestroy","replaceAccessToken","set","TO_READY","🚫 通道已銷毀不允許執行事件,被拒絕的事件 ","net_error","then","10760iuKOud","24cbtURO","open","warn","face","getStatusInfo","push","face_detect","get","sdk","no_permissions","close","signal","onDestroy","sendToCloud","linkStart","132131WnxkvN","osc"," --(","query","DESTROY","url","catch","3945RgVSqE","1092LdVbyG","registerTransition","TO_CONNECTING","_currentState","speech","monitor","channel","list","非預期的事件轉換參數","project_id","CLOSED","cloud","onDestory","state","❌ 轉換失敗:未定義的事件 ","interrupted","CONNECTING","209428ZnXKzw","5319VCzkIU","getProxySocketURL","2000369rNupIR","ueTools","變更代理, old cloud: ","error","TO_RECONNECTING","reconnect","content","uuid","767544ZgeGbb","fatal","未響應","TO_CLOSED","pcm","clear"];return(Ae=function(){return t})()}function Pe(t){const e=Te;try{return t?t[e(338)]("/")[e(340)]()[1]??null:null}catch(t){return null}}!function(){const t=Te,e=Ae();for(;;)try{if(911210===-parseInt(t(291))/1+-parseInt(t(316))/2+-parseInt(t(327))/3+-parseInt(t(299))/4*(parseInt(t(298))/5)+parseInt(t(362))/6*(parseInt(t(319))/7)+-parseInt(t(361))/8*(-parseInt(t(317))/9)+-parseInt(t(335))/10*(parseInt(t(344))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const xe=B("ChannelService");class Me{[Re(284)];[Re(333)];[Re(302)];[Re(347)];destroy;[Re(310)];project_id;get[Re(312)](){return this._currentState}constructor(e,n){const s=Re;this[s(284)]=e,this[s(333)]=n,this[s(351)]=new r.Subject,this[s(308)]=function(e){const n=Te;return t.isArray(e)?t.get(e,n(346),void 0):e??void 0}(n.handshake[s(294)][s(326)]),this[s(310)]=this[s(349)](),this[s(302)]=s(337),this[s(347)]=new Map,this[s(300)](),r.fromEvent(n,s(339))[s(348)](r.take(1))[s(350)](t=>{const e=s;this.transition(e(345),t)}),r.fromEvent(this[s(333)],"cloud").pipe(r.takeUntil(this.destroy)).subscribe(t=>{const e=s;this[e(310)][e(289)](t)}),r.fromEvent(this[s(333)],s(279)).pipe(r.takeUntil(this.destroy))[s(350)](t=>{const e=s,n=t,r=null!==n;this[e(284)][e(320)].eyeTrack(n),this.cloud[e(289)]({request:e(282),content:r})}),void 0===this[s(308)]?(this[s(284)].getProjectList()[s(360)](t=>{const e=s;n.emit(e(306),t)})[s(297)](t=>{const e=s;n[e(343)]("list",null),xe[e(322)](t)}),r.fromEvent(n,s(326))[s(348)](r.take(1),r.takeUntil(this[s(351)]))[s(350)](t=>{const e=s;this[e(308)]=t,this.sdk.getProxySocketURL(this[e(308)]).then(t=>{const n=e;this[n(336)](n(301),t)})})):this[s(284)][s(318)](this[s(308)]).then(t=>{this.transition("TO_CONNECTING",t)})}[Re(349)](){const e=Re,n=new wt(this[e(333)].id);return n[e(290)][e(348)](r.takeUntil(this[e(351)]))[e(350)](()=>{const t=e;this[t(336)](t(357),t(363))}),n[e(286)][e(348)](r.takeUntil(this[e(351)]))[e(350)](async t=>{const n=e;switch(t){case n(286):case n(285):this[n(336)]("TO_CLOSED",t);break;case n(324):try{this.transition(n(330),t),await this[n(284)][n(355)]();const e=await this[n(284)][n(318)](this.project_id);this[n(336)](n(323),e)}catch(t){this[n(336)]("TO_CLOSED","net_error")}}}),n.message[e(348)](r.takeUntil(this.destroy))[e(350)](n=>{const s=e,r=[],o=[];t.forEach(n,t=>{const e=Te;switch(t[e(287)]){case e(292):o[e(281)](t);break;case"audio":t[e(353)]===e(331)?this[e(284)][e(320)][e(303)](t[e(325)]):t[e(353)]===e(314)&&this[e(284)][e(320)][e(314)]();default:r[e(281)](t)}}),r[s(352)]>0&&this[s(333)][s(343)](s(310),r),o[s(352)]>0&&this[s(284)][s(320)].movement(o)}),n}[Re(300)](){const t=Re;this[t(347)][t(356)]("TO_DESTROY",e=>{const n=t;this.onDestory(),xe[n(342)](e)}),this.transitionMap[t(356)](t(330),e=>{const n=t;switch(e){case n(286):case n(285):case"reconnect":this.cloud[n(288)]();case n(359):this[n(333)][n(343)]("channel",e);break;default:xe[n(328)](n(307))}}),this[t(347)][t(356)](t(357),e=>{const n=t;this[n(333)][n(343)](n(305),e)}),this[t(347)][t(356)](t(301),t=>{this.cloud.start(t)}),this[t(347)][t(356)]("TO_RECONNECTING",e=>{const n=t,s=this[n(349)]();s.start(e),xe[n(342)](n(321)+this[n(310)][n(326)]+n(334)+s.uuid),this.cloud=s})}transition(t,e){const n=Re;if(this[n(302)]===n(295))return xe.warn(n(358)+t),!1;const s=this[n(302)];switch(t){case n(301):case n(323):this[n(302)]=n(315);break;case n(357):this[n(302)]="READY";break;case n(330):this[n(302)]=n(309);break;case n(345):this._currentState=n(295);break;default:return xe[n(278)](n(313)+t),!1}const r=this[n(347)][n(283)](t);return r&&r(e),xe[n(342)]("✅ 轉換成功: "+s+n(293)+t+")--\x3e "+this[n(302)]),!0}async[Re(280)](){const t=Re,e=new Promise(t=>{const e=Te,n=r.timer(3e3)[e(348)](r.map(()=>{const t=e;return{mic:w["未響應"],camera:w[t(329)]}})),s=r.fromEvent(this[e(333)],e(304))[e(348)](r.map(t=>t));r.merge(n,s).pipe(r.take(1),r.takeUntil(this[e(351)]))[e(350)](t),this.browser.emit(e(304),null)}),n=this.cloud[t(280)](),s=this[t(333)].id,o=await e;return{browser_id:s,access:Pe(this[t(310)][t(296)]),...o,...n}}[Re(311)](){const t=Re;this[t(347)][t(332)](),this.destroy.next(),this[t(351)][t(341)](),this[t(284)][t(354)](this[t(333)].id)}}const Le=Ue;function Ue(t,e){t-=389;return We()[t]}var je;function We(){const t=["from","1029336BylbuO","endPoint","core","start","getStatusInfo","stroage","啟動服務","服務結束","28oStIcd","apiProxy","54dkHVrC","onChannelDestroy",") should be closed. Auto clean service.","browser","/v1/chat/project/","已結束","The browser(","重複初始化","14aITTIS","228621gGsyaG","then","timestamp","pipe","udp tools","delete","setItemSync","getProjectList","335916VBphTX","getAccessToken","error","服務中","362910hGAqXd","set","ueTools","number","next","access_token","channelMap","port","replaceAccessToken","socketAddr","destorySub","now","指定模組初始化完成","expiment","onDestroy","1410568YWmZFO","memberChange","chat","5PbqcAG","automaion","api","17014cJJOzG","config","onStart","disconnected","subscribe","inspectClientSocket","onDestory","info","getStateInfo","accessToken","license","channels","getItemSync","code","initService","33eACBzB","417072lJpJJd","未啟動","state"];return(We=function(){return t})()}!function(){const t=Ue,e=We();for(;;)try{if(231318===-parseInt(t(446))/1*(parseInt(t(418))/2)+-parseInt(t(457))/3+parseInt(t(412))/4+parseInt(t(415))/5*(parseInt(t(434))/6)+parseInt(t(456))/7*(parseInt(t(438))/8)+-parseInt(t(448))/9*(parseInt(t(397))/10)+-parseInt(t(433))/11*(-parseInt(t(393))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(t){const e=Ue;t[t[e(435)]=0]=e(435),t[t[e(396)]=1]=e(396),t[t[e(453)]=2]=e(453)}(je||(je={}));class Xe{config;[Le(443)];[Le(410)];[Le(447)];[Le(414)];ueTools;[Le(416)];[Le(436)];[Le(403)];destorySub;[Le(402)];[Le(459)];[Le(406)];get accessToken(){return this[Le(402)]}constructor(t,e,n){const s=Le;this[s(419)]=t,this[s(443)]=e,this.expiment=n,this[s(436)]=je[s(435)],this.destorySub=new r.Subject,this[s(403)]=new Map,this.timestamp=0,this.access_token=e[s(430)](A);const{api:o,socket:i}=t[s(439)];this[s(406)]=i,this.apiProxy=new ut(o),J[s(431)](F[s(409)],s(417)),this.chat=new rt(t),J[s(431)](F[s(409)],"chat"),this[s(399)]=new ae(t),J[s(431)](F[s(409)],s(389)),this.initService()}async[Le(441)](){const e=Le;if(this.state!==je[e(435)])throw new Error(g[e(455)]);this[e(436)]=je[e(396)],await this[e(405)](),this[e(414)][e(413)].pipe(r.takeUntil(this[e(407)])).subscribe(({type:t,socket:n})=>{const s=e;"in"===t&&this[s(403)][s(398)](n.id,new Me(this,n))}),this.chat[e(441)](),J[e(431)](F[e(444)],e(414));const{interaction:n}=t.assign({},this[e(410)]);if(void 0!==n&&typeof n[e(404)]===e(400)){const{port:t,host:s}=n,r=new _e({port:t,host:s},this);this.destorySub[e(422)](()=>{r[e(411)]()})}}[Le(432)](){const e=Le,{automaion:n}=t.assign({},this.expiment);if(void 0!==n){const t=new we(n);t.exec({blockPorts:[this[e(419)][e(404)]]})[e(458)](t=>{this[e(399)].onStart(t)}),this[e(407)][e(422)](()=>{t[e(411)]()}),this.automaion=t}else this.ueTools[e(420)]();r.interval(18e4)[e(460)](r.takeUntil(this[e(407)]))[e(422)](()=>{const n=e;this[n(423)](),this[n(442)]()[n(458)](({channel:e,core:s,unreal:r})=>{const o=n;J[o(425)](o(440),s),J[o(425)]("Unreal state",E[r],r),J[o(425)](o(429),t.map(e,t=>{const{camera:e,mic:n,...s}=t;return{cameraState:w[e]+", "+e,micState:w[n]+", "+n,...s}}))})})}async replaceAccessToken(){const t=Le;try{const e=await this.apiProxy[t(394)](this[t(419)][t(428)],this[t(402)],this.config.note);this[t(402)]=e,this[t(459)]=0,this[t(443)][t(391)](A,e)}catch(t){throw J.error(t),t}}async[Le(392)](){const t=Le;try{return await this[t(447)].getProjectList(this[t(419)][t(428)])}catch(e){throw J[t(395)](e),e}}async getProxySocketURL(t){const e=Le,n=Date[e(408)]()-this[e(459)];return n<5e3&&await L(5100-n),this[e(459)]=Date[e(408)](),this[e(406)]+e(452)+this[e(427)]+"/"+t}[Le(423)](){const e=Le,n=Array.from(this[e(403)]);t.forEach(n,([t,n])=>{const s=e;"DESTROY"===n[s(436)]?this.channelMap[s(390)](t):n[s(451)][s(421)]&&(n[s(424)](),J[s(425)](s(454)+t+s(450)))})}[Le(449)](t){this[Le(403)].delete(t)}async[Le(442)](){const e=Le,n=t.map(Array[e(437)](this.channelMap),([t,n])=>n[e(442)]()),s=new Promise(t=>{const n=e;this.automaion?this[n(416)][n(426)]()[n(458)](t):t(E["未授權控制"])}),[r,...o]=await Promise.all([s,...n]);return{core:{state:this[e(436)],msg:je[this[e(436)]]},channel:o,unreal:r}}[Le(411)](){const t=Le;this[t(447)][t(411)](),this[t(414)][t(411)](),this[t(399)][t(411)](),this[t(407)][t(401)](),this[t(407)].complete(),this[t(436)]=je[t(453)],J.code(F[t(445)])}}function Ge(t,e){t-=429;return Fe()[t]}function Fe(){const t=["環境錯誤(nodejs)","41702BiwETH","9uRtpsg","experiment","string","4083260TEtlFL","113632KYGhaE","890256oJKZoS","88440huhmvq","main core","debug","45cNyHST","42ikqPZV","onDestroy","storage","674448iYgABX","start","未提供憑證","啟動服務","指定模組初始化完成","code","license","1433886CkHdrF","473IYwmgN","開始初始化必要模組","core","12oPAlJq"];return(Fe=function(){return t})()}!function(){const t=Ge,e=Fe();for(;;)try{if(271711===parseInt(t(442))/1*(parseInt(t(440))/2)+parseInt(t(448))/3+-parseInt(t(447))/4*(parseInt(t(452))/5)+-parseInt(t(436))/6+parseInt(t(453))/7*(-parseInt(t(429))/8)+-parseInt(t(443))/9*(-parseInt(t(446))/10)+-parseInt(t(437))/11*(-parseInt(t(449))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),exports.aiiaCore=function(e){const n=Ge;if(x){if(typeof t.get(e,n(435),void 0)!==n(445))throw new Error(g[n(431)]);(function(t){const e=G,{info:n,error:s,warn:r,debug:o,fatal:i,code:a}=function(t){const e=V;if(void 0===t||t===e(481))return{code:!0,error:!0,warn:!0,info:!0,debug:!0,fatal:!0};if("none"===t)return{error:!1,code:!1,warn:!1,info:!1,debug:!1,fatal:!1};if(typeof t===e(491))return{code:t,error:t,warn:t,info:t,debug:t,fatal:t};{const n=new Set(t);return{code:n.has("code"),debug:n[e(462)](e(477)),fatal:n[e(462)]("fatal"),error:n[e(462)](e(490)),warn:n[e(462)](e(482)),info:n.has(e(470))}}}(t);return!a&&(Y[e(474)]=()=>{}),!o&&(Y[e(477)]=()=>{}),!n&&(Y[e(470)]=()=>{}),!r&&(Y[e(482)]=()=>{}),!s&&(Y[e(490)]=()=>{}),!i&&(Y[e(504)]=()=>{}),K})(t.get(e,n(451),!0))(new Lt),J[n(434)](F[n(438)]);const s=new W(t.assign({},e));J[n(434)](F[n(433)],"config");const r=new Rt;J.code(F[n(433)],n(455));const o=new Xe(s,r,t.get(e,n(444)));return J.code(F[n(433)],n(439)),o[n(430)](),J.code(F[n(432)],n(450)),()=>{o[n(454)]()}}throw new Error(g[n(441)])};
package/dist/node.d.ts CHANGED
@@ -42,6 +42,14 @@ export declare interface ExperimentOptions {
42
42
  }
43
43
 
44
44
  declare interface InitOptions {
45
+ /**
46
+ * [zh]
47
+ * 簡易的機台資訊備註,於管理系統查看
48
+ *
49
+ * [en]
50
+ * Simple machine information notes, viewable in the management system.
51
+ */
52
+ note?: string;
45
53
  /**
46
54
  * [zh]
47
55
  * 請從 Aiia platform 取得授權
package/dist/node.mjs CHANGED
@@ -1 +1 @@
1
- import{get as e,assign as t,forEach as s,map as o,omit as r,pick as n,keys as i,isInteger as a,find as c,some as h,values as l,filter as u,isArray as d}from"lodash-es";import p from"moment";import{abs as f,matrix as g,multiply as m}from"mathjs";import{Server as y}from"socket.io";import{Subject as S,fromEvent as b,takeUntil as _,take as w,interval as E}from"rxjs";import D from"axios";import O from"ws";import N from"fs";import k from"os";import R from"path";import{Client as C}from"node-osc";import{spawn as A,exec as M}from"child_process";import P from"systeminformation";import{getWindows as T}from"@nut-tree-fork/nut-js";import*as I from"readline";import{createServer as x}from"net";var L;!function(e){e["網絡錯誤"]="ERROR CODE: 500",e["環境錯誤(browser)"]="ERROR CODE: 1001",e["Worklet模組載入失敗"]="ERROR CODE: 1002",e["未獲得媒體裝置權限"]="ERROR CODE: 1003",e["實例已摧毀"]="ERROR CODE: 1004",e["環境錯誤(nodejs)"]="ERROR CODE: 2001",e["未提供憑證"]="ERROR CODE: 2002",e["獲取權杖失敗"]="ERROR CODE: 2003",e["沒有可用專案"]="ERROR CODE: 2004",e["重複初始化"]="ERROR CODE: 2005"}(L||(L={}));const v="access_token",$="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node;function F(e){return new Promise(t=>{setTimeout(t,e)})}class W{config;get webserver(){return this.safeRead("webserver")}get environment(){const e=this.safeRead("env");return"string"==typeof e?e:"developement"}get license(){return this.safeRead("license")??""}get port(){return function(e,t){const s="number"==typeof t?t:NaN;if(e){const t=Number(e);return isNaN(t)?s:t}return s}(process.env.PORT,this.safeRead("port")??3e3)}get ws_url(){const e=this.safeRead("ws_url");return"string"==typeof e?e:""}get worklet_url(){const e=this.safeRead("worklet_url");return"string"==typeof e?e:""}get project(){const t=this.safeRead("project");if(void 0===t)return{specific:!1};if("string"==typeof t)return{name:t,id:t,specific:!1};{const s=e(t,"id",void 0),o=e(t,"name",void 0);return{id:"string"==typeof s?s:void 0,name:"string"==typeof o?o:void 0,specific:!0}}}get endPoint(){let e="dev";switch(this.environment){case"production":e="prod";break;case"test":e="test"}const t=`graphen-agentic-workflow-${e}-21193779403.asia-east1.run.app`;return{api:`https://${t}`,socket:`wss://${t}`}}get debug(){return this.safeRead("debug")??!0}get mediaStream(){return this.safeRead("mediaStream")}get chunkTimeInSeconds(){const e=this.safeRead("chunkTimeInSeconds");return"number"==typeof e&&e>0?e:.3}get llmSampleRate(){const e=this.safeRead("llmSampleRate");return"number"==typeof e&&e>0?e:16e3}get detection(){return t({perSecond:3,confidence:80},this.safeRead("faceDetection"),this.safeRead("cameraDetection"))}get autoClearSubtitle(){const e=this.safeRead("autoClearUserSubtitle"),t=this.safeRead("autoClearAiiaSubtitle");return{userDelayTime:"number"==typeof e?e:5e3,aiiaDelayTime:"number"==typeof t?t:NaN}}get eyeTrackEnable(){return Boolean(this.safeRead("eyeTrackEnable"))}get eyeTrackCorrection(){return t({x_axis_px:0,y_axis_px:0},this.safeRead("correction"))}constructor(e){this.config=e}safeRead(t){return e(this.config,t,void 0)}}var U;!function(e){e["通道、雲端服務、麥克風都已就緒"]="CODE: 1000",e["未取得媒體裝置權限,請重新設定或忽略此訊息"]="CODE: 1001",e["請訂閱專案列表"]="CODE: 1002",e["初始化必要依賴"]="CODE: 1010",e["指定依賴已完成"]="CODE: 1011",e["啟動SDK"]="CODE: 1012",e["結束SDK"]="CODE: 1013",e["已啟動SDK"]="CODE: 1014",e["安全的關閉連線"]="CODE: 2000",e["無副作用的關閉連線"]="CODE: 2001",e["與雲端的服務中斷"]="CODE: 2002",e["沒有授權,請聯繫Graphen"]="CODE: 2003",e["自動重新連線雲端服務"]="CODE: 2004",e["未預期的斷線,請聯繫Graphen"]="CODE: 2005",e["開始初始化必要模組"]="CODE: 2010",e["指定模組初始化完成"]="CODE: 2011",e["啟動服務"]="CODE: 2012",e["服務結束"]="CODE: 2013"}(U||(U={}));const j={code:console.log,debug:console.log,info:console.log,warn:console.warn,error:console.error,fatal:console.error},G=[];function B(e){return G.push(e),B}const Y=new Proxy(j,{get(e,t,o){if("string"==typeof t)switch(t){case"debug":case"info":case"error":case"warn":case"fatal":case"code":return(...o)=>{const r=p().format("yyyy-MM-DD[T]HH:mm:ss:sss");s(G,e=>{e.next(t,r,...o)}),e[t](`[Aiia::${t}_${r}_]`,...o)};default:return}},set:(e,t,s,o)=>!0});class H{config;server;memberSub;get port(){return this.config.port}get webserver(){return this.config.webserver}get memberChange(){return this.memberSub.asObservable()}constructor(e){this.config=e,this.memberSub=new S}start(){if(this.server=new y(this.webserver,{cors:{origin:"*"}}),this.server.on("connection",e=>{Y.debug("client on",e.id),this.memberSub.next({type:"in",socket:e}),e.on("disconnect",t=>{Y.debug("client off",e.id,"reason",t),this.memberSub.next({type:"out",socket:e})})}),void 0===this.webserver){const e=this.port;this.server.listen(e),Y.info("Websocket server run on",e)}else Y.info("Websocket server rely your webserver.")}onDestroy(){this.server&&this.server.close()}}class K{instance;controller;constructor(e){this.controller=new AbortController,this.instance=D.create({baseURL:e,signal:this.controller.signal})}async getAccessToken(t,s){const o=performance.now(),r={license_number:t,token_value:s??""},n=await this.instance.post("/api/v1/license/agent_token",r).then(t=>e(t.data,"token_value","")).catch(()=>null);if(Y.debug("Complete certification",`Took ${performance.now()-o} milliseconds.`),null===n)throw new Error(L["網絡錯誤"]);if(""===n)throw new Error(L["獲取權杖失敗"]);return n}async getProjectList(t){const s=performance.now(),r=await this.instance.post("/api/v1/license/projects",{license_number:t}).then(t=>o(e(t,"data.projects",[]),({id:e,sub_project_name:t,avatar:s})=>{const{name:o,url:r}=s;return{avatar:{name:o,url:r},id:e,name:t}})).catch(e=>null);if(Y.debug("Got Project List",`Took ${performance.now()-s} milliseconds.`),null===r)throw new Error(L["網絡錯誤"]);if(0===r.length)throw new Error(L["沒有可用專案"]);return r}onDestroy(){this.controller.abort()}}var X;!function(e){e[e.MDN_NORMAL_CLOSURE=1e3]="MDN_NORMAL_CLOSURE",e[e.MDN_GOING_AWAY=1001]="MDN_GOING_AWAY",e[e.MDN_PROTOCOL_ERROR=1002]="MDN_PROTOCOL_ERROR",e[e.MDN_UNSUPPORTED_DATA=1003]="MDN_UNSUPPORTED_DATA",e[e.MDN_RESERVED_1004=1004]="MDN_RESERVED_1004",e[e.MDN_NO_STATUS_RECEIVED=1005]="MDN_NO_STATUS_RECEIVED",e[e.MDN_ABNORMAL_CLOSURE=1006]="MDN_ABNORMAL_CLOSURE",e[e.MDN_INVALID_FRAME_PAYLOAD=1007]="MDN_INVALID_FRAME_PAYLOAD",e[e.MDN_POLICY_VIOLATION=1008]="MDN_POLICY_VIOLATION",e[e.MDN_MESSAGE_TOO_BIG=1009]="MDN_MESSAGE_TOO_BIG",e[e.MDN_MANDATORY_EXTENSION=1010]="MDN_MANDATORY_EXTENSION",e[e.MDN_INTERNAL_ERROR=1011]="MDN_INTERNAL_ERROR",e[e.MDN_SERVICE_RESTART=1012]="MDN_SERVICE_RESTART",e[e.MDN_TRY_AGAIN_LATER=1013]="MDN_TRY_AGAIN_LATER",e[e.MDN_BAD_GATEWAY=1014]="MDN_BAD_GATEWAY",e[e.MDN_TLS_HANDSHAKE=1015]="MDN_TLS_HANDSHAKE",e[e.WHEN_BROWSER_CLOSE=4001]="WHEN_BROWSER_CLOSE",e[e.WS_4100_NORAML_CLOSURE=4100]="WS_4100_NORAML_CLOSURE",e[e.WS_4101_UNAUTHORIZED=4101]="WS_4101_UNAUTHORIZED",e[e.WS_4102_LICENSE_EXPIRED=4102]="WS_4102_LICENSE_EXPIRED",e[e.WS_4103_TOKEN_EXPIRED=4103]="WS_4103_TOKEN_EXPIRED",e[e.WS_4104_LLM_SESSION_ERROR=4104]="WS_4104_LLM_SESSION_ERROR",e[e.WS_4105_TOO_MANY_CONNECTIONS=4105]="WS_4105_TOO_MANY_CONNECTIONS"}(X||(X={}));class V{id;uuid;socket;messageSub;linkStartSub;destorySub;closeSub;isFinished;debugInfo;lastCloseLog;get message(){return this.messageSub.asObservable()}get close(){return this.closeSub.asObservable()}get linkStart(){return this.linkStartSub.asObservable()}get isConnected(){return this.socket?.readyState===O.OPEN}constructor(e){this.id=e,this.messageSub=new S,this.linkStartSub=new S,this.closeSub=new S,this.destorySub=new S,this.isFinished=!1,this.uuid=crypto.randomUUID(),this.debugInfo=`browser(${this.id}), proxy(${this.uuid})`,Y.debug(`create proxy for browser(${this.id})`)}start(e){this.socket=new O(e,{autoPong:!0}),b(this.socket,"open").pipe(_(this.destorySub)).subscribe(()=>{Y.code(U["啟動服務"],"proxy",this.debugInfo),this.linkStartSub.next()}),b(this.socket,"message").pipe(_(this.destorySub)).subscribe(e=>{const{data:t}=e;this.messageSub.next(t)}),b(this.socket,"error").pipe(_(this.destorySub)).subscribe(e=>{const{error:t}=e;Y.error(this.debugInfo,"Proxy has some problem",t)}),b(this.socket,"close").pipe(_(this.destorySub)).subscribe(e=>{const{code:t,reason:s,type:o,wasClean:r}=e;switch(this.lastCloseLog=`最近一次關閉原因: ${s}, 錯誤碼: ${t}, Type: ${o}`,t){case X.WHEN_BROWSER_CLOSE:Y.code(U["無副作用的關閉連線"],this.debugInfo),this.onDestroy();break;case X.MDN_NORMAL_CLOSURE:case X.MDN_GOING_AWAY:this.closeSub.next("close"),Y.code(U["安全的關閉連線"],this.debugInfo);break;case X.MDN_NO_STATUS_RECEIVED:case X.MDN_ABNORMAL_CLOSURE:this.closeSub.next("close"),Y.code(U["與雲端的服務中斷"],this.debugInfo,{code:t,reason:s,type:o,wasClean:r});break;case X.WS_4100_NORAML_CLOSURE:case X.WS_4103_TOKEN_EXPIRED:case X.WS_4104_LLM_SESSION_ERROR:case X.WS_4105_TOO_MANY_CONNECTIONS:this.closeSub.next("reconnect"),Y.code(U["自動重新連線雲端服務"],this.debugInfo,`socket code: ${t}`);break;case X.WS_4101_UNAUTHORIZED:case X.WS_4102_LICENSE_EXPIRED:this.closeSub.next("no_permissions"),Y.code(U["沒有授權,請聯繫Graphen"],this.debugInfo,`socket code: ${t}`);break;default:this.closeSub.next("close"),Y.code(U["未預期的斷線,請聯繫Graphen"],this.debugInfo,{code:t,reason:s,type:o,wasClean:r})}})}reconnect(e){this.isFinished||(this.destorySub.next(),this.destorySub.complete(),this.destorySub=new S,this.start(e))}send(e){const t=`currentTime: ${p().format("yyyy-MM-DD[T]HH:mm:ss:sss")}`;this.isConnected?this.socket.send(e,s=>{s&&Y.error("send message fail",this.debugInfo,t,e.slice(0,100),s)}):Y.warn("The socket is not connected",this.debugInfo,t,e.slice(0,100))}sendToCloud(e){this.send(JSON.stringify(e))}onClose(){if(this.socket)switch(this.socket.readyState){case 0:Y.debug("Once the cloud connection is complete, the connection will be disconnected."),this.linkStart.pipe(_(this.destorySub),w(1)).subscribe(()=>{this.socket?.close(X.WHEN_BROWSER_CLOSE)});break;case 1:Y.debug("Close safely, no side effects"),this.socket.close(X.WHEN_BROWSER_CLOSE);break;case 2:case 3:Y.debug("The connection have been lost.")}}getStatusInfo(){const e=(()=>{if(!this.socket)return"雲端服務尚未啟動";{const e=this.socket.readyState;switch(e){case 0:return"正在連線雲端服務中";case 1:return"雲端服務正常運作";case 2:return"正在關閉雲端服務";case 3:return"雲端服務已關閉";default:return`未知的 Websocket 狀態: ${e}`}}})(),t=this.lastCloseLog?`${e}, ${this.lastCloseLog}`:e;return`瀏覽器(${this.id}) - 雲端代理(${this.uuid}), ${t}`}onDestroy(){this.isFinished=!0,this.destorySub.next(),this.destorySub.complete(),Y.debug(`Destroy cloud channel(${this.debugInfo})`)}}const J=new class{AppName;platform;isMAC;isWIN;isLINUX;saveFolder;homedir;appFolder;EOL;constructor(e){switch(this.AppName=e,this.platform=process.platform,this.homedir=k.homedir(),this.EOL=k.EOL,this.platform){case"darwin":this.isMAC=!0,this.isWIN=!1,this.isLINUX=!1,this.saveFolder=R.join(this.homedir,"Library","Application Support");break;case"win32":this.isMAC=!1,this.isWIN=!0,this.isLINUX=!1,this.saveFolder=process.env.APPDATA||R.join(this.homedir,"AppData","Roaming");break;case"linux":this.isMAC=!1,this.isWIN=!1,this.isLINUX=!0,this.saveFolder=process.env.XDG_CONFIG_HOME||R.join(this.homedir,".config");break;default:console.log(`當前系統是未知的平台: ${this.platform}`),this.isMAC=!1,this.isWIN=!1,this.isLINUX=!1,this.saveFolder=this.homedir}this.appFolder=R.join(this.saveFolder,this.AppName),this.folderCheck(this.appFolder)}addPath(...e){return R.join(...e)}folderCheck(e){N.mkdirSync(e,{recursive:!0})}createFolder(e){const t=this.addPath(this.appFolder,e);return this.folderCheck(t),t}fileCheck(e,t=""){N.existsSync(e)||N.writeFileSync(e,t,{encoding:"utf8"})}}("aiia-sdk");class Z{type="node";filePath;fileName;constructor(){this.fileName="storage.json",this.filePath=J.addPath(J.appFolder,this.fileName),J.fileCheck(this.filePath)}getFileDataSync(){const e=N.readFileSync(this.filePath,"utf8");try{return JSON.parse(e)}catch(e){return{}}}setFileDataSync(e){try{const t=JSON.stringify(e);N.writeFileSync(this.filePath,t,"utf8")}catch(e){}}async getFileData(){return new Promise(e=>{N.readFile(this.filePath,"utf8",(t,s)=>{if(t)e({});else try{e(JSON.parse(s))}catch(t){e({})}})})}async setFileData(e){return new Promise(t=>{try{const s=JSON.stringify(e);N.writeFile(this.filePath,s,"utf8",e=>{t()})}catch(e){}})}async getItem(e){return(await this.getFileData())[e]??null}async setItem(e,t){const s=await this.getFileData();s[e]=t,await this.setFileData(s)}async removeItem(e){const t=await this.getFileData(),s=r(t,e);await this.setFileData(s)}async clear(){await this.setFileData({})}getItemSync(e){return this.getFileDataSync()[e]??null}setItemSync(e,t){const s=this.getFileDataSync();s[e]=t,this.setFileDataSync(s)}removeItemSync(e){const t=r(this.getFileDataSync(),e);this.setFileDataSync(t)}clearSync(){this.setFileDataSync({})}}const q={[U["通道、雲端服務、麥克風都已就緒"]]:"通道、雲端服務、麥克風都已就緒",[U["未取得媒體裝置權限,請重新設定或忽略此訊息"]]:"未取得媒體裝置權限,請重新設定或忽略此訊息",[U["請訂閱專案列表"]]:"請訂閱專案列表",[U["初始化必要依賴"]]:"初始化必要依賴",[U["指定依賴已完成"]]:"指定依賴已完成",[U["啟動SDK"]]:"啟動SDK",[U["結束SDK"]]:"結束SDK",[U["已啟動SDK"]]:"已啟動SDK",[U["安全的關閉連線"]]:"安全的關閉連線",[U["無副作用的關閉連線"]]:"無副作用的關閉連線",[U["與雲端的服務中斷"]]:"與雲端的服務中斷",[U["沒有授權,請聯繫Graphen"]]:"沒有授權,請聯繫Graphen",[U["自動重新連線雲端服務"]]:"自動重新連線雲端服務",[U["未預期的斷線,請聯繫Graphen"]]:"未預期的斷線,請聯繫Graphen",[U["開始初始化必要模組"]]:"開始初始化必要模組",[U["指定模組初始化完成"]]:"指定模組初始化完成",[U["啟動服務"]]:"啟動服務",[U["服務結束"]]:"服務結束",[L["網絡錯誤"]]:"網絡錯誤",[L["環境錯誤(browser)"]]:"環境錯誤",[L["Worklet模組載入失敗"]]:"Worklet模組載入失敗",[L["未獲得媒體裝置權限"]]:"未獲得媒體裝置權限",[L["實例已摧毀"]]:"實例已摧毀",[L["環境錯誤(nodejs)"]]:"nodejs",[L["未提供憑證"]]:"未提供憑證",[L["獲取權杖失敗"]]:"獲取權杖失敗",[L["沒有可用專案"]]:"沒有可用專案",[L["重複初始化"]]:"重複初始化"},z=new RegExp(/^(ERROR )?CODE: [0-9]{3,4}$/);class Q{path;constructor(e){this.path=e?J.createFolder(e):J.appFolder}next(e,t,...s){const o=`log_${p().format("yyyy-MM-DD")}.txt`,r=J.addPath(this.path,o),n="code"===e?e=>z.test(e)?`${e}(${q[e]})`:e:e=>e;try{const o=s.reduce((e,t)=>{if(t instanceof Error){let s=`Error[${t.message??"No Message"}]${J.EOL}`;return s+=t.stack??"unknow stack","string"==typeof t.cause&&(s+=`${J.EOL}cause: ${t.cause}`),`${e}${J.EOL}${s}${J.EOL}`}switch(typeof t){case"string":return`${e} ${n(t)}`;case"number":case"bigint":return`${e} ${t.toString()}`;case"boolean":return`${e} ${t?"true":"false"}`;case"object":try{return`${e} ${JSON.stringify(t)}`}catch(t){return e}case"symbol":case"undefined":case"function":return`${e} [${typeof t}]`}},"");N.appendFileSync(r,`LOG(${e})__${t}__::${o}${J.EOL}`,{encoding:"utf8"})}catch(e){}}}const ee="127.0.0.1",te={AvatarPort:"9876",ActionPort:"6969",LocationPort:"4060",LookPort:"6745",BackGroundPort:"2400"},se={StreamAudioPort:"8080",CleanAudioPort:"8081"};function oe(){return{...te,...se}}class re{clientMap;eyeBallUdp;x_axis_px;y_axis_px;defPortMap;constructor(){this.clientMap=new Map,this.x_axis_px=0,this.y_axis_px=0,this.defPortMap={};const e=n(te,"AvatarPort","ActionPort","LocationPort","BackGroundPort");s(i(e),t=>{const s=t,o=e[s];this.defPortMap[o]=s})}enableUDPClient(e){s(i(e),t=>{const s=new C(ee,e[t]);this.clientMap.set(t,s)})}enableEyeTrack(e){this.eyeBallUdp=new C(ee,e.port),this.x_axis_px=e.x_axis_px,this.y_axis_px=e.y_axis_px}eyeTrack(e){if(void 0!==this.eyeBallUdp){const s=null!==e,{x:o,y:r}=(()=>{if(s){const{x:s,y:o}=function(e,s){const{maxX:o,maxY:r,minX:n,minY:i}=t({maxX:25,minX:-25,maxY:50,minY:-50},s),a=f(o)+f(n),c=f(r)+f(i),{clientHeight:h,clientWidth:l,originX:u,originY:d,width:p,height:y}=e,S=g([[a/l,0,n],[0,c/h,i],[0,0,1]]),b=g([[u+p/2],[h-(d+y/2)],[1]]),_=m(S,b);return{x:_.get([0,0]),y:_.get([1,0])}}(e);return{x:this.toFloat(s+this.x_axis_px),y:this.toFloat(o+this.y_axis_px)}}return{x:this.toFloat(7),y:this.toFloat(20)}})();this.eyeBallUdp.send(["/",o,r],e=>{null!=e&&Y.error("Eye track error:",e)})}}movement(t){o(t,({content:t})=>{const s=e(t,"port",""),o=e(t,"message"),r=this.defPortMap[s.toString()];this.clientMap.has(r)&&this.clientMap.get(r).send(o,e=>{null!=e&&Y.error("Occur error when send message to UE",e)})})}toFloat(e){return a(e)?e+1e-5:e}onDestroy(){s(Array.from(this.clientMap),([e,t])=>{t.close()}),Y.info("Close all UnrealEngine's UDP")}}class ne{destroy;speechWS;interruptWS;get speechIsConnected(){return this.speechWS?.readyState===O.OPEN}get intrIsConnected(){return this.interruptWS?.readyState===O.OPEN}constructor(){this.destroy=new S}connectSocket(e){this.speechWS=this.getSocket(e.speech,"speech"),this.interruptWS=this.getSocket(e.interrupt,"interrupt")}getSocket(e,t){const s=new O(`ws://${ee}:${e}`);return s.onerror=s=>{const{message:o,error:r,type:n}=s;Y.error(`UE Tool(${t}) fail: ${o}`,r,{port:e,type:n})},s.onclose=s=>{const{code:o,reason:r,type:n}=s;Y.debug(`UE Tool(${t}) close`,{code:o,reason:r,type:n,port:e})},s}interrupted(){this.intrIsConnected&&this.interruptWS.send("interrupted")}speech(e){if(this.speechIsConnected){const t=Buffer.allocUnsafe(2*e.length);for(let s=0;s<e.length;s++)t.writeInt16LE(e[s],2*s);this.speechWS.send(t)}}onDestroy(){this.speechWS?.close(),this.interruptWS?.close(),this.destroy.next(),this.destroy.complete(),Y.info("Close all UnrealEngine's WebSocket")}}class ie{config;udpManager;socketManager;movement;eyeTrack;interrupted;speech;constructor(e){this.config=e,this.udpManager=new re,this.socketManager=new ne,this.movement=()=>{},this.eyeTrack=()=>{},this.interrupted=()=>{},this.speech=()=>{}}onStart(e){const o={},r=oe(),n=t(oe(),e);s(i(r),e=>{const t=n[e],s=Number(t);o[e]=isNaN(s)?Number(r[e]):s});const{StreamAudioPort:a,CleanAudioPort:c,LookPort:h,...l}=o;this.udpManager.enableUDPClient(l),this.socketManager.connectSocket({speech:a,interrupt:c}),this.movement=this.udpManager.movement.bind(this.udpManager),this.eyeTrack=this.udpManager.eyeTrack.bind(this.udpManager),this.interrupted=this.socketManager.interrupted.bind(this.socketManager),this.speech=this.socketManager.speech.bind(this.socketManager),this.config.eyeTrackEnable&&this.udpManager.enableEyeTrack({...this.config.eyeTrackCorrection,port:h})}onDestroy(){this.udpManager.onDestroy(),this.socketManager.onDestroy(),Y.info("UE tools destroy")}}async function ae(e){return new Promise(t=>{N.stat(e,e=>{t(e?[!1,e]:[!0])})})}async function ce(e,t,...s){return J.isWIN?new Promise(o=>{const r=[`cd ${e} && ${t} `,...s].join(" "),n=M(r);n.once("error",e=>{o([!1,e])}),n.once("spawn",()=>{n.unref(),o([!0])})}):Promise.resolve([!1,new Error("The function isn't implement in this system")])}async function he(){try{return await P.networkConnections()}catch(e){return console.error("檢查 Port 時發生錯誤:",e),[]}}async function le(e){const t=e.toString(),s=await he();return h(s,e=>e.localPort===t)}async function ue(e){const t=await T();let s=null;const o=new RegExp(e.toLocaleLowerCase());for(const e of t){const t=await e.title;if(o.test(t.toLocaleLowerCase())){s=e;break}}return s}function de(e){return[2e3,2e3,2e3,1e3,1e3,2e3,3e3,5e3][e]??[6e3,4e3][e%2]}function pe(){if(J.isWIN){const e="UEProject_5_6";return{proc:e,name:`${e}.exe`}}return null}class fe{config;ueConfig;destroySub;constructor(e){this.destroySub=new S;const s={isKiosk:!1,browserKeeping:!1},{unrealFolder:o,openUrl:r,mode:n,foreground:i,remoteDebug:a}=t({},e);if("string"==typeof o&&""!==o.trim()){s.path=o;const e=pe();e&&(this.ueConfig=new ge(o,e.proc))}"string"==typeof r&&""!==r.trim()&&(s.url=r),"string"==typeof n&&""!==n.trim()&&(s.isKiosk="kiosk"===n),"string"==typeof i&&""!==i.trim()&&(s.browserKeeping="always"===i),"number"==typeof a&&(s.remoteDebug=a),this.config=s}async exec(){let e=!1,t=await this.isUnrealRunning();t||(this.ueConfig&&await this.ueConfig.getSafePortTable(),t=await this.openUnreal()),t&&(e=await this.isUnrealInService()),e&&await this.openBrowser();return this.ueConfig?await this.ueConfig.getPortTable():oe()}async isUnrealRunning(){const e=pe();if(null===e)return!1;const{proc:t}=e,s=await async function(...e){const t=e.length>0?e.join(", "):"*";return await P.processLoad(t).catch(()=>[])}(t);if(s.length<=0)return!1;const o=t.toLocaleLowerCase(),r=c(s,e=>e.proc.toLocaleLowerCase()===o);return!!(r&&"number"==typeof r.pid&&r.pids.length>=2)}async isUnrealInService(e=12){let t=!1,s=0;const{StreamAudioPort:o}=this.ueConfig?await this.ueConfig.getPortTable():oe();for(;!t&&s<e;)t=await le(o),await F(de(s)),s++;return t}async openUnreal(){const e=pe();if(null===e)return!1;const{path:t}=this.config;if(void 0===t)return!1;const s=J.addPath(t,e.name),[o,r]=await ae(s);if(!o)return Y.error(r),!1;const[n,i]=await async function(e,...t){return J.isWIN?new Promise(s=>{const o=A(e,t,{detached:!0,stdio:"ignore"});o.once("error",e=>{s([!1,e])}),o.once("spawn",()=>{o.unref(),s([!0])})}):Promise.resolve([!1,new Error("The function isn't implement in this system")])}(s);return i&&Y.error(i),n}async openBrowser(){const{url:e,isKiosk:t,remoteDebug:s}=this.config;if(void 0===e)return!1;const o=J.isWIN?{edge:["C:/Program Files (x86)/Microsoft/Edge/Application","msedge.exe"],chrome:["C:/Program Files/Google/Chrome/Application","chrome.exe"],chrome2:[`${J.homedir}/AppData/Local/Google/Chrome/Application`,"chrome.exe"]}:null;if(null===o)return!1;const{proc:r}=pe(),{chrome:n,chrome2:i,edge:a}=o,[[c],[h],[l]]=await Promise.all([ae(J.addPath(...n)),ae(J.addPath(...a)),ae(J.addPath(...i))]);if(c||l){const o=[];if(t&&(o.push("--kiosk"),o.push(`--auto-select-desktop-capture-source="${r}"`)),void 0!==s){o.push(`--remote-debugging-port=${s}`);const e=J.createFolder("google");o.push(`--user-data-dir=${e}`)}o.push(e);const[a,h]=c?n:i,[l,u]=await ce(a,h,...o);return l?(this.setAppInForeground("chrome"),!0):(Y.error(u),!1)}if(h){const o=[];if(t&&(o.push("--kiosk"),o.push(`--auto-select-desktop-capture-source="${r}"`)),void 0!==s){o.push(`--remote-debugging-port=${s}`);const e=J.createFolder("edge");o.push(`--user-data-dir=${e}`)}o.push(e);const[n,i]=a,[c,h]=await ce(n,i,...o);return c?(this.setAppInForeground("edge"),!0):(Y.error(h),!1)}return Y.info("Can't find browser"),!1}async setAppInForeground(e){await F(3e3);const t=await ue(e);t?.focus(),this.config.browserKeeping&&E(1e4).pipe(_(this.destroySub)).subscribe(()=>{ue(e).then(e=>{e?.focus()})})}async getStateInfo(){const e=await this.isUnrealRunning();return{isOpen:e,isReady:!!e&&await this.isUnrealInService(1)}}onDestroy(){this.destroySub.next(),this.destroySub.complete()}}class ge{folder;file;constructor(e,t){this.folder=J.addPath(e,t,"config"),this.file=J.addPath(this.folder,"config.json"),J.folderCheck(this.folder),J.fileCheck(this.file,JSON.stringify(oe()))}async getSafePortTable(){const e=oe(),t=await he(),r=await async function(e,t){const o=t??await he(),r={};return s(i(e),t=>{const s=h(o,({localPort:s})=>s===e[t]);r[t]=s}),r}(e,t);if(h(l(r),e=>e)){const n=new Set(u(o(t,e=>Number(e.localPort)),e=>!isNaN(e)));s(i(r),t=>{const s=t;if(r[s]){const t=Number(e[s]);let o=1,r=NaN;for(;isNaN(r)&&o<=200;){const e=t+o;n.has(e)?o++:(n.add(e),r=e)}isNaN(r)||(e[s]=r.toString())}})}await this.setPortTable(e)}getPortTable(){return new Promise(e=>{N.readFile(this.file,"utf8",(t,s)=>{if(t)e(oe());else try{e(JSON.parse(s))}catch(t){e(oe())}})})}async setPortTable(e){try{const t=JSON.stringify(e);await new Promise(e=>{N.writeFile(this.file,t,"utf8",t=>{e()})})}catch(e){}}}function me(...e){switch(e[0]){case"--status":return"服務狀態確認\n 用法: status [額外參數]\n 範例:\n status\n";case"--log":return"日誌讀取(無參數時,會返回可用日誌)\n 用法: log [額外參數]\n\n 範例:\n log --y\n log --yesterday\n log --specific=2025-11-28\n 可用參數:\n today : 讀取今天的日誌\n t : 讀取今天的日誌\n yesterday : 讀取昨天的日誌\n y : 讀取昨天的日誌\n specific=<yyyy-MM-dd> : 讀取指定日期的日誌\n s=<yyyy-MM-dd> : 讀取指定日期的日誌\n";case"--exit":case"--close":return"安全離開\n 用法 1: exit\n 用法 2: close\n";default:return"用法: [可用指令] [額外參數]\n 範例:\n help\n help --log\n 可用指令列表:\n help : 獲得可用的指令,使用 [--可用指令] 獲得該指令的詳細說明。\n status : 顯示當前的服務狀態\n log : 讀取今天的日誌\n exit : 關閉連線\n close : exit 的別稱,關閉連線\n"}}function ye(e){return async(...t)=>{const{core:s,channel:o}=e.getStatusInfo(),r=o.reduce((e,t,s)=>e+` channel ${s+1} - ${t}\n`,"\n");let n=`服務狀態\n 核心狀態 : ${s}\n 通道列表 : ${0===o.length?"無服務通道":r}\n`;if(e.automaion){const{isOpen:t,isReady:s}=await e.automaion.getStateInfo();n+=" Unreal : ",n+=t?s?"已啟動,服務已就緒":"已啟動,但服務未就緒":"尚未啟動",n+="\n"}return n}}function Se(...e){const t=e[0];if(!t)return new Promise(e=>{N.readdir(J.appFolder,(t,s)=>{e(t?"沒有可用日誌":s.filter(e=>e.endsWith(".txt")).join("\n"))})});{let e=null;switch(t){case"--today":case"--t":e=p();break;case"--yesterday":case"--y":e=p().add(-1);break;default:{const s=new RegExp(/^--(specific|s)=([0-9]{4}-[0-9]{1,2}-[0-9]{1,2})$/),o=t.match(s);if(o){const[t,s,r]=o[2].split("-");e=p(`${t}-${s.padStart(2,"0")}-${r.padStart(2,"0")}`);break}return"請使用 -- 開始,或使用 help --log 查看幫助"}}if(!e.isValid())return"指定了無效的日期,請再次確認";{const t=`log_${e.format("yyyy-MM-DD")}.txt`,s=J.addPath(J.appFolder,t);try{return N.readFileSync(s,"utf8")}catch(e){return"找不到日誌"}}}}class be{server;constructor(t,s){const o=function(e){return e?{help:me,status:ye(e),log:Se}:{}}(s),{port:r,host:n}=t;this.server=x(t=>{console.log(`⚙️ 新的連線來自: ${t.remoteAddress}`);const s=I.createInterface({input:t,output:t,prompt:"Aiia Admin > "});t.setEncoding("utf8"),t.write("歡迎使用Aiia Admin!\n"),t.write("使用 `help` 獲得幫助\n"),s.prompt(),s.on("line",async r=>{const[n,...i]=r.trim().split(/\s/),a=n.toLocaleLowerCase();if("exit"===a||"close"===a)t.write("👋 切斷連線...\n"),t.end();else{const r=e(o,a,null);if(r){const e=await r(...i);t.write("\n"+e+"\n")}else t.write(`"${n}"是無效的指令.\n`);s.prompt()}}),t.on("end",()=>{console.log(`⚙️ 切斷連線: ${t.remoteAddress}`)})}),this.server.listen(r,n,()=>{console.log(`連線指令: telnet 127.0.0.1 ${r}`)})}onDestroy(){this.server.close()}}class _e{config;stroage;expiment;apiProxy;chat;ueTools;automaion;state;browserSocketMap;destorySub;access_token;timestamp;socketAddr;get accessToken(){return this.access_token}constructor(e,t,s){this.config=e,this.stroage=t,this.expiment=s,this.state=0,this.destorySub=new S,this.browserSocketMap=new Map,this.timestamp=0,this.access_token=t.getItemSync(v);const{api:o,socket:r}=e.endPoint;this.socketAddr=r,this.apiProxy=new K(o),Y.code(U["指定模組初始化完成"],"api"),this.chat=new H(e),Y.code(U["指定模組初始化完成"],"chat"),this.ueTools=new ie(e),Y.code(U["指定模組初始化完成"],"udp tools"),this.openChannel=this.openChannel.bind(this),this.initService()}async start(){if(this.state>=1)throw new Error(L["重複初始化"]);this.state=1,await this.replaceAccessToken(),this.chat.memberChange.pipe(_(this.destorySub)).subscribe(({type:t,socket:s})=>{const o=s;switch(t){case"in":{const t=new V(s.id),n=new S;o.__cloudProxy=t;const i=(r=s.handshake.query.uuid,d(r)?e(r,"[0]",void 0):r??void 0);void 0===i?(this.getProjectList().then(e=>{s.emit("list",e)}).catch(e=>{Y.error(e),s.emit("list",null)}),b(s,"uuid").pipe(w(1),_(n)).subscribe(e=>{this.openChannel(e,o,t,n)})):this.openChannel(i,o,t,n),this.browserSocketMap.set(o,n);break}case"out":if(this.browserSocketMap.has(o)){const e=this.browserSocketMap.get(o);e.next(),e.complete(),this.browserSocketMap.delete(o)}}var r}),this.chat.start(),Y.code(U["啟動服務"],"chat");const{interaction:s}=t({},this.expiment);if(void 0!==s&&"number"==typeof s.port){const{port:e,host:t}=s,o=new be({port:e,host:t},this);this.destorySub.subscribe(()=>{o.onDestroy()})}}initService(){const{automaion:e}=t({},this.expiment);if(void 0!==e){const t=new fe(e);t.exec().then(e=>{this.ueTools.onStart(e)}),this.destorySub.subscribe(()=>{t.onDestroy()}),this.automaion=t}else this.ueTools.onStart();E(18e4).pipe(_(this.destorySub)).subscribe(()=>{this.inspectClientSocket()})}async replaceAccessToken(){try{const e=await this.apiProxy.getAccessToken(this.config.license,this.access_token),t=this.access_token;this.access_token=e,this.timestamp=0,this.stroage.setItemSync(v,e),this.stroage.setItemSync(p().format("yyyy-MM-DD[T]HH:mm:ss:sss"),t)}catch(e){throw Y.error(e),e}}async getProjectList(){try{return await this.apiProxy.getProjectList(this.config.license)}catch(e){throw Y.error(e),e}}async getProxySocketURL(e){const t=Date.now()-this.timestamp;return t<5e3&&await F(5100-t),this.timestamp=Date.now(),`${this.socketAddr}/v1/chat/project/${this.accessToken}/${e}`}async openChannel(t,o,r,n){b(o,"cloud").pipe(_(n)).subscribe(e=>{r.sendToCloud(e)}),b(o,"face").pipe(_(n)).subscribe(e=>{const t=e,s=null!==t;this.ueTools.eyeTrack(t),r.sendToCloud({request:"face_detect",content:s})}),r.message.pipe(_(n)).subscribe(t=>{const r=function(t){try{const s=JSON.parse(t);return e(s,"signal")?[s]:d(s)?s:l(s)}catch(e){return Y.error("message transfer fail",e),[]}}(t),n=[],i=[];s(r,e=>{switch(e.signal){case"osc":i.push(e);break;case"audio":"pcm"===e.command?this.ueTools.speech(e.content):"interrupted"===e.command&&this.ueTools.interrupted();default:n.push(e)}}),n.length>0&&o.emit("cloud",n),i.length>0&&this.ueTools.movement(i)}),r.close.pipe(_(n)).subscribe(async e=>{switch(o.emit("channel",e),e){case"close":case"no_permissions":r.onDestroy();break;case"reconnect":try{await this.replaceAccessToken();const e=await this.getProxySocketURL(t);o.connected?r.reconnect(e):Y.error(`The browser(${r.id}) leaves before reconnecting to the cloud`)}catch(e){r.onDestroy(),o.emit("channel","net_error"),Y.error(e)}}}),r.linkStart.pipe(_(n)).subscribe(()=>{o.emit("channel","open")}),n.subscribe(()=>{r.onClose()});const i=await this.getProxySocketURL(t);o.connected?r.start(i):Y.error(`The browser(${r.id}) leaves before connecting to the cloud`)}inspectClientSocket(){const e=Array.from(this.browserSocketMap);s(e,([e,t])=>{e.disconnected&&(t.next(),t.complete(),this.browserSocketMap.delete(e),Y.info(`The browser(${e.id}) should be closed. Auto clean service.`))})}getStatusInfo(){return{core:0===this.state?"未啟動":1===this.state?"服務中":"已結束",channel:Array.from(this.browserSocketMap).map(([e])=>e.__cloudProxy.getStatusInfo())}}onDestroy(){this.state=2,this.apiProxy.onDestroy(),this.chat.onDestroy(),this.ueTools.onDestroy(),this.destorySub.next(),this.destorySub.complete(),Y.code(U["服務結束"])}}function we(s){if($){if("string"!=typeof e(s,"license",void 0))throw new Error(L["未提供憑證"]);!function(e){const{info:t,error:s,warn:o,debug:r,fatal:n,code:i}=function(e){if(void 0===e||"all"===e)return{code:!0,error:!0,warn:!0,info:!0,debug:!0,fatal:!0};if("none"===e)return{error:!1,code:!1,warn:!1,info:!1,debug:!1,fatal:!1};if("boolean"==typeof e)return{code:e,error:e,warn:e,info:e,debug:e,fatal:e};{const t=new Set(e);return{code:t.has("code"),debug:t.has("debug"),fatal:t.has("fatal"),error:t.has("error"),warn:t.has("warn"),info:t.has("info")}}}(e);return i||(j.code=()=>{}),r||(j.debug=()=>{}),t||(j.info=()=>{}),o||(j.warn=()=>{}),s||(j.error=()=>{}),n||(j.fatal=()=>{}),B}(e(s,"debug",!0))(new Q),Y.code(U["開始初始化必要模組"]);const o=new W(t({},s));Y.code(U["指定模組初始化完成"],"config");const r=new Z;Y.code(U["指定模組初始化完成"],"storage");const n=new _e(o,r,e(s,"experiment"));return Y.code(U["指定模組初始化完成"],"core"),n.start(),Y.code(U["啟動服務"],"main core"),()=>{n.onDestroy()}}throw new Error(L["環境錯誤(nodejs)"])}export{we as aiiaCore};
1
+ import{get as t,assign as e,forEach as n,map as s,isArray as r,values as o,some as i,isNaN as a,omit as c,keys as u,pick as h,isInteger as p,find as f,filter as l}from"lodash-es";import I from"moment";import{abs as d,matrix as y,multiply as m}from"mathjs";import{Server as g}from"socket.io";import{Subject as b,delay as w,takeUntil as S,fromEvent as k,interval as E,take as O,timer as N,map as D,merge as _}from"rxjs";import C from"axios";import R from"ws";import T from"fs";import A from"os";import P from"path";import{Client as x}from"node-osc";import{spawn as v,exec as M}from"child_process";import L from"systeminformation";import{getWindows as U}from"@nut-tree-fork/nut-js";import*as j from"readline";import{createServer as X}from"net";function G(){var t=["3uNyNKK","11mfdsBH","ERROR CODE: 2001","未獲得媒體裝置權限","ERROR CODE: 1003","重複初始化","ERROR CODE: 1004","網絡錯誤","ERROR CODE: 1001","實例已摧毀","6PjEPOQ","2520YqFLXI","沒有可用專案","1583928HxMyGk","ERROR CODE: 500","3497809OtbvdR","97724ntfKUs","ERROR CODE: 2002","9613810XeusjT","1719eKeJvN","獲取權杖失敗","ERROR CODE: 1002","235182fVRlWj","2197105cpWvgV","ERROR CODE: 2004","Worklet模組載入失敗","ERROR CODE: 2005","環境錯誤(browser)"];return(G=function(){return t})()}function W(t,e){return t-=128,G()[t]}var F,Y,V,K,H,B,J,Z,q;function z(t,e){return t-=374,Q()[t]}function Q(){var t=["9OFiJIn","未授權控制","沒有服務","等待授權","1494748pDmsHp","3767397MUHbLj","1536190Vdbbmh","VAD模組載入失敗","778027ugxlgV","3149540fInulT","8319031ZCVnBd","30nzGjsP","8IYDbqa","可正常使用","已被拒絕","可使用","非預期的狀態","無服務","缺失該裝置","1640850XXgHPI","未響應","未啟動"];return(Q=function(){return t})()}!function(){for(var t=W,e=G();;)try{if(258648===-parseInt(t(138))/1+-parseInt(t(132))/2*(-parseInt(t(144))/3)+-parseInt(t(129))/4+parseInt(t(139))/5+parseInt(t(154))/6*(-parseInt(t(131))/7)+-parseInt(t(155))/8*(parseInt(t(135))/9)+parseInt(t(134))/10*(parseInt(t(145))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),(Y=F||(F={}))[(V=W)(151)]=V(130),Y[V(143)]=V(152),Y[V(141)]=V(137),Y[V(147)]=V(148),Y[V(153)]=V(150),Y["環境錯誤(nodejs)"]=V(146),Y["未提供憑證"]=V(133),Y[V(136)]="ERROR CODE: 2003",Y[V(128)]=V(140),Y[V(149)]=V(142),function(){for(var t=z,e=Q();;)try{if(924377===parseInt(t(382))/1+-parseInt(t(393))/2+parseInt(t(379))/3+parseInt(t(378))/4+parseInt(t(380))/5*(-parseInt(t(385))/6)+-parseInt(t(384))/7*(-parseInt(t(386))/8)+parseInt(t(374))/9*(-parseInt(t(383))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),(H=K||(K={}))[H[(B=z)(394)]=1]=B(394),H[H["等待授權"]=2]=B(377),H[H[B(388)]=3]=B(388),H[H[B(381)]=4]=B(381),H[H[B(387)]=5]=B(387),H[H["缺失該裝置"]=6]=B(392),H[H[B(376)]=7]=B(376),(Z=J||(J={}))[Z[(q=z)(390)]=1]="非預期的狀態",Z[Z[q(375)]=2]="未授權控制",Z[Z[q(395)]=3]=q(395),Z[Z[q(391)]=4]=q(391),Z[Z[q(389)]=5]=q(389);const $=et;!function(){const t=et,e=st();for(;;)try{if(433699===-parseInt(t(300))/1+-parseInt(t(305))/2*(-parseInt(t(307))/3)+parseInt(t(308))/4+-parseInt(t(306))/5+-parseInt(t(304))/6*(parseInt(t(309))/7)+-parseInt(t(302))/8+parseInt(t(297))/9*(parseInt(t(299))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const tt=$(301);function et(t,e){t-=297;return st()[t]}$(303);const nt="undefined"!=typeof process&&null!=process[$(310)]&&null!=process.versions.node;function st(){const t=["3886008bwONeC","undefined","2251842EAGNdE","8ExagCX","4016195xBceqI","372522fjXHYk","2359072IcEnDA","14MdcuJB","versions","4574097VtjqLo","number","40nHnPwj","646093ZWwgiY","access_token"];return(st=function(){return t})()}function rt(t){return new Promise(e=>{setTimeout(e,t)})}const ot=it;function it(t,e){t-=163;return ct()[t]}!function(){const t=it,e=ct();for(;;)try{if(643213===-parseInt(t(186))/1*(parseInt(t(168))/2)+parseInt(t(164))/3+parseInt(t(169))/4+-parseInt(t(191))/5+-parseInt(t(173))/6+parseInt(t(196))/7+parseInt(t(179))/8*(parseInt(t(180))/9))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class at{[ot(192)];get[ot(203)](){const t=ot;return this[t(170)](t(203))}get[ot(172)](){const t=ot,e=this[t(170)](t(189));return typeof e===t(194)?e:t(187)}get[ot(165)](){const t=ot;return this[t(170)](t(165))??""}get[ot(174)](){const t=ot;return this[t(170)](t(174))}get port(){const t=ot;return function(t,e){const n=typeof e===$(298)?e:NaN;if(t){const e=Number(t);return isNaN(e)?n:e}return n}(process.env[t(184)],this[t(170)](t(182))??3e3)}get[ot(176)](){const t=this[ot(170)]("ws_url");return"string"==typeof t?t:""}get[ot(177)](){const t=ot,e=this[t(170)](t(177));return typeof e===t(194)?e:""}get[ot(183)](){const e=ot,n=this[e(170)]("project");if(void 0===n)return{specific:!1};if(typeof n===e(194))return{name:n,id:n,specific:!1};{const e=t(n,"id",void 0),s=t(n,"name",void 0);return{id:"string"==typeof e?e:void 0,name:"string"==typeof s?s:void 0,specific:!0}}}get[ot(197)](){const t=ot;let e=t(163);switch(this[t(172)]){case t(202):e=t(188);break;case"test":e="test"}const n="graphen-agentic-workflow-"+e+"-21193779403.asia-east1.run.app";return{api:t(204)+n,socket:"wss://"+n}}get[ot(198)](){const t=ot;return this[t(170)](t(198))??!0}get[ot(195)](){const t=ot;return this[t(170)](t(195))}get[ot(199)](){const t=ot,e=this[t(170)](t(199));return"number"==typeof e&&e>0?e:.3}get llmSampleRate(){const t=ot,e=this[t(170)](t(200));return typeof e===t(178)&&e>0?e:16e3}get[ot(171)](){const t=ot;return e({perSecond:3,confidence:80},this[t(170)](t(190)),this[t(170)](t(201)))}get[ot(181)](){const t=ot,e=this.safeRead(t(167)),n=this[t(170)](t(175));return{userDelayTime:typeof e===t(178)?e:5e3,aiiaDelayTime:typeof n===t(178)?n:NaN}}get[ot(185)](){const t=ot;return Boolean(this.safeRead(t(185)))}get[ot(193)](){const t=ot;return e({x_axis_px:0,y_axis_px:0},this[t(170)](t(166)))}constructor(t){this.config=t}safeRead(e){return t(this[ot(192)],e,void 0)}}function ct(){const t=["webserver","https://","dev","413811oNZoHz","license","correction","autoClearUserSubtitle","1331170ARafnj","1214712qEhGMX","safeRead","detection","environment","4162590XZOSBP","note","autoClearAiiaSubtitle","ws_url","worklet_url","number","431352Ljyprc","153ygYYyI","autoClearSubtitle","port","project","PORT","eyeTrackEnable","1BgsKZX","developement","prod","env","faceDetection","3109470RCovGg","config","eyeTrackCorrection","string","mediaStream","8863533YtgnNx","endPoint","debug","chunkTimeInSeconds","llmSampleRate","cameraDetection","production"];return(ct=function(){return t})()}const ut=lt;var ht;!function(){const t=lt,e=dt();for(;;)try{if(540782===-parseInt(t(502))/1*(parseInt(t(501))/2)+parseInt(t(489))/3*(parseInt(t(506))/4)+parseInt(t(468))/5*(-parseInt(t(476))/6)+parseInt(t(453))/7*(parseInt(t(493))/8)+parseInt(t(463))/9+parseInt(t(449))/10*(parseInt(t(473))/11)+-parseInt(t(471))/12)break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(t){const e=lt;t["通道、雲端服務、麥克風都已就緒"]=e(486),t[e(465)]="CODE: 1001",t[e(457)]="CODE: 1002",t[e(492)]=e(503),t[e(467)]=e(485),t[e(496)]=e(479),t[e(455)]=e(466),t["已啟動SDK"]="CODE: 1014",t[e(505)]=e(499),t[e(483)]=e(494),t[e(472)]=e(450),t[e(454)]=e(495),t[e(488)]="CODE: 2004",t["未預期的斷線,請聯繫Graphen"]=e(469),t[e(451)]="CODE: 2010",t[e(497)]=e(478),t[e(452)]="CODE: 2012",t[e(460)]=e(480)}(ht||(ht={}));const pt={code:console[ut(456)],debug:console.log,info:console[ut(456)],warn:console.warn,error:console[ut(490)],fatal:console[ut(490)]},ft=[];function lt(t,e){t-=449;return dt()[t]}function It(...t){return ft[ut(484)](...t),It}function dt(){const t=["has","4014243kXGSPh","category","未取得媒體裝置權限,請重新設定或忽略此訊息","CODE: 1013","指定依賴已完成","3797740dJEowL","CODE: 2005","info","12253920NtvTeU","與雲端的服務中斷","561buLbZG","code","string","6fuueAk","debug","CODE: 2011","CODE: 1012","CODE: 2013","all","warn","無副作用的關閉連線","push","CODE: 1011","CODE: 1000","includes","自動重新連線雲端服務","39dPmmCA","error","boolean","初始化必要依賴","1400BNfynD","CODE: 2001","CODE: 2003","啟動SDK","指定模組初始化完成","yyyy-MM-DD[T]HH:mm:ss:sss","CODE: 2000","next","974aIcolo","134CbqOcV","CODE: 1010","fatal","安全的關閉連線","290024lxZqaU","6680jzQZWi","CODE: 2002","開始初始化必要模組","啟動服務","38563HXhbty","沒有授權,請聯繫Graphen","結束SDK","log","請訂閱專案列表","default","[Aiia::","服務結束","format"];return(dt=function(){return t})()}function yt(t){return new Proxy(pt,{get(e,s,r){const o=lt;if(typeof s===o(475))switch(s){case o(477):case"info":case o(490):case"warn":case o(504):case o(474):return(...r)=>{const i=o,a=I()[i(461)](i(498));n(ft,e=>{const n=i;(void 0===e[n(464)]||e[n(464)][n(487)](t))&&e[n(500)](s,a,t,...r)}),e[s](i(459)+s+"_"+a+"_]("+t+")",...r)};default:return}},set:(t,e,n,s)=>!0})}const mt=yt(ut(458));function gt(t,e){t-=224;return bt()[t]}function bt(){const t=["boundingBox","7044Tmgcdj","8biSMSA","717786bWUdpp","score","307360XSROVs","7iVlxYg","44zzFmnm","22072IkqAwn","396544PcivuX","categories","343032RDhXzX","width","94tvuwUi","height","390230EkLRXI","get"];return(bt=function(){return t})()}function wt(){var t=["19045960kmzEwy","842047PbegzN","3255875YUtnSU","321108lLQqaX","1292592iRELZd","3787272iaPspA","2OSZcXz","455336pPyvUp"];return(wt=function(){return t})()}function St(t,e){return t-=437,wt()[t]}!function(){const t=gt,e=bt();for(;;)try{if(100772===parseInt(t(239))/1+-parseInt(t(227))/2*(-parseInt(t(232))/3)+-parseInt(t(240))/4+-parseInt(t(229))/5+parseInt(t(225))/6*(-parseInt(t(237))/7)+parseInt(t(233))/8*(parseInt(t(234))/9)+parseInt(t(236))/10*(parseInt(t(238))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(){for(var t=St,e=wt();;)try{if(434169===-parseInt(t(440))/1*(parseInt(t(437))/2)+parseInt(t(442))/3+-parseInt(t(438))/4+-parseInt(t(441))/5+-parseInt(t(444))/6+parseInt(t(443))/7+parseInt(t(439))/8)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const kt=Ot;function Et(){const t=["Websocket server run on","225qYNEHA","out","memberSub","client off","connection","start","1832UNjitF","debug","webserver","9414KftLNk","next","109984nyfIIJ","client on","port","config","3388xHEYoT","info","server","236674AgjjdN","asObservable","1249262hgloYg","595685GnIuQA","ChatModule","listen","156000gHHZsU","onDestroy"];return(Et=function(){return t})()}function Ot(t,e){t-=335;return Et()[t]}!function(){const t=Ot,e=Et();for(;;)try{if(108067===-parseInt(t(343))/1+-parseInt(t(350))/2+-parseInt(t(359))/3*(-parseInt(t(347))/4)+-parseInt(t(353))/5+-parseInt(t(356))/6+parseInt(t(352))/7+parseInt(t(338))/8*(parseInt(t(341))/9))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const Nt=yt(kt(354));class Dt{[kt(346)];server;memberSub;get[kt(345)](){const t=kt;return this[t(346)][t(345)]}get[kt(340)](){const t=kt;return this[t(346)][t(340)]}get memberChange(){const t=kt;return this[t(361)][t(351)]()}constructor(t){this[kt(346)]=t,this.memberSub=new b}[kt(337)](){const t=kt;if(this[t(349)]=new g(this.webserver,{cors:{origin:"*"}}),this[t(349)].on(t(336),e=>{const n=t;Nt[n(339)](n(344),e.id),this[n(361)][n(342)]({type:"in",socket:e}),e.on("disconnect",t=>{const s=n;Nt[s(339)](s(335),e.id,"reason",t),this.memberSub[s(342)]({type:s(360),socket:e})})}),void 0===this[t(340)]){const e=this[t(345)];this.server[t(355)](e),Nt[t(348)](t(358),e)}else Nt[t(348)]("Websocket server rely your webserver.")}[kt(357)](){const t=kt;this[t(349)]&&this[t(349)].close()}}const _t=Ct;function Ct(t,e){t-=406;return Rt()[t]}function Rt(){const t=["post","4277808kzqahM","/api/v1/license/projects","/api/v1/license/agent_token","catch","4084104VdBVAZ","6566651raWKmo","now","data","note","沒有可用專案","data.projects","1804444xrhYTt"," milliseconds.","then","1525353zDUHJV","onDestroy","debug","獲取權杖失敗","Complete certification","網絡錯誤","Took ","create","getAccessToken","instance","signal","4310GqjkHf","abort","Got Project List","8394YfnsrZ","105021fqeXXn","controller","token_value"];return(Rt=function(){return t})()}!function(){const t=Ct,e=Rt();for(;;)try{if(877029===-parseInt(t(435))/1+parseInt(t(417))/2+-parseInt(t(420))/3+-parseInt(t(410))/4+-parseInt(t(431))/5*(-parseInt(t(434))/6)+parseInt(t(411))/7+-parseInt(t(406))/8)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const Tt=yt("ApiProxyModule");class At{[_t(429)];controller;constructor(t){const e=_t;this.controller=new AbortController,this.instance=C[e(427)]({baseURL:t,signal:this[e(436)][e(430)]})}async[_t(428)](e,n,s){const r=_t,o=performance[r(412)](),i={license_number:e,token_value:n??""};s&&(i[r(414)]=s);const a=await this[r(429)][r(438)](r(408),i)[r(419)](e=>t(e[r(413)],r(437),""))[r(409)](()=>null);if(Tt[r(422)](r(424),r(426)+(performance[r(412)]()-o)+r(418)),null===a)throw new Error(F["網絡錯誤"]);if(""===a)throw new Error(F[r(423)]);return a}async getProjectList(e){const n=_t,r=performance[n(412)](),o=await this.instance[n(438)](n(407),{license_number:e})[n(419)](e=>s(t(e,n(416),[]),({id:t,sub_project_name:e,avatar:n})=>{const{name:s,url:r}=n;return{avatar:{name:s,url:r},id:t,name:e}}))[n(409)](t=>null);if(Tt[n(422)](n(433),n(426)+(performance[n(412)]()-r)+n(418)),null===o)throw new Error(F[n(425)]);if(0===o.length)throw new Error(F[n(415)]);return o}[_t(421)](){const t=_t;this[t(436)][t(432)]()}}function Pt(){const t=["parse","79956qdKWvI","5023020tKvAyT","2054EdPkbq","stringify","pong","5276646ABgGRt","195SlVgyG","550LHavBA","53948seegzu","string","unknow","6mXMTGr","6662xipfvZ","beat","7xXThtT","3259912PBcbdk","280005VtKMPV","signal","message","253JCOjnK"];return(Pt=function(){return t})()}const xt=Mt;var vt;function Mt(t,e){t-=332;return Pt()[t]}!function(){const t=Mt,e=Pt();for(;;)try{if(883260===-parseInt(t(338))/1*(-parseInt(t(352))/2)+parseInt(t(346))/3*(parseInt(t(348))/4)+-parseInt(t(341))/5*(parseInt(t(351))/6)+-parseInt(t(333))/7*(-parseInt(t(334))/8)+-parseInt(t(345))/9+parseInt(t(347))/10*(parseInt(t(335))/11)+-parseInt(t(340))/12*(parseInt(t(342))/13))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(t){const e=Mt;t[t.unknow=0]=e(350),t[t[e(332)]=1]="beat",t[t.message=2]=e(337)}(vt||(vt={}));const Lt=JSON[xt(343)]({request:"ping",content:"2"}),Ut=jt;function jt(t,e){t-=214;return Xt()[t]}function Xt(){const t=["isConnected","與雲端的服務中斷","MDN_RESERVED_1004","180QfOcNW","), ",") - 雲端代理(","MDN_PROTOCOL_ERROR","closeSub","MDN_NO_STATUS_RECEIVED","Proxy has some problem","安全的關閉連線","2117421nciJNY","116488YNlmyc","沒有授權,請聯繫Graphen","WS_4104_LLM_SESSION_ERROR","SocketProxtModule","19674DDhZdg","WS_4103_TOKEN_EXPIRED","13268035AGXRTs","warn",", Type: ","7983209vYXMrV","readyState","averageLatency","slice","stringify","4iCvxHs","now","MDN_ABNORMAL_CLOSURE","WS_4100_NORAML_CLOSURE","socket","onDestroy","send","complete","正在關閉雲端服務","MDN_UNSUPPORTED_DATA",", 錯誤碼: ","21fIFdKb","MDN_MESSAGE_TOO_BIG","正在連線雲端服務中","shift","create proxy for browser(","瀏覽器(","lastCloseLog","10LHWPIi","最近一次關閉原因: ","2170BtvVOG","open","format","send message fail","pingSub","socket code: ","code","WHEN_BROWSER_CLOSE","reduce","length","MDN_INVALID_FRAME_PAYLOAD","currentTime: ","yyyy-MM-DD[T]HH:mm:ss:sss","push","uuid","getStatusInfo","setPing","pipe","MDN_MANDATORY_EXTENSION","no_permissions","MDN_POLICY_VIOLATION","59640qqpUuG","MDN_INTERNAL_ERROR","messageSub","linkStart","雲端服務尚未啟動","pingTime","24voxGgx","OPEN","beat","MDN_NORMAL_CLOSURE","url","subscribe","asObservable","MDN_BAD_GATEWAY","自動重新連線雲端服務","setPong","未知的 Websocket 狀態: ","The socket is not connected","Destroy cloud channel(","destorySub","reconnect","WS_4105_TOO_MANY_CONNECTIONS","proxy","雲端服務已關閉","close","type","MDN_SERVICE_RESTART","linkStartSub","next","message","WS_4102_LICENSE_EXPIRED","WS_4101_UNAUTHORIZED","MDN_TRY_AGAIN_LATER","error","2104496RSwrvu","MDN_TLS_HANDSHAKE","MDN_GOING_AWAY","_latency"];return(Xt=function(){return t})()}!function(){const t=jt,e=Xt();for(;;)try{if(637584===parseInt(t(227))/1*(parseInt(t(259))/2)+parseInt(t(226))/3*(parseInt(t(241))/4)+-parseInt(t(218))/5*(parseInt(t(282))/6)+-parseInt(t(252))/7*(parseInt(t(316))/8)+parseInt(t(231))/9*(parseInt(t(261))/10)+-parseInt(t(233))/11+parseInt(t(288))/12*(parseInt(t(236))/13))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const Gt=yt(Ut(230));var Wt;!function(t){const e=Ut;t[t[e(291)]=1e3]=e(291),t[t[e(318)]=1001]=e(318),t[t[e(221)]=1002]="MDN_PROTOCOL_ERROR",t[t[e(250)]=1003]=e(250),t[t[e(217)]=1004]=e(217),t[t[e(223)]=1005]=e(223),t[t[e(243)]=1006]=e(243),t[t[e(271)]=1007]="MDN_INVALID_FRAME_PAYLOAD",t[t[e(281)]=1008]="MDN_POLICY_VIOLATION",t[t[e(253)]=1009]=e(253),t[t.MDN_MANDATORY_EXTENSION=1010]=e(279),t[t[e(283)]=1011]=e(283),t[t[e(308)]=1012]=e(308),t[t[e(314)]=1013]="MDN_TRY_AGAIN_LATER",t[t[e(295)]=1014]="MDN_BAD_GATEWAY",t[t[e(317)]=1015]=e(317),t[t[e(268)]=4001]=e(268),t[t[e(244)]=4100]=e(244),t[t[e(313)]=4101]=e(313),t[t[e(312)]=4102]=e(312),t[t.WS_4103_TOKEN_EXPIRED=4103]=e(232),t[t[e(229)]=4104]="WS_4104_LLM_SESSION_ERROR",t[t.WS_4105_TOO_MANY_CONNECTIONS=4105]=e(303)}(Wt||(Wt={}));class Ft{id;uuid;[Ut(245)];[Ut(284)];[Ut(265)];[Ut(309)];[Ut(301)];[Ut(222)];[Ut(258)];_latency=[];pingTime=NaN;get[Ut(292)](){const t=Ut;return this[t(245)]?.[t(292)]}get[Ut(311)](){return this[Ut(284)].asObservable()}get[Ut(306)](){const t=Ut;return this.closeSub[t(294)]()}get[Ut(285)](){const t=Ut;return this[t(309)][t(294)]()}get[Ut(215)](){const t=Ut;return this[t(245)]?.[t(237)]===R[t(289)]}get latency(){const t=Ut,e=this[t(214)][t(270)];return e>1?this._latency[e-1]:NaN}get[Ut(238)](){const t=Ut,e=this[t(214)][t(270)];if(e>=1){return this[t(214)][t(269)]((t,e)=>t+e,0)/e}return NaN}constructor(t){const e=Ut;this.id=t,this.messageSub=new b,this[e(265)]=new b,this[e(309)]=new b,this.closeSub=new b,this[e(301)]=new b,this[e(275)]=crypto.randomUUID(),this.pingSub[e(278)](w(2e4),S(this[e(301)]))[e(293)](()=>{const t=e;this[t(215)]&&(this[t(277)](),this[t(245)].send(Lt))}),Gt.debug(e(256)+this.id+")")}start(e){const n=Ut;this[n(245)]=new R(e,{autoPong:!0}),k(this.socket,n(262)).pipe(S(this[n(301)]))[n(293)](()=>{const t=n;Gt[t(267)](ht["啟動服務"],t(304)),this[t(309)][t(310)](),this[t(265)].next()}),k(this[n(245)],n(311))[n(278)](S(this[n(301)]))[n(293)](e=>{const s=n,{data:a}=e,c=function(e){const n=Mt;if(typeof e!==n(349))return{type:vt.unknow};try{let s=[];const a=JSON[n(339)](e);return s=t(a,n(336))?[a]:r(a)?a:o(a),i(s,({signal:t})=>t===n(344))?{type:vt[n(332)]}:{type:vt.message,data:s}}catch(t){return{type:vt[n(350)]}}}(a);switch(c[s(307)]){case vt[s(290)]:this[s(297)](),this[s(265)][s(310)]();break;case vt[s(311)]:this[s(284)][s(310)](c.data);break;case vt.unknow:default:Gt[s(234)]("Got a message, but failed",a)}}),k(this[n(245)],n(315))[n(278)](S(this[n(301)]))[n(293)](t=>{const e=n,{error:s}=t;Gt[e(315)](e(224),s)}),k(this[n(245)],n(306)).pipe(S(this[n(301)])).subscribe(t=>{const e=n,{code:s,reason:r,type:o,wasClean:i}=t;switch(this[e(258)]=e(260)+r+e(251)+s+e(235)+o,s){case Wt[e(268)]:Gt[e(267)](ht["無副作用的關閉連線"]),this[e(246)]();break;case Wt[e(291)]:case Wt[e(318)]:this[e(222)][e(310)](e(306)),Gt[e(267)](ht[e(225)]);break;case Wt[e(223)]:case Wt[e(243)]:this[e(222)].next(e(306)),Gt[e(267)](ht[e(216)],{code:s,reason:r,type:o,wasClean:i});break;case Wt[e(244)]:case Wt.WS_4103_TOKEN_EXPIRED:case Wt[e(229)]:case Wt[e(303)]:this[e(222)][e(310)](e(302)),Gt.code(ht[e(296)],"socket code: "+s);break;case Wt.WS_4101_UNAUTHORIZED:case Wt[e(312)]:this[e(222)][e(310)](e(280)),Gt[e(267)](ht[e(228)],e(266)+s);break;default:this[e(222)][e(310)](e(306)),Gt[e(267)](ht["未預期的斷線,請聯繫Graphen"],{code:s,reason:r,type:o,wasClean:i})}})}[Ut(277)](){const t=Ut;a(this[t(287)])&&(this[t(287)]=Date[t(242)]())}[Ut(297)](){const t=Ut;if(!a(this.pingTime)){const e=Date.now()-this[t(287)];this._latency[t(274)](e/2),this[t(287)]=NaN,this[t(214)].length>6&&this[t(214)][t(255)]()}}[Ut(247)](t){const e=Ut,n=e(272)+I()[e(263)](e(273));this[e(215)]?this[e(245)].send(t,s=>{const r=e;s&&Gt[r(315)](r(264),n,t[r(239)](0,100),s)}):Gt[e(234)](e(299),n,t[e(239)](0,100))}sendToCloud(t){const e=Ut;this.send(JSON[e(240)](t))}[Ut(276)](){const t=Ut,e=(()=>{const t=jt;if(!this[t(245)])return t(286);{const e=this[t(245)][t(237)];switch(e){case 0:return t(254);case 1:return"雲端服務正常運作";case 2:return t(249);case 3:return t(305);default:return t(298)+e}}})(),n=this.lastCloseLog?e+", "+this[t(258)]:e;return{proxy_id:this[t(275)],latency:this.latency,averageLatency:this[t(238)],proxy_state:this[t(245)]?.readyState??-1,msg:t(257)+this.id+t(220)+this[t(275)]+t(219)+n}}[Ut(246)](){const t=Ut;this.destorySub[t(310)](),this.destorySub[t(248)](),Gt.debug(t(300)+this[t(275)]+")")}}function Yt(t,e){t-=408;return Kt()[t]}const Vt=Yt;function Kt(){const t=["platform","當前系統是未知的平台: ","mkdirSync","saveFolder","aiia-sdk","1507344uDlzcG","linux","EOL","existsSync","217190dTQgzJ","7FyQaZu","fileCheck","1213415PsufEb","AppName","Application Support","userName","isWIN","addPath","7DrrexW","XDG_CONFIG_HOME","env","join","writeFileSync","homedir","AppData","167622tIYJNF","username","log","5764208oUPxyN","2595832vCViQl","darwin","isLINUX","appFolder","utf8","Library","18bSgdRC","folderCheck","1645400jxsaJZ","isMAC"];return(Kt=function(){return t})()}!function(){const t=Yt,e=Kt();for(;;)try{if(388618===parseInt(t(423))/1*(-parseInt(t(422))/2)+-parseInt(t(438))/3+parseInt(t(442))/4+-parseInt(t(425))/5+parseInt(t(418))/6*(-parseInt(t(431))/7)+parseInt(t(441))/8+-parseInt(t(409))/9*(-parseInt(t(411))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class Ht{[Vt(426)];platform;[Vt(412)];[Vt(429)];[Vt(444)];[Vt(416)];[Vt(436)];[Vt(445)];[Vt(428)];[Vt(420)];constructor(t){const e=Vt;switch(this[e(426)]=t,this[e(413)]=process[e(413)],this[e(436)]=A[e(436)](),this[e(428)]=A.userInfo()[e(439)],this[e(420)]=A[e(420)],this[e(413)]){case e(443):this[e(412)]=!0,this[e(429)]=!1,this[e(444)]=!1,this[e(416)]=P[e(434)](this[e(436)],e(408),e(427));break;case"win32":this[e(412)]=!1,this.isWIN=!0,this[e(444)]=!1,this.saveFolder=process[e(433)].APPDATA||P[e(434)](this[e(436)],e(437),"Roaming");break;case e(419):this[e(412)]=!1,this.isWIN=!1,this[e(444)]=!0,this[e(416)]=process[e(433)][e(432)]||P[e(434)](this[e(436)],".config");break;default:console[e(440)](e(414)+this[e(413)]),this[e(412)]=!1,this[e(429)]=!1,this[e(444)]=!1,this[e(416)]=this[e(436)]}this[e(445)]=P[e(434)](this[e(416)],this.AppName),this[e(410)](this[e(445)])}addPath(...t){return P[Vt(434)](...t)}[Vt(410)](t){T[Vt(415)](t,{recursive:!0})}createFolder(t){const e=Vt,n=this[e(430)](this[e(445)],t);return this[e(410)](n),n}[Vt(424)](t,e=""){const n=Vt;!T[n(421)](t)&&T[n(435)](t,e,{encoding:n(446)})}}const Bt=new Ht(Vt(417));function Jt(){var t=["1794640SFdOmg","4163376tDekSM","2016296zHJWax","14muFtkV","126254aFeunp","3002229MduuDk","15cyenKe","697175ULsNfp","479398RFKdnD"];return(Jt=function(){return t})()}function Zt(t,e){return t-=174,Jt()[t]}!function(){for(var t=Zt,e=Jt();;)try{if(350697===parseInt(t(179))/1+-parseInt(t(175))/2*(-parseInt(t(177))/3)+-parseInt(t(180))/4+-parseInt(t(178))/5+-parseInt(t(181))/6+parseInt(t(174))/7*(parseInt(t(182))/8)+parseInt(t(176))/9)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const qt=$t;function zt(){const t=["2743572XTuVuY","20052WbcXGh","10415817kEIuRH","parse","1iELxCO","storage.json","205824MegpBH","26418tyEpGT","clearSync","getItem","setItemSyncByRecoord","setItemSync","writeFileSync","readFile","utf8","clear","appFolder","removeItemSync","fileCheck","node","stringify","112pVTadB","removeItem","fileName","110jwrXvu","35IKEwIX","107330luWGTN","1471340wCDQmW","getFileData","setFileData","352bXMmNb","filePath","getFileDataSync","setFileDataSync","setItem"];return(zt=function(){return t})()}!function(){const t=$t,e=zt();for(;;)try{if(629130===parseInt(t(274))/1*(-parseInt(t(296))/2)+parseInt(t(306))/3*(-parseInt(t(291))/4)+-parseInt(t(295))/5*(parseInt(t(276))/6)+-parseInt(t(277))/7*(parseInt(t(300))/8)+-parseInt(t(272))/9+parseInt(t(297))/10+parseInt(t(294))/11*(parseInt(t(305))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class Qt{type=qt(289);filePath;[qt(293)];constructor(){const t=qt;this.fileName=t(275),this[t(301)]=Bt.addPath(Bt[t(286)],this[t(293)]),Bt[t(288)](this[t(301)])}[qt(302)](){const t=qt,e=T.readFileSync(this[t(301)],t(284));try{return JSON[t(273)](e)}catch(t){return{}}}setFileDataSync(t){const e=qt;try{const n=JSON[e(290)](t);T[e(282)](this[e(301)],n,e(284))}catch(t){}}async[qt(298)](){return new Promise(t=>{const e=$t;T[e(283)](this.filePath,e(284),(n,s)=>{const r=e;if(n)t({});else try{t(JSON[r(273)](s))}catch(e){t({})}})})}async setFileData(t){return new Promise(e=>{const n=$t;try{const s=JSON[n(290)](t);T.writeFile(this[n(301)],s,"utf8",t=>{e()})}catch(t){}})}async[qt(279)](t){const e=qt;return(await this[e(298)]())[t]??null}async[qt(304)](t,e){const n=qt,s=await this.getFileData();s[t]=e,await this[n(299)](s)}async[qt(292)](t){const e=qt,n=await this[e(298)](),s=c(n,t);await this[e(299)](s)}async[qt(285)](){const t=qt;await this[t(299)]({})}getItemSync(t){return this[qt(302)]()[t]??null}[qt(281)](t,e){const n=qt,s=this[n(302)]();s[t]=e,this[n(303)](s)}[qt(280)](t){const e=this[qt(302)]();n(u(t),n=>{e[n]=t[n]}),this.setFileDataSync(e)}[qt(287)](t){const e=qt,n=c(this.getFileDataSync(),t);this[e(303)](n)}[qt(278)](){this[qt(303)]({})}}function $t(t,e){t-=272;return zt()[t]}const te=ee;function ee(t,e){t-=468;return oe()[t]}!function(){const t=ee,e=oe();for(;;)try{if(252291===parseInt(t(483))/1*(-parseInt(t(527))/2)+-parseInt(t(488))/3+parseInt(t(498))/4+parseInt(t(477))/5+parseInt(t(473))/6*(-parseInt(t(481))/7)+parseInt(t(475))/8+parseInt(t(480))/9)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const ne={[ht[te(518)]]:te(518),[ht[te(484)]]:te(484),[ht[te(508)]]:"請訂閱專案列表",[ht[te(486)]]:"初始化必要依賴",[ht[te(494)]]:te(494),[ht[te(492)]]:te(492),[ht[te(510)]]:te(510),[ht[te(526)]]:te(526),[ht[te(476)]]:te(476),[ht[te(487)]]:te(487),[ht[te(509)]]:"與雲端的服務中斷",[ht[te(505)]]:te(505),[ht[te(468)]]:te(468),[ht["未預期的斷線,請聯繫Graphen"]]:te(513),[ht["開始初始化必要模組"]]:te(523),[ht[te(482)]]:te(482),[ht[te(474)]]:"啟動服務",[ht[te(511)]]:te(511),[F[te(522)]]:te(522),[F[te(507)]]:te(516),[F["Worklet模組載入失敗"]]:te(499),[F["未獲得媒體裝置權限"]]:te(530),[F[te(495)]]:te(495),[F[te(517)]]:te(514),[F[te(497)]]:"未提供憑證",[F[te(469)]]:"獲取權杖失敗",[F[te(502)]]:te(502),[F[te(504)]]:te(504)},se=new RegExp(/^(ERROR )?CODE: [0-9]{3,4}$/);class re{path;constructor(t){const e=te;this[e(485)]=t?Bt[e(470)](t):Bt[e(493)]}next(t,e,n,...s){const r=te,o=I()[r(528)](r(520)),i=r(490)+o+r(496),a=Bt.addPath(this[r(485)],i),c=t===r(501)?t=>se[r(519)](t)?t+"("+ne[t]+")":t:t=>t;try{const o=s[r(478)]((t,e)=>{const n=r;if(e instanceof Error){let s=n(503)+(e[n(529)]??"No Message")+"]"+Bt[n(489)];return s+=e[n(535)]??n(471),typeof e[n(534)]===n(500)&&(s+=Bt.EOL+n(472)+e[n(534)]),""+t+Bt[n(489)]+s+Bt[n(489)]}switch(typeof e){case n(500):return t+" "+c(e);case n(479):case n(532):return t+" "+e[n(533)]();case"boolean":return t+" "+(e?n(521):"false");case n(524):try{return t+" "+JSON[n(531)](e)}catch(e){return t}case n(506):case n(525):case n(515):return t+" ["+typeof e+"]"}},"");T.appendFileSync(a,r(491)+t+")__"+e+"__"+n+"__::"+o+Bt[r(489)],{encoding:r(512)})}catch(t){}}}function oe(){const t=["cause","stack","自動重新連線雲端服務","獲取權杖失敗","createFolder","unknow stack","cause: ","313638xkTeFT","啟動服務","3231984SLXJhh","安全的關閉連線","770660dimGls","reduce","number","5037435ZdadVx","63AcAzMf","指定模組初始化完成","98402dxAoSA","未取得媒體裝置權限,請重新設定或忽略此訊息","path","初始化必要依賴","無副作用的關閉連線","1200999bVzoZs","EOL","log_","LOG(","啟動SDK","appFolder","指定依賴已完成","實例已摧毀",".txt","未提供憑證","1988984IwbKaN","Worklet模組載入失敗","string","code","沒有可用專案","Error[","重複初始化","沒有授權,請聯繫Graphen","symbol","環境錯誤(browser)","請訂閱專案列表","與雲端的服務中斷","結束SDK","服務結束","utf8","未預期的斷線,請聯繫Graphen","nodejs","function","環境錯誤","環境錯誤(nodejs)","通道、雲端服務、麥克風都已就緒","test","yyyy-MM-DD","true","網絡錯誤","開始初始化必要模組","object","undefined","已啟動SDK","10LxISxg","format","message","未獲得媒體裝置權限","stringify","bigint","toString"];return(oe=function(){return t})()}function ie(t,e){t-=166;return pe()[t]}const ae=ie;!function(){const t=ie,e=pe();for(;;)try{if(745317===parseInt(t(169))/1+-parseInt(t(174))/2*(parseInt(t(176))/3)+parseInt(t(175))/4+-parseInt(t(179))/5+-parseInt(t(170))/6*(parseInt(t(173))/7)+-parseInt(t(182))/8*(-parseInt(t(166))/9)+-parseInt(t(171))/10*(-parseInt(t(181))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const ce=ae(178),ue={AvatarPort:9876,ActionPort:6969,LocationPort:4060,LookPort:6745,BackGroundPort:2400},he={StreamAudioPort:8080,CleanAudioPort:8081};function pe(){const t=["127.0.0.1","3155535vkSLBo","ShortHair","330XlQqHl","80caZaoW","1026576LmFxbw","keys","DoctorSuit","761453xbCbqK","6xCxblY","59610pOdCGc","reduce","1718465XnlaCi","2gOhzjS","3533568xCXkTc","4027188xCzmkz","toString"];return(pe=function(){return t})()}function fe(){return{...ue,...he}}function le(t){const e=ae;return Object[e(167)](t)[e(172)]((n,s)=>{const r=e;return{...n,[s]:t[s][r(177)]()}},{})}function Ie(t){const e=ae;return Object[e(167)](t)[e(172)]((e,n)=>({...e,[n]:Number(t[n])}),{})}ae(168),ae(180);const de=ye;function ye(t,e){t-=219;return be()[t]}!function(){const t=ye,e=be();for(;;)try{if(262332===parseInt(t(223))/1*(parseInt(t(248))/2)+parseInt(t(247))/3+-parseInt(t(238))/4*(parseInt(t(258))/5)+-parseInt(t(231))/6*(parseInt(t(235))/7)+-parseInt(t(224))/8*(-parseInt(t(252))/9)+parseInt(t(257))/10*(-parseInt(t(249))/11)+-parseInt(t(240))/12*(parseInt(t(220))/13))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const me=yt(de(237));class ge{[de(255)];[de(233)];[de(221)];y_axis_px;[de(242)];constructor(){const t=de;this.udpClient=new Map,this.x_axis_px=0,this[t(244)]=0,this[t(242)]={};const e=h(ue,"AvatarPort",t(219),t(232),t(239));n(u(e),n=>{const s=t,r=n,o=e[r][s(229)]();this[s(242)][o]=r})}[de(243)](t){n(u(t),e=>{const n=ye,s=new x(ce,t[e]);this[n(255)][n(227)](e,s)})}enableEyeTrack(t){const e=de;this[e(233)]=new x(ce,t[e(225)]),this[e(221)]=t[e(221)],this[e(244)]=t.y_axis_px}[de(251)](t){const n=de;if(void 0!==this[n(233)]){const s=null!==t,{x:r,y:o}=(()=>{const r=n;if(s){const{x:n,y:s}=function(t,n){const s=gt,{maxX:r,maxY:o,minX:i,minY:a}=e({maxX:25,minX:-25,maxY:50,minY:-50},n),c=d(r)+d(i),u=d(o)+d(a),{clientHeight:h,clientWidth:p,originX:f,originY:l,width:I,height:g}=t,b=y([[c/p,0,i],[0,u/h,a],[0,0,1]]),w=y([[f+I/2],[h-(l+g/2)],[1]]),S=m(b,w);return{x:S[s(230)]([0,0]),y:S[s(230)]([1,0])}}(t);return{x:this[r(253)](n+this[r(221)]),y:this.toFloat(s+this[r(244)])}}return{x:this[r(253)](7),y:this[r(253)](20)}})();this[n(233)][n(250)](["/",r,o],t=>{const e=n;null!=t&&me[e(222)](e(228),t)})}}[de(254)](e){s(e,({content:e})=>{const n=ye,s=t(e,n(225),"")[n(229)](),r=this[n(242)][s];if(this.udpClient[n(241)](r)){const s=t(e,n(245));this[n(255)][n(236)](r)[n(250)](s,t=>{const e=n;t&&me[e(222)](e(226),t)})}})}toFloat(t){return p(t)?t+1e-5:t}[de(246)](){const t=de;n(Array[t(234)](this.udpClient),([e,n])=>{n[t(230)]()}),me[t(256)]("Close all UnrealEngine's UDP")}}function be(){const t=["BackGroundPort","852fuMBSC","has","mapping","enableUDPClient","y_axis_px","message","onDestroy","1257327aUFmKu","116562ZuPftF","77gfQaZE","send","eyeTrack","9EwnNjC","toFloat","movement","udpClient","debug","744220kKUyGQ","13315dQFKFe","ActionPort","12129QemQLo","x_axis_px","error","6EKOdyj","2404592nglqWt","port","Occur error when send message to UE","set","Eye track error:","toString","close","18mvcYcy","LocationPort","eyeBallUdp","from","158781IKcLKX","get","UnrealUdpModule","228pJbWXv"];return(be=function(){return t})()}const we=Ee;!function(){const t=Ee,e=ke();for(;;)try{if(464010===-parseInt(t(452))/1+-parseInt(t(467))/2+parseInt(t(477))/3+-parseInt(t(482))/4+-parseInt(t(460))/5*(-parseInt(t(447))/6)+-parseInt(t(448))/7+parseInt(t(470))/8)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const Se=yt(we(463));function ke(){const t=["Send to Unreal fail, type speech","debug","2172684BWwcKI","speechIsConnected","Unreal tools connection successful","interrupt","complete","1060036VpWvMZ","close","interruptWS","length","5473068ZDZCxz","5246080yQHPjU","speech","info","getSocket","615285mvRUqv","connectSocket","type ","intrIsConnected","speechWS","UE Tool(",") fail: ","onclose","5mFmrOz","onDestroy","send","UnrealSocketModule","interrupted","retrySub","readyState","849566STrNUw","next","onerror","7056968HPafho","error",") close, try reconnecting after a delay","destroy","allocUnsafe"];return(ke=function(){return t})()}function Ee(t,e){t-=446;return ke()[t]}class Oe{[we(473)];retrySub;speechWS;[we(484)];get speechIsConnected(){const t=we;return this[t(456)]?.[t(466)]===R.OPEN}get[we(455)](){const t=we;return this[t(484)]?.[t(466)]===R.OPEN}constructor(){const t=we;this[t(473)]=new b,this[t(465)]=new b}[we(453)](t){const e=we;this.speechWS=this[e(451)](t[e(449)],"speech"),this.interruptWS=this[e(451)](t[e(480)],e(480)),this[e(465)].pipe(w(1e3),S(this[e(473)])).subscribe(n=>{const s=e;switch(n){case s(449):this.speechWS=this[s(451)](t[s(449)],s(449));break;case s(480):this[s(484)]=this[s(451)](t.interrupt,s(480))}})}[we(451)](t,e){const n=we,s=new R("ws://"+ce+":"+t);return s.onopen=()=>{const t=Ee;Se.debug(t(479),t(454)+e)},s[n(469)]=s=>{const r=n,{message:o,error:i,type:a}=s;Se[r(471)](r(457)+e+r(458)+o,i,{port:t,type:a})},s[n(459)]=s=>{const r=n,{code:o,reason:i,type:a}=s;Se[r(476)](r(457)+e+r(472),{code:o,reason:i,type:a,port:t})},s}[we(464)](){const t=we;this[t(455)]?this[t(484)][t(462)](t(464)):Se[t(471)]("Send to Unreal fail, type interrupt")}speech(t){const e=we;this[e(478)]?this[e(456)].send(function(t){const e=we,n=Buffer[e(474)](2*t.length);for(let s=0;s<t[e(446)];s++)n.writeInt16LE(t[s],2*s);return n}(t)):Se[e(471)](e(475))}[we(461)](){const t=we;this.speechWS?.[t(483)](),this[t(484)]?.[t(483)](),this[t(473)][t(468)](),this[t(473)][t(481)](),Se[t(450)]("Close all UnrealEngine's WebSocket")}}const Ne=De;function De(t,e){t-=110;return _e()[t]}function _e(){const t=["1470560jijaDf","2OWlbzg","bind","UnrealModule","onDestroy","1740928XcASnI","udpManager","19818RSzDlx","1581856qBzXpj","eyeTrack","config","enableEyeTrack","450488ZUGyXD","movement","enableUDPClient","UE tools destroy","370UJqqxL","socketManager","onStart","eyeTrackCorrection","speech","1228695OTkmoa","interrupted","debug","6318cSEuSh"];return(_e=function(){return t})()}!function(){const t=De,e=_e();for(;;)try{if(241261===-parseInt(t(114))/1*(parseInt(t(125))/2)+parseInt(t(134))/3+-parseInt(t(121))/4+-parseInt(t(129))/5*(-parseInt(t(120))/6)+parseInt(t(118))/7+parseInt(t(113))/8+parseInt(t(112))/9)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const Ce=yt(Ne(116));class Re{config;[Ne(119)];socketManager;[Ne(126)];[Ne(122)];[Ne(110)];[Ne(133)];constructor(t){const e=Ne;this[e(123)]=t,this[e(119)]=new ge,this.socketManager=new Oe,this.movement=()=>{},this[e(122)]=()=>{},this[e(110)]=()=>{},this[e(133)]=()=>{}}[Ne(131)](t){const n=Ne,s=e(fe(),t);Ce[n(111)]("指定的 ue port",s);const{StreamAudioPort:r,CleanAudioPort:o,LookPort:i,...a}=s;this.udpManager[n(127)](a),this[n(130)].connectSocket({speech:r,interrupt:o}),this[n(126)]=this.udpManager[n(126)].bind(this.udpManager),this[n(122)]=this.udpManager.eyeTrack[n(115)](this[n(119)]),this.interrupted=this[n(130)][n(110)].bind(this[n(130)]),this[n(133)]=this[n(130)][n(133)].bind(this[n(130)]),this[n(123)].eyeTrackEnable&&this.udpManager[n(124)]({...this.config[n(132)],port:i})}[Ne(117)](){const t=Ne;this[t(119)][t(117)](),this[t(130)].onDestroy(),Ce.debug(t(128))}}function Te(t,e){return t-=278,Ae()[t]}function Ae(){var t=["3210810gFWTPj","3617710uRVIsm","8318871QTYDcV","3DErJmJ","80996jgkOuP","179972pHCRkc","2984940cxdrRu","10xskjep","11821720EasFME","8nVPzEf"];return(Ae=function(){return t})()}!function(){for(var t=Te,e=Ae();;)try{if(799246===-parseInt(t(287))/1*(parseInt(t(282))/2)+parseInt(t(281))/3*(-parseInt(t(283))/4)+parseInt(t(279))/5+-parseInt(t(278))/6+parseInt(t(284))/7+parseInt(t(286))/8+-parseInt(t(280))/9*(parseInt(t(285))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const Pe=xe;function xe(t,e){t-=210;return Ue()[t]}async function ve(t){return new Promise(e=>{T[xe(282)](t,t=>{e(t?[!1,t]:[!0])})})}async function Me(t,e,...n){const s=xe;return Bt.isWIN?new Promise(s=>{const r=xe,o=[r(279)+t+r(238)+e+" ",...n][r(225)](" "),i=M(o);i[r(254)]("error",t=>{s([!1,t])}),i.once(r(269),()=>{i[r(266)](),s([!0])})}):Promise[s(215)]([!1,new Error(s(239))])}async function Le(){const t=xe;try{return await L[t(214)]()}catch(e){return console[t(235)](t(265),e),[]}}function Ue(){const t=["fileCheck","232xYlQJw","all","number","focus","cd ","proc","28330IeVrAg","stat","isUnrealInService","debug","ueConfig","msedge.exe","setPortTable","browserKeeping","createFolder","always","title","12ZsOSTN","folderCheck","test","isUnrealRunning","path","trim","edge","setAppInForeground","3yClIZv","exec","isKiosk","settingSafePort","parse",'--auto-select-desktop-capture-source="',"getStateInfo","isWIN","networkConnections","resolve","push","has","5735820pkcXCL","config","1359VamJam","getPortTable","addPath","toString","folder","join","onDestroy","length","2828815XBkljA","url","file","utf8","--user-data-dir=","string","pipe","error","name","pids"," && ","The function isn't implement in this system","無服務","--kiosk","1974724pcagwj","chrome.exe","openBrowser","非預期的狀態","toLocaleLowerCase","可使用","231931lzplhc","openUnreal","chrome","8910814cioVzr","62bssauj","homedir","once","C:/Program Files/Google/Chrome/Application","C:/Program Files (x86)/Microsoft/Edge/Application","next","Can't find browser","then","UEProject_5_6",".exe","stringify","destroySub","3578xrNZgE","檢查 Port 時發生錯誤:","unref","localPort","--remote-debugging-port=","spawn","remoteDebug","/AppData/Local/Google/Chrome/Application","config.json","catch"];return(Ue=function(){return t})()}async function je(t){const e=xe,n=t[e(223)](),s=await Le();return i(s,t=>t[e(267)]===n)}async function Xe(t){const e=xe,n=await U();let s=null;const r=new RegExp(t[e(246)]());for(const t of n){const n=await t[e(291)];if(r[e(294)](n[e(246)]())){s=t;break}}return s}function Ge(t){return[2e3,2e3,2e3,1e3,1e3,2e3,3e3,5e3][t]??[6e3,4e3][t%2]}function We(){const t=xe;if(Bt.isWIN){const e=t(260);return{proc:e,name:e+t(261)}}return null}!function(){const t=xe,e=Ue();for(;;)try{if(495970===-parseInt(t(252))/1*(parseInt(t(264))/2)+parseInt(t(300))/3*(parseInt(t(242))/4)+-parseInt(t(228))/5+parseInt(t(218))/6+-parseInt(t(248))/7*(-parseInt(t(275))/8)+-parseInt(t(220))/9*(parseInt(t(281))/10)+parseInt(t(251))/11*(-parseInt(t(292))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class Fe{[Pe(219)];[Pe(285)];[Pe(263)];constructor(t){const n=Pe;this[n(263)]=new b;const s={isKiosk:!1,browserKeeping:!1},{unrealFolder:r,openUrl:o,mode:i,foreground:a,remoteDebug:c}=e({},t);if(typeof r===n(233)&&""!==r[n(297)]()){s[n(296)]=r;const t=We();t&&(this[n(285)]=new Ye(r,t[n(280)]))}typeof o===n(233)&&""!==o[n(297)]()&&(s[n(229)]=o),typeof i===n(233)&&""!==i[n(297)]()&&(s[n(302)]="kiosk"===i),typeof a===n(233)&&""!==a.trim()&&(s[n(288)]=a===n(290)),"number"==typeof c&&(s[n(270)]=c),this[n(219)]=s}async[Pe(301)](t){const n=Pe,{blockPorts:s=[]}=e({},t);let r=!1,o=await this[n(295)]();!o&&(this[n(285)]&&await this[n(285)][n(303)](...s),o=await this[n(249)]()),o&&(r=await this[n(283)]()),r&&await this.openBrowser();return this[n(285)]?await this[n(285)][n(221)]()[n(259)](Ie):fe()}async isUnrealRunning(){const t=Pe,e=We();if(null===e)return!1;const{proc:n}=e,s=await async function(...t){const e=xe,n=t[e(227)]>0?t[e(225)](", "):"*";return await L.processLoad(n)[e(273)](()=>[])}(n);if(s[t(227)]<=0)return!1;const r=n[t(246)](),o=f(s,e=>e[t(280)].toLocaleLowerCase()===r);return!!(o&&typeof o.pid===t(277)&&o[t(237)].length>=2)}async isUnrealInService(t=12){const e=Pe;let n=!1,s=0;const{StreamAudioPort:r}=this[e(285)]?await this[e(285)][e(221)]():fe();for(;!n&&s<t;)n=await je(r),await rt(Ge(s)),s++;return n}async[Pe(249)](){const t=Pe,e=We();if(null===e)return!1;const{path:n}=this[t(219)];if(void 0===n)return!1;const s=Bt.addPath(n,e[t(236)]),[r,o]=await ve(s);if(!r)return mt.error(o),!1;const[i,a]=await async function(t,...e){const n=xe;return Bt[n(213)]?new Promise(s=>{const r=n,o=v(t,e,{detached:!0,stdio:"ignore"});o.once(r(235),t=>{s([!1,t])}),o[r(254)]("spawn",()=>{o[r(266)](),s([!0])})}):Promise.resolve([!1,new Error("The function isn't implement in this system")])}(s);return a&&mt[t(235)](a),i}async[Pe(244)](){const t=Pe,{url:e,isKiosk:n,remoteDebug:s}=this[t(219)];if(void 0===e)return!1;const r=function(){const t=xe;return Bt[t(213)]?{edge:[t(256),t(286)],chrome:[t(255),t(243)],chrome2:[Bt[t(253)]+t(271),t(243)]}:null}();if(null===r)return!1;const{proc:o}=We(),{chrome:i,chrome2:a,edge:c}=r,[[u],[h],[p]]=await Promise[t(276)]([ve(Bt[t(222)](...i)),ve(Bt[t(222)](...c)),ve(Bt[t(222)](...a))]);if(u||p){const r=[];if(n&&(r[t(216)](t(241)),r[t(216)](t(211)+o+'"')),void 0!==s){r[t(216)](t(268)+s);const e=Bt[t(289)]("google");r.push("--user-data-dir="+e)}r[t(216)](e);const[c,h]=u?i:a,[p,f]=await Me(c,h,...r);return p?(this[t(299)](t(250)),!0):(mt[t(235)](f),!1)}if(h){const r=[];if(n&&(r.push(t(241)),r[t(216)](t(211)+o+'"')),void 0!==s){r[t(216)](t(268)+s);const e=Bt[t(289)](t(298));r[t(216)](t(232)+e)}r[t(216)](e);const[i,a]=c,[u,h]=await Me(i,a,...r);return u?(this[t(299)](t(298)),!0):(mt[t(235)](h),!1)}return mt[t(284)](t(258)),!1}async[Pe(299)](t){const e=Pe;await rt(3e3);const n=await Xe(t);n?.[e(278)](),this[e(219)][e(288)]&&E(1e4)[e(234)](S(this[e(263)])).subscribe(()=>{const n=e;Xe(t)[n(259)](t=>{const e=n;t?.[e(278)]()})})}async[Pe(212)](){const t=Pe,e=await this[t(295)](),n=!!e&&await this[t(283)](1);switch(Number("0b"+(n?1:0)+(e?1:0))){case 0:return J["未啟動"];case 1:return J[t(240)];case 3:return J[t(247)];default:return J[t(245)]}}[Pe(226)](){const t=Pe;this.destroySub[t(257)](),this[t(263)].complete()}}class Ye{[Pe(224)];[Pe(230)];constructor(t,e){const n=Pe;this.folder=Bt[n(222)](t,e,n(219)),this[n(230)]=Bt[n(222)](this[n(224)],n(272)),Bt[n(293)](this[n(224)]),Bt[n(274)](this.file,JSON[n(262)](fe()))}async[Pe(303)](...t){const e=Pe,r=fe(),a=await Le(),c=await async function(t,e){const s=e??await Le(),r={};return n(u(t),e=>{const n=xe,o=i(s,({localPort:s})=>s===t[e][n(223)]());r[e]=o}),r}(r,a);if(i(o(c),t=>t)){const o=[...t,...l(s(a,t=>Number(t[e(267)])),t=>!isNaN(t))],i=new Set(o);n(u(c),t=>{const n=e,s=t;if(c[s]){const t=r[s];let e=1,o=NaN;for(;isNaN(o)&&e<=200;){const s=t+e;i[n(217)](s)?e++:(i.add(s),o=s)}!isNaN(o)&&(r[s]=o)}})}await this[e(287)](le(r))}getPortTable(){return new Promise(t=>{const e=xe;T.readFile(this.file,e(231),(n,s)=>{const r=e;if(n)t(le(fe()));else try{t(JSON[r(210)](s))}catch(e){t(le(fe()))}})})}async setPortTable(t){const e=Pe;try{const n=JSON[e(262)](t);await new Promise(t=>{const s=e;T.writeFile(this[s(230)],n,s(231),e=>{t()})})}catch(t){}}}const Ve=Ke;function Ke(t,e){t-=183;return He()[t]}function He(){const t=["找不到日誌","prompt","endsWith","write","3061920AyJlDf","length",".txt","歡迎使用Aiia Admin!\n","👋 切斷連線...\n","server","exit","7036668ljNuuZ","15664XqrDKN","readdir","--yesterday","服務狀態\n 核心狀態 : "," - ","服務狀態確認\n 用法: status [額外參數]\n 範例:\n status\n","appFolder","log","getStatusInfo","--exit","remoteAddress","1180466bNkNQx","--today","yyyy-MM-DD","安全離開\n 用法 1: exit\n 用法 2: close\n"," Unreal : ","日誌讀取(無參數時,會返回可用日誌)\n 用法: log [額外參數]\n\n 範例:\n log --y\n log --yesterday\n log --specific=2025-11-28\n 可用參數:\n today : 讀取今天的日誌\n t : 讀取今天的日誌\n yesterday : 讀取昨天的日誌\n y : 讀取昨天的日誌\n specific=<yyyy-MM-dd> : 讀取指定日期的日誌\n s=<yyyy-MM-dd> : 讀取指定日期的日誌\n","296gUUkOL","19154mCzAOx","close","split","請使用 -- 開始,或使用 help --log 查看幫助","readFileSync","--y","用法: [可用指令] [額外參數]\n 範例:\n help\n help --log\n 可用指令列表:\n help : 獲得可用的指令,使用 [--可用指令] 獲得該指令的詳細說明。\n status : 顯示當前的服務狀態\n log : 讀取日誌\n exit : 關閉連線\n close : exit 的別稱,關閉連線\n","trim","167vXCRBo","isValid","--status","使用 `help` 獲得幫助\n","reduce","onDestroy","1827470GwQiDb","118584yXGTPT","630lMyyzo","padStart","沒有可用日誌"," channel ","--close","--t","join","format","\n 通道列表 : ","utf8","24gnxACt","⚙️ 新的連線來自: ","無服務通道","99uAmPXv","連線指令: telnet 127.0.0.1 ","createInterface"];return(He=function(){return t})()}function Be(...t){const e=Ke;switch(t[0]){case e(202):return e(241);case"--log":return e(190);case e(183):case e(212):return e(188);default:return e(198)}}function Je(...t){const e=Ke,n=t[0];if(!n)return new Promise(t=>{const n=e;T[n(237)](Bt[n(242)],(e,s)=>{const r=n;t(e?r(210):s.filter(t=>t[r(226)](r(230)))[r(214)]("\n"))})});{let t=null;switch(n){case e(186):case e(213):t=I();break;case e(238):case e(197):t=I().add(-1);break;default:{const s=new RegExp(/^--(specific|s)=([0-9]{4}-[0-9]{1,2}-[0-9]{1,2})$/),r=n.match(s);if(r){const[n,s,o]=r[2][e(194)]("-");t=I(n+"-"+s[e(209)](2,"0")+"-"+o[e(209)](2,"0"));break}return e(195)}}if(!t[e(201)]())return"指定了無效的日期,請再次確認";{const n="log_"+t[e(215)](e(187))+e(230),s=Bt.addPath(Bt.appFolder,n);try{return T[e(196)](s,e(217))}catch(t){return e(224)}}}}!function(){const t=Ke,e=He();for(;;)try{if(881209===-parseInt(t(200))/1*(-parseInt(t(192))/2)+parseInt(t(228))/3+parseInt(t(236))/4*(-parseInt(t(208))/5)+-parseInt(t(218))/6*(parseInt(t(185))/7)+parseInt(t(191))/8*(parseInt(t(207))/9)+-parseInt(t(206))/10*(parseInt(t(221))/11)+parseInt(t(235))/12)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class Ze{[Ve(233)];constructor(e,n){const s=Ve,r=(a=n)?{help:Be,status:(c=a,async(...t)=>{const e=Ke,{core:n,channel:s}=await c[e(244)](),r=s[e(204)]((t,n,s)=>{const r=e,o=n.msg;return t+(r(211)+(s+1)+r(240)+o+"}\n")},"\n");let o=e(239)+n+e(216)+(0===s[e(229)]?e(220):r)+"\n";if(c.automaion){const t=await c.automaion.getStateInfo();o+=e(189),o+=J[t],o+="\n"}return o}),log:Je}:{},{port:o,host:i}=e;var a,c;this[s(233)]=X(e=>{const n=s;console.log(n(219)+e[n(184)]);const o=j[n(223)]({input:e,output:e,prompt:"Aiia Admin > "});e.setEncoding(n(217)),e[n(227)](n(231)),e[n(227)](n(203)),o.prompt(),o.on("line",async s=>{const i=n,[a,...c]=s[i(199)]()[i(194)](/\s/),u=a.toLocaleLowerCase();if(u===i(234)||u===i(193))e[i(227)](i(232)),e.end();else{const n=t(r,u,null);if(n){const t=await n(...c);e.write("\n"+t+"\n")}else e[i(227)]('"'+a+'"是無效的指令.\n');o[i(225)]()}}),e.on("end",()=>{console[n(243)]("⚙️ 切斷連線: "+e.remoteAddress)})}),this[s(233)].listen(o,i,()=>{const t=s;console[t(243)](t(222)+o)})}[Ve(205)](){this[Ve(233)].close()}}function qe(){var t=["2rIWXEL","385595tHlWQe","4907529xOUlXD","10qYMAFA","4062784VutgKz","4579800pLLymY","8nBNujw","42642eJiiSS","5445620fCTxgv","2284329bZEOlq"];return(qe=function(){return t})()}function ze(t,e){return t-=438,qe()[t]}!function(){for(var t=ze,e=qe();;)try{if(714579===parseInt(t(441))/1+-parseInt(t(444))/2*(-parseInt(t(443))/3)+-parseInt(t(438))/4+parseInt(t(442))/5+-parseInt(t(439))/6+-parseInt(t(445))/7*(-parseInt(t(440))/8)+parseInt(t(446))/9*(parseInt(t(447))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const Qe=$e;function $e(t,e){t-=278;return tn()[t]}function tn(){const t=["browser"," --\x3e new cloud: ","30RmNArc","transition","JOIN","split","disconnect","reverse","complete","debug","emit","1168431qIvXbY","TO_DESTROY","[0]","transitionMap","pipe","getCloudProxy","subscribe","destroy","length","command","onChannelDestroy","replaceAccessToken","set","TO_READY","🚫 通道已銷毀不允許執行事件,被拒絕的事件 ","net_error","then","10760iuKOud","24cbtURO","open","warn","face","getStatusInfo","push","face_detect","get","sdk","no_permissions","close","signal","onDestroy","sendToCloud","linkStart","132131WnxkvN","osc"," --(","query","DESTROY","url","catch","3945RgVSqE","1092LdVbyG","registerTransition","TO_CONNECTING","_currentState","speech","monitor","channel","list","非預期的事件轉換參數","project_id","CLOSED","cloud","onDestory","state","❌ 轉換失敗:未定義的事件 ","interrupted","CONNECTING","209428ZnXKzw","5319VCzkIU","getProxySocketURL","2000369rNupIR","ueTools","變更代理, old cloud: ","error","TO_RECONNECTING","reconnect","content","uuid","767544ZgeGbb","fatal","未響應","TO_CLOSED","pcm","clear"];return(tn=function(){return t})()}function en(t){const e=$e;try{return t?t[e(338)]("/")[e(340)]()[1]??null:null}catch(t){return null}}!function(){const t=$e,e=tn();for(;;)try{if(911210===-parseInt(t(291))/1+-parseInt(t(316))/2+-parseInt(t(327))/3+-parseInt(t(299))/4*(parseInt(t(298))/5)+parseInt(t(362))/6*(parseInt(t(319))/7)+-parseInt(t(361))/8*(-parseInt(t(317))/9)+-parseInt(t(335))/10*(parseInt(t(344))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const nn=yt("ChannelService");class sn{[Qe(284)];[Qe(333)];[Qe(302)];[Qe(347)];destroy;[Qe(310)];project_id;get[Qe(312)](){return this._currentState}constructor(e,n){const s=Qe;this[s(284)]=e,this[s(333)]=n,this[s(351)]=new b,this[s(308)]=function(e){const n=$e;return r(e)?t(e,n(346),void 0):e??void 0}(n.handshake[s(294)][s(326)]),this[s(310)]=this[s(349)](),this[s(302)]=s(337),this[s(347)]=new Map,this[s(300)](),k(n,s(339))[s(348)](O(1))[s(350)](t=>{const e=s;this.transition(e(345),t)}),k(this[s(333)],"cloud").pipe(S(this.destroy)).subscribe(t=>{const e=s;this[e(310)][e(289)](t)}),k(this[s(333)],s(279)).pipe(S(this.destroy))[s(350)](t=>{const e=s,n=t,r=null!==n;this[e(284)][e(320)].eyeTrack(n),this.cloud[e(289)]({request:e(282),content:r})}),void 0===this[s(308)]?(this[s(284)].getProjectList()[s(360)](t=>{const e=s;n.emit(e(306),t)})[s(297)](t=>{const e=s;n[e(343)]("list",null),nn[e(322)](t)}),k(n,s(326))[s(348)](O(1),S(this[s(351)]))[s(350)](t=>{const e=s;this[e(308)]=t,this.sdk.getProxySocketURL(this[e(308)]).then(t=>{const n=e;this[n(336)](n(301),t)})})):this[s(284)][s(318)](this[s(308)]).then(t=>{this.transition("TO_CONNECTING",t)})}[Qe(349)](){const t=Qe,e=new Ft(this[t(333)].id);return e[t(290)][t(348)](S(this[t(351)]))[t(350)](()=>{const e=t;this[e(336)](e(357),e(363))}),e[t(286)][t(348)](S(this[t(351)]))[t(350)](async e=>{const n=t;switch(e){case n(286):case n(285):this[n(336)]("TO_CLOSED",e);break;case n(324):try{this.transition(n(330),e),await this[n(284)][n(355)]();const t=await this[n(284)][n(318)](this.project_id);this[n(336)](n(323),t)}catch(t){this[n(336)]("TO_CLOSED","net_error")}}}),e.message[t(348)](S(this.destroy))[t(350)](e=>{const s=t,r=[],o=[];n(e,t=>{const e=$e;switch(t[e(287)]){case e(292):o[e(281)](t);break;case"audio":t[e(353)]===e(331)?this[e(284)][e(320)][e(303)](t[e(325)]):t[e(353)]===e(314)&&this[e(284)][e(320)][e(314)]();default:r[e(281)](t)}}),r[s(352)]>0&&this[s(333)][s(343)](s(310),r),o[s(352)]>0&&this[s(284)][s(320)].movement(o)}),e}[Qe(300)](){const t=Qe;this[t(347)][t(356)]("TO_DESTROY",e=>{const n=t;this.onDestory(),nn[n(342)](e)}),this.transitionMap[t(356)](t(330),e=>{const n=t;switch(e){case n(286):case n(285):case"reconnect":this.cloud[n(288)]();case n(359):this[n(333)][n(343)]("channel",e);break;default:nn[n(328)](n(307))}}),this[t(347)][t(356)](t(357),e=>{const n=t;this[n(333)][n(343)](n(305),e)}),this[t(347)][t(356)](t(301),t=>{this.cloud.start(t)}),this[t(347)][t(356)]("TO_RECONNECTING",e=>{const n=t,s=this[n(349)]();s.start(e),nn[n(342)](n(321)+this[n(310)][n(326)]+n(334)+s.uuid),this.cloud=s})}transition(t,e){const n=Qe;if(this[n(302)]===n(295))return nn.warn(n(358)+t),!1;const s=this[n(302)];switch(t){case n(301):case n(323):this[n(302)]=n(315);break;case n(357):this[n(302)]="READY";break;case n(330):this[n(302)]=n(309);break;case n(345):this._currentState=n(295);break;default:return nn[n(278)](n(313)+t),!1}const r=this[n(347)][n(283)](t);return r&&r(e),nn[n(342)]("✅ 轉換成功: "+s+n(293)+t+")--\x3e "+this[n(302)]),!0}async[Qe(280)](){const t=Qe,e=new Promise(t=>{const e=$e,n=N(3e3)[e(348)](D(()=>{const t=e;return{mic:K["未響應"],camera:K[t(329)]}})),s=k(this[e(333)],e(304))[e(348)](D(t=>t));_(n,s).pipe(O(1),S(this[e(351)]))[e(350)](t),this.browser.emit(e(304),null)}),n=this.cloud[t(280)](),s=this[t(333)].id,r=await e;return{browser_id:s,access:en(this[t(310)][t(296)]),...r,...n}}[Qe(311)](){const t=Qe;this[t(347)][t(332)](),this.destroy.next(),this[t(351)][t(341)](),this[t(284)][t(354)](this[t(333)].id)}}const rn=on;function on(t,e){t-=389;return cn()[t]}var an;function cn(){const t=["from","1029336BylbuO","endPoint","core","start","getStatusInfo","stroage","啟動服務","服務結束","28oStIcd","apiProxy","54dkHVrC","onChannelDestroy",") should be closed. Auto clean service.","browser","/v1/chat/project/","已結束","The browser(","重複初始化","14aITTIS","228621gGsyaG","then","timestamp","pipe","udp tools","delete","setItemSync","getProjectList","335916VBphTX","getAccessToken","error","服務中","362910hGAqXd","set","ueTools","number","next","access_token","channelMap","port","replaceAccessToken","socketAddr","destorySub","now","指定模組初始化完成","expiment","onDestroy","1410568YWmZFO","memberChange","chat","5PbqcAG","automaion","api","17014cJJOzG","config","onStart","disconnected","subscribe","inspectClientSocket","onDestory","info","getStateInfo","accessToken","license","channels","getItemSync","code","initService","33eACBzB","417072lJpJJd","未啟動","state"];return(cn=function(){return t})()}!function(){const t=on,e=cn();for(;;)try{if(231318===-parseInt(t(446))/1*(parseInt(t(418))/2)+-parseInt(t(457))/3+parseInt(t(412))/4+parseInt(t(415))/5*(parseInt(t(434))/6)+parseInt(t(456))/7*(parseInt(t(438))/8)+-parseInt(t(448))/9*(parseInt(t(397))/10)+-parseInt(t(433))/11*(-parseInt(t(393))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),function(t){const e=on;t[t[e(435)]=0]=e(435),t[t[e(396)]=1]=e(396),t[t[e(453)]=2]=e(453)}(an||(an={}));class un{config;[rn(443)];[rn(410)];[rn(447)];[rn(414)];ueTools;[rn(416)];[rn(436)];[rn(403)];destorySub;[rn(402)];[rn(459)];[rn(406)];get accessToken(){return this[rn(402)]}constructor(t,e,n){const s=rn;this[s(419)]=t,this[s(443)]=e,this.expiment=n,this[s(436)]=an[s(435)],this.destorySub=new b,this[s(403)]=new Map,this.timestamp=0,this.access_token=e[s(430)](tt);const{api:r,socket:o}=t[s(439)];this[s(406)]=o,this.apiProxy=new At(r),mt[s(431)](ht[s(409)],s(417)),this.chat=new Dt(t),mt[s(431)](ht[s(409)],"chat"),this[s(399)]=new Re(t),mt[s(431)](ht[s(409)],s(389)),this.initService()}async[rn(441)](){const t=rn;if(this.state!==an[t(435)])throw new Error(F[t(455)]);this[t(436)]=an[t(396)],await this[t(405)](),this[t(414)][t(413)].pipe(S(this[t(407)])).subscribe(({type:e,socket:n})=>{const s=t;"in"===e&&this[s(403)][s(398)](n.id,new sn(this,n))}),this.chat[t(441)](),mt[t(431)](ht[t(444)],t(414));const{interaction:n}=e({},this[t(410)]);if(void 0!==n&&typeof n[t(404)]===t(400)){const{port:e,host:s}=n,r=new Ze({port:e,host:s},this);this.destorySub[t(422)](()=>{r[t(411)]()})}}[rn(432)](){const t=rn,{automaion:n}=e({},this.expiment);if(void 0!==n){const e=new Fe(n);e.exec({blockPorts:[this[t(419)][t(404)]]})[t(458)](e=>{this[t(399)].onStart(e)}),this[t(407)][t(422)](()=>{e[t(411)]()}),this.automaion=e}else this.ueTools[t(420)]();E(18e4)[t(460)](S(this[t(407)]))[t(422)](()=>{const e=t;this[e(423)](),this[e(442)]()[e(458)](({channel:t,core:n,unreal:r})=>{const o=e;mt[o(425)](o(440),n),mt[o(425)]("Unreal state",J[r],r),mt[o(425)](o(429),s(t,t=>{const{camera:e,mic:n,...s}=t;return{cameraState:K[e]+", "+e,micState:K[n]+", "+n,...s}}))})})}async replaceAccessToken(){const t=rn;try{const e=await this.apiProxy[t(394)](this[t(419)][t(428)],this[t(402)],this.config.note);this[t(402)]=e,this[t(459)]=0,this[t(443)][t(391)](tt,e)}catch(t){throw mt.error(t),t}}async[rn(392)](){const t=rn;try{return await this[t(447)].getProjectList(this[t(419)][t(428)])}catch(e){throw mt[t(395)](e),e}}async getProxySocketURL(t){const e=rn,n=Date[e(408)]()-this[e(459)];return n<5e3&&await rt(5100-n),this[e(459)]=Date[e(408)](),this[e(406)]+e(452)+this[e(427)]+"/"+t}[rn(423)](){const t=rn,e=Array.from(this[t(403)]);n(e,([e,n])=>{const s=t;"DESTROY"===n[s(436)]?this.channelMap[s(390)](e):n[s(451)][s(421)]&&(n[s(424)](),mt[s(425)](s(454)+e+s(450)))})}[rn(449)](t){this[rn(403)].delete(t)}async[rn(442)](){const t=rn,e=s(Array[t(437)](this.channelMap),([e,n])=>n[t(442)]()),n=new Promise(e=>{const n=t;this.automaion?this[n(416)][n(426)]()[n(458)](e):e(J["未授權控制"])}),[r,...o]=await Promise.all([n,...e]);return{core:{state:this[t(436)],msg:an[this[t(436)]]},channel:o,unreal:r}}[rn(411)](){const t=rn;this[t(447)][t(411)](),this[t(414)][t(411)](),this[t(399)][t(411)](),this[t(407)][t(401)](),this[t(407)].complete(),this[t(436)]=an[t(453)],mt.code(ht[t(445)])}}function hn(t,e){t-=429;return fn()[t]}function pn(n){const s=hn;if(nt){if(typeof t(n,s(435),void 0)!==s(445))throw new Error(F[s(431)]);(function(t){const e=ut,{info:n,error:s,warn:r,debug:o,fatal:i,code:a}=function(t){const e=lt;if(void 0===t||t===e(481))return{code:!0,error:!0,warn:!0,info:!0,debug:!0,fatal:!0};if("none"===t)return{error:!1,code:!1,warn:!1,info:!1,debug:!1,fatal:!1};if(typeof t===e(491))return{code:t,error:t,warn:t,info:t,debug:t,fatal:t};{const n=new Set(t);return{code:n.has("code"),debug:n[e(462)](e(477)),fatal:n[e(462)]("fatal"),error:n[e(462)](e(490)),warn:n[e(462)](e(482)),info:n.has(e(470))}}}(t);return!a&&(pt[e(474)]=()=>{}),!o&&(pt[e(477)]=()=>{}),!n&&(pt[e(470)]=()=>{}),!r&&(pt[e(482)]=()=>{}),!s&&(pt[e(490)]=()=>{}),!i&&(pt[e(504)]=()=>{}),It})(t(n,s(451),!0))(new re),mt[s(434)](ht[s(438)]);const r=new at(e({},n));mt[s(434)](ht[s(433)],"config");const o=new Qt;mt.code(ht[s(433)],s(455));const i=new un(r,o,t(n,s(444)));return mt.code(ht[s(433)],s(439)),i[s(430)](),mt.code(ht[s(432)],s(450)),()=>{i[s(454)]()}}throw new Error(F[s(441)])}function fn(){const t=["環境錯誤(nodejs)","41702BiwETH","9uRtpsg","experiment","string","4083260TEtlFL","113632KYGhaE","890256oJKZoS","88440huhmvq","main core","debug","45cNyHST","42ikqPZV","onDestroy","storage","674448iYgABX","start","未提供憑證","啟動服務","指定模組初始化完成","code","license","1433886CkHdrF","473IYwmgN","開始初始化必要模組","core","12oPAlJq"];return(fn=function(){return t})()}!function(){const t=hn,e=fn();for(;;)try{if(271711===parseInt(t(442))/1*(parseInt(t(440))/2)+parseInt(t(448))/3+-parseInt(t(447))/4*(parseInt(t(452))/5)+-parseInt(t(436))/6+parseInt(t(453))/7*(-parseInt(t(429))/8)+-parseInt(t(443))/9*(-parseInt(t(446))/10)+-parseInt(t(437))/11*(-parseInt(t(449))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();export{pn as aiiaCore};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphen.ai/aiia-sdk",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "Jay Huang",
@@ -61,10 +61,10 @@
61
61
  "@types/node-osc": "^9.1.0",
62
62
  "@types/ws": "^8.18.1",
63
63
  "@unrs/resolver-binding-darwin-arm64": "^1.11.1",
64
- "jest": "^30.1.3",
64
+ "jest": "^30.2.0",
65
65
  "jest-environment-jsdom": "^30.1.2",
66
66
  "rollup": "^4.46.2",
67
- "rollup-plugin-javascript-obfuscator": "^1.0.1",
67
+ "rollup-plugin-obfuscator": "^1.1.0",
68
68
  "ts-jest": "^29.4.1",
69
69
  "tslib": "^2.6.2",
70
70
  "typescript": "^5.9.2"
@@ -72,7 +72,7 @@
72
72
  "dependencies": {
73
73
  "@mediapipe/tasks-vision": "^0.10.22-rc.20250304",
74
74
  "@nut-tree-fork/nut-js": "^4.2.6",
75
- "axios": "^1.11.0",
75
+ "axios": "^1.13.2",
76
76
  "lodash-es": "^4.17.21",
77
77
  "mathjs": "^14.8.1",
78
78
  "moment": "^2.30.1",
@@ -80,7 +80,7 @@
80
80
  "rxjs": "^7.8.2",
81
81
  "socket.io": "^4.8.1",
82
82
  "socket.io-client": "^4.8.1",
83
- "systeminformation": "^5.27.11",
83
+ "systeminformation": "^5.27.13",
84
84
  "ws": "^8.18.3"
85
85
  }
86
86
  }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.11"
8
+ "packageVersion": "7.55.2"
9
9
  }
10
10
  ]
11
11
  }