text: Object.defineProperty(exports,"__esModule",{value:!0}),exports.HaxContextBehaviors=void 0;var e=require("lit-element/lit-element.js"),t=require("@lrnwebcomponents/simple-popover/lib/SimpleTourFinder"),o=require("mobx"),r=require("./hax-store.js");function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function _typeof(e){return typeof e}:function _typeof(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ownKeys(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function _defineProperty(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function _templateObject2_c1c4adc0012611ec9676957c409166bc(){var e=_taggedTemplateLiteral(["<slot></slot> "]);return _templateObject2_c1c4adc0012611ec9676957c409166bc=function _templateObject2_c1c4adc0012611ec9676957c409166bc(){return e},e}function _templateObject_c1c4adc0012611ec9676957c409166bc(){var e=_taggedTemplateLiteral(["\n          :host {\n            display: block;\n            pointer-events: none;\n            --hax-ui-spacing-sm: 1px;\n            max-width: 100%;\n          }\n          :host [hidden] {\n            display: none;\n          }\n          .selected-buttons {\n            transition: 0.1s all ease-in-out;\n            width: 0;\n          }\n          :host([has-selected-text]) .selected-buttons {\n            width: 100%;\n          }\n          :host(.hax-context-pin-top) #toolbar {\n            position: fixed;\n            top: 0px;\n          }\n          :host(:hover),\n          :host(:focus-within) {\n            z-index: var(--hax-ui-focus-z-index) !important;\n          }\n          .group {\n            padding: 0;\n            background-color: var(--hax-ui-background-color);\n          }\n          hax-toolbar {\n            flex: 0 1 auto;\n          }\n          hax-toolbar::part(morebutton) {\n            border: 1px solid var( --simple-toolbar-group-border-width, var(--simple-toolbar-border-width, 1px)) !important;\n          }\n          hax-toolbar[collapse-disabled]::part(morebutton) {\n            display: none !important;\n          }\n          hax-toolbar *[hidden] {\n            display: none !important;\n          }\n          hax-toolbar[collapse-disabled]::part(morebutton) {\n            display: none !important;\n          }\n        "]);return _templateObject_c1c4adc0012611ec9676957c409166bc=function _templateObject_c1c4adc0012611ec9676957c409166bc(){return e},e}function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof(t)&&"function"!=typeof t?function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function _get(e,t,o){return(_get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function _get(e,t,o){var r=function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(o):n.value}})(e,t,o||e)}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _defineProperties(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass(e,t,o){return t&&_defineProperties(e.prototype,t),o&&_defineProperties(e,o),e}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}exports.HaxContextBehaviors=function HaxContextBehaviors(n){return function(t){function _class(){var e;return function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,_class),(e=_possibleConstructorReturn(this,_getPrototypeOf(_class).call(this))).viewSource=!1,(0,o.autorun)((function(){e.hasSelectedText=(0,o.toJS)(r.HAXStore.haxSelectedText).length>0})),(0,o.autorun)((function(){(0,o.toJS)(r.HAXStore.editMode);var t=(0,o.toJS)(r.HAXStore.activeNode);if(e.sourceView=!1,t&&t.tagName){var n=r.HAXStore.haxSchemaFromTag(t.tagName);e.parentSchema=t&&t.parentNode?r.HAXStore.haxSchemaFromTag(t.parentNode.tagName):void 0,e.sourceView=n.canEditSource}})),e}return function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}(_class,t),_createClass(_class,null,[{key:"styles",get:function get(){return[(0,e.css)(_templateObject_c1c4adc0012611ec9676957c409166bc())]}}]),_createClass(_class,[{key:"render",value:function render(){return(0,e.html)(_templateObject2_c1c4adc0012611ec9676957c409166bc())}},{key:"getFilteredBlocks",value:function getFilteredBlocks(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return t.filter((function(t){if(t.tag){var o=t.tag||"",r=e.slotSchema&&e.slotSchema.slotWrapper&&e.slotSchema.slotWrapper?e.slotSchema.slotWrapper:void 0,n=e.slotSchema&&e.slotSchema.slotWrapper&&e.slotSchema.allowedSlotWrappers?e.slotSchema.allowedSlotWrappers:void 0,a=e.slotSchema&&e.slotSchema.slotWrapper&&e.slotSchema.excludedSlotWrappers?e.slotSchema.excludedSlotWrappers:void 0,c=!e.slotSchema||!n,i=!!r&&r===o||!!n&&n.includes(o),s=!!a&&a.includes(o),l=!s&&(c||i);return"hax-plate-context"==e.tag&&console.log(o,r,a,c,i,s,l),l}}))}},{key:"updated",value:function updated(e){var t=this;_get(_getPrototypeOf(_class.prototype),"updated",this)&&_get(_getPrototypeOf(_class.prototype),"updated",this).call(this,e),e.forEach((function(e,o){"activeNode"===o&&t.activeNode!==e&&t.setTarget(t.activeNode)}))}},{key:"setTarget",value:function setTarget(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.activeNode;_get(_getPrototypeOf(_class.prototype),"setTarget",this)&&_get(_getPrototypeOf(_class.prototype),"setTarget",this).call(this,e),this.parentSchema=e&&e.parentNode?r.HAXStore.haxSchemaFromTag(e.parentNode.tagName):void 0}},{key:"slotSchema",get:function get(){var e,t=this;if(this.activeNode&&this.parentSchema){var o=this.activeNode.slot||"";Object.keys(this.parentSchema.settings||{}).forEach((function(r){(t.parentSchema.settings[r]||[]).forEach((function(t){t.slot&&t.slot===o&&(e=t)}))}))}return e}}],[{key:"tag",get:function get(){return"hax-context-behaviors"}},{key:"properties",get:function get(){return function _objectSpread(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(o,!0).forEach((function(t){_defineProperty(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):ownKeys(o).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}({},_get(_getPrototypeOf(_class),"properties",this),{activeNode:{type:Object},parentSchema:{type:Object},realSelectedValue:{type:String},sourceView:{type:Boolean},viewSource:{type:Boolean}})}}]),_class}((0,t.SimpleTourFinder)(n))};