<commit_before>(ns frontend.core
  (:require [cljs.core.async :as async :refer [>! <! alts! chan sliding-buffer close!]]
            [frontend.async :refer [put!]]
            [clojure.string :as string]
            [datascript :as d]
            [goog.dom]
            [goog.dom.DomHelper]
            [goog.net.Cookies]
            [frontend.analytics :as analytics]
            [frontend.camera :as camera-helper]
            [frontend.clipboard :as clipboard]
            [frontend.components.app :as app]
            [frontend.controllers.controls :as controls-con]
            [frontend.controllers.navigation :as nav-con]
            [frontend.components.key-queue :as keyq]
            [frontend.datascript :as ds]
            [frontend.db :as db]
            [frontend.dev :as dev]
            [frontend.routes :as routes]
            [frontend.controllers.api :as api-con]
            [frontend.controllers.errors :as errors-con]
            [frontend.env :as env]
            [frontend.instrumentation :refer [wrap-api-instrumentation]]
            [frontend.sente :as sente]
            [frontend.state :as state]
            [goog.events]
            [goog.events.EventType]
            [om.core :as om :include-macros true]
            [frontend.history :as history]
            [frontend.browser-settings :as browser-settings]
            [frontend.utils :as utils :refer [mlog merror third]]
            [frontend.utils.ajax :as ajax]
            [frontend.datetime :as datetime]
            [goog.labs.dom.PageVisibilityMonitor]
            [secretary.core :as sec])
  (:require-macros [cljs.core.async.macros :as am :refer [go go-loop alt!]]
                   [frontend.utils :refer [inspect timing swallow-errors]])
  (:import [cljs.core.UUID]
           [goog.events.EventType]))

(enable-console-print!)

(defn event-props [event]
  {:button  (.-button event)
   :type (.-type event)
   :meta? (.-metaKey event)
   :ctrl? (.-ctrlKey event)
   :shift? (.-shiftKey event)})

(defn handle-mouse-move [cast! event]
  (cast! :mouse-moved (conj (camera-helper/screen-event-coords event) (event-props event))
         true))

(defn handle-mouse-down [cast! event]
  (cast! :mouse-depressed (conj (camera-helper/screen-event-coords event) (event-props event)) false))

(defn handle-mouse-up [cast! event]
  (cast! :mouse-released (conj (camera-helper/screen-event-coords event) (event-props event)) false))

(defn disable-mouse-wheel [event]
  (.stopPropagation event))

(defn track-key-state [cast! direction suppressed-key-combos event]
  (let [meta?      (when (.-metaKey event) "meta")
        shift?     (when (.-shiftKey event) "shift")
        ctrl?      (when (.-ctrlKey event) "ctrl")
        alt?       (when (.-altKey event) "alt")
        char       (or (get keyq/code->key (.-which event))
                       (js/String.fromCharCode (.-which event)))
        tokens     [shift? meta? ctrl? alt? char]
        key-string (string/join "+" (filter identity tokens))]
    (when-not (contains? #{"INPUT" "TEXTAREA"} (.. event -target -tagName))
      (when (get suppressed-key-combos key-string)
        (.preventDefault event))
      (when-not (.-repeat event)
        (let [human-name (keyq/event->key event)]<commit_msg>case-insensitive check for input or textarea<commit_after>(ns frontend.core
  (:require [cljs.core.async :as async :refer [>! <! alts! chan sliding-buffer close!]]
            [frontend.async :refer [put!]]
            [clojure.string :as string]
            [datascript :as d]
            [goog.dom]
            [goog.dom.DomHelper]
            [goog.net.Cookies]
            [frontend.analytics :as analytics]
            [frontend.camera :as camera-helper]
            [frontend.clipboard :as clipboard]
            [frontend.components.app :as app]
            [frontend.controllers.controls :as controls-con]
            [frontend.controllers.navigation :as nav-con]
            [frontend.components.key-queue :as keyq]
            [frontend.datascript :as ds]
            [frontend.db :as db]
            [frontend.dev :as dev]
            [frontend.routes :as routes]
            [frontend.controllers.api :as api-con]
            [frontend.controllers.errors :as errors-con]
            [frontend.env :as env]
            [frontend.instrumentation :refer [wrap-api-instrumentation]]
            [frontend.sente :as sente]
            [frontend.state :as state]
            [goog.events]
            [goog.events.EventType]
            [om.core :as om :include-macros true]
            [frontend.history :as history]
            [frontend.browser-settings :as browser-settings]
            [frontend.utils :as utils :refer [mlog merror third]]
            [frontend.utils.ajax :as ajax]
            [frontend.datetime :as datetime]
            [goog.labs.dom.PageVisibilityMonitor]
            [secretary.core :as sec])
  (:require-macros [cljs.core.async.macros :as am :refer [go go-loop alt!]]
                   [frontend.utils :refer [inspect timing swallow-errors]])
  (:import [cljs.core.UUID]
           [goog.events.EventType]))

(enable-console-print!)

(defn event-props [event]
  {:button  (.-button event)
   :type (.-type event)
   :meta? (.-metaKey event)
   :ctrl? (.-ctrlKey event)
   :shift? (.-shiftKey event)})

(defn handle-mouse-move [cast! event]
  (cast! :mouse-moved (conj (camera-helper/screen-event-coords event) (event-props event))
         true))

(defn handle-mouse-down [cast! event]
  (cast! :mouse-depressed (conj (camera-helper/screen-event-coords event) (event-props event)) false))

(defn handle-mouse-up [cast! event]
  (cast! :mouse-released (conj (camera-helper/screen-event-coords event) (event-props event)) false))

(defn disable-mouse-wheel [event]
  (.stopPropagation event))

(defn track-key-state [cast! direction suppressed-key-combos event]
  (let [meta?      (when (.-metaKey event) "meta")
        shift?     (when (.-shiftKey event) "shift")
        ctrl?      (when (.-ctrlKey event) "ctrl")
        alt?       (when (.-altKey event) "alt")
        char       (or (get keyq/code->key (.-which event))
                       (js/String.fromCharCode (.-which event)))
        tokens     [shift? meta? ctrl? alt? char]
        key-string (string/join "+" (filter identity tokens))]
    (when-not (contains? #{"input" "textarea"} (string/lower-case (.. event -target -tagName)))
      (when (get suppressed-key-combos key-string)
        (.preventDefault event))
      (when-not (.-repeat event)
        (let [human-name (keyq/event->key event)]
{'fraction_non_alphanumeric': 0.1400213773095129, 'fraction_numerical': 0.0, 'mean_word_length': 2.2490079365079363, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '7458191', 'n_tokens_mistral': 2069, 'n_tokens_neox': 2047, 'n_words': 499}