"use strict";function a(b){"@babel/helpers - typeof";return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},a(b)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;var b=l(require("react")),c=require("react-i18next"),d=j(require("prop-types")),e=require("../utils/common"),f=j(require("classnames")),g=j(require("lodash/uniqueId")),h=j(require("./Copier")),i=require("@carbon/icons-react");function j(a){return a&&a.__esModule?a:{default:a}}function k(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(k=function(a){return a?c:b})(a)}function l(b,c){if(!c&&b&&b.__esModule)return b;if(null===b||"object"!==a(b)&&"function"!=typeof b)return{default:b};var d=k(c);if(d&&d.has(b))return d.get(b);var e={},f=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var g in b)if("default"!=g&&Object.prototype.hasOwnProperty.call(b,g)){var h=f?Object.getOwnPropertyDescriptor(b,g):null;h&&(h.get||h.set)?Object.defineProperty(e,g,h):e[g]=b[g]}return e["default"]=b,d&&d.set(b,e),e}function m(a,b){return r(a)||q(a,b)||o(a,b)||n()}function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(a,b){if(a){if("string"==typeof a)return p(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?p(a,b):void 0}}function p(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function q(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f=[],g=!0,h=!1;try{for(c=c.call(a);!(g=(d=c.next()).done)&&(f.push(d.value),!(b&&f.length===b));g=!0);}catch(a){h=!0,e=a}finally{try{g||null==c["return"]||c["return"]()}finally{if(h)throw e}}return f}}function r(a){if(Array.isArray(a))return a}var s=function(a){var d=a.copyableContent,j=a.expanded,k=a.onExpand,l=a.expandLinesAfter,n=void 0===l?8:l,o=a.children,p=(0,b.useState)(!!j&&j),q=m(p,2),r=q[0],s=q[1],u=(0,b.useState)(!1),v=m(u,2),w=v[0],x=v[1],y=(0,c.useTranslation)(),z=y.t,t=(0,b.useRef)("copyable_content_".concat((0,g["default"])()));(0,b.useEffect)(function(){s(j)},[j]),(0,b.useEffect)(function(){var a=o?document.querySelector(".".concat(t.current)):null;x((0,e.isExpandable)(a?a.textContent:null,n))},[n,d,o]),k||(k=function(){s(!r)});var A=b["default"].createElement("button",{className:(0,f["default"])("bx--btn","bx--btn--ghost","bx--btn--field","bx--snippet-btn--expand"),type:"button",onClick:k,"data-testid":"more-less-button"},b["default"].createElement("span",{className:"bx--snippet-btn--text"},r?z("show_less"):z("show_more")),b["default"].createElement(i.ChevronDown16,{"aria-label":r?z("show_less"):z("show_more"),className:"bx--icon-chevron--down bx--snippet__icon",name:"chevron--down",role:"img"}));return b["default"].createElement("div",{className:"expandableDisplay","data-testid":"expandableDisplay"},b["default"].createElement("div",{className:(0,f["default"])("bx--snippet","bx--snippet--multi","bx--snippet--wraptext",{"bx--snippet--expand":r}),"data-testid":"content_panel"},b["default"].createElement("div",{className:(0,f["default"])("bx--snippet-container","body",{expanded:r},{small:!w}),"data-testid":"expandable-display",tabIndex:"0"},b["default"].createElement("div",{className:"boundedSection "+(!d&&t.current),"data-testid":"default-copyable-content"},o)),d&&b["default"].createElement("div",{className:(0,f["default"])("hiddenCopy",t.current),"data-testid":"copyable-content"},b["default"].createElement("pre",null,b["default"].createElement("code",null,d))),b["default"].createElement(h["default"],{element:".".concat(t.current)}),w&&A))};s.propTypes={copyableContent:d["default"].string,expanded:d["default"].bool,onExpand:d["default"].func,expandLinesAfter:d["default"].number,children:d["default"].node};var t=s;exports["default"]=t;