<commit_before>import { Arr, Fun, Thunk } from '@ephox/katamari';
import { Classes, Css, Position, Scroll, Traverse } from '@ephox/sugar';

import * as Boxes from '../../alien/Boxes';
import * as OffsetOrigin from '../../alien/OffsetOrigin';
import { AlloyComponent } from '../../api/component/ComponentApi';
import * as DragCoord from '../../api/data/DragCoord';
import * as Dockables from './Dockables';
import { DockingConfig, DockingState } from './DockingTypes';

const morphToStatic = (component: AlloyComponent, config: DockingConfig): void => {
  Arr.each([ 'left', 'top', 'position' ], (prop) => Css.remove(component.element(), prop));
  config.onUndocked(component);
};

const morphToCoord = (component: AlloyComponent, config: DockingConfig, scroll: Position, origin: Position, morph: DragCoord.CoordAdt): void => {
  // Remove properties conflicting with DragCoord.toStyles
  Css.remove(component.element(), 'bottom');
  Css.remove(component.element(), 'right');

  const styles = DragCoord.toStyles(morph, scroll, origin);
  Css.setAll(component.element(), styles);
  const method = styles.position === 'fixed' ? config.onDocked : config.onUndocked;
  method(component);
};

const updateVisibility = (component: AlloyComponent, config: DockingConfig, state: DockingState, viewport: Boxes.Bounds, morphToDocked: boolean = false) => {
  config.contextual.each((contextInfo) => {
    // Make the dockable component disappear if the context is outside the viewport
    contextInfo.lazyContext(component).each((box) => {
      const isVisible = Dockables.isPartiallyVisible(box, viewport);
      if (isVisible !== state.isVisible()) {
        state.setVisible(isVisible);

        // If morphing to docked and the context isn't visible then immediately set
        // the fadeout class and don't worry about transitioning, as the context
        // would never have been in view while docked
        if (morphToDocked && !isVisible) {
          Classes.add(component.element(), [ contextInfo.fadeOutClass ]);
          contextInfo.onHide(component);
        } else {
          const method = isVisible ? Dockables.appear : Dockables.disappear;
          method(component, contextInfo);
        }
      }
    });
  });
};<commit_msg>TINY-4587: Undo fix for conflicting styles<commit_after>import { Arr, Fun, Thunk } from '@ephox/katamari';
import { Classes, Css, Position, Scroll, Traverse } from '@ephox/sugar';

import * as Boxes from '../../alien/Boxes';
import * as OffsetOrigin from '../../alien/OffsetOrigin';
import { AlloyComponent } from '../../api/component/ComponentApi';
import * as DragCoord from '../../api/data/DragCoord';
import * as Dockables from './Dockables';
import { DockingConfig, DockingState } from './DockingTypes';

const morphToStatic = (component: AlloyComponent, config: DockingConfig): void => {
  Arr.each([ 'left', 'top', 'position' ], (prop) => Css.remove(component.element(), prop));
  config.onUndocked(component);
};

const morphToCoord = (component: AlloyComponent, config: DockingConfig, scroll: Position, origin: Position, morph: DragCoord.CoordAdt): void => {
  const styles = DragCoord.toStyles(morph, scroll, origin);
  Css.setAll(component.element(), styles);
  const method = styles.position === 'fixed' ? config.onDocked : config.onUndocked;
  method(component);
};

const updateVisibility = (component: AlloyComponent, config: DockingConfig, state: DockingState, viewport: Boxes.Bounds, morphToDocked: boolean = false) => {
  config.contextual.each((contextInfo) => {
    // Make the dockable component disappear if the context is outside the viewport
    contextInfo.lazyContext(component).each((box) => {
      const isVisible = Dockables.isPartiallyVisible(box, viewport);
      if (isVisible !== state.isVisible()) {
        state.setVisible(isVisible);

        // If morphing to docked and the context isn't visible then immediately set
        // the fadeout class and don't worry about transitioning, as the context
        // would never have been in view while docked
        if (morphToDocked && !isVisible) {
          Classes.add(component.element(), [ contextInfo.fadeOutClass ]);
          contextInfo.onHide(component);
        } else {
          const method = isVisible ? Dockables.appear : Dockables.disappear;
          method(component, contextInfo);
        }
      }
    });
  });
};
{'fraction_non_alphanumeric': 0.13555045871559632, 'fraction_numerical': 0.0009174311926605505, 'mean_word_length': 3.8294573643410854, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6347291', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1249, 'n_words': 344}