@SuppressWarnings({ "unchecked", "rawtypes"})
    public String require(String id) throws FileNotFoundException{
        String uri = loaded.get(id);
        if(uri != null){
            return uri;
        } else {
            Map<String, Map> map = this.getMap(id);
            Map<String, Map> res = map.get("res");
            Map<String, Object> info = res.get(id);
            if(info == null){
                throw new IllegalArgumentException("missing resource [" + id + "]");
            } else {
                String pkg = (String) info.get("pkg");
                if(!debug && pkg != null){
                    res = map.get("pkg");
                    info = res.get(pkg);
                    uri = (String) info.get("uri");
                    if(info.containsKey("has")){
                        Object[] has = ((JSONArray)info.get("has")).toArray();
                        for(Object obj:has){
                            loaded.put((String) obj, uri);
                        }
                    }
                } else {
                    uri = (String) info.get("uri");
                    loaded.put(id, uri);
                }
                if(info.containsKey("deps")){
                    Object[] deps = ((JSONArray)info.get("deps")).toArray();
                    for(Object dep:deps){
                        this.require((String) dep);
                    }
                }
                String type = (String) info.get("type");
                ArrayList<String> list = collection.get(type);
                if(list == null){
                    list = new ArrayList<String>();
                    collection.put(type, list);
                }
                list.add(uri);
            }
        }
        return uri;
    }