import{_ as _extends}from"./_rollupPluginBabelHelpers-B5fk9IVe.js";import React__default,{useState,useEffect,useId}from"react";import PropTypes from"prop-types";import{T as Textarea}from"./Textarea.component-4fIvQVeJ.js";import{B as ButtonRow}from"./ButtonRow.component-DlpAnXKj.js";import{B as Button}from"./Button.component-BKRhw0J0.js";import{L as Label,F as FormHint}from"./FormHint.component-BPhoMz7f.js";import{S as Stack}from"./Stack.component-D-jW201_.js";import"./Icon.component-BVkaZqpA.js";import"./widgets-njngpHa5.js";import"./Spinner.component-3BfGSLKB.js";const innerWrapperStyles=`
  jn-relative
`,labelStyles=`
  jn-pointer-events-none
  jn-top-2
  jn-left-[0.9375rem]
  jn-pr-4
  jn-bg-theme-textinput
  jn-z-20
`,coverStyles=`
  jn-absolute
  jn-top-0
  jn-left-0
  jn-right-0
  jn-bottom-0
  jn-cursor-not-allowed
  jn-backdrop-blur-[4px]
  jn-bg-theme-background-lvl-2/30
  jn-z-10
  jn-flex
  jn-justify-center
  jn-items-center
`,copyConfirmMessageStyles=`
  jn-bg-theme-background-lvl-1
  jn-font-bold
  jn-px-3
  jn-py-1
  jn-rounded
`,textareaStyles=`
  jn-break-all
  jn-min-h-[7.5rem]
`,hintStyles=``,actionStyles=`
  jn-h-[1.875rem]
`,SecretText=a=>{let{autoComplete:e="off",className:f="",clear:g=!0,copy:h=!0,copyConfirmtext:i="Secret copied to clipboard.",disableClear:j=!1,disableCopy:k=!1,disabled:l=!1,disablePaste:m=!1,disableToggle:n=!1,errortext:o=void 0,helptext:p=void 0,id:q="",onBlur:r=void 0,onChange:s=void 0,onClear:t=void 0,onCopy:u=void 0,onFocus:v=void 0,onHide:w=void 0,onPaste:x=void 0,onReveal:y=void 0,onToggle:z=void 0,label:b,paste:A=!0,placeholder:B="",readOnly:C=!1,required:D=!1,reveal:E=!1,successtext:F=void 0,toggle:G=!0,valid:H=!1,invalid:c,value:I="",wrapperClassName:J="",...d}=a;const K=a=>"string"!=typeof a||0!==a.trim().length,L=q||(()=>"juno-secrettext-"+useId())(),[M,N]=useState(!1),[O,P]=useState(""),[Q,R]=useState(!1),[S,T]=useState(!1),U=React__default.useRef(null);useEffect(()=>{N(E)},[E]),useEffect(()=>{P(I)},[I]);return React__default.createElement("div",{className:`
        juno-secret-wrapper  
        ${J}  
      `},React__default.createElement("div",{className:`
          juno-secret-wrapper-inner
          ${innerWrapperStyles} 
        `},b&&K(b)?React__default.createElement(Label,{className:`${labelStyles}`,htmlFor:L,text:b,disabled:l,required:D,floating:!0,minimized:!!(B||S||O&&O.length)}):"",Q||!M?React__default.createElement("div",{className:`juno-secret-cover ${coverStyles} `},Q?React__default.createElement("span",{className:`juno-secret-copyconfirmmessage ${copyConfirmMessageStyles}`},i):""):"",React__default.createElement(Textarea,_extends({autoComplete:e,className:`juno-secret-textarea jn-font-mono ${textareaStyles} ${f}`,disabled:l,id:L,invalid:c,name:name,onBlur:a=>{T(!1),r&&r(a)},onChange:a=>{P(a.target.value),s&&s(a)},onFocus:a=>{T(!0),v&&v(a)},placeholder:B,readOnly:C,valid:H,value:O},d))),React__default.createElement(Stack,null,React__default.createElement("div",{className:"jn-grow"},o&&K(o)?React__default.createElement(FormHint,{text:o,variant:"error",className:`${hintStyles}`}):"",F&&K(F)?React__default.createElement(FormHint,{text:F,variant:"success",className:`${hintStyles}`}):"",p&&K(p)?React__default.createElement(FormHint,{text:p,className:`${hintStyles}`}):""),React__default.createElement(ButtonRow,{className:"jn-secret-actions jn-justify-self-end jn-mt-2"},g&&!C?React__default.createElement(Button,{size:"small",className:`${actionStyles}`,onClick:()=>{P(""),t&&t()},disabled:!!(l||j||!O.length)||null,title:"Clear"},"Clear"):"",G?React__default.createElement(Button,{size:"small",className:`${actionStyles}`,onClick:()=>{M?w&&w():y&&y(),N(!M),z&&z()},title:M?"Hide":"Reveal",disabled:!!(l||n)||null},M?"Hide":"Reveal"):"",h?React__default.createElement(Button,{size:"small",className:`${actionStyles}`,onClick:()=>{navigator.clipboard.writeText(O||""),R(!0),clearTimeout(U.current),U.current=setTimeout(()=>R(!1),1e3),u&&u(O)},disabled:!!(l||k||!O.length)||null,title:"Copy"},"Copy"):"",A&&!C?React__default.createElement(Button,{size:"small",className:`${actionStyles}`,onClick:()=>{try{navigator.clipboard.readText().then(a=>{P(a),x&&x(a)})}catch(a){console.warn("Failed to read clipboard.")}},title:"Paste",disabled:!!(l||m)||null},"Paste"):"")))};SecretText.propTypes={autoComplete:PropTypes.string,className:PropTypes.string,clear:PropTypes.bool,copy:PropTypes.bool,copyConfirmtext:PropTypes.string,disableClear:PropTypes.bool,disableCopy:PropTypes.bool,disabled:PropTypes.bool,disablePaste:PropTypes.bool,disableToggle:PropTypes.bool,errortext:PropTypes.string,helptext:PropTypes.string,id:PropTypes.string,invalid:PropTypes.bool,label:PropTypes.string,name:PropTypes.string,onBlur:PropTypes.func,onChange:PropTypes.func,onClear:PropTypes.func,onCopy:PropTypes.func,onFocus:PropTypes.func,onHide:PropTypes.func,onPaste:PropTypes.func,onReveal:PropTypes.func,onToggle:PropTypes.func,paste:PropTypes.bool,placeholder:PropTypes.string,readOnly:PropTypes.bool,required:PropTypes.bool,reveal:PropTypes.bool,successtext:PropTypes.string,toggle:PropTypes.bool,valid:PropTypes.bool,value:PropTypes.string,wrapperClassName:PropTypes.string};export{SecretText};