<commit_before>(ns braid.client.state
  (:require [reagent.ratom :include-macros true :refer-macros [reaction]]
            [braid.client.store :as store]
            [clojure.set :refer [union intersection subset?]]
[braid.client.state.subscription :refer [subscription]]
            [braid.client.quests.subscriptions])
  (:import goog.Uri))

(defn subscribe
  "Get a reaction for the given data.
  In one-argument form, this looks like `(subscribe [:key arg1 arg2])`
  Two-argument form enables you to have a subscription which takes reactions or
  atoms as arguments, e.g.
  `(let [foo (subscribe [:some-key 1])
         bar (r/atom ...)
         baz (subscribe [:other-key 2] [foo bar])]
     ...)"
  ([v] (subscription store/app-state v))
  ([v dynv] ; Dynamic subscription
   (let [dyn-vals (reaction (mapv deref dynv))
         sub (reaction (subscription store/app-state (into v @dyn-vals)))]
     (reaction @@sub))))

(defmethod subscription :default
  [_ [sub-name args]]
  (ex-info (str "No subscription for " sub-name) {::name sub-name ::args args}))

(defmethod subscription :active-group
  [state _]
  (let [group-id (reaction (:open-group-id @state))]
    (reaction (get-in @state [:groups @group-id]))))

(defmethod subscription :groups
  [state _]<commit_msg>Fix indentation<commit_after>(ns braid.client.state
  (:require [reagent.ratom :include-macros true :refer-macros [reaction]]
            [braid.client.store :as store]
            [clojure.set :refer [union intersection subset?]]
            [braid.client.state.subscription :refer [subscription]]
            [braid.client.quests.subscriptions])
  (:import goog.Uri))

(defn subscribe
  "Get a reaction for the given data.
  In one-argument form, this looks like `(subscribe [:key arg1 arg2])`
  Two-argument form enables you to have a subscription which takes reactions or
  atoms as arguments, e.g.
  `(let [foo (subscribe [:some-key 1])
         bar (r/atom ...)
         baz (subscribe [:other-key 2] [foo bar])]
     ...)"
  ([v] (subscription store/app-state v))
  ([v dynv] ; Dynamic subscription
   (let [dyn-vals (reaction (mapv deref dynv))
         sub (reaction (subscription store/app-state (into v @dyn-vals)))]
     (reaction @@sub))))

(defmethod subscription :default
  [_ [sub-name args]]
  (ex-info (str "No subscription for " sub-name) {::name sub-name ::args args}))

(defmethod subscription :active-group
  [state _]
  (let [group-id (reaction (:open-group-id @state))]
    (reaction (get-in @state [:groups @group-id]))))

(defmethod subscription :groups
  [state _]
{'fraction_non_alphanumeric': 0.14563862928348908, 'fraction_numerical': 0.003115264797507788, 'mean_word_length': 3.339527027027027, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2984021', 'n_tokens_mistral': 839, 'n_tokens_neox': 816, 'n_words': 253}