// Compiled by ClojureScript 1.9.562 {}
goog.provide('octet.spec.collections');
goog.require('cljs.core');
goog.require('octet.buffer');
goog.require('octet.spec');
/**
 * Create a arbitrary length (dynamic) array like
 *   typespec composition for `t` type.
 */
octet.spec.collections.vector_STAR_ = (function octet$spec$collections$vector_STAR_(t){
if(typeof octet.spec.collections.t_octet$spec$collections34422 !== 'undefined'){
} else {

/**
* @constructor
 * @implements {octet.spec.ISpecDynamicSize}
 * @implements {octet.spec.ISpec}
 * @implements {cljs.core.IMeta}
 * @implements {cljs.core.IWithMeta}
*/
octet.spec.collections.t_octet$spec$collections34422 = (function (t,meta34423){
this.t = t;
this.meta34423 = meta34423;
this.cljs$lang$protocol_mask$partition0$ = 393216;
this.cljs$lang$protocol_mask$partition1$ = 0;
})
octet.spec.collections.t_octet$spec$collections34422.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_34424,meta34423__$1){
var self__ = this;
var _34424__$1 = this;
return (new octet.spec.collections.t_octet$spec$collections34422(self__.t,meta34423__$1));
});

octet.spec.collections.t_octet$spec$collections34422.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_34424){
var self__ = this;
var _34424__$1 = this;
return self__.meta34423;
});

octet.spec.collections.t_octet$spec$collections34422.prototype.octet$spec$ISpecDynamicSize$ = cljs.core.PROTOCOL_SENTINEL;

octet.spec.collections.t_octet$spec$collections34422.prototype.octet$spec$ISpecDynamicSize$size_STAR_$arity$2 = (function (_,data){
var self__ = this;
var ___$1 = this;
return ((4) + cljs.core.reduce.call(null,((function (___$1){
return (function (p1__34413_SHARP_,p2__34414_SHARP_){
return (p1__34413_SHARP_ + ((((!((self__.t == null)))?(((false) || ((cljs.core.PROTOCOL_SENTINEL === self__.t.octet$spec$ISpecDynamicSize$)))?true:(((!self__.t.cljs$lang$protocol_mask$partition$))?cljs.core.native_satisfies_QMARK_.call(null,octet.spec.ISpecDynamicSize,self__.t):false)):cljs.core.native_satisfies_QMARK_.call(null,octet.spec.ISpecDynamicSize,self__.t)))?octet.spec.size_STAR_.call(null,self__.t,p2__34414_SHARP_):octet.spec.size.call(null,self__.t)));
});})(___$1))
,(0),data));
});

octet.spec.collections.t_octet$spec$collections34422.prototype.octet$spec$ISpec$ = cljs.core.PROTOCOL_SENTINEL;

octet.spec.collections.t_octet$spec$collections34422.prototype.octet$spec$ISpec$read$arity$3 = (function (_,buff,pos){
var self__ = this;
var ___$1 = this;
var nitems = octet.buffer.read_int.call(null,buff,pos);
var typespec = octet.spec.repeat.call(null,nitems,self__.t);
var vec__34426 = octet.spec.read.call(null,typespec,buff,(pos + (4)));
var readed = cljs.core.nth.call(null,vec__34426,(0),null);
var data = cljs.core.nth.call(null,vec__34426,(1),null);
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(readed + (4)),data], null);
});

octet.spec.collections.t_octet$spec$collections34422.prototype.octet$spec$ISpec$write$arity$4 = (function (_,buff,pos,input){
var self__ = this;
var ___$1 = this;
var nitems = cljs.core.count.call(null,input);
var typespec = octet.spec.repeat.call(null,nitems,self__.t);
octet.buffer.write_int.call(null,buff,pos,nitems);

return ((4) + octet.spec.write.call(null,typespec,buff,(pos + (4)),input));
});

octet.spec.collections.t_octet$spec$collections34422.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"t","t",242699008,null),new cljs.core.Symbol(null,"meta34423","meta34423",-220912450,null)], null);
});

octet.spec.collections.t_octet$spec$collections34422.cljs$lang$type = true;

octet.spec.collections.t_octet$spec$collections34422.cljs$lang$ctorStr = "octet.spec.collections/t_octet$spec$collections34422";

octet.spec.collections.t_octet$spec$collections34422.cljs$lang$ctorPrWriter = (function (this__23995__auto__,writer__23996__auto__,opt__23997__auto__){
return cljs.core._write.call(null,writer__23996__auto__,"octet.spec.collections/t_octet$spec$collections34422");
});

octet.spec.collections.__GT_t_octet$spec$collections34422 = (function octet$spec$collections$vector_STAR__$___GT_t_octet$spec$collections34422(t__$1,meta34423){
return (new octet.spec.collections.t_octet$spec$collections34422(t__$1,meta34423));
});

}

return (new octet.spec.collections.t_octet$spec$collections34422(t,cljs.core.PersistentArrayMap.EMPTY));
});
