// Compiled by ClojureScript 1.9.562 {}
goog.provide('weathergen.ipc');
goog.require('cljs.core');
goog.require('weathergen.encoding');
weathergen.ipc.electron = require("electron");
weathergen.ipc.channel = "weathergen-ipc";
if(typeof weathergen.ipc.on_message !== 'undefined'){
} else {
weathergen.ipc.on_message = (function (){var method_table__24179__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var prefer_table__24180__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var method_cache__24181__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var cached_hierarchy__24182__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var hierarchy__24183__auto__ = cljs.core.get.call(null,cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"hierarchy","hierarchy",-1053470341),cljs.core.get_global_hierarchy.call(null));
return (new cljs.core.MultiFn(cljs.core.symbol.call(null,"weathergen.ipc","on-message"),((function (method_table__24179__auto__,prefer_table__24180__auto__,method_cache__24181__auto__,cached_hierarchy__24182__auto__,hierarchy__24183__auto__){
return (function() { 
var G__41929__delegate = function (type,event,args){
return type;
};
var G__41929 = function (type,event,var_args){
var args = null;
if (arguments.length > 2) {
var G__41930__i = 0, G__41930__a = new Array(arguments.length -  2);
while (G__41930__i < G__41930__a.length) {G__41930__a[G__41930__i] = arguments[G__41930__i + 2]; ++G__41930__i;}
  args = new cljs.core.IndexedSeq(G__41930__a,0,null);
} 
return G__41929__delegate.call(this,type,event,args);};
G__41929.cljs$lang$maxFixedArity = 2;
G__41929.cljs$lang$applyTo = (function (arglist__41931){
var type = cljs.core.first(arglist__41931);
arglist__41931 = cljs.core.next(arglist__41931);
var event = cljs.core.first(arglist__41931);
var args = cljs.core.rest(arglist__41931);
return G__41929__delegate(type,event,args);
});
G__41929.cljs$core$IFn$_invoke$arity$variadic = G__41929__delegate;
return G__41929;
})()
;})(method_table__24179__auto__,prefer_table__24180__auto__,method_cache__24181__auto__,cached_hierarchy__24182__auto__,hierarchy__24183__auto__))
,new cljs.core.Keyword(null,"default","default",-1987822328),hierarchy__24183__auto__,method_table__24179__auto__,prefer_table__24180__auto__,method_cache__24181__auto__,cached_hierarchy__24182__auto__));
})();
}
/**
 * Sends a message from a renderer process to the main process.
 */
weathergen.ipc.send_to_main = (function weathergen$ipc$send_to_main(var_args){
var args__24376__auto__ = [];
var len__24369__auto___41935 = arguments.length;
var i__24370__auto___41936 = (0);
while(true){
if((i__24370__auto___41936 < len__24369__auto___41935)){
args__24376__auto__.push((arguments[i__24370__auto___41936]));

var G__41937 = (i__24370__auto___41936 + (1));
i__24370__auto___41936 = G__41937;
continue;
} else {
}
break;
}

var argseq__24377__auto__ = ((((1) < args__24376__auto__.length))?(new cljs.core.IndexedSeq(args__24376__auto__.slice((1)),(0),null)):null);
return weathergen.ipc.send_to_main.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__24377__auto__);
});

weathergen.ipc.send_to_main.cljs$core$IFn$_invoke$arity$variadic = (function (type,args){
return cljs.core.apply.call(null,(function (){var G__41934 = weathergen.ipc.electron.ipcRenderer;
return G__41934;
})().send,weathergen.ipc.channel,type,cljs.core.map.call(null,weathergen.encoding.encode,args));
});

weathergen.ipc.send_to_main.cljs$lang$maxFixedArity = (1);

weathergen.ipc.send_to_main.cljs$lang$applyTo = (function (seq41932){
var G__41933 = cljs.core.first.call(null,seq41932);
var seq41932__$1 = cljs.core.next.call(null,seq41932);
return weathergen.ipc.send_to_main.cljs$core$IFn$_invoke$arity$variadic(G__41933,seq41932__$1);
});

/**
 * Sends a message from the main process to a renderer process.
 */
weathergen.ipc.send_to_renderer = (function weathergen$ipc$send_to_renderer(var_args){
var args__24376__auto__ = [];
var len__24369__auto___41941 = arguments.length;
var i__24370__auto___41942 = (0);
while(true){
if((i__24370__auto___41942 < len__24369__auto___41941)){
args__24376__auto__.push((arguments[i__24370__auto___41942]));

var G__41943 = (i__24370__auto___41942 + (1));
i__24370__auto___41942 = G__41943;
continue;
} else {
}
break;
}

var argseq__24377__auto__ = ((((2) < args__24376__auto__.length))?(new cljs.core.IndexedSeq(args__24376__auto__.slice((2)),(0),null)):null);
return weathergen.ipc.send_to_renderer.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__24377__auto__);
});

weathergen.ipc.send_to_renderer.cljs$core$IFn$_invoke$arity$variadic = (function (window,type,args){
var wc = window.webContents;
var send = wc.send;
return send.apply(wc,cljs.core.clj__GT_js.call(null,cljs.core.into.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [weathergen.ipc.channel,type], null),cljs.core.map.call(null,weathergen.encoding.encode,args))));
});

weathergen.ipc.send_to_renderer.cljs$lang$maxFixedArity = (2);

weathergen.ipc.send_to_renderer.cljs$lang$applyTo = (function (seq41938){
var G__41939 = cljs.core.first.call(null,seq41938);
var seq41938__$1 = cljs.core.next.call(null,seq41938);
var G__41940 = cljs.core.first.call(null,seq41938__$1);
var seq41938__$2 = cljs.core.next.call(null,seq41938__$1);
return weathergen.ipc.send_to_renderer.cljs$core$IFn$_invoke$arity$variadic(G__41939,G__41940,seq41938__$2);
});

weathergen.ipc.ipc = ((cljs.core._EQ_.call(null,"renderer",process.type))?weathergen.ipc.electron.ipcRenderer:weathergen.ipc.electron.ipcMain);
weathergen.ipc.ipc.on(weathergen.ipc.channel,(function() { 
var G__41948__delegate = function (event,p__41944){
var vec__41945 = p__41944;
var seq__41946 = cljs.core.seq.call(null,vec__41945);
var first__41947 = cljs.core.first.call(null,seq__41946);
var seq__41946__$1 = cljs.core.next.call(null,seq__41946);
var type = first__41947;
var args = seq__41946__$1;
return cljs.core.apply.call(null,weathergen.ipc.on_message,type,event,cljs.core.map.call(null,weathergen.encoding.decode,args));
};
var G__41948 = function (event,var_args){
var p__41944 = null;
if (arguments.length > 1) {
var G__41949__i = 0, G__41949__a = new Array(arguments.length -  1);
while (G__41949__i < G__41949__a.length) {G__41949__a[G__41949__i] = arguments[G__41949__i + 1]; ++G__41949__i;}
  p__41944 = new cljs.core.IndexedSeq(G__41949__a,0,null);
} 
return G__41948__delegate.call(this,event,p__41944);};
G__41948.cljs$lang$maxFixedArity = 1;
G__41948.cljs$lang$applyTo = (function (arglist__41950){
var event = cljs.core.first(arglist__41950);
var p__41944 = cljs.core.rest(arglist__41950);
return G__41948__delegate(event,p__41944);
});
G__41948.cljs$core$IFn$_invoke$arity$variadic = G__41948__delegate;
return G__41948;
})()
);
