System.register(["reactive-jsx", "src/client/graphics.js"], function (_export, _context) {
  "use strict";

  var _addSourceLocation, pt;

  return {
    setters: [function (_reactiveJsx) {
      _addSourceLocation = _reactiveJsx.addSourceLocation;
    }, function (_srcClientGraphicsJs) {
      pt = _srcClientGraphicsJs.pt;
    }],
    execute: function () {
      const __SystemJSRewritingHack = {};
      _recorder_._src_client_morphic_dragbehavior_js = _recorder_._src_client_morphic_dragbehavior_js || {};
      Object.defineProperty(_recorder_._src_client_morphic_dragbehavior_js, "pt", {
        get() {
          return pt;
        },

        set(thisIsVererySecretVariableName) {
          pt = thisIsVererySecretVariableName;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      class DragBehavior {
        static on(target) {
          return new DragBehavior(target);
        }

        constructor(target) {
          this.target = target;
          this.target.draggable = true;
          lively.addEventListener("DragBehavior", this.target, "dragstart", evt => this.onDragStart(evt));
        }

        onDragStart(evt) {
          this.originalPosition = lively.getPosition(this.target);
          this.offset = this.originalPosition.subPt(pt(evt.clientX, evt.clientY));
          evt.dataTransfer.setDragImage(_addSourceLocation(document.createElement("div"), {
            file: 'https://lively-kernel.org/lively4/composed-offset/src/client/morphic/dragbehavior.js',
            end: {
              column: 63,
              line: 19
            },
            start: {
              column: 34,
              line: 19
            }
          }), 0, 0);

          lively.addEventListener("DragBehavior", this.target, "drag", evt => this.onDrag(evt));
          lively.addEventListener("DragBehavior", this.target, "dragend", evt => this.onDragEnd(evt));

          if (this.target.dragBehaviorStart) {
            this.target.dragBehaviorStart(evt, this.originalPosition);
          }
        }

        onDrag(evt) {
          // console.log("pos " + evt.clientX, evt.offsetX, evt.clientX - evt.offsetX, evt )
          if (evt.clientX == 0 && evt.clientY == 0) return; // #Garbage event
          if (evt.offsetX < 0) return; // another #Garbage event

          var pos = pt(evt.clientX, evt.clientY).addPt(this.offset);
          if (this.target.dragBehaviorMove) {
            this.target.dragBehaviorMove(evt, pos, this.originalPosition);
          } else {
            lively.setPosition(this.target, pos);
          }
        }

        onDragEnd(evt) {
          lively.removeEventListener("DragBehavior", this.target, "drag");
          lively.removeEventListener("DragBehavior", this.target, "dragend");

          if (this.target.dragBehaviorEnd) {
            this.target.dragBehaviorEnd(evt, this.originalPosition);
          }
        }
      }

      _export("default", DragBehavior);

      Object.defineProperty(_recorder_._src_client_morphic_dragbehavior_js, "DragBehavior", {
        get() {
          return DragBehavior;
        },

        set(thisIsVererySecretVariableName) {
          _export("default", DragBehavior = thisIsVererySecretVariableName);

          return true;
        },

        enumerable: true,
        configurable: true
      });
    }
  };
});