mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2025-02-10 01:24:03 +00:00
13 lines
127 KiB
JavaScript
13 lines
127 KiB
JavaScript
|
import{dx as A,eK as t,dz as i,eL as e,a as s,dA as o,du as g,dv as I,ds as a,l as B,cP as r,x as C,dh as n,r as E,_ as Q,n as h,b as d,t as c}from"./card-320adb66.js";import{d as l}from"./dispatch-live-error-c649b480.js";import{c as u}from"./endpoint-a6d38c7a.js";function w(){return w=Object.assign?Object.assign.bind():function(A){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(A[e]=i[e])}return A},w.apply(this,arguments)}function p(A,t){A.prototype=Object.create(t.prototype),A.prototype.constructor=A,m(A,t)}function m(A,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(A,t){return A.__proto__=t,A},m(A,t)}var D=A=>"string"==typeof A&&A.constructor===String,f=function(A){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t=A,"Promise"===Object.prototype.toString.call(t).slice(8,-1)?A:new Promise((t=>{A(),setTimeout(t,i)}))};var y="WJ3NAvwFY9",R="tR2-0dd-e1",k="ZgIIHVSSYI",b="kAA8SjbHe2",S="OueN4AU4CJ";!function(A,t){void 0===t&&(t={});var i=t.insertAt;if(A&&"undefined"!=typeof document){var e=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&e.firstChild?e.insertBefore(s,e.firstChild):e.appendChild(s),s.styleSheet?s.styleSheet.cssText=A:s.appendChild(document.createTextNode(A))}}(".WJ3NAvwFY9,.ZgIIHVSSYI,.kAA8SjbHe2,.tR2-0dd-e1{height:100%;left:0;position:absolute;top:0;width:100%;z-index:1}.ZgIIHVSSYI{-ms-flex-pack:center;-ms-flex-align:center;-webkit-align-items:center;align-items:center;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-justify-content:center;justify-content:center}.WJ3NAvwFY9,.tR2-0dd-e1{display:block}.tR2-0dd-e1.OueN4AU4CJ{display:none}.ZgIIHVSSYI,.kAA8SjbHe2{-webkit-tap-highlight-color:rgba(255,0,0,0);cursor:pointer;opacity:.7}.OueN4AU4CJ.ZgIIHVSSYI,.OueN4AU4CJ.kAA8SjbHe2{display:none}.ZgIIHVSSYI{z-index:10}.ZgIIHVSSYI>svg{fill:#fff;height:12vw;max-height:60px;max-width:60px;width:12vw}.kAA8SjbHe2{-ms-flex-pack:end;-ms-flex-align:end;-webkit-align-items:flex-end;align-items:flex-end;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-justify-content:flex-end;justify-content:flex-end;z-index:10}.kAA8SjbHe2>svg{fill:#fff;height:9vw;margin:0 15px 15px 0;max-height:40px;max-width:40px;width:9vw}");var G=function(){function A(A,t,i,e){var s=void 0===i?{}:i,o=s.canvas,g=void 0===o?"":o,I=s.poster,a=void 0===I?"":I,B=s.autoplay,r=void 0!==B&&B,C=s.autoSetWrapperSize,n=void 0!==C&&C,E=s.loop,Q=void 0!==E&&E,h=s.control,d=void 0===h||h,c=s.decodeFirstFrame,l=void 0===c||c,u=s.picMode,p=void 0!==u&&u,m=s.progressive,f=void 0===m||m,y=s.chunkSize,R=void 0===y?1048576:y,k=s.hooks,b=void 0===k?{}:k;void 0===e&&(e={}),this.options=w({videoUrl:t,canvas:g,poster:a,picMode:p,autoplay:r,autoSetWrapperSize:n,loop:Q,control:d,decodeFirstFrame:l,progressive:f,chunkSize:R,hooks:w({play:function(){},pause:function(){},stop:function(){},load:function(){}},b)},e),this.options.needPlayButton=this.options.control&&!this.options.picMode,this.player=null,this.els={wrapper:D(A)?document.querySelector(A):A,canvas:null,playButton:document.createElement("div"),unmuteButton:null,poster:null},"static"===window.getComputedStyle(this.els.wrapper).getPropertyValue("position")&&(this.els.wrapper.style.position="relative"),this.els.wrapper.clientRect=this.els.wrapper.getBoundingClientRect(),this.initCanvas(),this.initPlayButton(),this.initPlayer()}var t=A.prototype;return t.initCanvas=function(){this.options.canvas?this.els.canvas=D(this.options.canvas)?document.querySelector(this.options.canvas):this.options.canvas:(this.els.canvas=document.createElement("canvas"),this.els.canvas.classList.add(y),this.els.wrapper.appendChild(this.els.canvas))},t.initPlayer=function(){var A=this;this.options=w(this.options,{canvas:this.els.canvas});var t=w({},this.options,{autoplay:!1});if(this.player=new Z(this.options.videoUrl,t,{play:function(){A.options.needPlayButton&&A.els.playButton.classList.add(S),A.els.poster&&A.els.poster.classList.add(S),A.option
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright 2021 Google LLC
|
||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||
|
*/
|
||
|
class V{constructor(A){this.Y=A}disconnect(){this.Y=void 0}reconnect(A){this.Y=A}deref(){return this.Y}}class z{constructor(){this.Z=void 0,this.q=void 0}get(){return this.Z}pause(){this.Z??=new Promise((A=>this.q=A))}resume(){this.q?.(),this.Z=this.q=void 0}}
|
||
|
/**
|
||
|
* @license
|
||
|
* Copyright 2017 Google LLC
|
||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||
|
*/const $=A=>!e(A)&&"function"==typeof A.then,AA=1073741823;const tA=A(class extends t{constructor(){super(...arguments),this._$Cwt=AA,this._$Cbt=[],this._$CK=new V(this),this._$CX=new z}render(...A){return A.find((A=>!$(A)))??i}update(A,t){const e=this._$Cbt;let s=e.length;this._$Cbt=t;const o=this._$CK,g=this._$CX;this.isConnected||this.disconnected();for(let A=0;A<t.length&&!(A>this._$Cwt);A++){const i=t[A];if(!$(i))return this._$Cwt=A,i;A<s&&i===e[A]||(this._$Cwt=AA,s=0,Promise.resolve(i).then((async A=>{for(;g.get();)await g.get();const t=o.deref();if(void 0!==t){const e=t._$Cbt.indexOf(i);e>-1&&e<t._$Cwt&&(t._$Cwt=e,t.setValue(A))}})))}return i}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}});let iA=class extends s{constructor(){super(...arguments),this._refreshPlayerTimer=new o,this._message=null}async play(){return this._jsmpegVideoPlayer?.play()}async pause(){this._jsmpegVideoPlayer?.stop()}async mute(){const A=this._jsmpegVideoPlayer?.player;A&&(A.volume=0)}async unmute(){const A=this._jsmpegVideoPlayer?.player;A&&(A.volume=1)}isMuted(){return!this._jsmpegVideoPlayer||0===this._jsmpegVideoPlayer.player.volume}async seek(A){}async setControls(A){}isPaused(){return this._jsmpegVideoPlayer?.player?.paused??!0}async getScreenshotURL(){return this._jsmpegCanvasElement?.toDataURL("image/jpeg")??null}willUpdate(A){["cameraConfig","cameraEndpoints"].some((t=>A.has(t)))&&(this._message=null)}async _createJSMPEGPlayer(A){this._jsmpegVideoPlayer=await new Promise((t=>{let i=!1;const e=new j.VideoElement(this,A,{canvas:this._jsmpegCanvasElement},{pauseWhenHidden:!1,autoplay:!1,protocols:[],audio:!1,videoBufferSize:4194304,preserveDrawingBuffer:!0,...this.cameraConfig?.jsmpeg?.options,reconnectInterval:0,onVideoDecode:()=>{!i&&this._jsmpegCanvasElement&&(i=!0,t(e))},onPlay:()=>g(this),onPause:()=>I(this)})})),this._jsmpegCanvasElement&&a(this,this._jsmpegCanvasElement,{player:this,capabilities:{supportsPause:!0},technology:["jsmpeg"]})}_resetPlayer(){if(this._message=null,this._refreshPlayerTimer.stop(),this._jsmpegVideoPlayer){try{this._jsmpegVideoPlayer.destroy()}catch(A){}this._jsmpegVideoPlayer=void 0}this._jsmpegCanvasElement&&(this._jsmpegCanvasElement.remove(),this._jsmpegCanvasElement=void 0)}connectedCallback(){super.connectedCallback(),this.isConnected&&this.requestUpdate()}disconnectedCallback(){this.isConnected||this._resetPlayer(),super.disconnectedCallback()}async _refreshPlayer(){if(!this.hass)return;this._resetPlayer(),this._jsmpegCanvasElement=document.createElement("canvas"),this._jsmpegCanvasElement.className="media";const A=this.cameraEndpoints?.jsmpeg;if(!A)return this._message={message:B("error.live_camera_no_endpoint"),type:"error",context:this.cameraConfig},void l(this);const t=await u(this.hass,A,86400);if(!t)return this._message={type:"error",message:B("error.failed_sign"),context:this.cameraConfig},void l(this);await this._createJSMPEGPlayer(t),this._refreshPlayerTimer.start(82800,(()=>this.requestUpdate()))}render(){if(this._message)return r(this._message);return C`${tA((async()=>{if(await this._refreshPlayer(),this._jsmpegVideoPlayer&&this._jsmpegCanvasElement)return C`${this._jsmpegCanvasElement}`;this._message||(this._message={message:B("error.jsmpeg_no_player"),type:"error",context:this.cameraConfig},l(this))})(),n({cardWideConfig:this.cardWideConfig}))}`}static get styles(){return E(":host {\n width: 100%;\n height: 100%;\n display: flex;\n}\n\ncanvas {\n display: block;\n width: 100%;\n height: 100%;\n object-fit: var(--frigate-card-media-layout-fit, contain);\n object-position: var(--frigate-card-media-layout-position-x, 50%) var(--frigate-card-media-layout-position-y, 50%);\n object-view-box: inset(var(--frigate-card-media-layout-view-box-top, 0%) var(--frigate-card-media-layout-view-box-right, 0%) var(--frigate-card-media-layout-view-box-bottom, 0%) var(--frigate-card-media-layout-view-box-left, 0%));\n}")}};Q([h({attribute:!1})],iA.prototype,"cameraConfig",void 0),Q([h({attribute:!1})],iA.prototype,"cameraEn
|