            remove-query     (fn [i] (swap! search-queries
                                            #(vec (concat (subvec % 0 i) (subvec % (inc i))))))]
        (doall (for [index (range nqueries)]
-                (let [query-cursor         (reagent/cursor search-queries [index])
+                (let [query-cursor         (reagent/cursor query-get-set [index])
                       selected-language    (-> @query-cursor :query :lang)
                       remove-query-handler (partial remove-query index)]
                   (when multilingual? [language-select languages selected-language])

  (:require [clojure.string :as str]
            [reagent.core :as reagent]))

(defn- phrase->cqp [phrase phonetic?]
  (let [attr                (if phonetic? "phon" "word")
        chinese-chars-range "[\u4E00-\u9FFF\u3400-\u4DFF\uF900-\uFAFF]"
        ; Surround every Chinese character by space when constructing a cqp query,
        ; to treat it as if it was an individual word:
        phrase              (str/replace phrase
                                         (re-pattern (str "(" chinese-chars-range ")"))
                                         " $1 ")]
    (->> (str/split phrase #"\s")
         (map #(if (= % "")
                ""
                (str "[" attr "=\"" % "\" %c]")))
         (str/join " "))))

(defn- search! [query-cursor]
  (.log js/console "soker"))


(defn- on-text-changed [event query-cursor phonetic?]
  (let [value (aget event "target" "value")
        query (if (= value "") "" (phrase->cqp value phonetic?))]
    (swap! query-cursor assoc :query query)))

(defn- on-phonetic-changed [event query-cursor]
  (let [query    (:query @query-cursor)
