          :cursor 0
          :input ""))
 
-(defn eval-input [state]
-  (let [expression (str/trim (:input @state))]
+(defn eval-input [state input]
+  (let [expression (str/trim input)]
     (when-not (str/blank? expression)
       (eval-str! expression)
       (swap! state assoc :ready? false :input "" :cursor 0))))

     [:div.flex-h
      [repl-input props]
      [run-button props]]]]])

(defn input-ok? [{:keys [history]}]
  (or (= (count history) 0)
      (some? (-> history last second :result))))


(defn history [props]

    [editor/text (str/trim-newline output)]]
   [:hr.border]])

(defn render-value [value]
  (cond
    (string? value)
    [editor/code (-> value unescape-string pprint-str)]

    (map? value)
    (case (:type value)
      :hiccup (:content value)
      [editor/code (pprint-str value)])

    :default
    [editor/code (pprint-str value)]))

(defn render-error [error]
  [:pre.error
   (or (:stack error)
       (if (and (:message error) (not= "ERROR" (:message error)))
         (:message error)
         (str (:cause error))
         #_(or (str (:cause error)) (str error))))])


(defn render-progress []
  [mdl/upgrade
   [:div.mdl-progress.mdl-js-progress.mdl-progress__indeterminate {:style {:width "100%"}}]])

(defn history-card-result [props {:keys [success? value error] :as result}]
  [:div.card-data.result
   (if result
     (if success?
       [render-value value]
       [render-error error])
     [render-progress])])

(defn history-card [{:keys [state columns] :as props} {:keys [ns expression result output] :as history-item}]
  [:div
   {:class (str "mdl-cell " (card-size-class columns))}
   [:div.mdl-card.mdl-shadow--2dp
