     (while true
       (let [[type ev arg] (<! channel)]
         (case type
+          :screen (om/update! app [:screen] arg)
+          :import (if (= 13 (:key-code ev)) 
+            (om/transact! app #(merge % {:screen :summary, :txs (into (:txs app) (import-transactions ev))})))
           :create (om/transact! app [:txs] #(conj % (create-transaction (get-inputs-state))))
           :change (om/transact! app [:entry-parts] #(change-part-field ev arg %))
           :blur (om/transact! app [:entry-parts] #(blur-amount ev arg %)))))))

   {:account "", :amount ""}])

(def app-state (atom 
  {:txs sample-txs 
   :entry-parts empty-entry-parts}))

(defn store-event [ev]
  {:target (aget ev "target")
   :target-value (aget ev "target" "value")})

(defn send! 

  ([type arg]
    (fn [ev]
      (put! channel [type (store-event ev) arg]))))
      
(defn summarize [txs]
  (->> txs
       (map :parts)
       (apply concat)
       (group-by :account)
       (map (fn [[account parts]] 
              {:account (account->str account), 
               :amount (fixpt->str (apply + (map :amount parts)))}))
       (sort-by :amount #(compare %2 %1))))

(defn render-menu-link [this-screen title active-screen]
  (if (= this-screen active-screen)
    (dom/span #js {:style #js {:fontWeight "bold"}} title)
    (dom/a #js {:onClick (send! :screen this-screen) :href "#"} title)))
      
(defn render-import [state]
  (dom/textarea #js {:onKeyDown (send! :import) :rows 25 :cols 100}))
  
(defn render-summary [summary-rows]
  (dom/table nil
    (dom/thead nil
      (dom/tr nil
        (dom/th nil "Account")
        (dom/th nil "Amount")))
    (apply dom/tbody nil
      (for [{:keys [account amount]} summary-rows]
        (dom/tr nil
          (dom/td nil account)
          (dom/td #js {:style #js {:textAlign "right"}} amount))))))

(defn render-detail [state]
  (dom/div nil
    (dom/table nil
      (dom/thead nil
        (apply dom/tr nil
