import{h,c as Host,r as registerInstance}from"./index-38ad4957.js";import{u as useMemo,f as useEffect,n as h$1}from"./dom-context-hooks.module-50442785.js";import{_}from"./index.module-b23fdad8.js";import{g as getProps}from"./utils-334c1e34.js";import{u as useRerenderListener}from"./re-render-f30aeb6b.js";import{u as useChildElements}from"./useChildElements-9bccfb72.js";var TabsView=function(t){var e=t.content,r=t.placement,n=t.textColor,a=n===void 0?"var(--sqm-text)":n;var s=!r||r==="top"||r==="bottom"?"var(--sl-spacing-x-large) 0;":"0 var(--sl-spacing-xx-large);";var o="\n    sl-tab-panel::part(base) {\n      padding: "+s+";\n    }\n\n    sl-tab::part(base) {\n      color: "+a+";\n      font-family: var(--sqm-primary-font);\n    }\n\n\n\n    sl-tab-group::part(tabs) {\n      border-bottom: 2px solid var(--sqm-border-color);\n      font-family: var(--sqm-primary-font);\n    }\n  ";return h(Host,null,h("style",{type:"text/css"},o),h("sl-tab-group",{placement:r},e.tabs.map((function(t){var e=t.getAttribute("slot");if(t.tagName==="RAISINS-PLOP-TARGET"){return h("sl-tab",{slot:"nav"},h("div",{style:{marginTop:"10px"}},h("slot",{name:e})))}return[h("sl-tab",{slot:"nav",panel:e,part:"tab",id:t.getAttribute("id")||e},t.getAttribute("header")),h("sl-tab-panel",{name:e},h("slot",{name:e}))]}))),h("div",{style:{display:"none"}},h("slot",null)))};var REVEAL_EVENT="sq:reveal";function useTabs(){var t=useChildElements();var e=_();var r=useRerenderListener();var n=useMemo((function(){return t.filter((function(t){return t.tagName==="SQM-TAB"||t.tagName==="RAISINS-PLOP-TARGET"})).map((function(t,e){if(t.tagName==="RAISINS-PLOP-TARGET"){var r=t;r.style.position="absolute";r.style.left="6px";var n=t.firstElementChild.childNodes[1];n.innerHTML="＋";n.style.lineHeight="20px"}t.setAttribute("slot","tab-"+e);t.setAttribute("id","tab-"+e);return t}))}),[t,r]);useEffect((function(){var t=function(t){var r;var n=t.target;t.stopPropagation();if(!n)return;var a=n.closest("sqm-tabs");if(!e.contains(n)||!a)return;var s=n.closest("sqm-tab");var o=a.shadowRoot.querySelector("sl-tab-group");(r=o)===null||r===void 0?void 0:r.show(s.id)};e.addEventListener(REVEAL_EVENT,t);return function(){e.removeEventListener(REVEAL_EVENT,t)}}),[]);return{content:{tabs:n}}}var Tabs=function(){function t(t){registerInstance(this,t);h$1(this)}t.prototype.disconnectedCallback=function(){};t.prototype.render=function(){var t=useTabs().content;var e=getProps(this),r=e.placement,n=e.textColor;return h(TabsView,{placement:r,content:t,textColor:n},h("slot",null))};return t}();export{Tabs as sqm_tabs};