@junobuild/analytics 0.0.29 → 0.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,7 +37,7 @@ ic-request`),yn=class{getPrincipal(){return de.anonymous()}async transformReques
37
37
  `)}case nr.Done:throw new Error(`Call was marked as done but we never saw the reply:
38
38
  Request ID: ${Me(r)}
39
39
  `)}throw new Error("unreachable")}yt();lt();Bn();var tl=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=i,o=t.Record({network:e}),a=t.Nat64,c=t.Vec(a),l=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),h=t.Vec(t.Nat8),d=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),w=t.Record({height:t.Nat32,value:i,outpoint:d}),b=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:h,utxos:t.Vec(w)}),f=t.Record({transaction:t.Vec(t.Nat8),network:e}),S=t.Principal,R=t.Record({canister_id:S,num_requested_changes:t.Opt(t.Nat64)}),O=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),V=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),q=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:O,details:V}),Y=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(q),total_num_changes:t.Nat64}),E=t.Record({canister_id:S}),H=t.Variant({controllers:t.Null,public:t.Null}),z=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:H,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),Z=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:z,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),C=t.Record({canister_id:S}),ie=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(H),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),re=t.Record({settings:t.Opt(ie),sender_canister_version:t.Opt(t.Nat64)}),ee=t.Record({canister_id:S}),g=t.Record({canister_id:S}),B=t.Record({canister_id:S}),$=t.Variant({secp256k1:t.Null}),F=t.Record({key_id:t.Record({name:t.Text,curve:$}),canister_id:t.Opt(S),derivation_path:t.Vec(t.Vec(t.Nat8))}),U=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),G=t.Record({canister_id:S}),J=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),fe=t.Record({canister_log_records:t.Vec(J)}),ce=t.Record({value:t.Text,name:t.Text}),W=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(ce)}),P=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:W})],[W],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(ce)}),m=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),L=t.Record({hash:t.Vec(t.Nat8)}),te=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:m,chunk_hashes_list:t.Vec(L),target_canister:S,store_canister:t.Opt(S),sender_canister_version:t.Opt(t.Nat64)}),le=t.Vec(t.Nat8),D=t.Record({arg:t.Vec(t.Nat8),wasm_module:le,mode:m,canister_id:S,sender_canister_version:t.Opt(t.Nat64)}),u=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),p=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),y=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(p)})),T=t.Record({settings:t.Opt(ie),specified_id:t.Opt(S),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),v=t.Record({canister_id:S}),A=t.Record({canister_id:S,amount:t.Nat}),M=t.Vec(t.Nat8),x=t.Variant({ed25519:t.Null,bip340secp256k1:t.Null}),N=t.Record({key_id:t.Record({algorithm:x,name:t.Text}),canister_id:t.Opt(S),derivation_path:t.Vec(t.Vec(t.Nat8))}),k=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),I=t.Record({key_id:t.Record({name:t.Text,curve:$}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),K=t.Record({signature:t.Vec(t.Nat8)}),Q=t.Record({key_id:t.Record({algorithm:x,name:t.Text}),derivation_path:t.Vec(t.Vec(t.Nat8)),message:t.Vec(t.Nat8)}),oe=t.Record({signature:t.Vec(t.Nat8)}),ye=t.Record({canister_id:S}),ve=t.Record({canister_id:S}),Se=t.Record({canister_id:S}),me=t.Vec(L),ae=t.Record({canister_id:S,sender_canister_version:t.Opt(t.Nat64)}),ke=t.Record({canister_id:t.Principal,settings:ie,sender_canister_version:t.Opt(t.Nat64)}),Gt=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),ir=L;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_current_fee_percentiles:t.Func([o],[c],[]),bitcoin_get_utxos:t.Func([l],[b],[]),bitcoin_send_transaction:t.Func([f],[],[]),canister_info:t.Func([R],[Y],[]),canister_status:t.Func([E],[Z],[]),clear_chunk_store:t.Func([C],[],[]),create_canister:t.Func([re],[ee],[]),delete_canister:t.Func([g],[],[]),deposit_cycles:t.Func([B],[],[]),ecdsa_public_key:t.Func([F],[U],[]),fetch_canister_logs:t.Func([G],[fe],["query"]),http_request:t.Func([P],[W],[]),install_chunked_code:t.Func([te],[],[]),install_code:t.Func([D],[],[]),node_metrics_history:t.Func([u],[y],[]),provisional_create_canister_with_cycles:t.Func([T],[v],[]),provisional_top_up_canister:t.Func([A],[],[]),raw_rand:t.Func([],[M],[]),schnorr_public_key:t.Func([N],[k],[]),sign_with_ecdsa:t.Func([I],[K],[]),sign_with_schnorr:t.Func([Q],[oe],[]),start_canister:t.Func([ye],[],[]),stop_canister:t.Func([ve],[],[]),stored_chunks:t.Func([Se],[me],[]),uninstall_code:t.Func([ae],[],[]),update_settings:t.Func([ke],[],[]),upload_chunk:t.Func([Gt],[ir],[])})};var co=class extends Pe{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
40
- `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},pc=class extends co{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Cn[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},uo=class extends co{constructor(e,r,n,i,s,o,a){super(e,r,"update",Object.assign({"Request ID":Me(n)},i.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(s),"Reject message":o}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=o,this.error_code=a}},St=Symbol.for("ic-agent-metadata"),Dr=class t{constructor(e){this[St]=Object.freeze(e)}static agentOf(e){return e[St].config.agent}static interfaceOf(e){return e[St].service}static canisterIdOf(e){return de.from(e[St].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?de.fromText(r.canisterId):r.canisterId;await rl(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await rl(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:vr});class i extends t{constructor(o){if(!o.canisterId)throw new Pe(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?de.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},il),o),{canisterId:a}),service:n});for(let[c,l]of n._fields)r?.httpDetails&&l.annotations.push(mc),r?.certificate&&l.annotations.push(sl),this[c]=zm(this,c,l,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Pe(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};function On(t,e){let r=vr.decode(t,nl.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var il={pollingStrategyFactory:ao.defaultStrategy},mc="http-details",sl="certificate";function zm(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=t[St].config).queryTransform)===null||l===void 0?void 0:l.call(c,e,a,Object.assign(Object.assign({},t[St].config),o)));let h=o.agent||t[St].config.agent||hc(),d=de.from(o.canisterId||t[St].config.canisterId),w=vr.encode(r.argTypes,a),b=await h.query(d,{methodName:e,arg:w,effectiveCanisterId:o.effectiveCanisterId}),f=Object.assign(Object.assign({},b.httpDetails),{requestDetails:b.requestDetails});switch(b.status){case"rejected":throw new pc(d,e,b);case"replied":return r.annotations.includes(mc)?{httpDetails:f,result:On(r.retTypes,b.reply.arg)}:On(r.retTypes,b.reply.arg)}}:i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=t[St].config).callTransform)===null||l===void 0?void 0:l.call(c,e,a,Object.assign(Object.assign({},t[St].config),o)));let h=o.agent||t[St].config.agent||hc(),{canisterId:d,effectiveCanisterId:w,pollingStrategyFactory:b}=Object.assign(Object.assign(Object.assign({},il),t[St].config),o),f=de.from(d),S=w!==void 0?de.from(w):f,R=vr.encode(r.argTypes,a);if(h.rootKey==null)throw new Pe("Agent root key not initialized before making call");let{requestId:O,response:V,requestDetails:q}=await h.call(f,{methodName:e,arg:R,effectiveCanisterId:S}),Y,E;if(V.body&&V.body.certificate){let C=V.body.certificate;E=await Ur.create({certificate:Vn(C),rootKey:h.rootKey,canisterId:de.from(d),blsVerify:n});let ie=[new TextEncoder().encode("request_status"),O];switch(new TextDecoder().decode(ot(E.lookup([...ie,"status"])))){case"replied":Y=ot(E.lookup([...ie,"reply"]));break;case"rejected":{let ee=new Uint8Array(ot(E.lookup([...ie,"reject_code"])))[0],g=new TextDecoder().decode(ot(E.lookup([...ie,"reject_message"]))),B=ot(E.lookup([...ie,"error_code"])),$=B?new TextDecoder().decode(B):void 0;throw new uo(f,e,O,V,ee,g,$)}}}else if(V.body&&"reject_message"in V.body){let{reject_code:C,reject_message:ie,error_code:re}=V.body;throw new uo(f,e,O,V,C,ie,re)}if(V.status===202){let C=b(),ie=await dc(h,S,O,C,n);E=ie.certificate,Y=ie.reply}let H=r.annotations.includes(mc),z=r.annotations.includes(sl),Z=Object.assign(Object.assign({},V),{requestDetails:q});if(Y!==void 0)return H&&z?{httpDetails:Z,certificate:E,result:On(r.retTypes,Y)}:z?{certificate:E,result:On(r.retTypes,Y)}:H?{httpDetails:Z,result:On(r.retTypes,Y)}:On(r.retTypes,Y);if(r.retTypes.length===0)return H?{httpDetails:V,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...a)=>i(o,...a),s}function rl(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:de.from(t.effectiveCanisterId)};let i=n[0],s=de.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=de.from(i.canister_id)),{effectiveCanisterId:s}}return Dr.createActor(tl,Object.assign(Object.assign(Object.assign({},t),{canisterId:de.fromHex("")}),{callTransform:e,queryTransform:e}))}li();_s();ti();da();Bn();oc();yt();hi();lc();ac();Qn();Ja();lt();va();hi();Dn();var ol=async({orbiterId:t,idlFactory:e,container:r})=>{let n=wr(r)&&r!==!1,i=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io",s=await xi.create({identity:new yn,host:i,shouldFetchRootKey:n});return Dr.createActor(e,{agent:s,canisterId:t})};var fo=async t=>ol({idlFactory:Vc,...t});function _i(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Ei(t,e){let r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);let n=_i(r);return(i,s)=>n.then(o=>s(o.transaction(e,i).objectStore(e)))}var yc;function al(){return yc||(yc=Ei("keyval-store","keyval")),yc}function lo(t,e=al()){return e("readwrite",r=>(t.forEach(n=>r.delete(n)),_i(r.transaction)))}function Km(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},_i(t.transaction)}function ho(t=al()){return t("readonly",e=>{if(e.getAll&&e.getAllKeys)return Promise.all([_i(e.getAllKeys()),_i(e.getAll())]).then(([n,i])=>n.map((s,o)=>[s,i[o]]));let r=[];return t("readonly",n=>Km(n,i=>r.push([i.key,i.value])).then(()=>r))})}var cl=Ei("juno-views","views"),ul=Ei("juno-events","events"),fl=Ei("juno-metrics","metrics");var ll=()=>ho(cl),hl=t=>lo(t,cl);var dl=()=>ho(ul),pl=t=>lo(t,ul);var ml=()=>ho(fl),yl=t=>lo(t,fl);onmessage=async({data:t})=>{let{msg:e,data:r}=t;switch(e){case"junoInitEnvironment":await Xm(r);return;case"junoTrackPageView":t1();return;case"junoTrackEvent":r1();return;case"junoStartTrackTimer":await Qm();return;case"junoStopTracker":await Jm();return}};var Wm="Analytics worker not initialized. Did you set `satelliteId`?",Zm="Analytics worker not initialized. Did you set `orbiterId`?",mt,Xm=async t=>{let{orbiterId:e,satelliteId:r}=t;_o(e,Zm),_o(r,Wm),mt=t},vi,xc=async()=>await Promise.all([gl(),wl(),e1()]),Jm=async()=>{await xc(),wr(vi)&&(clearInterval(vi),vi=void 0),self.close()},Qm=async()=>{wr(vi)||(await xc(),vi=setInterval(xc,mt?.worker?.timerInterval??1e3))},gc=!1,wc=!1,bc=!1,gl=async()=>{if(!Bi(mt)||gc)return;let t=await ll();if(!($r(t)||t.length===0)){gc=!0;try{let r=await(await fo(mt)).set_page_views(t.map(([n,{collected_at:i,...s}])=>[_c({key:n,collected_at:i}),{...s,...Ec(mt)}]));await hl(t.map(([n,i])=>n)),vc(r)}catch(e){console.error(e)}gc=!1}},Lm=xo(async()=>await gl(),100),wl=async()=>{if(!Bi(mt)||wc)return;let t=await dl();if(!($r(t)||t.length===0)){wc=!0;try{let e=await fo(mt),r=({metadata:i,...s})=>({metadata:$r(i)?[]:[Object.entries(i??{})],...s,...Ec(mt)}),n=await e.set_track_events(t.map(([i,{collected_at:s,...o}])=>[_c({key:i,collected_at:s}),r(o)]));await pl(t.map(([i,s])=>i)),vc(n)}catch(e){console.error(e)}wc=!1}},Dm=xo(async()=>await wl(),250),e1=async()=>{if(!Bi(mt)||mt?.options?.performance===!1||bc)return;let t=await ml();if(!($r(t)||t.length===0)){bc=!0;try{let r=await(await fo(mt)).set_performance_metrics(t.map(([n,{collected_at:i,...s}])=>[_c({key:n,collected_at:i}),{...s,...Ec(mt)}]));await yl(t.map(([n,i])=>n)),vc(r)}catch(e){console.error(e)}bc=!1}},t1=()=>{Bi(mt)&&(bl()||Lm())},r1=()=>{Bi(mt)&&(bl()||Dm())},_c=({key:t,collected_at:e})=>({collected_at:e,key:t}),Ec=t=>({satellite_id:de.fromText(t.satelliteId)}),bl=()=>{let{userAgent:t}=navigator;return wr(t)?$c(t):!1},Bi=t=>t!=null&&wr(t.orbiterId)&&wr(t.satelliteId),vc=t=>{"Ok"in t||t.Err.forEach(([e,r])=>console.warn(`${r} [Key: ${e.key}]`))};})();
40
+ `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},pc=class extends co{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Cn[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},uo=class extends co{constructor(e,r,n,i,s,o,a){super(e,r,"update",Object.assign({"Request ID":Me(n)},i.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(s),"Reject message":o}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=o,this.error_code=a}},St=Symbol.for("ic-agent-metadata"),Dr=class t{constructor(e){this[St]=Object.freeze(e)}static agentOf(e){return e[St].config.agent}static interfaceOf(e){return e[St].service}static canisterIdOf(e){return de.from(e[St].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?de.fromText(r.canisterId):r.canisterId;await rl(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await rl(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:vr});class i extends t{constructor(o){if(!o.canisterId)throw new Pe(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?de.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},il),o),{canisterId:a}),service:n});for(let[c,l]of n._fields)r?.httpDetails&&l.annotations.push(mc),r?.certificate&&l.annotations.push(sl),this[c]=zm(this,c,l,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Pe(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};function On(t,e){let r=vr.decode(t,nl.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var il={pollingStrategyFactory:ao.defaultStrategy},mc="http-details",sl="certificate";function zm(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=t[St].config).queryTransform)===null||l===void 0?void 0:l.call(c,e,a,Object.assign(Object.assign({},t[St].config),o)));let h=o.agent||t[St].config.agent||hc(),d=de.from(o.canisterId||t[St].config.canisterId),w=vr.encode(r.argTypes,a),b=await h.query(d,{methodName:e,arg:w,effectiveCanisterId:o.effectiveCanisterId}),f=Object.assign(Object.assign({},b.httpDetails),{requestDetails:b.requestDetails});switch(b.status){case"rejected":throw new pc(d,e,b);case"replied":return r.annotations.includes(mc)?{httpDetails:f,result:On(r.retTypes,b.reply.arg)}:On(r.retTypes,b.reply.arg)}}:i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=t[St].config).callTransform)===null||l===void 0?void 0:l.call(c,e,a,Object.assign(Object.assign({},t[St].config),o)));let h=o.agent||t[St].config.agent||hc(),{canisterId:d,effectiveCanisterId:w,pollingStrategyFactory:b}=Object.assign(Object.assign(Object.assign({},il),t[St].config),o),f=de.from(d),S=w!==void 0?de.from(w):f,R=vr.encode(r.argTypes,a);if(h.rootKey==null)throw new Pe("Agent root key not initialized before making call");let{requestId:O,response:V,requestDetails:q}=await h.call(f,{methodName:e,arg:R,effectiveCanisterId:S}),Y,E;if(V.body&&V.body.certificate){let C=V.body.certificate;E=await Ur.create({certificate:Vn(C),rootKey:h.rootKey,canisterId:de.from(d),blsVerify:n});let ie=[new TextEncoder().encode("request_status"),O];switch(new TextDecoder().decode(ot(E.lookup([...ie,"status"])))){case"replied":Y=ot(E.lookup([...ie,"reply"]));break;case"rejected":{let ee=new Uint8Array(ot(E.lookup([...ie,"reject_code"])))[0],g=new TextDecoder().decode(ot(E.lookup([...ie,"reject_message"]))),B=ot(E.lookup([...ie,"error_code"])),$=B?new TextDecoder().decode(B):void 0;throw new uo(f,e,O,V,ee,g,$)}}}else if(V.body&&"reject_message"in V.body){let{reject_code:C,reject_message:ie,error_code:re}=V.body;throw new uo(f,e,O,V,C,ie,re)}if(V.status===202){let C=b(),ie=await dc(h,S,O,C,n);E=ie.certificate,Y=ie.reply}let H=r.annotations.includes(mc),z=r.annotations.includes(sl),Z=Object.assign(Object.assign({},V),{requestDetails:q});if(Y!==void 0)return H&&z?{httpDetails:Z,certificate:E,result:On(r.retTypes,Y)}:z?{certificate:E,result:On(r.retTypes,Y)}:H?{httpDetails:Z,result:On(r.retTypes,Y)}:On(r.retTypes,Y);if(r.retTypes.length===0)return H?{httpDetails:V,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...a)=>i(o,...a),s}function rl(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:de.from(t.effectiveCanisterId)};let i=n[0],s=de.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=de.from(i.canister_id)),{effectiveCanisterId:s}}return Dr.createActor(tl,Object.assign(Object.assign(Object.assign({},t),{canisterId:de.fromHex("")}),{callTransform:e,queryTransform:e}))}li();_s();ti();da();Bn();oc();yt();hi();lc();ac();Qn();Ja();lt();va();hi();Dn();var ol=async({orbiterId:t,idlFactory:e,container:r})=>{let n=wr(r)&&r!==!1,i=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io",s=await xi.create({identity:new yn,host:i,shouldFetchRootKey:n});return Dr.createActor(e,{agent:s,canisterId:t})};var fo=t=>ol({idlFactory:Vc,...t});function _i(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Ei(t,e){let r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);let n=_i(r);return(i,s)=>n.then(o=>s(o.transaction(e,i).objectStore(e)))}var yc;function al(){return yc||(yc=Ei("keyval-store","keyval")),yc}function lo(t,e=al()){return e("readwrite",r=>(t.forEach(n=>r.delete(n)),_i(r.transaction)))}function Km(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},_i(t.transaction)}function ho(t=al()){return t("readonly",e=>{if(e.getAll&&e.getAllKeys)return Promise.all([_i(e.getAllKeys()),_i(e.getAll())]).then(([n,i])=>n.map((s,o)=>[s,i[o]]));let r=[];return t("readonly",n=>Km(n,i=>r.push([i.key,i.value])).then(()=>r))})}var cl=Ei("juno-views","views"),ul=Ei("juno-events","events"),fl=Ei("juno-metrics","metrics");var ll=()=>ho(cl),hl=t=>lo(t,cl);var dl=()=>ho(ul),pl=t=>lo(t,ul);var ml=()=>ho(fl),yl=t=>lo(t,fl);onmessage=async({data:t})=>{let{msg:e,data:r}=t;switch(e){case"junoInitEnvironment":Xm(r);return;case"junoTrackPageView":t1();return;case"junoTrackEvent":r1();return;case"junoStartTrackTimer":await Qm();return;case"junoStopTracker":await Jm();return}};var Wm="Analytics worker not initialized. Did you set `satelliteId`?",Zm="Analytics worker not initialized. Did you set `orbiterId`?",mt,Xm=t=>{let{orbiterId:e,satelliteId:r}=t;_o(e,Zm),_o(r,Wm),mt=t},vi,xc=async()=>await Promise.all([gl(),wl(),e1()]),Jm=async()=>{await xc(),wr(vi)&&(clearInterval(vi),vi=void 0),self.close()},Qm=async()=>{wr(vi)||(await xc(),vi=setInterval(xc,mt?.worker?.timerInterval??1e3))},gc=!1,wc=!1,bc=!1,gl=async()=>{if(!Bi(mt)||gc)return;let t=await ll();if(!($r(t)||t.length===0)){gc=!0;try{let r=await(await fo(mt)).set_page_views(t.map(([n,{collected_at:i,...s}])=>[_c({key:n,collected_at:i}),{...s,...Ec(mt)}]));await hl(t.map(([n,i])=>n)),vc(r)}catch(e){console.error(e)}gc=!1}},Lm=xo(async()=>await gl(),100),wl=async()=>{if(!Bi(mt)||wc)return;let t=await dl();if(!($r(t)||t.length===0)){wc=!0;try{let e=await fo(mt),r=({metadata:i,...s})=>({metadata:$r(i)?[]:[Object.entries(i??{})],...s,...Ec(mt)}),n=await e.set_track_events(t.map(([i,{collected_at:s,...o}])=>[_c({key:i,collected_at:s}),r(o)]));await pl(t.map(([i,s])=>i)),vc(n)}catch(e){console.error(e)}wc=!1}},Dm=xo(async()=>await wl(),250),e1=async()=>{if(!Bi(mt)||mt?.options?.performance===!1||bc)return;let t=await ml();if(!($r(t)||t.length===0)){bc=!0;try{let r=await(await fo(mt)).set_performance_metrics(t.map(([n,{collected_at:i,...s}])=>[_c({key:n,collected_at:i}),{...s,...Ec(mt)}]));await yl(t.map(([n,i])=>n)),vc(r)}catch(e){console.error(e)}bc=!1}},t1=()=>{Bi(mt)&&(bl()||Lm())},r1=()=>{Bi(mt)&&(bl()||Dm())},_c=({key:t,collected_at:e})=>({collected_at:e,key:t}),Ec=t=>({satellite_id:de.fromText(t.satelliteId)}),bl=()=>{let{userAgent:t}=navigator;return wr(t)?$c(t):!1},Bi=t=>t!=null&&wr(t.orbiterId)&&wr(t.satelliteId),vc=t=>{"Ok"in t||t.Err.forEach(([e,r])=>console.warn(`${r} [Key: ${e.key}]`))};})();
41
41
  /*!
42
42
  * The buffer module from node.js, for the browser.
43
43
  *