 `import Save from '../models/save'`
+
+utf8_to_b64 = (str) ->
+    btoa encodeURIComponent escape str
+
+b64_to_utf8 = (str) ->
+    unescape decodeURIComponent atob str
 
 guid = (->
     s4 = ->

        s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4()
)()

getKey = (type, id) ->
    if typeof id is 'object'
        id = id.get 'id'

    type.typeKey + "#" + id

Promise = Ember.RSVP.Promise


        record.set 'id', guid()
        serializer = store.serializerFor type.typeKey

        key = getKey record
        data = serializer.serialize record

        localStorage.setItem key, utf8_to_b64 JSON.stringify data
        resolve()

    updateRecord: (store, type, record) -> new Promise (resolve) ->
        serializer = store.serializerFor type.typeKey

        key = getKey record
        data = serializer.serialize record

        localStorage.setItem key, utf8_to_b64 JSON.stringify data
        resolve()

    deleteRecord: (store, type, record) ->
