"use strict";(self.webpackChunkpasswords_webextension=self.webpackChunkpasswords_webextension||[]).push([[7638],{8962:(e,t,r)=>{r.d(t,{Z:()=>a});class a{async execute(e,t){console.trace("controller.execute() not implemented")}}},4277:(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var a=r(6567),s=r(7577),i=r(8838);const o=new class{async requestReadPermission(){try{return await i.Z.getBrowserApi().permissions.request({permissions:["clipboardRead"]})}catch(e){a.Z.logError(e,"ClipboardManager.getReadPermission()")}}async getReadPermissions(){try{return await i.Z.getBrowserApi().permissions.contains({permissions:["clipboardRead"]})}catch(e){return a.Z.logError(e,"ClipboardManager.getReadPermission()"),!1}}async readText(){try{let e=!1;if(await i.Z.getBrowserApi().extension.getBackgroundPage()!==window&&(e=await this.requestReadPermission()),!0===e||await this.getReadPermissions()){let e=this._createDOMElement();await document.execCommand("paste");let t=e.value;return this._removeDOMElement(e),t}}catch(e){a.Z.logError(e,"ClipboardManager.readText()")}}write(e,t){"password"===e?this.writePassword(t):this.writeText(t)}writeText(e){try{let t=this._createDOMElement(e);document.execCommand("copy",!1,t.value),this._removeDOMElement(t)}catch(e){a.Z.logError(e)}}async writePassword(e){this.writeText(e),!0===await s.Z.getValue("clipboard.clear.passwords")&&setTimeout((async()=>{let t=await this.readText();void 0!==t&&""!==t&&t!==e||this.writeText(" ")}),1e3*Number(await s.Z.getValue("clipboard.clear.delay")))}_createDOMElement(e="",t="text"){let r=document.createElement("INPUT");return r.setAttribute("type",t),r.setAttribute("value",e),document.body.appendChild(r),r.select(),r}_removeDOMElement(e){e.blur(),document.body.removeChild(e)}};var n=r(8962);class c extends n.Z{async execute(e,t){try{o.write(e.getPayload().type,e.getPayload().value)&&t.setPayload(!0)}catch(e){a.Z.logError(e)}}}}}]);