import{LitElement as e,html as t,css as o}from"../../../lit/index.js";import{SimpleTourFinder as a}from"../../simple-popover/lib/SimpleTourFinder.js";import{autorun as i,toJS as r}from"../../../mobx/dist/mobx.esm.js";import{HAXStore as s}from"./hax-store.js";export const HaxContextBehaviors=function(e){return class extends(a(e)){static get styles(){return[o`
          :host {
            display: block;
            --hax-ui-spacing-sm: 1px;
            max-width: 100%;
          }
          :host [hidden] {
            display: none;
          }
          .selected-buttons {
            transition: 0.1s all ease-in-out;
            width: 0;
          }
          :host([has-selected-text]) .selected-buttons {
            width: 100%;
          }
          :host(.hax-context-pin-top) #toolbar {
            position: fixed;
            top: 0px;
          }
          :host(:hover),
          :host(:focus-within) {
            z-index: var(--hax-ui-focus-z-index) !important;
          }
          .group {
            padding: 0;
            background-color: var(--hax-ui-background-color);
          }
          hax-toolbar {
            flex: 0 1 auto;
          }
          hax-toolbar::part(morebutton) {
            border: 1px solid
              var(
                --simple-toolbar-group-border-width,
                var(--simple-toolbar-border-width, 1px)
              ) !important;
          }
          hax-toolbar[collapse-disabled]::part(morebutton) {
            display: none !important;
          }
          hax-toolbar *[hidden] {
            display: none !important;
          }
          hax-toolbar[collapse-disabled]::part(morebutton) {
            display: none !important;
          }
        `]}constructor(){super(),this.viewSource=!1,i((()=>{this.hasSelectedText=r(s.haxSelectedText).length>0})),i((()=>{r(s.editMode);const e=r(s.activeNode);if(this.sourceView=!1,e&&e.tagName){let t=s.haxSchemaFromTag(e.tagName);this.parentSchema=e&&e.parentNode?s.haxSchemaFromTag(e.parentNode.tagName):void 0,this.sourceView=t.canEditSource}}))}render(){return t`<slot></slot> `}static get tag(){return"hax-context-behaviors"}static get properties(){return{...super.properties,activeNode:{type:Object},parentSchema:{type:Object},realSelectedValue:{type:String},sourceView:{type:Boolean},viewSource:{type:Boolean}}}get slotSchema(){let e={};if(this.activeNode&&this.parentSchema){let t=this.activeNode.slot||"";this.activeNode&&this.activeNode.parentNode||(e=s.schemaBySlotId(this.activeNode.parentNode,t))}return e}get layoutElement(){return this.activeNode&&s.isLayoutElement(this.activeNode)?this.activeNode:this.activeNode&&this.activeNode.parentNode&&s.isLayoutElement(this.activeNode.parentNode)?this.activeNode.parentNode:void 0}get layoutParent(){return this.layoutElement&&this.layoutElement.parentNode&&s.isLayoutElement(this.layoutElement.parentNode)&&this.layoutElement.parentNode.tagName&&"HAX-BODY"!==this.layoutElement.parentNode.tagName?this.layoutElement.parentNode:void 0}get slottedItems(){if(!this.activeNode)return[];let e=s.slottedContentByNode(this.layoutElement)||{};return Object.keys(e).map((t=>e[t]))}elementIcon(e){let t=e&&this.elementGizmo(e)?this.elementGizmo(e):void 0;return t?t.icon:void 0}elementLabel(e){let t=e&&this.elementGizmo(e)?this.elementGizmo(e):void 0;return t?t.title||t.tag:e&&e.tagName?e.tagName.toLowerCase():""}elementGizmo(e){let t=e&&e.tagName?s.haxSchemaFromTag(e.tagName):void 0;return t&&t.gizmo?t.gizmo:void 0}getFilteredBlocks(e=[]){return e.filter((e=>{if(!e.tag)return;let t=e.tag||"",o=this.slotSchema&&this.slotSchema.slotWrapper&&this.slotSchema.slotWrapper?this.slotSchema.slotWrapper:void 0,a=this.slotSchema&&this.slotSchema.slotWrapper&&this.slotSchema.allowedSlotWrappers?this.slotSchema.allowedSlotWrappers:void 0,i=this.slotSchema&&this.slotSchema.slotWrapper&&this.slotSchema.excludedSlotWrappers?this.slotSchema.excludedSlotWrappers:void 0,r=!this.slotSchema||!a,s=!!o&&o===t||!!a&&a.includes(t);return!(!!i&&i.includes(t))&&(r||s)}))}updated(e){super.updated&&super.updated(e),e.forEach(((e,t)=>{"activeNode"===t&&this.activeNode!==e&&this.setTarget(this.activeNode)}))}setTarget(e=this.activeNode){super.setTarget&&super.setTarget(e),this.parentSchema=e&&e.parentNode?s.haxSchemaFromTag(e.parentNode.tagName):void 0}}};