"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[7901],{990530(e,t,n){n.d(t,{A:()=>h});var i=n(274934),s=n(95032),o=n(247816),a=n(347625);const r=(0,o.A)("span")`
  white-space: nowrap;
`;var l=n(100978),c=n(974390);const m=(0,o.A)(c.A)`
  float: left;
`,h=({defaultName:e="",device:{model:t,name:n,mac:o}={},width:c=25,height:h=25,leftOffset:d=0})=>(0,i.jsxs)(l.A,{alignItems:"center",marginLeft:d,width:"100%",maxWidth:"100%",children:[(0,i.jsx)(l.A,{marginRight:8,flex:`0 0 ${c}px`,width:c,height:h,children:(0,i.jsx)(m,{model:t,width:c,height:h})}),(0,i.jsx)(s.A,{isTruncated:!0,size:"medium",color:"text-2",children:(0,i.jsx)(r,{children:(0,a.Q)({model:t,name:n,mac:o})||e})})]})},207901(e,t,n){n.r(t),n.d(t,{default:()=>D});var i=n(274934),s=n(602086),o=n(977872),a=n(814557),r=n(168998),l=n(247816),c=n(938984),m=n(263705),h=n(642687),d=n(954702),u=n(613842),C=n(159469),p=n(79777),A=n(78118),g=n(789784),E=n(347625);var N=n(372180),O=n(709035),f=n(693884);const x=class{closed;eventBus;props;terminal;constructor(e){this.props=e,this.eventBus=new g.EventEmitter}writeToTerminalConnectionStatus(e){const{device:{name:t,model:n,mac:i},formatMessage:s}=this.props;this.terminal.write(`[${O.AB.FONT}${s({id:"COMMON_DEVICE"})} ${(0,E.Q)({name:t,model:n,mac:i})}: ${e}[m\r\n`)}open(e){this.terminal=new A.B({cols:O.XF.COLS,rows:O.XF.ROWS,cursorBlink:!1,fontSize:O.XF.FONT,theme:{background:O.AB.BACKGROUND,foreground:O.AB.FOREGROUND,selection:O.AB.SELECTION,cursor:O.AB.FOREGROUND}}),this.closed=!1,e&&this.updateTheme(e),this.initTerminal();const{formatMessage:t}=this.props;return(0,N.fz)(this.props.device.mac,this.eventBus,this.props).then(e=>e.dataChannelDeferred.promise.then(e=>{e.options&&e.options.messages&&e.options.messages.forEach(e=>{this.terminal.write(e)}),this.setupTerminalCommunication(e.channel),this.writeToTerminalConnectionStatus(t({id:O.ih.TERMINAL_CONNECTED}))})).catch(e=>(this.writeToTerminalConnectionStatus(t({id:O.ih.TERMINAL_CONNECTION_ERROR})),Promise.reject(new Error("ConnectionError"))))}updateTheme(e){this.terminal.setOption("theme",e)}onChannelMessage=e=>{this.terminal&&this.terminal.write(e)};onChannelClose=()=>{const{formatMessage:e,onClose:t,device:{mac:n}}=this.props;this.terminal&&(this.terminal.write("\r\n"),this.writeToTerminalConnectionStatus(e({id:O.ih.TERMINAL_CONNECTION_DROPPED})),this.releaseConnection(n),t&&t())};setupTerminalCommunication(e){this.eventBus.on(f.w.MESSAGE_RECEIVED,this.onChannelMessage),this.eventBus.on(f.w.CHANNEL_CLOSED,this.onChannelClose),this.terminal.on("data",t=>{"open"===e.rtcDataChannel.readyState&&e.send(t)})}releaseConnection(e){this.closed||(this.closed=!0,(0,N.eh)(e))}initTerminal(){const{element:e,formatMessage:t}=this.props;this.terminal.open(e),this.writeToTerminalConnectionStatus(t({id:O.ih.TERMINAL_CONNECTING}))}close=()=>{const{device:{mac:e},formatMessage:t}=this.props;this.eventBus.emit(f.J.CANCEL_CONNECTION,e),this.writeToTerminalConnectionStatus(t({id:"COMMON_DISCONNECTED"})),this.terminal&&(this.releaseConnection(e),this.terminal.dispose())};getTerminalSelection(){if(this.terminal.hasSelection())return this.terminal.getSelection();this.terminal.selectAll();const e=this.terminal.getSelection();return this.terminal.clearSelection(),e}copyContent(){!function(e){const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t);const n=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);t.select(),document.execCommand("copy"),document.body.removeChild(t),n&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(n))}(this.getTerminalSelection())}};var T=n(100978),S=n(700444),w=n(869332),M=n(470070),b=n(726831),v=n(976458),j=n(309130),k=n(384783),_=n(990530);const R=(0,l.A)("div")`
  width: 100%;
  height: ${13*O.XF.ROWS+48}px;
  background: ${({theme:{motifPalette:{uiShell:e}}})=>e};
  padding: ${({theme:{spacing:e}})=>e["spacing-xxl"]};

  .xterm {
    overflow: hidden;
    position: relative;
  }

  .xterm-viewport {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: auto;

    ::-webkit-scrollbar-thumb {
      min-height: 3em;
    }
  }

  .xterm-helpers {
    opacity: 0;
    position: absolute;
  }

  .xterm-text-layer,
  .xterm-selection-layer,
  .xterm-link-layer,
  .xterm-cursor-layer {
    position: absolute;
  }
`,I=({createTerminal:e})=>{const t=(0,s.useRef)(null),[n,o]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{t.current&&!n&&(o(!0),e(t.current))},[n]),(0,i.jsx)(R,{ref:t})},y=(0,l.A)(r.A)`
  color: ${({theme:{themeName:e}})=>a.Ay[`desktop-color-neutral-08-${e}`]};
  cursor: pointer;
`,D=({device:e})=>{const{formatMessage:t}=(0,M.tz)(),[n,a]=(0,s.useState)(!1),r=(0,o.d4)(v.bI),l=(0,o.d4)(v.ub),A=(0,o.d4)(p.a),{motifPalette:{uiShell:g,ui05:E,activeInteractive02:N}}=(0,m.u)(),O=(0,o.wA)(),[f,R]=(0,s.useState)(!1),[D,B]=(0,s.useState)(),L=(0,s.useMemo)(()=>({background:g,foreground:E,cursor:N}),[g,E,N]),$=(0,s.useCallback)(()=>{D&&D.close()},[D]),F=(0,s.useCallback)(()=>{$(),O((0,w.AS)())},[$,O]),P=(0,s.useCallback)(()=>{D&&(D.copyContent(),O((0,S.ox)({icon:C.C.success,message:"COMMON_COPIED_TO_CLIPBOARD"})))},[D,O]),z=(0,s.useCallback)(n=>{if(!n||D||f)return;R(!0);const i=new x({formatMessage:t,device:{name:e.name,model:e.model,mac:e.mac},element:n,dispatch:O,isWebrtc:r,webSocketPool:A,onClose:$,isHybridApp:l});B(i),i.open(L).catch($)},[D,f,O,t,e.name,e.model,e.mac,r,A,l,$,L]);(0,s.useEffect)(()=>{D&&D.updateTheme(L)},[D,L]);const G=(0,s.useCallback)(()=>{a(!0)},[]),U=(0,s.useCallback)(()=>{u.A.open(b.A.uiLegal)},[]),W=(0,s.useCallback)(()=>{u.A.open(b.A.uiEula)},[]),{title:X,content:H}=(0,s.useMemo)(()=>({title:(0,i.jsx)(T.A,{alignItems:"center",width:"100%",justifyContent:"space-between",position:"relative",bottom:"2px",children:n?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(_.A,{device:{name:e.name,model:e.model,mac:e.mac}}),(0,i.jsx)(y,{onClick:P})]}):(0,i.jsx)(M.sA,{id:"COMMON_NOTICE"})}),content:n?(0,i.jsx)(I,{createTerminal:z}):(0,i.jsxs)(T.A,{flexDirection:"column",padding:j.S2,gap:j.Er,children:[(0,i.jsx)(c.A,{size:"inherit",color:"inherit",children:(0,i.jsx)(M.sA,{id:"COMMON_DEBUG_TERMINAL_TOS",values:{tos:(0,i.jsx)(d.A,{type:"button",fontSize:"medium",onClick:U,children:(0,i.jsx)(M.sA,{id:"COMMON_TOS"})}),eula:(0,i.jsx)(d.A,{type:"button",fontSize:"medium",onClick:W,children:(0,i.jsx)(M.sA,{id:"COMMON_END_USER_LICENSE_AGREEMENT"})})}})}),(0,i.jsxs)(T.A,{alignItems:"center",gap:j.kc,justifyContent:"flex-end",children:[(0,i.jsx)(h.A,{type:"button",onClick:F,variant:"neutral",children:(0,i.jsx)(M.sA,{id:"COMMON_ACTION_CANCEL"})}),(0,i.jsx)(h.A,{type:"button",onClick:G,children:(0,i.jsx)(M.sA,{id:"COMMON_I_ACCEPT"})})]})]})}),[n,e.name,e.model,e.mac,F,P,z,G,U,W]);return(0,i.jsx)(k.A,{flushContent:!0,noSlide:!0,onRequestClose:F,headerClassName:"custom-header-padding",title:X,size:"medium",children:H})}}}]);