/*
MagJS v0.23.8
http://github.com/magnumjs/mag.js
(c) Michael Glazer
License: MIT
*/

(function(mag) {

  'use strict';

  var utils = {};

  utils.callHook = function (hookins, key, name, i, data, before) {
    if (hookins[name][i].key == key) {
      before = {v: data.value, k: data.key}
      data.change = false;
      hookins[name][i].handler.call(hookins[name][i].context, data);
        //if any change
      if (before !==  {v: data.value, k: data.key}) {
        data.change = true
      }
    }
  }

  var handlers = []
  utils.onLCEvent = function(eventName, index, handler) {
    handlers[eventName + '-' + index] = handler
  }
  utils.callLCEvent = function(eventName, controller, node, index, once, extra) {
    var isPrevented = false,
      event = {
        preventDefault: function() {
          isPrevented = true
        }
      }

    if (controller && controller[eventName]) {
      controller[eventName].call(controller, event, node, mag.mod.getProps(index), index, extra)
      if (once) controller[eventName] = 0
    }

    // on Handlers
    handlers[eventName + '-' + index] && handlers[eventName + '-' + index](mag.mod.getState(index), mag.mod.getProps(index));

    return isPrevented
  }

  //UTILITY
  utils.copy = function(o) {
    return Object.assign({}, o);
  }

  utils.merge = function() {
    return Object.assign.apply({}, arguments);
  }

  var a = {
    i: [],
    isItem: function(id) {
      return a.i.indexOf(id) > -1
    },
    setItem: function(id) {
      a.i[a.i.length] = id
    },
    getItem: function(id) {
      return a.i.indexOf(id)
    },
    getItemVal: function(index) {
      return a.i[index]
    },
    removeItem: function(id) {
      a.i.splice(a.i.indexOf(id), 1)
    }
  }

  utils.items = a

  utils.getItemInstanceIdAll = function() {
    return a.i
  }

  utils.getItemInstanceId = function(id) {
    if (a.isItem(id)) {
      return a.getItem(id)
    } else {
      a.setItem(id)
      return a.getItem(id)
    }
  }


  mag.utils = utils

}(mag));

@@ -10,11 +10,11 @@
 v0.2
-3.8
+4.9
 %0Ahtt
@@ -161,17 +161,16 @@
 function
- 
 (hookins
@@ -256,16 +256,25 @@
 fore = %7B
+%0A        
 v: data.
@@ -271,32 +271,40 @@
   v: data.value,
+%0A       
  k: data.key%7D%0A  
@@ -299,16 +299,23 @@
 data.key
+%0A      
 %7D%0A      
@@ -410,18 +410,16 @@
 ;%0A      
-  
 //if any
@@ -447,18 +447,28 @@
 ore !== 
- 
 %7B
+%0A          
 v: data.
@@ -473,16 +473,26 @@
 a.value,
+%0A         
  k: data
@@ -495,16 +495,25 @@
 data.key
+%0A        
 %7D) %7B%0A   
@@ -1232,16 +1232,81 @@
 s(index)
+, function() %7B%0A      handlers%5BeventName + '-' + index%5D = 0;%0A    %7D
 );%0A%0A    

Update utils.js