(()=>{var vi=Object.create;var et=Object.defineProperty,bi=Object.defineProperties,wi=Object.getOwnPropertyDescriptor,yi=Object.getOwnPropertyDescriptors,Ai=Object.getOwnPropertyNames,xe=Object.getOwnPropertySymbols,Si=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty,kt=Object.prototype.propertyIsEnumerable;var St=(e,t,i)=>t in e?et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,U=(e,t)=>{for(var i in t||(t={}))tt.call(t,i)&&St(e,i,t[i]);if(xe)for(var i of xe(t))kt.call(t,i)&&St(e,i,t[i]);return e},Et=(e,t)=>bi(e,yi(t));var Ct=(e,t)=>{var i={};for(var s in e)tt.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(e!=null&&xe)for(var s of xe(e))t.indexOf(s)<0&&kt.call(e,s)&&(i[s]=e[s]);return i};var ki=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ei=(e,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ai(t))!tt.call(e,n)&&n!==i&&et(e,n,{get:()=>t[n],enumerable:!(s=wi(t,n))||s.enumerable});return e};var Ci=(e,t,i)=>(i=e!=null?vi(Si(e)):{},Ei(t||!e||!e.__esModule?et(i,"default",{value:e,enumerable:!0}):i,e));var ui=ki((ci,Ke)=>{(function(e,t){"use strict";(function(){for(var f=0,m=["ms","moz","webkit","o"],v=0;vp.show(),f)}else n=!0,o!==null&&e.cancelAnimationFrame(o),i||g(),i.style.opacity=1,i.style.display="block",p.progress(0),h.autoRun&&function m(){r=e.requestAnimationFrame(m),p.progress("+"+.05*Math.pow(1-Math.sqrt(s),2))}()},progress:function(f){return typeof f=="undefined"||(typeof f=="string"&&(f=(f.indexOf("+")>=0||f.indexOf("-")>=0?s:0)+parseFloat(f)),s=f>1?1:f,c()),s},hide:function(){clearTimeout(a),a=null,n&&(n=!1,r!=null&&(e.cancelAnimationFrame(r),r=null),function f(){if(p.progress("+.1")>=1&&(i.style.opacity-=.05,i.style.opacity<=.05)){i.style.display="none",o=null;return}o=e.requestAnimationFrame(f)}())}};typeof Ke=="object"&&typeof Ke.exports=="object"?Ke.exports=p:typeof define=="function"&&define.amd?define(function(){return p}):this.topbar=p}).call(ci,window,document)});(function(){var e=t();function t(){if(typeof window.CustomEvent=="function")return window.CustomEvent;function n(r,o){o=o||{bubbles:!1,cancelable:!1,detail:void 0};var a=document.createEvent("CustomEvent");return a.initCustomEvent(r,o.bubbles,o.cancelable,o.detail),a}return n.prototype=window.Event.prototype,n}function i(n,r){var o=document.createElement("input");return o.type="hidden",o.name=n,o.value=r,o}function s(n,r){var o=n.getAttribute("data-to"),a=i("_method",n.getAttribute("data-method")),l=i("_csrf_token",n.getAttribute("data-csrf")),h=document.createElement("form"),c=document.createElement("input"),g=n.getAttribute("target");h.method=n.getAttribute("data-method")==="get"?"get":"post",h.action=o,h.style.display="none",g?h.target=g:r&&(h.target="_blank"),h.appendChild(l),h.appendChild(a),document.body.appendChild(h),c.type="submit",h.appendChild(c),c.click()}window.addEventListener("click",function(n){var r=n.target;if(!n.defaultPrevented)for(;r&&r.getAttribute;){var o=new e("phoenix.link.click",{bubbles:!0,cancelable:!0});if(!r.dispatchEvent(o))return n.preventDefault(),n.stopImmediatePropagation(),!1;if(r.getAttribute("data-method"))return s(r,n.metaKey||n.shiftKey),n.preventDefault(),!1;r=r.parentNode}},!1),window.addEventListener("phoenix.link.click",function(n){var r=n.target.getAttribute("data-confirm");r&&!window.confirm(r)&&n.preventDefault()},!1)})();var be=e=>typeof e=="function"?e:function(){return e},Ti=typeof self!="undefined"?self:null,ve=typeof window!="undefined"?window:null,oe=Ti||ve||oe,_i="2.0.0",j={connecting:0,open:1,closing:2,closed:3},Ri=1e4,Pi=1e3,F={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},W={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},it={longpoll:"longpoll",websocket:"websocket"},xi={complete:4},Le=class{constructor(e,t,i,s){this.channel=e,this.event=t,this.payload=i||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(e){this.timeout=e,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:e,response:t,_ref:i}){this.recHooks.filter(s=>s.status===e).forEach(s=>s.callback(t))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}},Tt=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=null,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},Li=class{constructor(e,t,i){this.state=F.closed,this.topic=e,this.params=be(t||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Le(this,W.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new Tt(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=F.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=F.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=F.closed,this.socket.remove(this)}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=F.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic} (${this.joinRef()})`,this.joinPush.timeout),new Le(this,W.leave,be({}),this.timeout).send(),this.state=F.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(W.reply,(s,n)=>{this.trigger(this.replyEventName(n),s)})}join(e=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(e){this.on(W.close,e)}onError(e){return this.on(W.error,t=>e(t))}on(e,t){let i=this.bindingRef++;return this.bindings.push({event:e,ref:i,callback:t}),i}off(e,t){this.bindings=this.bindings.filter(i=>!(i.event===e&&(typeof t=="undefined"||t===i.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,i=this.timeout){if(t=t||{},!this.joinedOnce)throw new Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new Le(this,e,function(){return t},i);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=F.leaving;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(W.close,"leave")},i=new Le(this,W.leave,be({}),e);return i.receive("ok",()=>t()).receive("timeout",()=>t()),i.send(),this.canPush()||i.trigger("ok",{}),i}onMessage(e,t,i){return t}isMember(e,t,i,s){return this.topic!==e?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:i,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=F.joining,this.joinPush.resend(e))}trigger(e,t,i,s){let n=this.onMessage(e,t,i,s);if(t&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let r=this.bindings.filter(o=>o.event===e);for(let o=0;o{let a=this.parseJSON(e.responseText);o&&o(a)},r&&(e.ontimeout=r),e.onprogress=()=>{},e.send(s),e}static xhrRequest(e,t,i,s,n,r,o,a){return e.open(t,i,!0),e.timeout=r,e.setRequestHeader("Content-Type",s),e.onerror=()=>a&&a(null),e.onreadystatechange=()=>{if(e.readyState===xi.complete&&a){let l=this.parseJSON(e.responseText);a(l)}},o&&(e.ontimeout=o),e.send(n),e}static parseJSON(e){if(!e||e==="")return null;try{return JSON.parse(e)}catch(t){return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let i=[];for(var s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;let n=t?`${t}[${s}]`:s,r=e[s];typeof r=="object"?i.push(this.serialize(r,n)):i.push(encodeURIComponent(n)+"="+encodeURIComponent(r))}return i.join("&")}static appendParams(e,t){if(Object.keys(t).length===0)return e;let i=e.match(/\?/)?"&":"?";return`${e}${i}${this.serialize(t)}`}},Ii=e=>{let t="",i=new Uint8Array(e),s=i.byteLength;for(let n=0;nthis.poll(),0)}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+it.websocket),"$1/"+it.longpoll)}endpointURL(){return Oe.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,i){this.close(e,t,i),this.readyState=j.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===j.open||this.readyState===j.connecting}poll(){this.ajax("GET","application/json",null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:i,messages:s}=e;this.token=i}else t=0;switch(t){case 200:s.forEach(n=>{setTimeout(()=>this.onmessage({data:n}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=j.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${t}`)}})}send(e){typeof e!="string"&&(e=Ii(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e){this.awaitingBatchAck=!0,this.ajax("POST","application/x-ndjson",e.join(` `),()=>this.onerror("timeout"),t=>{this.awaitingBatchAck=!1,!t||t.status!==200?(this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(e,t,i){for(let n of this.reqs)n.abort();this.readyState=j.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:i});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent!="undefined"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(e,t,i,s,n){let r,o=()=>{this.reqs.delete(r),s()};r=Oe.request(e,this.endpointURL(),t,i,this.timeout,o,a=>{this.reqs.delete(r),this.isActive()&&n(a)}),this.reqs.add(r)}};var Ie={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let i=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(i))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[i,s,n,r,o]=JSON.parse(e);return t({join_ref:i,ref:s,topic:n,event:r,payload:o})}},binaryEncode(e){let{join_ref:t,ref:i,event:s,topic:n,payload:r}=e,o=this.META_LENGTH+t.length+i.length+n.length+s.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),l=new DataView(a),h=0;l.setUint8(h++,this.KINDS.push),l.setUint8(h++,t.length),l.setUint8(h++,i.length),l.setUint8(h++,n.length),l.setUint8(h++,s.length),Array.from(t,g=>l.setUint8(h++,g.charCodeAt(0))),Array.from(i,g=>l.setUint8(h++,g.charCodeAt(0))),Array.from(n,g=>l.setUint8(h++,g.charCodeAt(0))),Array.from(s,g=>l.setUint8(h++,g.charCodeAt(0)));var c=new Uint8Array(a.byteLength+r.byteLength);return c.set(new Uint8Array(a),0),c.set(new Uint8Array(r),a.byteLength),c.buffer},binaryDecode(e){let t=new DataView(e),i=t.getUint8(0),s=new TextDecoder;switch(i){case this.KINDS.push:return this.decodePush(e,t,s);case this.KINDS.reply:return this.decodeReply(e,t,s);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,s)}},decodePush(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=i.decode(e.slice(o,o+s));o=o+s;let l=i.decode(e.slice(o,o+n));o=o+n;let h=i.decode(e.slice(o,o+r));o=o+r;let c=e.slice(o,e.byteLength);return{join_ref:a,ref:null,topic:l,event:h,payload:c}},decodeReply(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),o=t.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,l=i.decode(e.slice(a,a+s));a=a+s;let h=i.decode(e.slice(a,a+n));a=a+n;let c=i.decode(e.slice(a,a+r));a=a+r;let g=i.decode(e.slice(a,a+o));a=a+o;let p=e.slice(a,e.byteLength),f={status:g,response:p};return{join_ref:l,ref:h,topic:c,event:W.reply,payload:f}},decodeBroadcast(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=this.HEADER_LENGTH+2,o=i.decode(e.slice(r,r+s));r=r+s;let a=i.decode(e.slice(r,r+n));r=r+n;let l=e.slice(r,e.byteLength);return{join_ref:null,ref:null,topic:o,event:a,payload:l}}},_t=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=t.timeout||Ri,this.transport=t.transport||oe.WebSocket||ge,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=t.sessionStorage||oe&&oe.sessionStorage,this.establishedConnections=0,this.defaultEncoder=Ie.encode.bind(Ie),this.defaultDecoder=Ie.decode.bind(Ie),this.closeWasClean=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.transport!==ge?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;ve&&ve.addEventListener&&(ve.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock)}),ve.addEventListener("pageshow",s=>{i===this.connectClock&&(i=null,this.connect())})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.rejoinAfterMs=s=>t.rejoinAfterMs?t.rejoinAfterMs(s):[1e3,2e3,5e3][s-1]||1e4,this.reconnectAfterMs=s=>t.reconnectAfterMs?t.reconnectAfterMs(s):[10,50,100,150,200,250,500,1e3,2e3][s-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(s,n,r)=>{console.log(`${s}: ${n}`,r)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=be(t.params||{}),this.endPoint=`${e}/${it.websocket}`,this.vsn=t.vsn||_i,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new Tt(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return ge}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=Oe.appendParams(Oe.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return e.charAt(0)!=="/"?e:e.charAt(1)==="/"?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,i){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(e,t,i)}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=be(e)),!this.conn&&(this.longPollFallbackMs&&this.transport!==ge?this.connectWithFallback(ge,this.longPollFallbackMs):this.transportConnect())}log(e,t,i){this.logger&&this.logger(e,t,i)}hasLogger(){return this.logger!==null}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),i=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let s=this.onMessage(n=>{n.ref===t&&(this.off([s]),e(Date.now()-i))});return!0}transportConnect(){this.connectClock++,this.closeWasClean=!1,this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){clearTimeout(this.fallbackTimer);let i=!1,s=!0,n,r,o=a=>{this.log("transport",`falling back to ${e.name}...`,a),this.off([n,r]),s=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${e.name}`))return o("memorized");this.fallbackTimer=setTimeout(o,t),r=this.onError(a=>{this.log("transport","error",a),s&&!i&&(clearTimeout(this.fallbackTimer),o(a))}),this.onOpen(()=>{if(i=!0,!s)return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${e.name}`,"true"),this.log("transport",`established ${e.name} fallback`);clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(o,t),this.ping(a=>{this.log("transport","connected to primary after",a),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`${this.transport.name} connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,e])=>e())}heartbeatTimeout(){this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.triggerChanError(),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),Pi,"heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,i){if(!this.conn)return e&&e();this.waitForBufferDone(()=>{this.conn&&(t?this.conn.close(t,i||""):this.conn.close()),this.waitForSocketClosed(()=>{this.conn&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e()})})}waitForBufferDone(e,t=1){if(t===5||!this.conn||!this.conn.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(e,t+1)},150*t)}waitForSocketClosed(e,t=1){if(t===5||!this.conn||this.conn.readyState===j.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(e,t+1)},150*t)}onConnClose(e){let t=e&&e.code;this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&t!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,i])=>i(e))}onConnError(e){this.hasLogger()&&this.log("transport",e);let t=this.transport,i=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,s])=>{s(e,t,i)}),(t===this.transport||i>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(W.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case j.connecting:return"connecting";case j.open:return"open";case j.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([i])=>e.indexOf(i)===-1)}channel(e,t={}){let i=new Li(e,t,this);return this.channels.push(i),i}push(e){if(this.hasLogger()){let{topic:t,event:i,payload:s,ref:n,join_ref:r}=e;this.log("push",`${t} ${i} (${r}, ${n})`,s)}this.isConnected()?this.encode(e,t=>this.conn.send(t)):this.sendBuffer.push(()=>this.encode(e,t=>this.conn.send(t)))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){this.pendingHeartbeatRef&&!this.isConnected()||(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs))}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,t=>{let{topic:i,event:s,payload:n,ref:r,join_ref:o}=t;r&&r===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${n.status||""} ${i} ${s} ${r&&"("+r+")"||""}`,n);for(let a=0;ai.topic===e&&(i.isJoined()||i.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave())}};var ei="consecutive-reloads",Oi=10,Di=5e3,Hi=1e4,Fi=3e4,ti=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],K="data-phx-component",st="data-phx-link",Ni="track-static",Mi="data-phx-link-state",N="data-phx-ref",te="data-phx-ref-src",ii="track-uploads",G="data-phx-upload-ref",vt="data-phx-preflighted-refs",$i="data-phx-done-refs",Rt="drop-target",ut="data-phx-active-refs",Je="phx:live-file:updated",si="data-phx-skip",ni="data-phx-id",Pt="data-phx-prune",xt="page-loading",Lt="phx-connected",we="phx-loading",De="phx-no-feedback",He="phx-error",It="phx-client-error",nt="phx-server-error",ae="data-phx-parent-id",bt="data-phx-main",le="data-phx-root-id",ft="viewport-top",pt="viewport-bottom",Ui="trigger-action",qe="feedback-for",Xe="feedback-group",mt="phx-has-focused",ji=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],ri=["checkbox","radio"],We="phx-has-submitted",Y="data-phx-session",me=`[${Y}]`,Ot="data-phx-sticky",fe="data-phx-static",rt="data-phx-readonly",ce="data-phx-disabled",gt="disable-with",Fe="data-phx-disable-with-restore",ye="hook",Bi="debounce",Ji="throttle",ze="update",ot="stream",at="data-phx-stream",Vi="key",B="phxPrivate",Dt="auto-recover",Ne="phx:live-socket:debug",lt="phx:live-socket:profiling",ht="phx:live-socket:latency-sim",qi="progress",Ht="mounted",Xi=1,Wi=200,zi="phx-",Ki=3e4,Ae="debounce-trigger",Se="throttled",Ft="debounce-prev-key",Gi={debounce:300,throttle:300},Me="d",J="s",dt="r",I="c",Nt="e",Mt="r",$t="t",Yi="p",Ut="stream",Qi=class{constructor(e,t,i){this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=t,this.chunkTimer=null,this.errored=!1,this.uploadChannel=i.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),this.entry.error(e))}upload(){this.uploadChannel.onError(e=>this.error(e)),this.uploadChannel.join().receive("ok",e=>this.readNextChunk()).receive("error",e=>this.error(e))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let e=new window.FileReader,t=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=i=>{if(i.target.error===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return M("Read error: "+i.target.error)},e.readAsArrayBuffer(t)}pushChunk(e){this.uploadChannel.isJoined()&&this.uploadChannel.push("chunk",e).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))}).receive("error",({reason:t})=>this.error(t))}},M=(e,t)=>console.error&&console.error(e,t),z=e=>{let t=typeof e;return t==="number"||t==="string"&&/^(0|[1-9]\d*)$/.test(e)};function Zi(){let e=new Set,t=document.querySelectorAll("*[id]");for(let i=0,s=t.length;i{e.liveSocket.isDebugEnabled()&&console.log(`${e.id} ${t}: ${i} - `,s)},ke=e=>typeof e=="function"?e:function(){return e},Ve=e=>JSON.parse(JSON.stringify(e)),_e=(e,t,i)=>{do{if(e.matches(`[${t}]`)&&!e.disabled)return e;e=e.parentElement||e.parentNode}while(e!==null&&e.nodeType===1&&!(i&&i.isSameNode(e)||e.matches(me)));return null},ue=e=>e!==null&&typeof e=="object"&&!(e instanceof Array),ts=(e,t)=>JSON.stringify(e)===JSON.stringify(t),jt=e=>{for(let t in e)return!1;return!0},ie=(e,t)=>e&&t(e),is=function(e,t,i,s){e.forEach(n=>{new Qi(n,i.config.chunk_size,s).upload()})},oi={canPushState(){return typeof history.pushState!="undefined"},dropLocal(e,t,i){return e.removeItem(this.localKey(t,i))},updateLocal(e,t,i,s,n){let r=this.getLocal(e,t,i),o=this.localKey(t,i),a=r===null?s:n(r);return e.setItem(o,JSON.stringify(a)),a},getLocal(e,t,i){return JSON.parse(e.getItem(this.localKey(t,i)))},updateCurrentState(e){this.canPushState()&&history.replaceState(e(history.state||{}),"",window.location.href)},pushState(e,t,i){if(this.canPushState()){if(i!==window.location.href){if(t.type=="redirect"&&t.scroll){let n=history.state||{};n.scroll=t.scroll,history.replaceState(n,"",window.location.href)}delete t.scroll,history[e+"State"](t,"",i||null);let s=this.getHashTargetEl(window.location.hash);s?s.scrollIntoView():t.type==="redirect"&&window.scroll(0,0)}}else this.redirect(i)},setCookie(e,t){document.cookie=`${e}=${t}`},getCookie(e){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${e}s*=s*([^;]*).*$)|^.*$`),"$1")},redirect(e,t){t&&oi.setCookie("__phoenix_flash__",t+"; max-age=60000; path=/"),window.location=e},localKey(e,t){return`${e}-${t}`},getHashTargetEl(e){let t=e.toString().substring(1);if(t!=="")return document.getElementById(t)||document.querySelector(`a[name="${t}"]`)}},V=oi,ss={focusMain(){let e=document.querySelector("main h1, main, h1");if(e){let t=e.tabIndex;e.tabIndex=-1,e.focus(),e.tabIndex=t}},anyOf(e,t){return t.find(i=>e instanceof i)},isFocusable(e,t){return e instanceof HTMLAnchorElement&&e.rel!=="ignore"||e instanceof HTMLAreaElement&&e.href!==void 0||!e.disabled&&this.anyOf(e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||e instanceof HTMLIFrameElement||e.tabIndex>0||!t&&e.getAttribute("tabindex")!==null&&e.getAttribute("aria-hidden")!=="true"},attemptFocus(e,t){if(this.isFocusable(e,t))try{e.focus()}catch(i){}return!!document.activeElement&&document.activeElement.isSameNode(e)},focusFirstInteractive(e){let t=e.firstElementChild;for(;t;){if(this.attemptFocus(t,!0)||this.focusFirstInteractive(t,!0))return!0;t=t.nextElementSibling}},focusFirst(e){let t=e.firstElementChild;for(;t;){if(this.attemptFocus(t)||this.focusFirst(t))return!0;t=t.nextElementSibling}},focusLast(e){let t=e.lastElementChild;for(;t;){if(this.attemptFocus(t)||this.focusLast(t))return!0;t=t.previousElementSibling}}},pe=ss,Bt=[],Jt=200,ns={exec(e,t,i,s,n){let[r,o]=n||[null,{callback:n&&n.callback}];(t.charAt(0)==="["?JSON.parse(t):[[r,o]]).forEach(([l,h])=>{l===r&&o.data&&(h.data=Object.assign(h.data||{},o.data),h.callback=h.callback||o.callback),this.filterToEls(s,h).forEach(c=>{this[`exec_${l}`](e,t,i,s,c,h)})})},isVisible(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length>0)},isInViewport(e){let t=e.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight,s=window.innerWidth||document.documentElement.clientWidth;return t.right>0&&t.bottom>0&&t.left{let h=l.getAttribute(r);if(!h)throw new Error(`expected ${r} to contain JS command on "${o}"`);i.liveSocket.execJS(l,h,e)})},exec_dispatch(e,t,i,s,n,{to:r,event:o,detail:a,bubbles:l}){a=a||{},a.dispatcher=s,d.dispatchEvent(n,o,{detail:a,bubbles:l})},exec_push(e,t,i,s,n,r){let{event:o,data:a,target:l,page_loading:h,loading:c,value:g,dispatcher:p,callback:f}=r,m={loading:c,value:g,target:l,page_loading:!!h},v=e==="change"&&p?p:s,C=l||v.getAttribute(i.binding("target"))||v;i.withinTargets(C,(P,R)=>{if(P.isConnected())if(e==="change"){let{newCid:x,_target:L}=r;L=L||(d.isFormInput(s)?s.name:void 0),L&&(m._target=L),P.pushInput(s,R,x,o||t,m,f)}else if(e==="submit"){let{submitter:x}=r;P.submitForm(s,R,o||t,x,m,f)}else P.pushEvent(e,s,R,o||t,a,m,f)})},exec_navigate(e,t,i,s,n,{href:r,replace:o}){i.liveSocket.historyRedirect(r,o?"replace":"push")},exec_patch(e,t,i,s,n,{href:r,replace:o}){i.liveSocket.pushHistoryPatch(r,o?"replace":"push",s)},exec_focus(e,t,i,s,n){window.requestAnimationFrame(()=>pe.attemptFocus(n))},exec_focus_first(e,t,i,s,n){window.requestAnimationFrame(()=>pe.focusFirstInteractive(n)||pe.focusFirst(n))},exec_push_focus(e,t,i,s,n){window.requestAnimationFrame(()=>Bt.push(n||s))},exec_pop_focus(e,t,i,s,n){window.requestAnimationFrame(()=>{let r=Bt.pop();r&&r.focus()})},exec_add_class(e,t,i,s,n,{names:r,transition:o,time:a}){this.addOrRemoveClasses(n,r,[],o,a,i)},exec_remove_class(e,t,i,s,n,{names:r,transition:o,time:a}){this.addOrRemoveClasses(n,[],r,o,a,i)},exec_toggle_class(e,t,i,s,n,{to:r,names:o,transition:a,time:l}){this.toggleClasses(n,o,a,l,i)},exec_toggle_attr(e,t,i,s,n,{attr:[r,o,a]}){n.hasAttribute(r)?a!==void 0?n.getAttribute(r)===o?this.setOrRemoveAttrs(n,[[r,a]],[]):this.setOrRemoveAttrs(n,[[r,o]],[]):this.setOrRemoveAttrs(n,[],[r]):this.setOrRemoveAttrs(n,[[r,o]],[])},exec_transition(e,t,i,s,n,{time:r,transition:o}){this.addOrRemoveClasses(n,[],[],o,r,i)},exec_toggle(e,t,i,s,n,{display:r,ins:o,outs:a,time:l}){this.toggle(e,i,n,r,o,a,l)},exec_show(e,t,i,s,n,{display:r,transition:o,time:a}){this.show(e,i,n,r,o,a)},exec_hide(e,t,i,s,n,{display:r,transition:o,time:a}){this.hide(e,i,n,r,o,a)},exec_set_attr(e,t,i,s,n,{attr:[r,o]}){this.setOrRemoveAttrs(n,[[r,o]],[])},exec_remove_attr(e,t,i,s,n,{attr:r}){this.setOrRemoveAttrs(n,[],[r])},show(e,t,i,s,n,r){this.isVisible(i)||this.toggle(e,t,i,s,n,null,r)},hide(e,t,i,s,n,r){this.isVisible(i)&&this.toggle(e,t,i,s,null,n,r)},toggle(e,t,i,s,n,r,o){o=o||Jt;let[a,l,h]=n||[[],[],[]],[c,g,p]=r||[[],[],[]];if(a.length>0||c.length>0)if(this.isVisible(i)){let f=()=>{this.addOrRemoveClasses(i,g,a.concat(l).concat(h)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,c,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,p,g))})};i.dispatchEvent(new Event("phx:hide-start")),t.transition(o,f,()=>{this.addOrRemoveClasses(i,[],c.concat(p)),d.putSticky(i,"toggle",m=>m.style.display="none"),i.dispatchEvent(new Event("phx:hide-end"))})}else{if(e==="remove")return;let f=()=>{this.addOrRemoveClasses(i,l,c.concat(g).concat(p));let m=s||this.defaultDisplay(i);d.putSticky(i,"toggle",v=>v.style.display=m),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,h,l))})};i.dispatchEvent(new Event("phx:show-start")),t.transition(o,f,()=>{this.addOrRemoveClasses(i,[],a.concat(h)),i.dispatchEvent(new Event("phx:show-end"))})}else this.isVisible(i)?window.requestAnimationFrame(()=>{i.dispatchEvent(new Event("phx:hide-start")),d.putSticky(i,"toggle",f=>f.style.display="none"),i.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{i.dispatchEvent(new Event("phx:show-start"));let f=s||this.defaultDisplay(i);d.putSticky(i,"toggle",m=>m.style.display=f),i.dispatchEvent(new Event("phx:show-end"))})},toggleClasses(e,t,i,s,n){window.requestAnimationFrame(()=>{let[r,o]=d.getSticky(e,"classes",[[],[]]),a=t.filter(h=>r.indexOf(h)<0&&!e.classList.contains(h)),l=t.filter(h=>o.indexOf(h)<0&&e.classList.contains(h));this.addOrRemoveClasses(e,a,l,i,s,n)})},addOrRemoveClasses(e,t,i,s,n,r){n=n||Jt;let[o,a,l]=s||[[],[],[]];if(o.length>0){let h=()=>{this.addOrRemoveClasses(e,a,[].concat(o).concat(l)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(e,o,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(e,l,a))})},c=()=>this.addOrRemoveClasses(e,t.concat(l),i.concat(o).concat(a));return r.transition(n,h,c)}window.requestAnimationFrame(()=>{let[h,c]=d.getSticky(e,"classes",[[],[]]),g=t.filter(v=>h.indexOf(v)<0&&!e.classList.contains(v)),p=i.filter(v=>c.indexOf(v)<0&&e.classList.contains(v)),f=h.filter(v=>i.indexOf(v)<0).concat(g),m=c.filter(v=>t.indexOf(v)<0).concat(p);d.putSticky(e,"classes",v=>(v.classList.remove(...m),v.classList.add(...f),[f,m]))})},setOrRemoveAttrs(e,t,i){let[s,n]=d.getSticky(e,"attrs",[[],[]]),r=t.map(([l,h])=>l).concat(i),o=s.filter(([l,h])=>!r.includes(l)).concat(t),a=n.filter(l=>!r.includes(l)).concat(i);d.putSticky(e,"attrs",l=>(a.forEach(h=>l.removeAttribute(h)),o.forEach(([h,c])=>l.setAttribute(h,c)),[o,a]))},hasAllClasses(e,t){return t.every(i=>e.classList.contains(i))},isToggledOut(e,t){return!this.isVisible(e)||this.hasAllClasses(e,t)},filterToEls(e,{to:t}){return t?d.all(document,t):[e]},defaultDisplay(e){return{tr:"table-row",td:"table-cell"}[e.tagName.toLowerCase()]||"block"}},O=ns,$={byId(e){return document.getElementById(e)||M(`no id found for ${e}`)},removeClass(e,t){e.classList.remove(t),e.classList.length===0&&e.removeAttribute("class")},all(e,t,i){if(!e)return[];let s=Array.from(e.querySelectorAll(t));return i?s.forEach(i):s},childNodeLength(e){let t=document.createElement("template");return t.innerHTML=e,t.content.childElementCount},isUploadInput(e){return e.type==="file"&&e.getAttribute(G)!==null},isAutoUpload(e){return e.hasAttribute("data-phx-auto-upload")},findUploadInputs(e){let t=e.id,i=this.all(document,`input[type="file"][${G}][form="${t}"]`);return this.all(e,`input[type="file"][${G}]`).concat(i)},findComponentNodeList(e,t){return this.filterWithinSameLiveView(this.all(e,`[${K}="${t}"]`),e)},isPhxDestroyed(e){return!!(e.id&&$.private(e,"destroyed"))},wantsNewTab(e){let t=e.ctrlKey||e.shiftKey||e.metaKey||e.button&&e.button===1,i=e.target instanceof HTMLAnchorElement&&e.target.hasAttribute("download"),s=e.target.hasAttribute("target")&&e.target.getAttribute("target").toLowerCase()==="_blank",n=e.target.hasAttribute("target")&&!e.target.getAttribute("target").startsWith("_");return t||s||i||n},isUnloadableFormSubmit(e){return e.target&&e.target.getAttribute("method")==="dialog"||e.submitter&&e.submitter.getAttribute("formmethod")==="dialog"?!1:!e.defaultPrevented&&!this.wantsNewTab(e)},isNewPageClick(e,t){let i=e.target instanceof HTMLAnchorElement?e.target.getAttribute("href"):null,s;if(e.defaultPrevented||i===null||this.wantsNewTab(e)||i.startsWith("mailto:")||i.startsWith("tel:")||e.target.isContentEditable)return!1;try{s=new URL(i)}catch(n){try{s=new URL(i,t)}catch(r){return!0}}return s.host===t.host&&s.protocol===t.protocol&&s.pathname===t.pathname&&s.search===t.search?s.hash===""&&!s.href.endsWith("#"):s.protocol.startsWith("http")},markPhxChildDestroyed(e){this.isPhxChild(e)&&e.setAttribute(Y,""),this.putPrivate(e,"destroyed",!0)},findPhxChildrenInFragment(e,t){let i=document.createElement("template");return i.innerHTML=e,this.findPhxChildren(i.content,t)},isIgnored(e,t){return(e.getAttribute(t)||e.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(e,t,i){return e.getAttribute&&i.indexOf(e.getAttribute(t))>=0},findPhxSticky(e){return this.all(e,`[${Ot}]`)},findPhxChildren(e,t){return this.all(e,`${me}[${ae}="${t}"]`)},findExistingParentCIDs(e,t){let i=new Set,s=new Set;return t.forEach(n=>{this.filterWithinSameLiveView(this.all(e,`[${K}="${n}"]`),e).forEach(r=>{i.add(n),this.all(r,`[${K}]`).map(o=>parseInt(o.getAttribute(K))).forEach(o=>s.add(o))})}),s.forEach(n=>i.delete(n)),i},filterWithinSameLiveView(e,t){return t.querySelector(me)?e.filter(i=>this.withinSameLiveView(i,t)):e},withinSameLiveView(e,t){for(;e=e.parentNode;){if(e.isSameNode(t))return!0;if(e.getAttribute(Y)!==null)return!1}},private(e,t){return e[B]&&e[B][t]},deletePrivate(e,t){e[B]&&delete e[B][t]},putPrivate(e,t,i){e[B]||(e[B]={}),e[B][t]=i},updatePrivate(e,t,i,s){let n=this.private(e,t);n===void 0?this.putPrivate(e,t,s(i)):this.putPrivate(e,t,s(n))},copyPrivates(e,t){t[B]&&(e[B]=t[B])},putTitle(e){let t=document.querySelector("title");if(t){let{prefix:i,suffix:s}=t.dataset;document.title=`${i||""}${e}${s||""}`}else document.title=e},debounce(e,t,i,s,n,r,o,a){let l=e.getAttribute(i),h=e.getAttribute(n);l===""&&(l=s),h===""&&(h=r);let c=l||h;switch(c){case null:return a();case"blur":this.once(e,"debounce-blur")&&e.addEventListener("blur",()=>{o()&&a()});return;default:let g=parseInt(c),p=()=>h?this.deletePrivate(e,Se):a(),f=this.incCycle(e,Ae,p);if(isNaN(g))return M(`invalid throttle/debounce value: ${c}`);if(h){let v=!1;if(t.type==="keydown"){let C=this.private(e,Ft);this.putPrivate(e,Ft,t.key),v=C!==t.key}if(!v&&this.private(e,Se))return!1;{a();let C=setTimeout(()=>{o()&&this.triggerCycle(e,Ae)},g);this.putPrivate(e,Se,C)}}else setTimeout(()=>{o()&&this.triggerCycle(e,Ae,f)},g);let m=e.form;m&&this.once(m,"bind-debounce")&&m.addEventListener("submit",()=>{Array.from(new FormData(m).entries(),([v])=>{let C=m.querySelector(`[name="${v}"]`);this.incCycle(C,Ae),this.deletePrivate(C,Se)})}),this.once(e,"bind-debounce")&&e.addEventListener("blur",()=>{clearTimeout(this.private(e,Se)),this.triggerCycle(e,Ae)})}},triggerCycle(e,t,i){let[s,n]=this.private(e,t);i||(i=s),i===s&&(this.incCycle(e,t),n())},once(e,t){return this.private(e,t)===!0?!1:(this.putPrivate(e,t,!0),!0)},incCycle(e,t,i=function(){}){let[s]=this.private(e,t)||[0,i];return s++,this.putPrivate(e,t,[s,i]),s},maybeAddPrivateHooks(e,t,i){e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute(i))&&e.setAttribute("data-phx-hook","Phoenix.InfiniteScroll")},isFeedbackContainer(e,t){return e.hasAttribute&&e.hasAttribute(t)},maybeHideFeedback(e,t,i,s){let n={};t.forEach(r=>{if(!e.contains(r))return;let o=r.getAttribute(i);if(!o){O.addOrRemoveClasses(r,[],[De]);return}if(n[o]===!0){this.hideFeedback(r);return}n[o]=this.shouldHideFeedback(e,o,s),n[o]===!0&&this.hideFeedback(r)})},hideFeedback(e){O.addOrRemoveClasses(e,[De],[])},shouldHideFeedback(e,t,i){let s=`[name="${t}"], [name="${t}[]"], [${i}="${t}"]`,n=!1;return $.all(e,s,r=>{(this.private(r,mt)||this.private(r,We))&&(n=!0)}),!n},feedbackSelector(e,t,i){let s=`[${t}="${e.name}"], [${t}="${e.name.replace(/\[\]$/,"")}"]`;return e.getAttribute(i)&&(s+=`,[${t}="${e.getAttribute(i)}"]`),s},resetForm(e,t,i){Array.from(e.elements).forEach(s=>{let n=this.feedbackSelector(s,t,i);this.deletePrivate(s,mt),this.deletePrivate(s,We),this.all(document,n,r=>{O.addOrRemoveClasses(r,[De],[])})})},showError(e,t,i){if(e.name){let s=this.feedbackSelector(e,t,i);this.all(document,s,n=>{O.addOrRemoveClasses(n,[],[De])})}},isPhxChild(e){return e.getAttribute&&e.getAttribute(ae)},isPhxSticky(e){return e.getAttribute&&e.getAttribute(Ot)!==null},isChildOfAny(e,t){return!!t.find(i=>i.contains(e))},firstPhxChild(e){return this.isPhxChild(e)?e:this.all(e,`[${ae}]`)[0]},dispatchEvent(e,t,i={}){let s=!0;e.nodeName==="INPUT"&&e.type==="file"&&t==="click"&&(s=!1);let o={bubbles:i.bubbles===void 0?s:!!i.bubbles,cancelable:!0,detail:i.detail||{}},a=t==="click"?new MouseEvent("click",o):new CustomEvent(t,o);e.dispatchEvent(a)},cloneNode(e,t){if(typeof t=="undefined")return e.cloneNode(!0);{let i=e.cloneNode(!1);return i.innerHTML=t,i}},mergeAttrs(e,t,i={}){let s=new Set(i.exclude||[]),n=i.isIgnored,r=t.attributes;for(let a=r.length-1;a>=0;a--){let l=r[a].name;if(s.has(l))l==="value"&&e.value===t.value&&e.setAttribute("value",t.getAttribute(l));else{let h=t.getAttribute(l);e.getAttribute(l)!==h&&(!n||n&&l.startsWith("data-"))&&e.setAttribute(l,h)}}let o=e.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;n?l.startsWith("data-")&&!t.hasAttribute(l)&&![N,te].includes(l)&&e.removeAttribute(l):t.hasAttribute(l)||e.removeAttribute(l)}},mergeFocusedInput(e,t){e instanceof HTMLSelectElement||$.mergeAttrs(e,t,{exclude:["value"]}),t.readOnly?e.setAttribute("readonly",!0):e.removeAttribute("readonly")},hasSelectionRange(e){return e.setSelectionRange&&(e.type==="text"||e.type==="textarea")},restoreFocus(e,t,i){if(e instanceof HTMLSelectElement&&e.focus(),!$.isTextualInput(e))return;e.matches(":focus")||e.focus(),this.hasSelectionRange(e)&&e.setSelectionRange(t,i)},isFormInput(e){return/^(?:input|select|textarea)$/i.test(e.tagName)&&e.type!=="button"},syncAttrsToProps(e){e instanceof HTMLInputElement&&ri.indexOf(e.type.toLocaleLowerCase())>=0&&(e.checked=e.getAttribute("checked")!==null)},isTextualInput(e){return ji.indexOf(e.type)>=0},isNowTriggerFormExternal(e,t){return e.getAttribute&&e.getAttribute(t)!==null},syncPendingRef(e,t,i){let s=e.getAttribute(N);if(s===null)return!0;let n=e.getAttribute(te);return $.isFormInput(e)||e.getAttribute(i)!==null?($.isUploadInput(e)&&$.mergeAttrs(e,t,{isIgnored:!0}),$.putPrivate(e,N,t),!1):(ti.forEach(r=>{e.classList.contains(r)&&t.classList.add(r)}),t.setAttribute(N,s),t.setAttribute(te,n),!0)},cleanChildNodes(e,t){if($.isPhxUpdate(e,t,["append","prepend"])){let i=[];e.childNodes.forEach(s=>{s.id||(!(s.nodeType===Node.TEXT_NODE&&s.nodeValue.trim()==="")&&s.nodeType!==Node.COMMENT_NODE&&M(`only HTML element tags with an id are allowed inside containers with phx-update. removing illegal node: "${(s.outerHTML||s.nodeValue).trim()}" `),i.push(s))}),i.forEach(s=>s.remove())}},replaceRootContainer(e,t,i){let s=new Set(["id",Y,fe,bt,le]);if(e.tagName.toLowerCase()===t.toLowerCase())return Array.from(e.attributes).filter(n=>!s.has(n.name.toLowerCase())).forEach(n=>e.removeAttribute(n.name)),Object.keys(i).filter(n=>!s.has(n.toLowerCase())).forEach(n=>e.setAttribute(n,i[n])),e;{let n=document.createElement(t);return Object.keys(i).forEach(r=>n.setAttribute(r,i[r])),s.forEach(r=>n.setAttribute(r,e.getAttribute(r))),n.innerHTML=e.innerHTML,e.replaceWith(n),n}},getSticky(e,t,i){let s=($.private(e,"sticky")||[]).find(([n])=>t===n);if(s){let[n,r,o]=s;return o}else return typeof i=="function"?i():i},deleteSticky(e,t){this.updatePrivate(e,"sticky",[],i=>i.filter(([s,n])=>s!==t))},putSticky(e,t,i){let s=i(e);this.updatePrivate(e,"sticky",[],n=>{let r=n.findIndex(([o])=>t===o);return r>=0?n[r]=[t,i,s]:n.push([t,i,s]),n})},applyStickyOperations(e){let t=$.private(e,"sticky");t&&t.forEach(([i,s,n])=>this.putSticky(e,i,s))}},d=$,Ee=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(ut).split(",").indexOf(_.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(vt).split(",").indexOf(_.genFileRef(t))>=0&&this.isActive(e,t)}static isPreflightInProgress(e){return e._preflightInProgress===!0}static markPreflightInProgress(e){e._preflightInProgress=!0}constructor(e,t,i,s){this.ref=_.genFileRef(t),this.fileEl=e,this.file=t,this.view=i,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(Je,this._onElUpdated),this.autoUpload=s}metadata(){return this.meta}progress(e){this._progress=Math.floor(e),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{_.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}isCancelled(){return this._isCancelled}cancel(){this.file._preflightInProgress=!1,this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(Je,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),this.isAutoUpload()||_.clearFiles(this.fileEl)}isAutoUpload(){return this.autoUpload}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(Je,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(ut).split(",").indexOf(this.ref)===-1&&(_.untrackFile(this.fileEl,this.file),this.cancel())}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||M(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:is}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||M(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}},rs=0,_=class{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(rs++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let s=this.activeFiles(e).find(n=>this.genFileRef(n)===t);i(URL.createObjectURL(s))}static hasUploadsInProgress(e){let t=0;return d.findUploadInputs(e).forEach(i=>{i.getAttribute(vt)!==i.getAttribute($i)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(s=>{let n={path:e.name},r=e.getAttribute(G);i[r]=i[r]||[],n.ref=this.genFileRef(s),n.last_modified=s.lastModified,n.name=s.name||n.ref,n.relative_path=s.webkitRelativePath,n.type=s.type,n.size=s.size,typeof s.meta=="function"&&(n.meta=s.meta()),i[r].push(n)}),i}static clearFiles(e){e.value=null,e.removeAttribute(G),d.putPrivate(e,"files",[])}static untrackFile(e,t){d.putPrivate(e,"files",d.private(e,"files").filter(i=>!Object.is(i,t)))}static trackFiles(e,t,i){if(e.getAttribute("multiple")!==null){let s=t.filter(n=>!this.activeFiles(e).find(r=>Object.is(r,n)));d.updatePrivate(e,"files",[],n=>n.concat(s)),e.value=null}else i&&i.files.length>0&&(e.files=i.files),d.putPrivate(e,"files",t)}static activeFileInputs(e){let t=d.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(d.private(e,"files")||[]).filter(t=>Ee.isActive(e,t))}static inputsAwaitingPreflight(e){let t=d.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!Ee.isPreflighted(e,t)&&!Ee.isPreflightInProgress(t))}static markPreflightInProgress(e){e.forEach(t=>Ee.markPreflightInProgress(t.file))}constructor(e,t,i){this.autoUpload=d.isAutoUpload(e),this.view=t,this.onComplete=i,this._entries=Array.from(_.filesAwaitingPreflight(e)||[]).map(s=>new Ee(e,s,t,this.autoUpload)),_.markPreflightInProgress(this._entries),this.numEntriesInProgress=this._entries.length}isAutoUpload(){return this.autoUpload}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(n=>(n.isCancelled()?(this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()):(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()})),n));let s=this._entries.reduce((n,r)=>{if(!r.meta)return n;let{name:o,callback:a}=r.uploader(i.uploaders);return n[o]=n[o]||{callback:a,entries:[]},n[o].entries.push(r),n},{});for(let n in s){let{callback:r,entries:o}=s[n];r(o,t,e,i)}}},ai={LiveFileUpload:{activeRefs(){return this.el.getAttribute(ut)},preflightedRefs(){return this.el.getAttribute(vt)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let e=this.preflightedRefs();this.preflightedWas!==e&&(this.preflightedWas=e,e===""&&this.__view.cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(Je))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(G)),_.getEntryDataURL(this.inputEl,this.ref,e=>{this.url=e,this.el.src=e})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",()=>pe.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>pe.focusFirst(this.el)),this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&pe.focusFirst(this.el)}}},li=e=>["HTML","BODY"].indexOf(e.nodeName.toUpperCase())>=0?null:["scroll","auto"].indexOf(getComputedStyle(e).overflowY)>=0?e:li(e.parentElement),Vt=e=>e?e.scrollTop:document.documentElement.scrollTop||document.body.scrollTop,wt=e=>e?e.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight,yt=e=>e?e.getBoundingClientRect().top:0,os=(e,t)=>{let i=e.getBoundingClientRect();return i.top>=yt(t)&&i.left>=0&&i.top<=wt(t)},as=(e,t)=>{let i=e.getBoundingClientRect();return i.right>=yt(t)&&i.left>=0&&i.bottom<=wt(t)},qt=(e,t)=>{let i=e.getBoundingClientRect();return i.top>=yt(t)&&i.left>=0&&i.top<=wt(t)};ai.InfiniteScroll={mounted(){this.scrollContainer=li(this.el);let e=Vt(this.scrollContainer),t=!1,i=500,s=null,n=this.throttle(i,(a,l)=>{s=()=>!0,this.liveSocket.execJSHookPush(this.el,a,{id:l.id,_overran:!0},()=>{s=null})}),r=this.throttle(i,(a,l)=>{s=()=>l.scrollIntoView({block:"start"}),this.liveSocket.execJSHookPush(this.el,a,{id:l.id},()=>{s=null,window.requestAnimationFrame(()=>{qt(l,this.scrollContainer)||l.scrollIntoView({block:"start"})})})}),o=this.throttle(i,(a,l)=>{s=()=>l.scrollIntoView({block:"end"}),this.liveSocket.execJSHookPush(this.el,a,{id:l.id},()=>{s=null,window.requestAnimationFrame(()=>{qt(l,this.scrollContainer)||l.scrollIntoView({block:"end"})})})});this.onScroll=a=>{let l=Vt(this.scrollContainer);if(s)return e=l,s();let h=this.el.getBoundingClientRect(),c=this.el.getAttribute(this.liveSocket.binding("viewport-top")),g=this.el.getAttribute(this.liveSocket.binding("viewport-bottom")),p=this.el.lastElementChild,f=this.el.firstElementChild,m=le;m&&c&&!t&&h.top>=0?(t=!0,n(c,f)):v&&t&&h.top<=0&&(t=!1),c&&m&&os(f,this.scrollContainer)?r(c,f):g&&v&&as(p,this.scrollContainer)&&o(g,p),e=l},this.scrollContainer?this.scrollContainer.addEventListener("scroll",this.onScroll):window.addEventListener("scroll",this.onScroll)},destroyed(){this.scrollContainer?this.scrollContainer.removeEventListener("scroll",this.onScroll):window.removeEventListener("scroll",this.onScroll)},throttle(e,t){let i=0,s;return(...n)=>{let r=Date.now(),o=e-(r-i);o<=0||o>e?(s&&(clearTimeout(s),s=null),i=r,t(...n)):s||(s=setTimeout(()=>{i=Date.now(),s=null,t(...n)},o))}}};var ls=ai,hs=class{constructor(e,t,i){let s=new Set,n=new Set([...t.children].map(o=>o.id)),r=[];Array.from(e.children).forEach(o=>{if(o.id&&(s.add(o.id),n.has(o.id))){let a=o.previousElementSibling&&o.previousElementSibling.id;r.push({elementId:o.id,previousElementId:a})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=r,this.elementIdsToAdd=[...n].filter(o=>!s.has(o))}perform(){let e=d.byId(this.containerId);this.elementsToModify.forEach(t=>{t.previousElementId?ie(document.getElementById(t.previousElementId),i=>{ie(document.getElementById(t.elementId),s=>{s.previousElementSibling&&s.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",s)})}):ie(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{ie(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}},Xt=11;function ds(e,t){var i=t.attributes,s,n,r,o,a;if(!(t.nodeType===Xt||e.nodeType===Xt)){for(var l=i.length-1;l>=0;l--)s=i[l],n=s.name,r=s.namespaceURI,o=s.value,r?(n=s.localName||n,a=e.getAttributeNS(r,n),a!==o&&(s.prefix==="xmlns"&&(n=s.name),e.setAttributeNS(r,n,o))):(a=e.getAttribute(n),a!==o&&e.setAttribute(n,o));for(var h=e.attributes,c=h.length-1;c>=0;c--)s=h[c],n=s.name,r=s.namespaceURI,r?(n=s.localName||n,t.hasAttributeNS(r,n)||e.removeAttributeNS(r,n)):t.hasAttribute(n)||e.removeAttribute(n)}}var $e,cs="http://www.w3.org/1999/xhtml",H=typeof document=="undefined"?void 0:document,us=!!H&&"content"in H.createElement("template"),fs=!!H&&H.createRange&&"createContextualFragment"in H.createRange();function ps(e){var t=H.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function ms(e){$e||($e=H.createRange(),$e.selectNode(H.body));var t=$e.createContextualFragment(e);return t.childNodes[0]}function gs(e){var t=H.createElement("body");return t.innerHTML=e,t.childNodes[0]}function vs(e){return e=e.trim(),us?ps(e):fs?ms(e):gs(e)}function Ue(e,t){var i=e.nodeName,s=t.nodeName,n,r;return i===s?!0:(n=i.charCodeAt(0),r=s.charCodeAt(0),n<=90&&r>=97?i===s.toUpperCase():r<=90&&n>=97?s===i.toUpperCase():!1)}function bs(e,t){return!t||t===cs?H.createElement(e):H.createElementNS(t,e)}function ws(e,t){for(var i=e.firstChild;i;){var s=i.nextSibling;t.appendChild(i),i=s}return t}function ct(e,t,i){e[i]!==t[i]&&(e[i]=t[i],e[i]?e.setAttribute(i,""):e.removeAttribute(i))}var Wt={OPTION:function(e,t){var i=e.parentNode;if(i){var s=i.nodeName.toUpperCase();s==="OPTGROUP"&&(i=i.parentNode,s=i&&i.nodeName.toUpperCase()),s==="SELECT"&&!i.hasAttribute("multiple")&&(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),i.selectedIndex=-1)}ct(e,t,"selected")},INPUT:function(e,t){ct(e,t,"checked"),ct(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var i=t.value;e.value!==i&&(e.value=i);var s=e.firstChild;if(s){var n=s.nodeValue;if(n==i||!i&&n==e.placeholder)return;s.nodeValue=i}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var i=-1,s=0,n=e.firstChild,r,o;n;)if(o=n.nodeName&&n.nodeName.toUpperCase(),o==="OPTGROUP")r=n,n=r.firstChild;else{if(o==="OPTION"){if(n.hasAttribute("selected")){i=s;break}s++}n=n.nextSibling,!n&&r&&(n=r.nextSibling,r=null)}e.selectedIndex=i}}},Ce=1,zt=11,Kt=3,Gt=8;function ee(){}function ys(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function As(e){return function(i,s,n){if(n||(n={}),typeof s=="string")if(i.nodeName==="#document"||i.nodeName==="HTML"||i.nodeName==="BODY"){var r=s;s=H.createElement("html"),s.innerHTML=r}else s=vs(s);else s.nodeType===zt&&(s=s.firstElementChild);var o=n.getNodeKey||ys,a=n.onBeforeNodeAdded||ee,l=n.onNodeAdded||ee,h=n.onBeforeElUpdated||ee,c=n.onElUpdated||ee,g=n.onBeforeNodeDiscarded||ee,p=n.onNodeDiscarded||ee,f=n.onBeforeElChildrenUpdated||ee,m=n.skipFromChildren||ee,v=n.addChild||function(y,b){return y.appendChild(b)},C=n.childrenOnly===!0,P=Object.create(null),R=[];function x(y){R.push(y)}function L(y,b){if(y.nodeType===Ce)for(var E=y.firstChild;E;){var A=void 0;b&&(A=o(E))?x(A):(p(E),E.firstChild&&L(E,b)),E=E.nextSibling}}function se(y,b,E){g(y)!==!1&&(b&&b.removeChild(y),p(y),L(y,E))}function T(y){if(y.nodeType===Ce||y.nodeType===zt)for(var b=y.firstChild;b;){var E=o(b);E&&(P[E]=b),T(b),b=b.nextSibling}}T(i);function q(y){l(y);for(var b=y.firstChild;b;){var E=b.nextSibling,A=o(b);if(A){var k=P[A];k&&Ue(b,k)?(b.parentNode.replaceChild(k,b),u(k,b)):q(b)}else q(b);b=E}}function ne(y,b,E){for(;b;){var A=b.nextSibling;(E=o(b))?x(E):se(b,y,!0),b=A}}function u(y,b,E){var A=o(b);A&&delete P[A],!(!E&&(h(y,b)===!1||(e(y,b),c(y),f(y,b)===!1)))&&(y.nodeName!=="TEXTAREA"?w(y,b):Wt.TEXTAREA(y,b))}function w(y,b){var E=m(y,b),A=b.firstChild,k=y.firstChild,he,X,de,Re,Q;e:for(;A;){for(Re=A.nextSibling,he=o(A);!E&&k;){if(de=k.nextSibling,A.isSameNode&&A.isSameNode(k)){A=Re,k=de;continue e}X=o(k);var Pe=k.nodeType,Z=void 0;if(Pe===A.nodeType&&(Pe===Ce?(he?he!==X&&((Q=P[he])?de===Q?Z=!1:(y.insertBefore(Q,k),X?x(X):se(k,y,!0),k=Q,X=o(k)):Z=!1):X&&(Z=!1),Z=Z!==!1&&Ue(k,A),Z&&u(k,A)):(Pe===Kt||Pe==Gt)&&(Z=!0,k.nodeValue!==A.nodeValue&&(k.nodeValue=A.nodeValue))),Z){A=Re,k=de;continue e}X?x(X):se(k,y,!0),k=de}if(he&&(Q=P[he])&&Ue(Q,A))E||v(y,Q),u(Q,A);else{var Ze=a(A);Ze!==!1&&(Ze&&(A=Ze),A.actualize&&(A=A.actualize(y.ownerDocument||H)),v(y,A),q(A))}A=Re,k=de}ne(y,k,X);var At=Wt[y.nodeName];At&&At(y,b)}var S=i,D=S.nodeType,re=s.nodeType;if(!C){if(D===Ce)re===Ce?Ue(i,s)||(p(i),S=ws(i,bs(s.nodeName,s.namespaceURI))):S=s;else if(D===Kt||D===Gt){if(re===D)return S.nodeValue!==s.nodeValue&&(S.nodeValue=s.nodeValue),S;S=s}}if(S===s)p(i);else{if(s.isSameNode&&s.isSameNode(S))return;if(u(S,s,C),R)for(var Ye=0,gi=R.length;Ye{if(i&&i.isSameNode(s)&&d.isFormInput(s))return d.mergeFocusedInput(s,n),!1}})}constructor(e,t,i,s,n,r){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=s,this.streams=n,this.streamInserts={},this.streamComponentRestore={},this.targetCID=r,this.cidPatch=z(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]}}before(e,t){this.callbacks[`before${e}`].push(t)}after(e,t){this.callbacks[`after${e}`].push(t)}trackBefore(e,...t){this.callbacks[`before${e}`].forEach(i=>i(...t))}trackAfter(e,...t){this.callbacks[`after${e}`].forEach(i=>i(...t))}markPrunableContentForRemoval(){let e=this.liveSocket.binding(ze);d.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(Pt,"")})}perform(e){let{view:t,liveSocket:i,container:s,html:n}=this,r=this.isCIDPatch()?this.targetCIDContainer(n):s;if(this.isCIDPatch()&&!r)return;let o=i.getActiveElement(),{selectionStart:a,selectionEnd:l}=o&&d.hasSelectionRange(o)?o:{},h=i.binding(ze),c=i.binding(qe),g=i.binding(Xe),p=i.binding(gt),f=i.binding(ft),m=i.binding(pt),v=i.binding(Ui),C=[],P=[],R=[],x=[],L=null;function se(T,q,ne=!1){Yt(T,q,{childrenOnly:T.getAttribute(K)===null&&!ne,getNodeKey:u=>d.isPhxDestroyed(u)?null:e?u.id:u.id||u.getAttribute&&u.getAttribute(ni),skipFromChildren:u=>u.getAttribute(h)===ot,addChild:(u,w)=>{let{ref:S,streamAt:D}=this.getStreamInsert(w);if(S===void 0)return u.appendChild(w);if(this.setStreamRef(w,S),D===0)u.insertAdjacentElement("afterbegin",w);else if(D===-1)u.appendChild(w);else if(D>0){let re=Array.from(u.children)[D];u.insertBefore(w,re)}},onBeforeNodeAdded:u=>{d.maybeAddPrivateHooks(u,f,m),this.trackBefore("added",u);let w=u;return!e&&this.streamComponentRestore[u.id]&&(w=this.streamComponentRestore[u.id],delete this.streamComponentRestore[u.id],se.call(this,w,u,!0)),w},onNodeAdded:u=>{u.getAttribute&&this.maybeReOrderStream(u,!0),d.isFeedbackContainer(u,c)&&P.push(u),u instanceof HTMLImageElement&&u.srcset?u.srcset=u.srcset:u instanceof HTMLVideoElement&&u.autoplay&&u.play(),d.isNowTriggerFormExternal(u,v)&&(L=u),(d.isPhxChild(u)&&t.ownsElement(u)||d.isPhxSticky(u)&&t.ownsElement(u.parentNode))&&this.trackAfter("phxChildAdded",u),C.push(u)},onNodeDiscarded:u=>this.onNodeDiscarded(u),onBeforeNodeDiscarded:u=>u.getAttribute&&u.getAttribute(Pt)!==null?!0:!(u.parentElement!==null&&u.id&&d.isPhxUpdate(u.parentElement,h,[ot,"append","prepend"])||this.maybePendingRemove(u)||this.skipCIDSibling(u)),onElUpdated:u=>{d.isNowTriggerFormExternal(u,v)&&(L=u),R.push(u),this.maybeReOrderStream(u,!1)},onBeforeElUpdated:(u,w)=>{if(d.maybeAddPrivateHooks(w,f,m),(d.isFeedbackContainer(u,c)||d.isFeedbackContainer(w,c))&&(P.push(u),P.push(w)),d.cleanChildNodes(w,h),this.skipCIDSibling(w))return this.maybeReOrderStream(u),!1;if(d.isPhxSticky(u))return!1;if(d.isIgnored(u,h)||u.form&&u.form.isSameNode(L))return this.trackBefore("updated",u,w),d.mergeAttrs(u,w,{isIgnored:d.isIgnored(u,h)}),R.push(u),d.applyStickyOperations(u),!1;if(u.type==="number"&&u.validity&&u.validity.badInput)return!1;if(!d.syncPendingRef(u,w,p))return d.isUploadInput(u)&&(this.trackBefore("updated",u,w),R.push(u)),d.applyStickyOperations(u),!1;if(d.isPhxChild(w)){let re=u.getAttribute(Y);return d.mergeAttrs(u,w,{exclude:[fe]}),re!==""&&u.setAttribute(Y,re),u.setAttribute(le,this.rootID),d.applyStickyOperations(u),!1}d.copyPrivates(w,u);let S=o&&u.isSameNode(o)&&d.isFormInput(u),D=S&&this.isChangedSelect(u,w);return S&&u.type!=="hidden"&&!D?(this.trackBefore("updated",u,w),d.mergeFocusedInput(u,w),d.syncAttrsToProps(u),R.push(u),d.applyStickyOperations(u),!1):(D&&u.blur(),d.isPhxUpdate(w,h,["append","prepend"])&&x.push(new hs(u,w,w.getAttribute(h))),d.syncAttrsToProps(w),d.applyStickyOperations(w),this.trackBefore("updated",u,w),!0)}})}return this.trackBefore("added",s),this.trackBefore("updated",s,s),i.time("morphdom",()=>{this.streams.forEach(([T,q,ne,u])=>{q.forEach(([w,S,D])=>{this.streamInserts[w]={ref:T,streamAt:S,limit:D,reset:u}}),u!==void 0&&d.all(s,`[${at}="${T}"]`,w=>{this.removeStreamChildElement(w)}),ne.forEach(w=>{let S=s.querySelector(`[id="${w}"]`);S&&this.removeStreamChildElement(S)})}),e&&d.all(this.container,`[${h}=${ot}]`,T=>{this.liveSocket.owner(T,q=>{q===this.view&&Array.from(T.children).forEach(ne=>{this.removeStreamChildElement(ne)})})}),se.call(this,r,n)}),i.isDebugEnabled()&&(Zi(),Array.from(document.querySelectorAll("input[name=id]")).forEach(T=>{T.form&&console.error(`Detected an input with name="id" inside a form! This will cause problems when patching the DOM. `,T)})),x.length>0&&i.time("post-morph append/prepend restoration",()=>{x.forEach(T=>T.perform())}),d.maybeHideFeedback(r,P,c,g),i.silenceEvents(()=>d.restoreFocus(o,a,l)),d.dispatchEvent(document,"phx:update"),C.forEach(T=>this.trackAfter("added",T)),R.forEach(T=>this.trackAfter("updated",T)),this.transitionPendingRemoves(),L&&(i.unload(),Object.getPrototypeOf(L).submit.call(L)),!0}onNodeDiscarded(e){(d.isPhxChild(e)||d.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfter("discarded",e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}removeStreamChildElement(e){this.streamInserts[e.id]?(this.streamComponentRestore[e.id]=e,e.remove()):this.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}setStreamRef(e,t){d.putSticky(e,at,i=>i.setAttribute(at,t))}maybeReOrderStream(e,t){let{ref:i,streamAt:s,reset:n}=this.getStreamInsert(e);if(s!==void 0&&(this.setStreamRef(e,i),!(!n&&!t)&&e.parentElement)){if(s===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(s>0){let r=Array.from(e.parentElement.children),o=r.indexOf(e);if(s>=r.length-1)e.parentElement.appendChild(e);else{let a=r[s];o>s?e.parentElement.insertBefore(e,a):e.parentElement.insertBefore(e,a.nextElementSibling)}}this.maybeLimitStream(e)}}maybeLimitStream(e){let{limit:t}=this.getStreamInsert(e),i=t!==null&&Array.from(e.parentElement.children);t&&t<0&&i.length>t*-1?i.slice(0,i.length+t).forEach(s=>this.removeStreamChildElement(s)):t&&t>=0&&i.length>t&&i.slice(t).forEach(s=>this.removeStreamChildElement(s))}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:t}=this;e.length>0&&(t.transitionRemoves(e),t.requestDOMUpdate(()=>{e.forEach(i=>{let s=d.firstPhxChild(i);s&&t.destroyViewByEl(s),i.remove()}),this.trackAfter("transitionsDiscarded",e)}))}isChangedSelect(e,t){if(!(e instanceof HTMLSelectElement)||e.multiple)return!1;if(e.options.length!==t.options.length)return!0;let i=e.selectedOptions[0],s=t.selectedOptions[0];return i&&i.hasAttribute("selected")&&s.setAttribute("selected",i.getAttribute("selected")),!e.isEqualNode(t)}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(si)}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=d.findComponentNodeList(this.container,this.targetCID);return i.length===0&&d.childNodeLength(e)===1?t:t&&t.parentNode}indexOf(e,t){return Array.from(e.children).indexOf(t)}},ks=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),Es=new Set(["'",'"']),Qt=(e,t,i)=>{let s=0,n=!1,r,o,a,l,h,c,g=e.match(/^(\s*(?:\s*)*)<([^\s\/>]+)/);if(g===null)throw new Error(`malformed html ${e}`);for(s=g[0].length,r=g[1],a=g[2],l=s,s;s";s++)if(e.charAt(s)==="="){let m=e.slice(s-3,s)===" id";s++;let v=e.charAt(s);if(Es.has(v)){let C=s;for(s++,s;s=r.length+a.length;){let m=e.charAt(p);if(n)m==="-"&&e.slice(p-3,p)===""&&e.slice(p-2,p)==="--")n=!0,p-=3;else{if(m===">")break;p-=1}}o=e.slice(p+1,e.length);let f=Object.keys(t).map(m=>t[m]===!0?m:`${m}="${t[m]}"`).join(" ");if(i){let m=h?` id="${h}"`:"";ks.has(a)?c=`<${a}${m}${f===""?"":" "}${f}/>`:c=`<${a}${m}${f===""?"":" "}${f}>`}else{let m=e.slice(l,p+1);c=`<${a}${f===""?"":" "}${f}${m}`}return[c,r,o]},Zt=class{static extract(e){let{[Mt]:t,[Nt]:i,[$t]:s}=e;return delete e[Mt],delete e[Nt],delete e[$t],{diff:e,title:s,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.magicId=0,this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){let[t,i]=this.recursiveToString(this.rendered,this.rendered[I],e,!0,{});return[t,i]}recursiveToString(e,t=e[I],i,s,n){i=i?new Set(i):null;let r={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,r,s,n),[r.buffer,r.streams]}componentCIDs(e){return Object.keys(e[I]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[I]?Object.keys(e).length===1:!1}getComponent(e,t){return e[I][t]}resetRender(e){this.rendered[I][e]&&(this.rendered[I][e].reset=!0)}mergeDiff(e){let t=e[I],i={};if(delete e[I],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[I]=this.rendered[I]||{},t){let s=this.rendered[I];for(let n in t)t[n]=this.cachedFindComponent(n,t[n],s,t,i);for(let n in t)s[n]=t[n];e[I]=t}}cachedFindComponent(e,t,i,s,n){if(n[e])return n[e];{let r,o,a=t[J];if(z(a)){let l;a>0?l=this.cachedFindComponent(a,s[a],i,s,n):l=i[-a],o=l[J],r=this.cloneMerge(l,t,!0),r[J]=o}else r=t[J]!==void 0||i[e]===void 0?t:this.cloneMerge(i[e],t,!1);return n[e]=r,r}}mutableMerge(e,t){return t[J]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let s=t[i],n=e[i];ue(s)&&s[J]===void 0&&ue(n)?this.doMutableMerge(n,s):e[i]=s}e[dt]&&(e.newRender=!0)}cloneMerge(e,t,i){let s=U(U({},e),t);for(let n in s){let r=t[n],o=e[n];ue(r)&&r[J]===void 0&&ue(o)?s[n]=this.cloneMerge(o,r,i):r===void 0&&ue(o)&&(s[n]=this.cloneMerge(o,{},i))}return i?(delete s.magicId,delete s.newRender):e[dt]&&(s.newRender=!0),s}componentToString(e){let[t,i]=this.recursiveCIDToString(this.rendered[I],e,null),[s,n,r]=Qt(t,{});return[s,i]}pruneCIDs(e){e.forEach(t=>delete this.rendered[I][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[J]}templateStatic(e,t){return typeof e=="number"?t[e]:e}nextMagicID(){return this.magicId++,`m${this.magicId}-${this.parentViewId()}`}toOutputBuffer(e,t,i,s,n={}){if(e[Me])return this.comprehensionToBuffer(e,t,i);let{[J]:r}=e;r=this.templateStatic(r,t);let o=e[dt],a=i.buffer;o&&(i.buffer=""),s&&o&&!e.magicId&&(e.newRender=!0,e.magicId=this.nextMagicID()),i.buffer+=r[0];for(let l=1;l0||l.length>0||h)&&(delete e[Ut],e[Me]=[],i.streams.add(r))}dynamicToBuffer(e,t,i,s){if(typeof e=="number"){let[n,r]=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=n,i.streams=new Set([...i.streams,...r])}else ue(e)?this.toOutputBuffer(e,t,i,s,{}):i.buffer+=e}recursiveCIDToString(e,t,i){let s=e[t]||M(`no component for CID ${t}`,e),n={[K]:t},r=i&&!i.has(t);s.newRender=!r,s.magicId=`c${t}-${this.parentViewId()}`;let o=!s.reset,[a,l]=this.recursiveToString(s,e,i,o,n);return delete s.reset,[a,l]}},Cs=1,Te=class{static makeID(){return Cs++}static elementID(e){return e.phxHookId}constructor(e,t,i){this.__view=e,this.liveSocket=e.liveSocket,this.__callbacks=i,this.__listeners=new Set,this.__isDisconnected=!1,this.el=t,this.el.phxHookId=this.constructor.makeID();for(let s in this.__callbacks)this[s]=this.__callbacks[s]}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed()}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}pushEvent(e,t={},i=function(){}){return this.__view.pushHookEvent(this.el,null,e,t,i)}pushEventTo(e,t,i={},s=function(){}){return this.__view.withinTargets(e,(n,r)=>n.pushHookEvent(this.el,r,t,i,s))}handleEvent(e,t){let i=(s,n)=>n?e:t(s.detail);return window.addEventListener(`phx:${e}`,i),this.__listeners.add(i),i}removeHandleEvent(e){let t=e(null,!0);window.removeEventListener(`phx:${t}`,e),this.__listeners.delete(e)}upload(e,t){return this.__view.dispatchUploads(null,e,t)}uploadTo(e,t,i){return this.__view.withinTargets(e,(s,n)=>{s.dispatchUploads(n,t,i)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}},Be=(e,t,i=[])=>{let h=t,{submitter:s}=h,n=Ct(h,["submitter"]),r;if(s&&s.name){let c=document.createElement("input");c.type="hidden";let g=s.getAttribute("form");g&&c.setAttribute("form",g),c.name=s.name,c.value=s.value,s.parentElement.insertBefore(c,s),r=c}let o=new FormData(e),a=[];o.forEach((c,g,p)=>{c instanceof File&&a.push(g)}),a.forEach(c=>o.delete(c));let l=new URLSearchParams;for(let[c,g]of o.entries())(i.length===0||i.indexOf(c)>=0)&&l.append(c,g);s&&r&&s.parentElement.removeChild(r);for(let c in n)l.append(c,n[c]);return l.toString()},hi=class{constructor(e,t,i,s,n){this.isDead=!1,this.liveSocket=t,this.flash=s,this.parent=i,this.root=i?i.root:this,this.el=e,this.id=this.el.id,this.ref=0,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],this.pendingForms=new Set,this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(r){r&&r()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.formsForRecovery={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{let r=this.href&&this.expandURL(this.href);return{redirect:this.redirect?r:void 0,url:this.redirect?void 0:r||void 0,params:this.connectParams(n),session:this.getSession(),static:this.getStatic(),flash:this.flash}})}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(bt)}connectParams(e){let t=this.liveSocket.params(this.el),i=d.all(document,`[${this.binding(Ni)}]`).map(s=>s.src||s.href).filter(s=>typeof s=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._live_referer=e,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(Y)}getStatic(){let e=this.el.getAttribute(fe);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyed=!0,delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);let t=()=>{e();for(let i in this.viewHooks)this.destroyHook(this.viewHooks[i])};d.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",t).receive("error",t).receive("timeout",t)}setContainerClasses(...e){this.el.classList.remove(Lt,we,He,It,nt),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let t in this.viewHooks)this.viewHooks[t].__disconnected();this.setContainerClasses(we)}}execAll(e){d.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(Lt),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,t){this.liveSocket.log(this,e,t)}transition(e,t,i=function(){}){this.liveSocket.transition(e,t,i)}withinTargets(e,t,i=document,s){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,n=>t(n,e));if(z(e))d.findComponentNodeList(s||this.el,e).length===0?M(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let n=Array.from(i.querySelectorAll(e));n.length===0&&M(`nothing found matching the phx-target selector "${e}"`),n.forEach(r=>this.liveSocket.owner(r,o=>t(o,r)))}}applyDiff(e,t,i){this.log(e,()=>["",Ve(t)]);let{diff:s,reply:n,events:r,title:o}=Zt.extract(t);i({diff:s,reply:n,events:r}),typeof o=="string"&&window.requestAnimationFrame(()=>d.putTitle(o))}onJoin(e){let{rendered:t,container:i,liveview_version:s}=e;if(i){let[n,r]=i;this.el=d.replaceRootContainer(this.el,n,r)}this.childJoins=0,this.joinPending=!0,this.flash=null,this.root===this&&(this.formsForRecovery=this.getFormsForRecovery()),s!==this.liveSocket.version()&&console.error(`LiveView asset version mismatch. JavaScript version ${this.liveSocket.version()} vs. server ${s}. To avoid issues, please ensure that your assets use the same version as the server.`),V.dropLocal(this.liveSocket.localStorage,window.location.pathname,ei),this.applyDiff("mount",t,({diff:n,events:r})=>{this.rendered=new Zt(this.id,n);let[o,a]=this.renderContainer(null,"join");this.dropPendingRefs(),this.joinCount++,this.maybeRecoverForms(o,()=>{this.onJoinComplete(e,o,a,r)})})}dropPendingRefs(){d.all(document,`[${te}="${this.id}"][${N}]`,e=>{e.removeAttribute(N),e.removeAttribute(te)})}onJoinComplete({live_patch:e},t,i,s){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i,s);d.findPhxChildrenInFragment(t,this.id).filter(r=>{let o=r.id&&this.el.querySelector(`[id="${r.id}"]`),a=o&&o.getAttribute(fe);return a&&r.setAttribute(fe,a),o&&o.setAttribute(le,this.root.id),this.joinChild(r)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i,s)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)])}attachTrueDocEl(){this.el=d.byId(this.id),this.el.setAttribute(le,this.root.id)}execNewMounted(){let e=this.binding(ft),t=this.binding(pt);d.all(this.el,`[${e}], [${t}]`,i=>{this.ownsElement(i)&&(d.maybeAddPrivateHooks(i,e,t),this.maybeAddNewHook(i))}),d.all(this.el,`[${this.binding(ye)}], [data-phx-${ye}]`,i=>{this.ownsElement(i)&&this.maybeAddNewHook(i)}),d.all(this.el,`[${this.binding(Ht)}]`,i=>{this.ownsElement(i)&&this.maybeMounted(i)})}applyJoinPatch(e,t,i,s){this.attachTrueDocEl();let n=new je(this,this.el,this.id,t,i,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(s),this.applyPendingUpdates(),e){let{kind:r,to:o}=e;this.liveSocket.historyPatch(o,r)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),s=i&&d.isIgnored(e,this.binding(ze));if(i&&!e.isEqualNode(t)&&!(s&&ts(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(Ht)),i=t&&d.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),d.putPrivate(e,"mounted",!0))}maybeAddNewHook(e,t){let i=this.addHook(e);i&&i.__mounted()}performPatch(e,t,i=!1){let s=[],n=!1,r=new Set;return e.after("added",o=>{this.liveSocket.triggerDOM("onNodeAdded",[o]);let a=this.binding(ft),l=this.binding(pt);d.maybeAddPrivateHooks(o,a,l),this.maybeAddNewHook(o),o.getAttribute&&this.maybeMounted(o)}),e.after("phxChildAdded",o=>{d.isPhxSticky(o)?this.liveSocket.joinRootViews():n=!0}),e.before("updated",(o,a)=>{this.triggerBeforeUpdateHook(o,a)&&r.add(o.id)}),e.after("updated",o=>{r.has(o.id)&&this.getHook(o).__updated()}),e.after("discarded",o=>{o.nodeType===Node.ELEMENT_NODE&&s.push(o)}),e.after("transitionsDiscarded",o=>this.afterElementsRemoved(o,t)),e.perform(i),this.afterElementsRemoved(s,t),n}afterElementsRemoved(e,t){let i=[];e.forEach(s=>{let n=d.all(s,`[${K}]`),r=d.all(s,`[${this.binding(ye)}]`);n.concat(s).forEach(o=>{let a=this.componentID(o);z(a)&&i.indexOf(a)===-1&&i.push(a)}),r.concat(s).forEach(o=>{let a=this.getHook(o);a&&this.destroyHook(a)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){d.findPhxChildren(this.el,this.id).forEach(e=>this.joinChild(e))}maybeRecoverForms(e,t){let i=this.binding("change"),s=this.root.formsForRecovery,n=document.createElement("template");n.innerHTML=e;let r=n.content.firstElementChild;r.id=this.id,r.setAttribute(le,this.root.id),r.setAttribute(Y,this.getSession()),r.setAttribute(fe,this.getStatic()),r.setAttribute(ae,this.parent?this.parent.id:null);let o=d.all(n.content,"form").filter(a=>a.id&&s[a.id]).filter(a=>!this.pendingForms.has(a.id)).filter(a=>s[a.id].getAttribute(i)===a.getAttribute(i)).map(a=>[s[a.id],a]);if(o.length===0)return t();o.forEach(([a,l],h)=>{this.pendingForms.add(l.id),this.pushFormRecovery(a,l,n.content,()=>{this.pendingForms.delete(l.id),h===o.length-1&&t()})})}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){return e.id===this.id?this:this.children[e.getAttribute(ae)][e.id]}destroyDescendent(e){for(let t in this.root.children)for(let i in this.root.children[t])if(i===e)return this.root.children[t][i].destroy()}joinChild(e){if(!this.getChildById(e.id)){let i=new hi(e,this.liveSocket,this);return this.root.children[this.id][i.id]=i,i.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(e){this.childJoins--,this.childJoins===0&&(this.parent?this.parent.ackJoin(this):this.onAllChildJoinsComplete())}onAllChildJoinsComplete(){this.pendingForms.clear(),this.formsForRecovery={},this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,t])=>{e.isDestroyed()||t()}),this.pendingJoinOps=[]})}update(e,t){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:t});this.rendered.mergeDiff(e);let i=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{d.findExistingParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(i=!0)})}):jt(e)||this.liveSocket.time("full patch complete",()=>{let[s,n]=this.renderContainer(e,"update"),r=new je(this,this.el,this.id,s,n,null);i=this.performPatch(r,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,s=e?this.rendered.componentCIDs(e):null,[n,r]=this.rendered.toString(s);return[`<${i}>${n}`,r]})}componentPatch(e,t){if(jt(e))return!1;let[i,s]=this.rendered.componentToString(t),n=new je(this,this.el,this.id,i,s,t);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[Te.elementID(e)]}addHook(e){if(Te.elementID(e)||!e.getAttribute)return;let t=e.getAttribute(`data-phx-${ye}`)||e.getAttribute(this.binding(ye));if(t&&!this.ownsElement(e))return;let i=this.liveSocket.getHookCallbacks(t);if(i){e.id||M(`no DOM ID for hook "${t}". Hooks require a unique ID on each element.`,e);let s=new Te(this,e,i);return this.viewHooks[Te.elementID(s.el)]=s,s}else t!==null&&M(`unknown hook found for "${t}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[Te.elementID(e.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates())}eachChild(e){let t=this.root.children[this.id]||{};for(let i in t)e(this.getChildById(i))}onChannel(e,t){this.liveSocket.onChannel(this.channel,e,i=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>t(i)]):this.liveSocket.requestDOMUpdate(()=>t(i))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:t,events:i})=>this.update(t,i))})}),this.onChannel("redirect",({to:e,flash:t})=>this.onRedirect({to:e,flash:t})),this.onChannel("live_patch",e=>this.onLivePatch(e)),this.onChannel("live_redirect",e=>this.onLiveRedirect(e)),this.channel.onError(e=>this.onError(e)),this.channel.onClose(e=>this.onClose(e))}destroyAllChildren(){this.eachChild(e=>e.destroy())}onLiveRedirect(e){let{to:t,kind:i,flash:s}=e,n=this.expandURL(t);this.liveSocket.historyRedirect(n,i,s)}onLivePatch(e){let{to:t,kind:i}=e;this.href=this.expandURL(t),this.liveSocket.historyPatch(t,i)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:t}){this.liveSocket.redirect(e,t)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.liveSocket.wrapPush(this,{timeout:!1},()=>this.channel.join().receive("ok",t=>{this.isDestroyed()||this.liveSocket.requestDOMUpdate(()=>this.onJoin(t))}).receive("error",t=>!this.isDestroyed()&&this.onJoinError(t)).receive("timeout",()=>!this.isDestroyed()&&this.onJoinError({reason:"timeout"})))}onJoinError(e){if(e.reason==="reload"){this.log("error",()=>[`failed mount with ${e.status}. Falling back to page request`,e]),this.isMain()&&this.onRedirect({to:this.href});return}else if(e.reason==="unauthorized"||e.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.isMain()&&this.onRedirect({to:this.href});return}if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);this.displayError([we,He,nt]),this.log("error",()=>["unable to join",e]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this)}onClose(e){if(!this.isDestroyed()){if(this.liveSocket.hasPendingLink()&&e!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),document.activeElement&&document.activeElement.blur(),this.liveSocket.isUnloaded()&&this.showLoader(Wi)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([we,He,nt]):this.displayError([we,He,It]))}displayError(e){this.isMain()&&d.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(...e),this.execAll(this.binding("disconnected"))}pushWithReply(e,t,i,s=function(){}){if(!this.isConnected())return;let[n,[r],o]=e?e():[null,[],{}],a=function(){};return(o.page_loading||r&&r.getAttribute(this.binding(xt))!==null)&&(a=this.liveSocket.withPageLoading({kind:"element",target:r})),typeof i.cid!="number"&&delete i.cid,this.liveSocket.wrapPush(this,{timeout:!0},()=>this.channel.push(t,i,Ki).receive("ok",l=>{let h=c=>{l.redirect&&this.onRedirect(l.redirect),l.live_patch&&this.onLivePatch(l.live_patch),l.live_redirect&&this.onLiveRedirect(l.live_redirect),a(),s(l,c)};l.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",l.diff,({diff:c,reply:g,events:p})=>{n!==null&&this.undoRefs(n),this.update(c,p),h(g)})}):(n!==null&&this.undoRefs(n),h(null))}))}undoRefs(e,t){t=t?new Set(t):null,this.isConnected()&&d.all(document,`[${te}="${this.id}"][${N}="${e}"]`,i=>{if(t&&!t.has(i))return;i.dispatchEvent(new CustomEvent("phx:unlock",{bubbles:!0,cancelable:!1}));let s=i.getAttribute(ce),n=i.getAttribute(rt);i.removeAttribute(N),i.removeAttribute(te),n!==null&&(i.readOnly=n==="true",i.removeAttribute(rt)),s!==null&&(i.disabled=s==="true",i.removeAttribute(ce)),ti.forEach(a=>d.removeClass(i,a));let r=i.getAttribute(Fe);r!==null&&(i.innerText=r,i.removeAttribute(Fe));let o=d.private(i,N);if(o){let a=this.triggerBeforeUpdateHook(i,o);je.patchEl(i,o,this.liveSocket.getActiveElement()),a&&a.__updated(),d.deletePrivate(i,N)}})}putRef(e,t,i={}){let s=this.ref++,n=this.binding(gt);i.loading&&(e=e.concat(d.all(document,i.loading)));for(let r of e){if(r.setAttribute(N,s),r.setAttribute(te,this.el.id),i.submitter&&!(r===i.submitter||r===i.form))continue;r.classList.add(`phx-${t}-loading`),r.dispatchEvent(new CustomEvent(`phx:${t}-loading`,{bubbles:!0,cancelable:!1}));let o=r.getAttribute(n);o!==null&&(r.getAttribute(Fe)||r.setAttribute(Fe,r.innerText),o!==""&&(r.innerText=o),r.setAttribute(ce,r.getAttribute(ce)||r.disabled),r.setAttribute("disabled",""))}return[s,e,i]}componentID(e){let t=e.getAttribute&&e.getAttribute(K);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(z(t))return t;let s=i.target||e.getAttribute(this.binding("target"));return z(s)?parseInt(s):t&&(s!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return z(e)?e:e?ie(e.closest(`[${K}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,s,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",i,s]),!1;let[r,o,a]=this.putRef([e],"hook");return this.pushWithReply(()=>[r,o,a],"event",{type:"hook",event:i,value:s,cid:this.closestComponentID(t)},(l,h)=>n(h,r)),r}extractMeta(e,t,i){let s=this.binding("value-");for(let n=0;n=0&&!e.checked&&delete t.value),i){t||(t={});for(let n in i)t[n]=i[n]}return t}pushEvent(e,t,i,s,n,r={},o){this.pushWithReply(()=>this.putRef([t],e,r),"event",{type:e,event:s,value:this.extractMeta(t,n,r.value),cid:this.targetComponentID(t,i,r)},(a,l)=>o&&o(l))}pushFileProgress(e,t,i,s=function(){}){this.liveSocket.withinOwners(e.form,(n,r)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(qi)),ref:e.getAttribute(G),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,r)},s)})}pushInput(e,t,i,s,n,r){let o,a=z(i)?i:this.targetComponentID(e.form,t,n),l=()=>this.putRef([e,e.form],"change",n),h,c=this.extractMeta(e.form);e instanceof HTMLButtonElement&&(c.submitter=e),e.getAttribute(this.binding("change"))?h=Be(e.form,U({_target:n._target},c),[e.name]):h=Be(e.form,U({_target:n._target},c)),d.isUploadInput(e)&&e.files&&e.files.length>0&&_.trackFiles(e,Array.from(e.files)),o=_.serializeUploads(e);let g={type:"form",event:s,value:h,uploads:o,cid:a};this.pushWithReply(l,"event",g,p=>{if(d.showError(e,this.liveSocket.binding(qe),this.liveSocket.binding(Xe)),d.isUploadInput(e)&&d.isAutoUpload(e)){if(_.filesAwaitingPreflight(e).length>0){let[f,m]=l();this.undoRefs(f,[e.form]),this.uploadFiles(e.form,t,f,a,v=>{r&&r(p),this.triggerAwaitingSubmit(e.form),this.undoRefs(f)})}}else r&&r(p)})}triggerAwaitingSubmit(e){let t=this.getScheduledSubmit(e);if(t){let[i,s,n,r]=t;this.cancelSubmit(e),r()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,s,n])=>t.isSameNode(e))}scheduleSubmit(e,t,i,s){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,s])}cancelSubmit(e){this.formSubmits=this.formSubmits.filter(([t,i,s])=>t.isSameNode(e)?(this.undoRefs(i),!1):!0)}disableForm(e,t={}){let i=c=>!(_e(c,`${this.binding(ze)}=ignore`,c.form)||_e(c,"data-phx-update=ignore",c.form)),s=c=>c.hasAttribute(this.binding(gt)),n=c=>c.tagName=="BUTTON",r=c=>["INPUT","TEXTAREA","SELECT"].includes(c.tagName),o=Array.from(e.elements),a=o.filter(s),l=o.filter(n).filter(i),h=o.filter(r).filter(i);return l.forEach(c=>{c.setAttribute(ce,c.disabled),c.disabled=!0}),h.forEach(c=>{c.setAttribute(rt,c.readOnly),c.readOnly=!0,c.files&&(c.setAttribute(ce,c.disabled),c.disabled=!0)}),e.setAttribute(this.binding(xt),""),this.putRef([e].concat(a).concat(l).concat(h),"submit",t)}pushFormSubmit(e,t,i,s,n,r){let o=()=>this.disableForm(e,Et(U({},n),{form:e,submitter:s})),a=this.targetComponentID(e,t);if(_.hasUploadsInProgress(e)){let[l,h]=o(),c=()=>this.pushFormSubmit(e,t,i,s,n,r);return this.scheduleSubmit(e,l,n,c)}else if(_.inputsAwaitingPreflight(e).length>0){let[l,h]=o(),c=()=>[l,h,n];this.uploadFiles(e,t,l,a,g=>{if(_.inputsAwaitingPreflight(e).length>0)return this.undoRefs(l);let p=this.extractMeta(e),f=Be(e,U({submitter:s},p));this.pushWithReply(c,"event",{type:"form",event:i,value:f,cid:a},r)})}else if(!(e.hasAttribute(N)&&e.classList.contains("phx-submit-loading"))){let l=this.extractMeta(e),h=Be(e,U({submitter:s},l));this.pushWithReply(o,"event",{type:"form",event:i,value:h,cid:a},r)}}uploadFiles(e,t,i,s,n){let r=this.joinCount,o=_.activeFileInputs(e),a=o.length;o.forEach(l=>{let h=new _(l,this,()=>{a--,a===0&&n()}),c=h.entries().map(p=>p.toPreflightPayload());if(c.length===0){a--;return}let g={ref:l.getAttribute(G),entries:c,cid:this.targetComponentID(l.form,t)};this.log("upload",()=>["sending preflight request",g]),this.pushWithReply(null,"allow_upload",g,p=>{if(this.log("upload",()=>["got preflight response",p]),h.entries().forEach(f=>{p.entries&&!p.entries[f.ref]&&this.handleFailedEntryPreflight(f.ref,"failed preflight",h)}),p.error||Object.keys(p.entries).length===0)this.undoRefs(i),(p.error||[]).map(([m,v])=>{this.handleFailedEntryPreflight(m,v,h)});else{let f=m=>{this.channel.onError(()=>{this.joinCount===r&&m()})};h.initAdapterUpload(p,f,this.liveSocket)}})})}handleFailedEntryPreflight(e,t,i){if(i.isAutoUpload()){let s=i.entries().find(n=>n.ref===e.toString());s&&s.cancel()}else i.entries().map(s=>s.cancel());this.log("upload",()=>[`error for entry ${e}`,t])}dispatchUploads(e,t,i){let s=this.targetCtxElement(e)||this.el,n=d.findUploadInputs(s).filter(r=>r.name===t);n.length===0?M(`no live file inputs found matching the name "${t}"`):n.length>1?M(`duplicate live file inputs found matching the name "${t}"`):d.dispatchEvent(n[0],ii,{detail:{files:i}})}targetCtxElement(e){if(z(e)){let[t]=d.findComponentNodeList(this.el,e);return t}else return e||null}pushFormRecovery(e,t,i,s){let n=this.binding("change"),r=t.getAttribute(this.binding("target"))||t,o=t.getAttribute(this.binding(Dt))||t.getAttribute(this.binding("change")),a=Array.from(e.elements).filter(c=>d.isFormInput(c)&&c.name&&!c.hasAttribute(n));if(a.length===0)return;a.forEach(c=>c.hasAttribute(G)&&_.clearFiles(c));let l=a.find(c=>c.type!=="hidden")||a[0],h=0;this.withinTargets(r,(c,g)=>{let p=this.targetComponentID(t,g);h++,c.pushInput(l,g,p,o,{_target:l.name},()=>{h--,h===0&&s()})},i,i)}pushLinkPatch(e,t,i){let s=this.liveSocket.setPendingLink(e),n=t?()=>this.putRef([t],"click"):null,r=()=>this.liveSocket.redirect(window.location.href),o=e.startsWith("/")?`${location.protocol}//${location.host}${e}`:e,a=this.pushWithReply(n,"live_patch",{url:o},l=>{this.liveSocket.requestDOMUpdate(()=>{l.link_redirect?this.liveSocket.replaceMain(e,null,i,s):(this.liveSocket.commitPendingLink(s)&&(this.href=e),this.applyPendingUpdates(),i&&i(s))})});a?a.receive("timeout",r):r()}getFormsForRecovery(){if(this.joinCount===0)return{};let e=this.binding("change");return d.all(this.el,`form[${e}]`).filter(t=>t.id).filter(t=>t.elements.length>0).filter(t=>t.getAttribute(this.binding(Dt))!=="ignore").map(t=>t.cloneNode(!0)).reduce((t,i)=>(t[i.id]=i,t),{})}maybePushComponentsDestroyed(e){let t=e.filter(i=>d.findComponentNodeList(this.el,i).length===0);t.length>0&&(t.forEach(i=>this.rendered.resetRender(i)),this.pushWithReply(null,"cids_will_destroy",{cids:t},()=>{this.liveSocket.requestDOMUpdate(()=>{let i=t.filter(s=>d.findComponentNodeList(this.el,s).length===0);i.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:i},s=>{this.rendered.pruneCIDs(s.cids)})})}))}ownsElement(e){let t=e.closest(me);return e.getAttribute(ae)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,s,n={}){d.putPrivate(e,We,!0);let r=this.liveSocket.binding(qe),o=this.liveSocket.binding(Xe),a=Array.from(e.elements);a.forEach(l=>d.putPrivate(l,We,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,s,n,()=>{a.forEach(l=>d.showError(l,r,o)),this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}},di=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(` a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example: import {Socket} from "phoenix" import {LiveSocket} from "phoenix_live_view" let liveSocket = new LiveSocket("/live", Socket, {...}) `);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||zi,this.opts=i,this.params=ke(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(Ve(Gi),i.defaults||{}),this.activeElement=null,this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=Ve(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Xi,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||Oi,this.reloadJitterMin=i.reloadJitterMin||Di,this.reloadJitterMax=i.reloadJitterMax||Hi,this.failsafeJitter=i.failsafeJitter||Fi,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.serverCloseRef=null,this.domCallbacks=Object.assign({onPatchStart:ke(),onPatchEnd:ke(),onNodeAdded:ke(),onBeforeElUpdated:ke()},i.dom||{}),this.transitions=new Ts,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}version(){return"0.20.17"}isProfileEnabled(){return this.sessionStorage.getItem(lt)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Ne)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Ne)==="false"}enableDebug(){this.sessionStorage.setItem(Ne,"true")}enableProfiling(){this.sessionStorage.setItem(lt,"true")}disableDebug(){this.sessionStorage.setItem(Ne,"false")}disableProfiling(){this.sessionStorage.removeItem(lt)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(ht,e)}disableLatencySim(){this.sessionStorage.removeItem(ht)}getLatencySim(){let e=this.sessionStorage.getItem(ht);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let e=()=>{this.joinRootViews()?(this.bindTopLevelEvents(),this.socket.connect()):this.main?this.socket.connect():this.bindTopLevelEvents({dead:!0}),this.joinDeadView()};["complete","loaded","interactive"].indexOf(document.readyState)>=0?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.serverCloseRef&&(this.socket.off(this.serverCloseRef),this.serverCloseRef=null),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){this.owner(e,s=>O.exec(i,t,s,e))}execJSHookPush(e,t,i,s){this.withinOwners(e,n=>{O.exec("hook",t,n,e,["push",{data:i,callback:s}])})}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(e,t){this.domCallbacks[e](...t)}time(e,t){if(!this.isProfileEnabled()||!console.time)return t();console.time(e);let i=t();return console.timeEnd(e),i}log(e,t,i){if(this.viewLogger){let[s,n]=i();this.viewLogger(e,t,s,n)}else if(this.isDebugEnabled()){let[s,n]=i();es(e,t,s,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,s=>{let n=this.getLatencySim();n?setTimeout(()=>i(s),n):i(s)})}wrapPush(e,t,i){let s=this.getLatencySim(),n=e.joinCount;if(!s)return this.isConnected()&&t.timeout?i().receive("timeout",()=>{e.joinCount===n&&!e.isDestroyed()&&this.reloadWithJitter(e,()=>{this.log(e,"timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}):i();let r={receives:[],receive(o,a){this.receives.push([o,a])}};return setTimeout(()=>{e.isDestroyed()||r.receives.reduce((o,[a,l])=>o.receive(a,l),i())},s),r}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,s=this.reloadJitterMax,n=Math.floor(Math.random()*(s-i+1))+i,r=V.updateLocal(this.localStorage,window.location.pathname,ei,0,o=>o+1);r>this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{e.isDestroyed()||e.isConnected()||(e.destroy(),t?t():this.log(e,"join",()=>[`encountered ${r} consecutive reloads`]),r>this.maxReloads&&this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?ls[e.split(".")[1]]:this.hooks[e]}isUnloaded(){return this.unloaded}isConnected(){return this.socket.isConnected()}getBindingPrefix(){return this.bindingPrefix}binding(e){return`${this.getBindingPrefix()}${e}`}channel(e,t){return this.socket.channel(e,t)}joinDeadView(){let e=document.body;if(e&&!this.isPhxView(e)&&!this.isPhxView(document.firstElementChild)){let t=this.newRootView(e);t.setHref(this.getHref()),t.joinDead(),this.main||(this.main=t),window.requestAnimationFrame(()=>t.execNewMounted())}}joinRootViews(){let e=!1;return d.all(document,`${me}:not([${ae}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);i.setHref(this.getHref()),i.join(),t.hasAttribute(bt)&&(this.main=i)}e=!0}),e}redirect(e,t){this.unload(),V.redirect(e,t)}replaceMain(e,t,i=null,s=this.setPendingLink(e)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let r=d.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(r,t,n),this.main.setRedirect(e),this.transitionRemoves(null,!0),this.main.join((o,a)=>{o===1&&this.commitPendingLink(s)&&this.requestDOMUpdate(()=>{d.findPhxSticky(document).forEach(l=>r.appendChild(l)),this.outgoingMainEl.replaceWith(r),this.outgoingMainEl=null,i&&i(s),a()})})}transitionRemoves(e,t){let i=this.binding("remove");if(e=e||d.all(document,`[${i}]`),t){let s=d.findPhxSticky(document)||[];e=e.filter(n=>!d.isChildOfAny(n,s))}e.forEach(s=>{this.execJS(s,s.getAttribute(i),"remove")})}isPhxView(e){return e.getAttribute&&e.getAttribute(Y)!==null}newRootView(e,t,i){let s=new hi(e,this,null,t,i);return this.roots[s.id]=s,s}owner(e,t){let i=ie(e.closest(me),s=>this.getViewByEl(s))||this.main;i&&t(i)}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(le);return ie(this.getRootById(t),i=>i.getDescendentByEl(e))}getRootById(e){return this.roots[e]}destroyAllViews(){for(let e in this.roots)this.roots[e].destroy(),delete this.roots[e];this.main=null}destroyViewByEl(e){let t=this.getRootById(e.getAttribute(le));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}setActiveElement(e){if(this.activeElement===e)return;this.activeElement=e;let t=()=>{e===this.activeElement&&(this.activeElement=null),e.removeEventListener("mouseup",this),e.removeEventListener("touchend",this)};e.addEventListener("mouseup",t),e.addEventListener("touchend",t)}getActiveElement(){return document.activeElement===document.body?this.activeElement||document.activeElement:document.activeElement||document.body}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents({dead:e}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.serverCloseRef=this.socket.onClose(t=>{if(t&&t.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",t=>{t.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),e||this.bindNav(),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(t,i,s,n,r,o)=>{let a=n.getAttribute(this.binding(Vi)),l=t.key&&t.key.toLowerCase();if(a&&a.toLowerCase()!==l)return;let h=U({key:t.key},this.eventMeta(i,t,n));O.exec(i,r,s,n,["push",{data:h}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,s,n,r,o)=>{if(!o){let a=U({key:t.key},this.eventMeta(i,t,n));O.exec(i,r,s,n,["push",{data:a}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,s,n,r,o)=>{if(o==="window"){let a=this.eventMeta(i,t,n);O.exec(i,r,s,n,["push",{data:a}])}}),window.addEventListener("dragover",t=>t.preventDefault()),window.addEventListener("drop",t=>{t.preventDefault();let i=ie(_e(t.target,this.binding(Rt)),r=>r.getAttribute(this.binding(Rt))),s=i&&document.getElementById(i),n=Array.from(t.dataTransfer.files||[]);!s||s.disabled||n.length===0||!(s.files instanceof FileList)||(_.trackFiles(s,n,t.dataTransfer),s.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(ii,t=>{let i=t.target;if(!d.isUploadInput(i))return;let s=Array.from(t.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);_.trackFiles(i,s),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let s=this.metadataCallbacks[e];return s?s(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.linkRef}commitPendingLink(e){return this.linkRef!==e?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(e,t){for(let i in e){let s=e[i];this.on(s,n=>{let r=this.binding(i),o=this.binding(`window-${i}`),a=n.target.getAttribute&&n.target.getAttribute(r);a?this.debounce(n.target,n,s,()=>{this.withinOwners(n.target,l=>{t(n,i,l,n.target,a,null)})}):d.all(document,`[${o}]`,l=>{let h=l.getAttribute(o);this.debounce(l,n,s,()=>{this.withinOwners(l,c=>{t(n,i,c,l,h,"window")})})})})}}bindClicks(){window.addEventListener("mousedown",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click")}bindClick(e,t){let i=this.binding(t);window.addEventListener(e,s=>{let n=null;s.detail===0&&(this.clickStartedAtTarget=s.target);let r=this.clickStartedAtTarget||s.target;n=_e(r,i),this.dispatchClickAway(s,r),this.clickStartedAtTarget=null;let o=n&&n.getAttribute(i);if(!o){d.isNewPageClick(s,window.location)&&this.unload();return}n.getAttribute("href")==="#"&&s.preventDefault(),!n.hasAttribute(N)&&this.debounce(n,s,"click",()=>{this.withinOwners(n,a=>{O.exec("click",o,a,n,["push",{data:this.eventMeta("click",s,n)}])})})},!1)}dispatchClickAway(e,t){let i=this.binding("click-away");d.all(document,`[${i}]`,s=>{s.isSameNode(t)||s.contains(t)||this.withinOwners(s,n=>{let r=s.getAttribute(i);O.isVisible(s)&&O.isInViewport(s)&&O.exec("click",r,n,s,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!V.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{V.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,id:s,root:n,scroll:r}=t.state||{},o=window.location.href;d.dispatchEvent(window,"phx:navigate",{detail:{href:o,patch:i==="patch",pop:!0}}),this.requestDOMUpdate(()=>{this.main.isConnected()&&i==="patch"&&s===this.main.id?this.main.pushLinkPatch(o,null,()=>{this.maybeScroll(r)}):this.replaceMain(o,null,()=>{n&&this.replaceRootHistory(),this.maybeScroll(r)})})},!1),window.addEventListener("click",t=>{let i=_e(t.target,st),s=i&&i.getAttribute(st);if(!s||!this.isConnected()||!this.main||d.wantsNewTab(t))return;let n=i.href instanceof SVGAnimatedString?i.href.baseVal:i.href,r=i.getAttribute(Mi);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==n&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(n,r,i);else if(s==="redirect")this.historyRedirect(n,r);else throw new Error(`expected ${st} to be "patch" or "redirect", got: ${s}`);let o=i.getAttribute(this.binding("click"));o&&this.requestDOMUpdate(()=>this.execJS(i,o,"click"))})},!1)}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}dispatchEvent(e,t={}){d.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){d.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>d.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i){if(!this.isConnected()||!this.main.isMain())return V.redirect(e);this.withPageLoading({to:e,kind:"patch"},s=>{this.main.pushLinkPatch(e,i,n=>{this.historyPatch(e,t,n),s()})})}historyPatch(e,t,i=this.setPendingLink(e)){this.commitPendingLink(i)&&(V.pushState(t,{type:"patch",id:this.main.id},e),d.dispatchEvent(window,"phx:navigate",{detail:{patch:!0,href:e,pop:!1}}),this.registerNewLocation(window.location))}historyRedirect(e,t,i){if(!this.isConnected()||!this.main.isMain())return V.redirect(e,i);if(/^\/$|^\/[^\/]+.*$/.test(e)){let{protocol:n,host:r}=window.location;e=`${n}//${r}${e}`}let s=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},n=>{this.replaceMain(e,i,r=>{r===this.linkRef&&(V.pushState(t,{type:"redirect",id:this.main.id,scroll:s},e),d.dispatchEvent(window,"phx:navigate",{detail:{href:e,patch:!1,pop:!1}}),this.registerNewLocation(window.location)),n()})})}replaceRootHistory(){V.pushState("replace",{root:!0,type:"patch",id:this.main.id})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=Ve(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit")),n=i.target.getAttribute(this.binding("change"));!t&&n&&!s&&(t=!0,i.preventDefault(),this.withinOwners(i.target,r=>{r.disableForm(i.target),window.requestAnimationFrame(()=>{d.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))},!0),this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit"));if(!s){d.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{O.exec("submit",s,n,i.target,["push",{submitter:i.submitter}])})},!1);for(let i of["change","input"])this.on(i,s=>{let n=this.binding("change"),r=s.target,o=r.getAttribute(n),a=r.form&&r.form.getAttribute(n),l=o||a;if(!l||r.type==="number"&&r.validity&&r.validity.badInput)return;let h=o?r:r.form,c=e;e++;let{at:g,type:p}=d.private(r,"prev-iteration")||{};g===c-1&&i==="change"&&p==="input"||(d.putPrivate(r,"prev-iteration",{at:c,type:i}),this.debounce(r,s,i,()=>{this.withinOwners(h,f=>{d.putPrivate(r,mt,!0),d.isTextualInput(r)||this.setActiveElement(r),O.exec("change",l,f,r,["push",{_target:s.target.name,dispatcher:h}])})}))},!1);this.on("reset",i=>{let s=i.target;d.resetForm(s,this.binding(qe),this.binding(Xe));let n=Array.from(s.elements).find(r=>r.type==="reset");n&&window.requestAnimationFrame(()=>{n.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,t,i,s){if(i==="blur"||i==="focusout")return s();let n=this.binding(Bi),r=this.binding(Ji),o=this.defaults.debounce.toString(),a=this.defaults.throttle.toString();this.withinOwners(e,l=>{let h=()=>!l.isDestroyed()&&document.body.contains(e);d.debounce(e,t,n,o,r,a,h,()=>{s()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){window.addEventListener(e,i=>{this.silenced||t(i)})}},Ts=class{constructor(){this.transitions=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let s=setTimeout(()=>{this.transitions.delete(s),i(),this.flushPendingOps()},e);this.transitions.add(s)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){if(this.size()>0)return;let e=this.pendingOps.shift();e&&(e(),this.flushPendingOps())}};var Ge=Ci(ui());var fi={mounted(){let e=this,t=1;this.el.dataset.selectable&&(t=JSON.parse(this.el.dataset.selectable));let i=new Tabulator(this.el,{columns:JSON.parse(this.el.dataset.columns),selectable:t,ajaxURL:"dummy_url",ajaxRequestFunc:(s,n,r)=>new Promise((o,a)=>{this.pushEventTo(this.el,"fetch_data",r,(l,h)=>{o(l)})}),filterMode:"remote",sortMode:"remote",pagination:!0,paginationMode:"remote",selectablePersistence:!0});i.on("rowSelectionChanged",function(s,n,r,o){t==!0&&t!==1&&e.pushEventTo(e.el,"tabulator_rowselection_changed",s)}),i.on("cellEditing",function(s){console.log(s),e.pushEventTo(e.el,"cellediting",s.getData())}),i.on("cellEdited",function(s){console.log(s),e.pushEventTo(e.el,"celledited",s.getData())}),i.on("rowSelected",function(s){e.pushEventTo(e.el,"tabulator_rowselected",s.getData())}),i.on("rowDeselected",function(s){e.pushEventTo(e.el,"tabulator_rowdeselected",{})}),i.on("dataProcessed",function(){this.rowManager.rows.forEach(n=>{n.data.selected!=null&&this.selectRow(n)})}),this.handleEvent("update_tabulator",function(s){i.setData()})}};var pi={Tabulator:fi};console.log(pi);var _s=document.querySelector("meta[name='csrf-token']").getAttribute("content"),mi=new di("/api/live",_t,{hooks:pi,params:{_csrf_token:_s}});Ge.default.config({barColors:{0:"#29d"},shadowColor:"rgba(0, 0, 0, .3)"});window.addEventListener("phx:page-loading-start",e=>Ge.default.show(300));window.addEventListener("phx:page-loading-stop",e=>Ge.default.hide());mi.connect();window.liveSocket=mi;})(); /** * @license MIT * topbar 2.0.0, 2023-02-04 * https://buunguyen.github.io/topbar * Copyright (c) 2021 Buu Nguyen */