(()=>{var di=Object.create;var Qe=Object.defineProperty;var ci=Object.getOwnPropertyDescriptor;var ui=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols,fi=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable;var St=(e,t,i)=>t in e?Qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,X=(e,t)=>{for(var i in t||(t={}))Ze.call(t,i)&&St(e,i,t[i]);if(_e)for(var i of _e(t))Et.call(t,i)&&St(e,i,t[i]);return e};var kt=(e,t)=>{var i={};for(var s in e)Ze.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(e!=null&&_e)for(var s of _e(e))t.indexOf(s)<0&&Et.call(e,s)&&(i[s]=e[s]);return i};var pi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var mi=(e,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ui(t))!Ze.call(e,n)&&n!==i&&Qe(e,n,{get:()=>t[n],enumerable:!(s=ci(t,n))||s.enumerable});return e};var gi=(e,t,i)=>(i=e!=null?di(fi(e)):{},mi(t||!e||!e.__esModule?Qe(i,"default",{value:e,enumerable:!0}):i,e));var Pt=pi((_t,Le)=>{(function(e,t){"use strict";(function(){for(var f=0,p=["ms","moz","webkit","o"],v=0;vg.show(),f)}else n=!0,o!==null&&e.cancelAnimationFrame(o),i||m(),i.style.opacity=1,i.style.display="block",g.progress(0),h.autoRun&&function p(){r=e.requestAnimationFrame(p),g.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(g.progress("+.1")>=1&&(i.style.opacity-=.05,i.style.opacity<=.05)){i.style.display="none",o=null;return}o=e.requestAnimationFrame(f)}())}};typeof Le=="object"&&typeof Le.exports=="object"?Le.exports=g:typeof define=="function"&&define.amd?define(function(){return g}):this.topbar=g}).call(_t,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"),m=n.getAttribute("target");h.method=n.getAttribute("data-method")==="get"?"get":"post",h.action=o,h.style.display="none",m?h.target=m: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 ue=e=>typeof e=="function"?e:function(){return e},vi=typeof self!="undefined"?self:null,ce=typeof window!="undefined"?window:null,fe=vi||ce||fe,bi="2.0.0",j={connecting:0,open:1,closing:2,closed:3},yi=1e4,wi=1e3,H={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},q={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},tt={longpoll:"longpoll",websocket:"websocket"},Ai={complete:4},Pe=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})}},Ct=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))}},Si=class{constructor(e,t,i){this.state=H.closed,this.topic=e,this.params=ue(t||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Pe(this,q.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new Ct(()=>{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=H.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=H.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=H.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=H.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 Pe(this,q.leave,ue({}),this.timeout).send(),this.state=H.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(q.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(q.close,e)}onError(e){return this.on(q.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 Pe(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=H.leaving;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(q.close,"leave")},i=new Pe(this,q.leave,ue({}),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=H.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===Ai.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)}`}},Ei=e=>{let t="",i=new Uint8Array(e),s=i.byteLength;for(let n=0;nthis.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=Ei(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=Re.request(e,this.endpointURL(),t,i,this.timeout,o,a=>{this.reqs.delete(r),this.isActive()&&n(a)}),this.reqs.add(r)}};var xe={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,m=>l.setUint8(h++,m.charCodeAt(0))),Array.from(i,m=>l.setUint8(h++,m.charCodeAt(0))),Array.from(n,m=>l.setUint8(h++,m.charCodeAt(0))),Array.from(s,m=>l.setUint8(h++,m.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 m=i.decode(e.slice(a,a+o));a=a+o;let g=e.slice(a,e.byteLength),f={status:m,response:g};return{join_ref:l,ref:h,topic:c,event:q.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}}},Tt=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=t.timeout||yi,this.transport=t.transport||fe.WebSocket||et,this.establishedConnections=0,this.defaultEncoder=xe.encode.bind(xe),this.defaultDecoder=xe.decode.bind(xe),this.closeWasClean=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.transport!==et?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;ce&&ce.addEventListener&&(ce.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock)}),ce.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.longpollerTimeout=t.longpollerTimeout||2e4,this.params=ue(t.params||{}),this.endPoint=`${e}/${tt.websocket}`,this.vsn=t.vsn||bi,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new Ct(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return et}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,this.reconnectTimer.reset(),this.sendBuffer=[],this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=Re.appendParams(Re.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,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=ue(e)),!this.conn&&(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=t=>this.onConnError(t),this.conn.onmessage=t=>this.onConnMessage(t),this.conn.onclose=t=>this.onConnClose(t))}log(e,t,i){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}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`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(),wi,"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(q.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.joinRef()!==e.joinRef())}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 Si(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 ze=gi(Pt());var Qt="consecutive-reloads",ki=10,Ci=5e3,Ti=1e4,_i=3e4,Zt=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],M="data-phx-component",it="data-phx-link",Pi="track-static",xi="data-phx-link-state",U="data-phx-ref",ne="data-phx-ref-src",ei="track-uploads",ee="data-phx-upload-ref",gt="data-phx-preflighted-refs",Ri="data-phx-done-refs",xt="drop-target",ut="data-phx-active-refs",Je="phx:live-file:updated",ft="data-phx-skip",Rt="data-phx-prune",Lt="page-loading",It="phx-connected",pe="phx-loading",st="phx-no-feedback",Ie="phx-error",Dt="phx-client-error",nt="phx-server-error",ae="data-phx-parent-id",vt="data-phx-main",Ee="data-phx-root-id",ti="viewport-top",ii="viewport-bottom",Li="trigger-action",Xe="feedback-for",pt="phx-has-focused",Ii=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],si=["checkbox","radio"],qe="phx-has-submitted",te="data-phx-session",he=`[${te}]`,Ot="data-phx-sticky",Ae="data-phx-static",rt="data-phx-readonly",De="data-phx-disabled",mt="disable-with",Oe="data-phx-disable-with-restore",me="hook",Di="debounce",Oi="throttle",We="update",ot="stream",ge="data-phx-stream",Hi="key",B="phxPrivate",Ht="auto-recover",He="phx:live-socket:debug",at="phx:live-socket:profiling",lt="phx:live-socket:latency-sim",Ni="progress",Nt="mounted",Mi=1,Fi=200,Ui="phx-",$i=3e4,ve="debounce-trigger",Ne="throttled",Mt="debounce-prev-key",ji={debounce:300,throttle:300},Me="d",J="s",N="c",Ft="e",Ut="r",$t="t",Bi="p",jt="stream",Ji=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.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 x("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))}},x=(e,t)=>console.error&&console.error(e,t),W=e=>{let t=typeof e;return t==="number"||t==="string"&&/^(0|[1-9]\d*)$/.test(e)};function Vi(){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)},ht=e=>typeof e=="function"?e:function(){return e},Ve=e=>JSON.parse(JSON.stringify(e)),Se=(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(he)));return null},be=e=>e!==null&&typeof e=="object"&&!(e instanceof Array),qi=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Bt=e=>{for(let t in e)return!1;return!0},Z=(e,t)=>e&&t(e),Wi=function(e,t,i,s){e.forEach(n=>{new Ji(n,i.config.chunk_size,s).upload()})},ni={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&&ni.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=ni,F={byId(e){return document.getElementById(e)||x(`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(ee)!==null},isAutoUpload(e){return e.hasAttribute("data-phx-auto-upload")},findUploadInputs(e){return this.all(e,`input[type="file"][${ee}]`)},findComponentNodeList(e,t){return this.filterWithinSameLiveView(this.all(e,`[${M}="${t}"]`),e)},isPhxDestroyed(e){return!!(e.id&&F.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";return t||s||i},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(te,""),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,`${he}[${ae}="${t}"]`)},findParentCIDs(e,t){let i=new Set(t),s=t.reduce((n,r)=>{let o=`[${M}="${r}"] [${M}]`;return this.filterWithinSameLiveView(this.all(e,o),e).map(a=>parseInt(a.getAttribute(M))).forEach(a=>n.delete(a)),n},i);return s.size===0?new Set(t):s},filterWithinSameLiveView(e,t){return t.querySelector(he)?e.filter(i=>this.withinSameLiveView(i,t)):e},withinSameLiveView(e,t){for(;e=e.parentNode;){if(e.isSameNode(t))return!0;if(e.getAttribute(te)!==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",()=>a());return;default:let m=parseInt(c),g=()=>h?this.deletePrivate(e,Ne):a(),f=this.incCycle(e,ve,g);if(isNaN(m))return x(`invalid throttle/debounce value: ${c}`);if(h){let v=!1;if(t.type==="keydown"){let C=this.private(e,Mt);this.putPrivate(e,Mt,t.key),v=C!==t.key}if(!v&&this.private(e,Ne))return!1;a(),this.putPrivate(e,Ne,!0),setTimeout(()=>{o()&&this.triggerCycle(e,ve)},m)}else setTimeout(()=>{o()&&this.triggerCycle(e,ve,f)},m);let p=e.form;p&&this.once(p,"bind-debounce")&&p.addEventListener("submit",()=>{Array.from(new FormData(p).entries(),([v])=>{let C=p.querySelector(`[name="${v}"]`);this.incCycle(C,ve),this.deletePrivate(C,Ne)})}),this.once(e,"bind-debounce")&&e.addEventListener("blur",()=>this.triggerCycle(e,ve))}},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")},maybeHideFeedback(e,t,i){if(!(this.private(t,pt)||this.private(t,qe))){let s=[t.name];t.name.endsWith("[]")&&s.push(t.name.slice(0,-2));let n=s.map(r=>`[${i}="${r}"]`).join(", ");F.all(e,n,r=>r.classList.add(st))}},resetForm(e,t){Array.from(e.elements).forEach(i=>{let s=`[${t}="${i.id}"], [${t}="${i.name}"], [${t}="${i.name.replace(/\[\]$/,"")}"]`;this.deletePrivate(i,pt),this.deletePrivate(i,qe),this.all(document,s,n=>{n.classList.add(st)})})},showError(e,t){(e.id||e.name)&&this.all(e.form,`[${t}="${e.id}"], [${t}="${e.name}"]`,i=>{this.removeClass(i,st)})},isPhxChild(e){return e.getAttribute&&e.getAttribute(ae)},isPhxSticky(e){return e.getAttribute&&e.getAttribute(Ot)!==null},firstPhxChild(e){return this.isPhxChild(e)?e:this.all(e,`[${ae}]`)[0]},dispatchEvent(e,t,i={}){let n={bubbles:i.bubbles===void 0?!0:!!i.bubbles,cancelable:!0,detail:i.detail||{}},r=t==="click"?new MouseEvent("click",n):new CustomEvent(t,n);e.dispatchEvent(r)},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=i.exclude||[],n=i.isIgnored,r=t.attributes;for(let a=r.length-1;a>=0;a--){let l=r[a].name;s.indexOf(l)<0&&e.setAttribute(l,t.getAttribute(l))}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)&&e.removeAttribute(l):t.hasAttribute(l)||e.removeAttribute(l)}},mergeFocusedInput(e,t){e instanceof HTMLSelectElement||F.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(!F.isTextualInput(e))return;let s=e.matches(":focus");e.readOnly&&e.blur(),s||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&&si.indexOf(e.type.toLocaleLowerCase())>=0&&(e.checked=e.getAttribute("checked")!==null)},isTextualInput(e){return Ii.indexOf(e.type)>=0},isNowTriggerFormExternal(e,t){return e.getAttribute&&e.getAttribute(t)!==null},syncPendingRef(e,t,i){let s=e.getAttribute(U);if(s===null)return!0;let n=e.getAttribute(ne);return F.isFormInput(e)||e.getAttribute(i)!==null?(F.isUploadInput(e)&&F.mergeAttrs(e,t,{isIgnored:!0}),F.putPrivate(e,U,t),!1):(Zt.forEach(r=>{e.classList.contains(r)&&t.classList.add(r)}),t.setAttribute(U,s),t.setAttribute(ne,n),!0)},cleanChildNodes(e,t){if(F.isPhxUpdate(e,t,["append","prepend"])){let i=[];e.childNodes.forEach(s=>{s.id||(s.nodeType===Node.TEXT_NODE&&s.nodeValue.trim()===""||x(`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",te,Ae,vt,Ee]);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=(F.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=F.private(e,"sticky");t&&t.forEach(([i,s,n])=>this.putSticky(e,i,s))}},d=F,dt=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(ut).split(",").indexOf(P.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(gt).split(",").indexOf(P.genFileRef(t))>=0&&this.isActive(e,t)}constructor(e,t,i){this.ref=P.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)}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,()=>{P.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}cancel(){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}),d.isAutoUpload(this.fileEl)||P.clearFiles(this.fileEl)}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(Je,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(ut).split(",").indexOf(this.ref)===-1&&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]||x(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:Wi}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||x(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}},zi=0,P=class{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(zi++).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(gt)!==i.getAttribute(Ri)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(s=>{let n={path:e.name},r=e.getAttribute(ee);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(ee),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.putPrivate(e,"files",this.activeFiles(e).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=>dt.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=>!dt.isPreflighted(e,t))}constructor(e,t,i){this.view=t,this.onComplete=i,this._entries=Array.from(P.filesAwaitingPreflight(e)||[]).map(s=>new dt(e,s,t)),this.numEntriesInProgress=this._entries.length}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(n=>(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)}}},Ki={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.tabIndex===0&&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}}},le=Ki,ri={LiveFileUpload:{activeRefs(){return this.el.getAttribute(ut)},preflightedRefs(){return this.el.getAttribute(gt)},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(ee)),P.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",()=>le.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>le.focusFirst(this.el)),this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&le.focusFirst(this.el)}}},Jt=()=>document.documentElement.scrollTop||document.body.scrollTop,bt=()=>window.innerHeight||document.documentElement.clientHeight,Gi=e=>{let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.top<=bt()},Yi=e=>{let t=e.getBoundingClientRect();return t.right>=0&&t.left>=0&&t.bottom<=bt()},Vt=e=>{let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.top<=bt()};ri.InfiniteScroll={mounted(){let e=Jt(),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,Vt(l)||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,Vt(l)||l.scrollIntoView({block:"end"})})});this.onScroll=a=>{let l=Jt();if(s)return e=l,s();let h=this.el.getBoundingClientRect(),c=this.el.getAttribute(this.liveSocket.binding("viewport-top")),m=this.el.getAttribute(this.liveSocket.binding("viewport-bottom")),g=this.el.lastElementChild,f=this.el.firstElementChild,p=le;p&&c&&!t&&h.top>=0?(t=!0,n(c,f)):v&&t&&h.top<=0&&(t=!1),c&&p&&Gi(f)?r(c,f):m&&v&&Yi(g)&&o(m,g),e=l},window.addEventListener("scroll",this.onScroll)},destroyed(){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 Qi=ri,Zi=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?Z(document.getElementById(t.previousElementId),i=>{Z(document.getElementById(t.elementId),s=>{s.previousElementSibling&&s.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",s)})}):Z(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{Z(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}},Xt=11;function es(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 Fe,ts="http://www.w3.org/1999/xhtml",D=typeof document=="undefined"?void 0:document,is=!!D&&"content"in D.createElement("template"),ss=!!D&&D.createRange&&"createContextualFragment"in D.createRange();function ns(e){var t=D.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function rs(e){Fe||(Fe=D.createRange(),Fe.selectNode(D.body));var t=Fe.createContextualFragment(e);return t.childNodes[0]}function os(e){var t=D.createElement("body");return t.innerHTML=e,t.childNodes[0]}function as(e){return e=e.trim(),is?ns(e):ss?rs(e):os(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 ls(e,t){return!t||t===ts?D.createElement(e):D.createElementNS(t,e)}function hs(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 qt={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}}},ye=1,Wt=11,zt=3,Kt=8;function Q(){}function ds(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function cs(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=D.createElement("html"),s.innerHTML=r}else s=as(s);else s.nodeType===Wt&&(s=s.firstElementChild);var o=n.getNodeKey||ds,a=n.onBeforeNodeAdded||Q,l=n.onNodeAdded||Q,h=n.onBeforeElUpdated||Q,c=n.onElUpdated||Q,m=n.onBeforeNodeDiscarded||Q,g=n.onNodeDiscarded||Q,f=n.onBeforeElChildrenUpdated||Q,p=n.skipFromChildren||Q,v=n.addChild||function(y,b){return y.appendChild(b)},C=n.childrenOnly===!0,R=Object.create(null),T=[];function I(y){T.push(y)}function u(y,b){if(y.nodeType===ye)for(var k=y.firstChild;k;){var A=void 0;b&&(A=o(k))?I(A):(g(k),k.firstChild&&u(k,b)),k=k.nextSibling}}function w(y,b,k){m(y)!==!1&&(b&&b.removeChild(y),g(y),u(y,k))}function z(y){if(y.nodeType===ye||y.nodeType===Wt)for(var b=y.firstChild;b;){var k=o(b);k&&(R[k]=b),z(b),b=b.nextSibling}}z(i);function O(y){l(y);for(var b=y.firstChild;b;){var k=b.nextSibling,A=o(b);if(A){var E=R[A];E&&Ue(b,E)?(b.parentNode.replaceChild(E,b),L(E,b)):O(b)}else O(b);b=k}}function _(y,b,k){for(;b;){var A=b.nextSibling;(k=o(b))?I(k):w(b,y,!0),b=A}}function L(y,b,k){var A=o(b);A&&delete R[A],!(!k&&(h(y,b)===!1||(e(y,b),c(y),f(y,b)===!1)))&&(y.nodeName!=="TEXTAREA"?se(y,b):qt.TEXTAREA(y,b))}function se(y,b){var k=p(y),A=b.firstChild,E=y.firstChild,re,K,oe,Ce,G;e:for(;A;){for(Ce=A.nextSibling,re=o(A);!k&&E;){if(oe=E.nextSibling,A.isSameNode&&A.isSameNode(E)){A=Ce,E=oe;continue e}K=o(E);var Te=E.nodeType,Y=void 0;if(Te===A.nodeType&&(Te===ye?(re?re!==K&&((G=R[re])?oe===G?Y=!1:(y.insertBefore(G,E),K?I(K):w(E,y,!0),E=G):Y=!1):K&&(Y=!1),Y=Y!==!1&&Ue(E,A),Y&&L(E,A)):(Te===zt||Te==Kt)&&(Y=!0,E.nodeValue!==A.nodeValue&&(E.nodeValue=A.nodeValue))),Y){A=Ce,E=oe;continue e}K?I(K):w(E,y,!0),E=oe}if(re&&(G=R[re])&&Ue(G,A))k||v(y,G),L(G,A);else{var Ye=a(A);Ye!==!1&&(Ye&&(A=Ye),A.actualize&&(A=A.actualize(y.ownerDocument||D)),v(y,A),O(A))}A=Ce,E=oe}_(y,E,K);var At=qt[y.nodeName];At&&At(y,b)}var S=i,ke=S.nodeType,wt=s.nodeType;if(!C){if(ke===ye)wt===ye?Ue(i,s)||(g(i),S=hs(i,ls(s.nodeName,s.namespaceURI))):S=s;else if(ke===zt||ke===Kt){if(wt===ke)return S.nodeValue!==s.nodeValue&&(S.nodeValue=s.nodeValue),S;S=s}}if(S===s)g(i);else{if(s.isSameNode&&s.isSameNode(S))return;if(L(S,s,C),T)for(var Ke=0,hi=T.length;Ke{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.targetCID=r,this.cidPatch=W(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(We);d.all(this.container,`[${e}=${ot}]`,t=>t.innerHTML=""),d.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(Rt,"")})}perform(){let{view:e,liveSocket:t,container:i,html:s}=this,n=this.isCIDPatch()?this.targetCIDContainer(s):i;if(this.isCIDPatch()&&!n)return;let r=t.getActiveElement(),{selectionStart:o,selectionEnd:a}=r&&d.hasSelectionRange(r)?r:{},l=t.binding(We),h=t.binding(Xe),c=t.binding(mt),m=t.binding(ti),g=t.binding(ii),f=t.binding(Li),p=[],v=[],C=[],R=[],T=null,I=t.time("premorph container prep",()=>this.buildDiffHTML(i,s,l,n));return this.trackBefore("added",i),this.trackBefore("updated",i,i),t.time("morphdom",()=>{this.streams.forEach(([u,w,z,O])=>{Object.entries(w).forEach(([_,[L,se]])=>{this.streamInserts[_]={ref:u,streamAt:L,limit:se}}),O!==void 0&&d.all(i,`[${ge}="${u}"]`,_=>{w[_.id]||this.removeStreamChildElement(_)}),z.forEach(_=>{let L=i.querySelector(`[id="${_}"]`);L&&this.removeStreamChildElement(L)})}),Gt(n,I,{childrenOnly:n.getAttribute(M)===null,getNodeKey:u=>d.isPhxDestroyed(u)?null:u.id,skipFromChildren:u=>u.getAttribute(l)===ot,addChild:(u,w)=>{let{ref:z,streamAt:O,limit:_}=this.getStreamInsert(w);if(z===void 0)return u.appendChild(w);if(d.putSticky(w,ge,S=>S.setAttribute(ge,z)),O===0)u.insertAdjacentElement("afterbegin",w);else if(O===-1)u.appendChild(w);else if(O>0){let S=Array.from(u.children)[O];u.insertBefore(w,S)}let L=_!==null&&Array.from(u.children),se=[];_&&_<0&&L.length>_*-1?se=L.slice(0,L.length+_):_&&_>=0&&L.length>_&&(se=L.slice(_)),se.forEach(S=>{this.streamInserts[S.id]||this.removeStreamChildElement(S)})},onBeforeNodeAdded:u=>(d.maybeAddPrivateHooks(u,m,g),this.trackBefore("added",u),u),onNodeAdded:u=>{u.getAttribute&&this.maybeReOrderStream(u),u instanceof HTMLImageElement&&u.srcset?u.srcset=u.srcset:u instanceof HTMLVideoElement&&u.autoplay&&u.play(),d.isNowTriggerFormExternal(u,f)&&(T=u),u.getAttribute&&u.getAttribute("name")&&d.isFormInput(u)&&v.push(u),(d.isPhxChild(u)&&e.ownsElement(u)||d.isPhxSticky(u)&&e.ownsElement(u.parentNode))&&this.trackAfter("phxChildAdded",u),p.push(u)},onNodeDiscarded:u=>this.onNodeDiscarded(u),onBeforeNodeDiscarded:u=>u.getAttribute&&u.getAttribute(Rt)!==null?!0:!(u.parentElement!==null&&u.id&&d.isPhxUpdate(u.parentElement,l,[ot,"append","prepend"])||this.maybePendingRemove(u)||this.skipCIDSibling(u)),onElUpdated:u=>{d.isNowTriggerFormExternal(u,f)&&(T=u),C.push(u),this.maybeReOrderStream(u)},onBeforeElUpdated:(u,w)=>{if(d.maybeAddPrivateHooks(w,m,g),d.cleanChildNodes(w,l),this.skipCIDSibling(w)||d.isPhxSticky(u))return!1;if(d.isIgnored(u,l)||u.form&&u.form.isSameNode(T))return this.trackBefore("updated",u,w),d.mergeAttrs(u,w,{isIgnored:!0}),C.push(u),d.applyStickyOperations(u),!1;if(u.type==="number"&&u.validity&&u.validity.badInput)return!1;if(!d.syncPendingRef(u,w,c))return d.isUploadInput(u)&&(this.trackBefore("updated",u,w),C.push(u)),d.applyStickyOperations(u),!1;if(d.isPhxChild(w)){let O=u.getAttribute(te);return d.mergeAttrs(u,w,{exclude:[Ae]}),O!==""&&u.setAttribute(te,O),u.setAttribute(Ee,this.rootID),d.applyStickyOperations(u),!1}return d.copyPrivates(w,u),r&&u.isSameNode(r)&&d.isFormInput(u)&&u.type!=="hidden"?(this.trackBefore("updated",u,w),d.mergeFocusedInput(u,w),d.syncAttrsToProps(u),C.push(u),d.applyStickyOperations(u),v.push(u),!1):(d.isPhxUpdate(w,l,["append","prepend"])&&R.push(new Zi(u,w,w.getAttribute(l))),d.syncAttrsToProps(w),d.applyStickyOperations(w),w.getAttribute("name")&&d.isFormInput(w)&&v.push(w),this.trackBefore("updated",u,w),!0)}})}),t.isDebugEnabled()&&Vi(),R.length>0&&t.time("post-morph append/prepend restoration",()=>{R.forEach(u=>u.perform())}),v.forEach(u=>{d.maybeHideFeedback(n,u,h)}),t.silenceEvents(()=>d.restoreFocus(r,o,a)),d.dispatchEvent(document,"phx:update"),p.forEach(u=>this.trackAfter("added",u)),C.forEach(u=>this.trackAfter("updated",u)),this.transitionPendingRemoves(),T&&(t.unload(),Object.getPrototypeOf(T).submit.call(T)),!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.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}maybeReOrderStream(e){let{ref:t,streamAt:i,limit:s}=this.getStreamInsert(e);if(i!==void 0){if(d.putSticky(e,ge,n=>n.setAttribute(ge,t)),i===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(i>0){let n=Array.from(e.parentElement.children),r=n.indexOf(e);if(i>=n.length-1)e.parentElement.appendChild(e);else{let o=n[i];r>i?e.parentElement.insertBefore(e,o):e.parentElement.insertBefore(e,o.nextElementSibling)}}}}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)}))}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.getAttribute(ft)!==null}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}buildDiffHTML(e,t,i,s){let n=this.isCIDPatch(),r=n&&s.getAttribute(M)===this.targetCID.toString();if(!n||r)return t;{let o=null,a=document.createElement("template");o=d.cloneNode(s);let[l,...h]=d.findComponentNodeList(o,this.targetCID);return a.innerHTML=t,h.forEach(c=>c.remove()),Array.from(o.childNodes).forEach(c=>{c.id&&c.nodeType===Node.ELEMENT_NODE&&c.getAttribute(M)!==this.targetCID.toString()&&(c.setAttribute(ft,""),c.innerHTML="")}),Array.from(a.content.childNodes).forEach(c=>o.insertBefore(c,l)),l.remove(),o.outerHTML}}indexOf(e,t){return Array.from(e.children).indexOf(t)}},Yt=class{static extract(e){let{[Ut]:t,[Ft]:i,[$t]:s}=e;return delete e[Ut],delete e[Ft],delete e[$t],{diff:e,title:s,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){let[t,i]=this.recursiveToString(this.rendered,this.rendered[N],e);return[t,i]}recursiveToString(e,t=e[N],i){i=i?new Set(i):null;let s={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,s),[s.buffer,s.streams]}componentCIDs(e){return Object.keys(e[N]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[N]?Object.keys(e).length===1:!1}getComponent(e,t){return e[N][t]}mergeDiff(e){let t=e[N],i={};if(delete e[N],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[N]=this.rendered[N]||{},t){let s=this.rendered[N];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[N]=t}}cachedFindComponent(e,t,i,s,n){if(n[e])return n[e];{let r,o,a=t[J];if(W(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),r[J]=o}else r=t[J]!==void 0?t:this.cloneMerge(i[e]||{},t);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];be(s)&&s[J]===void 0&&be(n)?this.doMutableMerge(n,s):e[i]=s}}cloneMerge(e,t){let i=X(X({},e),t);for(let s in i){let n=t[s],r=e[s];be(n)&&n[J]===void 0&&be(r)&&(i[s]=this.cloneMerge(r,n))}return i}componentToString(e){let[t,i]=this.recursiveCIDToString(this.rendered[N],e,null,!1);return[t,i]}pruneCIDs(e){e.forEach(t=>delete this.rendered[N][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[J]}templateStatic(e,t){return typeof e=="number"?t[e]:e}toOutputBuffer(e,t,i){if(e[Me])return this.comprehensionToBuffer(e,t,i);let{[J]:s}=e;s=this.templateStatic(s,t),i.buffer+=s[0];for(let n=1;n0||l.length>0||h)&&(delete e[jt],e[Me]=[],i.streams.add(r))}dynamicToBuffer(e,t,i){if(typeof e=="number"){let[s,n]=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=s,i.streams=new Set([...i.streams,...n])}else be(e)?this.toOutputBuffer(e,t,i):i.buffer+=e}recursiveCIDToString(e,t,i,s=!0){let n=e[t]||x(`no component for CID ${t}`,e),r=document.createElement("template"),[o,a]=this.recursiveToString(n,e,i);r.innerHTML=o;let l=r.content,h=i&&!i.has(t),[c,m]=Array.from(l.childNodes).reduce(([g,f],p,v)=>p.nodeType===Node.ELEMENT_NODE?p.getAttribute(M)?[g,!0]:(p.setAttribute(M,t),p.id||(p.id=`${this.parentViewId()}-${t}-${v}`),h&&(p.setAttribute(ft,""),p.innerHTML=""),[!0,f]):p.nodeType===Node.COMMENT_NODE?(s||p.remove(),[g,f]):p.nodeValue.trim()!==""?(x(`only HTML element tags are allowed at the root of components. got: "${p.nodeValue.trim()}" within: `,r.innerHTML.trim()),p.replaceWith(this.createSpan(p.nodeValue,t)),[!0,f]):(p.remove(),[g,f]),[!1,!1]);return!c&&!m?(x(`expected at least one HTML element tag inside a component, but the component is empty: `,r.innerHTML.trim()),[this.createSpan("",t).outerHTML,a]):!c&&m?(x("expected at least one HTML element tag directly inside a component, but only subcomponents were found. A component must render at least one HTML tag directly inside itself.",r.innerHTML.trim()),[r.innerHTML,a]):[r.innerHTML,a]}createSpan(e,t){let i=document.createElement("span");return i.innerText=e,i.setAttribute(M,t),i}},fs=1,we=class{static makeID(){return fs++}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))}},je=null,ps={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)},exec_exec(e,t,i,s,n,[r,o]){(o?d.all(document,o):[s]).forEach(l=>{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){if(!i.isConnected())return;let{event:o,data:a,target:l,page_loading:h,loading:c,value:m,dispatcher:g,callback:f}=r,p={loading:c,value:m,target:l,page_loading:!!h},v=e==="change"&&g?g:s,C=l||v.getAttribute(i.binding("target"))||v;i.withinTargets(C,(R,T)=>{if(e==="change"){let{newCid:I,_target:u}=r;u=u||(d.isFormInput(s)?s.name:void 0),u&&(p._target=u),R.pushInput(s,T,I,o||t,p,f)}else if(e==="submit"){let{submitter:I}=r;R.submitForm(s,T,o||t,I,p,f)}else R.pushEvent(e,s,T,o||t,a,p,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(()=>le.attemptFocus(n))},exec_focus_first(e,t,i,s,n){window.requestAnimationFrame(()=>le.focusFirstInteractive(n)||le.focusFirst(n))},exec_push_focus(e,t,i,s,n){window.requestAnimationFrame(()=>je=n||s)},exec_pop_focus(e,t,i,s,n){window.requestAnimationFrame(()=>{je&&je.focus(),je=null})},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_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){let[a,l,h]=n||[[],[],[]],[c,m,g]=r||[[],[],[]];if(a.length>0||c.length>0)if(this.isVisible(i)){let f=()=>{this.addOrRemoveClasses(i,m,a.concat(l).concat(h)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,c,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,g,m))})};i.dispatchEvent(new Event("phx:hide-start")),t.transition(o,f,()=>{this.addOrRemoveClasses(i,[],c.concat(g)),d.putSticky(i,"toggle",p=>p.style.display="none"),i.dispatchEvent(new Event("phx:hide-end"))})}else{if(e==="remove")return;let f=()=>{this.addOrRemoveClasses(i,l,c.concat(m).concat(g));let p=s||this.defaultDisplay(i);d.putSticky(i,"toggle",v=>v.style.display=p),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",p=>p.style.display=f),i.dispatchEvent(new Event("phx:show-end"))})},addOrRemoveClasses(e,t,i,s,n,r){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",[[],[]]),m=t.filter(v=>h.indexOf(v)<0&&!e.classList.contains(v)),g=i.filter(v=>c.indexOf(v)<0&&e.classList.contains(v)),f=h.filter(v=>i.indexOf(v)<0).concat(m),p=c.filter(v=>t.indexOf(v)<0).concat(g);d.putSticky(e,"classes",v=>(v.classList.remove(...p),v.classList.add(...f),[f,p]))})},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"}},$=ps,Be=(e,t,i=[])=>{let l=t,{submitter:s}=l,n=kt(l,["submitter"]),r=new FormData(e);s&&s.hasAttribute("name")&&s.form&&s.form===e&&r.append(s.name,s.value);let o=[];r.forEach((h,c,m)=>{h instanceof File&&o.push(c)}),o.forEach(h=>r.delete(h));let a=new URLSearchParams;for(let[h,c]of r.entries())(i.length===0||i.indexOf(h)>=0)&&a.append(h,c);for(let h in n)a.append(h,n[h]);return a.toString()},oi=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.pruningCIDs=[],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.uploaders={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},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(vt)}connectParams(e){let t=this.liveSocket.params(this.el),i=d.all(document,`[${this.binding(Pi)}]`).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(te)}getStatic(){let e=this.el.getAttribute(Ae);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(It,pe,Ie,Dt,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(pe)}}execAll(e){d.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(It),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){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,i=>t(i,e));if(W(e))d.findComponentNodeList(this.el,e).length===0?x(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let i=Array.from(document.querySelectorAll(e));i.length===0&&x(`nothing found matching the phx-target selector "${e}"`),i.forEach(s=>this.liveSocket.owner(s,n=>t(n,s)))}}applyDiff(e,t,i){this.log(e,()=>["",Ve(t)]);let{diff:s,reply:n,events:r,title:o}=Yt.extract(t);i({diff:s,reply:n,events:r}),o&&window.requestAnimationFrame(()=>d.putTitle(o))}onJoin(e){let{rendered:t,container:i}=e;if(i){let[s,n]=i;this.el=d.replaceRootContainer(this.el,s,n)}this.childJoins=0,this.joinPending=!0,this.flash=null,V.dropLocal(this.liveSocket.localStorage,window.location.pathname,Qt),this.applyDiff("mount",t,({diff:s,events:n})=>{this.rendered=new Yt(this.id,s);let[r,o]=this.renderContainer(null,"join");this.dropPendingRefs();let a=this.formsForRecovery(r);this.joinCount++,a.length>0?a.forEach(([l,h,c],m)=>{this.pushFormRecovery(l,c,g=>{m===a.length-1&&this.onJoinComplete(g,r,o,n)})}):this.onJoinComplete(e,r,o,n)})}dropPendingRefs(){d.all(document,`[${ne}="${this.id}"][${U}]`,e=>{e.removeAttribute(U),e.removeAttribute(ne)})}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(Ae);return a&&r.setAttribute(Ae,a),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(Ee,this.root.id)}execNewMounted(){let e=this.binding(ti),t=this.binding(ii);d.all(this.el,`[${e}], [${t}]`,i=>{d.maybeAddPrivateHooks(i,e,t),this.maybeAddNewHook(i)}),d.all(this.el,`[${this.binding(me)}], [data-phx-${me}]`,i=>{this.maybeAddNewHook(i)}),d.all(this.el,`[${this.binding(Nt)}]`,i=>this.maybeMounted(i))}applyJoinPatch(e,t,i,s){this.attachTrueDocEl();let n=new $e(this,this.el,this.id,t,i,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1),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(We));if(i&&!e.isEqualNode(t)&&!(s&&qi(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(Nt)),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){let i=[],s=!1,n=new Set;return e.after("added",r=>{this.liveSocket.triggerDOM("onNodeAdded",[r]),this.maybeAddNewHook(r),r.getAttribute&&this.maybeMounted(r)}),e.after("phxChildAdded",r=>{d.isPhxSticky(r)?this.liveSocket.joinRootViews():s=!0}),e.before("updated",(r,o)=>{this.triggerBeforeUpdateHook(r,o)&&n.add(r.id)}),e.after("updated",r=>{n.has(r.id)&&this.getHook(r).__updated()}),e.after("discarded",r=>{r.nodeType===Node.ELEMENT_NODE&&i.push(r)}),e.after("transitionsDiscarded",r=>this.afterElementsRemoved(r,t)),e.perform(),this.afterElementsRemoved(i,t),s}afterElementsRemoved(e,t){let i=[];e.forEach(s=>{let n=d.all(s,`[${M}]`),r=d.all(s,`[${this.binding(me)}]`);n.concat(s).forEach(o=>{let a=this.componentID(o);W(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))}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 oi(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.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.findParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(i=!0)})}):Bt(e)||this.liveSocket.time("full patch complete",()=>{let[s,n]=this.renderContainer(e,"update"),r=new $e(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).concat(this.pruningCIDs):null,[n,r]=this.rendered.toString(s);return[`<${i}>${n}`,r]})}componentPatch(e,t){if(Bt(e))return!1;let[i,s]=this.rendered.componentToString(t),n=new $e(this,this.el,this.id,i,s,t);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[we.elementID(e)]}addHook(e){if(we.elementID(e)||!e.getAttribute)return;let t=e.getAttribute(`data-phx-${me}`)||e.getAttribute(this.binding(me));if(t&&!this.ownsElement(e))return;let i=this.liveSocket.getHookCallbacks(t);if(i){e.id||x(`no DOM ID for hook "${t}". Hooks require a unique ID on each element.`,e);let s=new we(this,e,i);return this.viewHooks[we.elementID(s.el)]=s,s}else t!==null&&x(`unknown hook found for "${t}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[we.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([pe,Ie,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(Fi)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([pe,Ie,nt]):this.displayError([pe,Ie,Dt]))}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(Lt))!==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,$i).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:m,events:g})=>{n!==null&&this.undoRefs(n),this.update(c,g),h(m)})}):(n!==null&&this.undoRefs(n),h(null))}))}undoRefs(e){this.isConnected()&&d.all(document,`[${ne}="${this.id}"][${U}="${e}"]`,t=>{let i=t.getAttribute(De);t.removeAttribute(U),t.removeAttribute(ne),t.getAttribute(rt)!==null&&(t.readOnly=!1,t.removeAttribute(rt)),i!==null&&(t.disabled=i==="true",t.removeAttribute(De)),Zt.forEach(r=>d.removeClass(t,r));let s=t.getAttribute(Oe);s!==null&&(t.innerText=s,t.removeAttribute(Oe));let n=d.private(t,U);if(n){let r=this.triggerBeforeUpdateHook(t,n);$e.patchEl(t,n,this.liveSocket.getActiveElement()),r&&r.__updated(),d.deletePrivate(t,U)}})}putRef(e,t,i={}){let s=this.ref++,n=this.binding(mt);return i.loading&&(e=e.concat(d.all(document,i.loading))),e.forEach(r=>{r.classList.add(`phx-${t}-loading`),r.setAttribute(U,s),r.setAttribute(ne,this.el.id);let o=r.getAttribute(n);o!==null&&(r.getAttribute(Oe)||r.setAttribute(Oe,r.innerText),o!==""&&(r.innerText=o),r.setAttribute("disabled",""))}),[s,e,i]}componentID(e){let t=e.getAttribute&&e.getAttribute(M);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(W(t))return t;let s=e.getAttribute(this.binding("target"));return W(s)?parseInt(s):t&&(s!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return W(e)?e:e?Z(e.closest(`[${M}]`),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(Ni)),ref:e.getAttribute(ee),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,r)},s)})}pushInput(e,t,i,s,n,r){let o,a=W(i)?i:this.targetComponentID(e.form,t),l=()=>this.putRef([e,e.form],"change",n),h,c=this.extractMeta(e.form);e.getAttribute(this.binding("change"))?h=Be(e.form,X({_target:n._target},c),[e.name]):h=Be(e.form,X({_target:n._target},c)),d.isUploadInput(e)&&e.files&&e.files.length>0&&P.trackFiles(e,Array.from(e.files)),o=P.serializeUploads(e);let m={type:"form",event:s,value:h,uploads:o,cid:a};this.pushWithReply(l,"event",m,g=>{if(d.showError(e,this.liveSocket.binding(Xe)),d.isUploadInput(e)&&d.isAutoUpload(e)){if(P.filesAwaitingPreflight(e).length>0){let[f,p]=l();this.uploadFiles(e.form,t,f,a,v=>{r&&r(g),this.triggerAwaitingSubmit(e.form)})}}else r&&r(g)})}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=>!(Se(c,`${this.binding(We)}=ignore`,c.form)||Se(c,"data-phx-update=ignore",c.form)),s=c=>c.hasAttribute(this.binding(mt)),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(De,c.disabled),c.disabled=!0}),h.forEach(c=>{c.setAttribute(rt,c.readOnly),c.readOnly=!0,c.files&&(c.setAttribute(De,c.disabled),c.disabled=!0)}),e.setAttribute(this.binding(Lt),""),this.putRef([e].concat(a).concat(l).concat(h),"submit",t)}pushFormSubmit(e,t,i,s,n,r){let o=()=>this.disableForm(e,n),a=this.targetComponentID(e,t);if(P.hasUploadsInProgress(e)){let[l,h]=o(),c=()=>this.pushFormSubmit(e,s,t,i,n,r);return this.scheduleSubmit(e,l,n,c)}else if(P.inputsAwaitingPreflight(e).length>0){let[l,h]=o(),c=()=>[l,h,n];this.uploadFiles(e,t,l,a,m=>{let g=this.extractMeta(e),f=Be(e,X({submitter:s},g));this.pushWithReply(c,"event",{type:"form",event:i,value:f,cid:a},r)})}else if(!(e.hasAttribute(U)&&e.classList.contains("phx-submit-loading"))){let l=this.extractMeta(e),h=Be(e,X({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=P.activeFileInputs(e),a=o.length;o.forEach(l=>{let h=new P(l,this,()=>{a--,a===0&&n()});this.uploaders[l]=h;let c=h.entries().map(g=>g.toPreflightPayload()),m={ref:l.getAttribute(ee),entries:c,cid:this.targetComponentID(l.form,t)};this.log("upload",()=>["sending preflight request",m]),this.pushWithReply(null,"allow_upload",m,g=>{if(this.log("upload",()=>["got preflight response",g]),g.error){this.undoRefs(i);let[f,p]=g.error;this.log("upload",()=>[`error for entry ${f}`,p])}else{let f=p=>{this.channel.onError(()=>{this.joinCount===r&&p()})};h.initAdapterUpload(g,f,this.liveSocket)}})})}dispatchUploads(e,t,i){let s=this.targetCtxElement(e)||this.el,n=d.findUploadInputs(s).filter(r=>r.name===t);n.length===0?x(`no live file inputs found matching the name "${t}"`):n.length>1?x(`duplicate live file inputs found matching the name "${t}"`):d.dispatchEvent(n[0],ei,{detail:{files:i}})}targetCtxElement(e){if(W(e)){let[t]=d.findComponentNodeList(this.el,e);return t}else return e||null}pushFormRecovery(e,t,i){this.liveSocket.withinOwners(e,(s,n)=>{let r=this.binding("change"),o=Array.from(e.elements).filter(h=>d.isFormInput(h)&&h.name&&!h.hasAttribute(r));if(o.length===0)return;o.forEach(h=>h.hasAttribute(ee)&&P.clearFiles(h));let a=o.find(h=>h.type!=="hidden")||o[0],l=e.getAttribute(this.binding(Ht))||e.getAttribute(this.binding("change"));$.exec("change",l,s,a,["push",{_target:a.name,newCid:t,callback: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()}formsForRecovery(e){if(this.joinCount===0)return[];let t=this.binding("change"),i=document.createElement("template");return i.innerHTML=e,d.all(this.el,`form[${t}]`).filter(s=>s.id&&this.ownsElement(s)).filter(s=>s.elements.length>0).filter(s=>s.getAttribute(this.binding(Ht))!=="ignore").map(s=>{let n=s.getAttribute(t).replaceAll(/([\[\]"])/g,"\\$1"),r=i.content.querySelector(`form[id="${s.id}"][${t}="${n}"]`);return r?[s,r,this.targetComponentID(r)]:[s,s,this.targetComponentID(s)]}).filter(([s,n,r])=>n)}maybePushComponentsDestroyed(e){let t=e.filter(i=>d.findComponentNodeList(this.el,i).length===0);t.length>0&&(this.pruningCIDs.push(...t),this.pushWithReply(null,"cids_will_destroy",{cids:t},()=>{this.pruningCIDs=this.pruningCIDs.filter(s=>t.indexOf(s)!==-1);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(he);return e.getAttribute(ae)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,s,n={}){d.putPrivate(e,qe,!0);let r=this.liveSocket.binding(Xe),o=Array.from(e.elements);o.forEach(a=>d.putPrivate(a,qe,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,s,n,()=>{o.forEach(a=>d.showError(a,r)),this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}},ai=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||Ui,this.opts=i,this.params=ht(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(Ve(ji),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||Mi,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||ki,this.reloadJitterMin=i.reloadJitterMin||Ci,this.reloadJitterMax=i.reloadJitterMax||Ti,this.failsafeJitter=i.failsafeJitter||_i,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:ht(),onBeforeElUpdated:ht()},i.dom||{}),this.transitions=new ms,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}isProfileEnabled(){return this.sessionStorage.getItem(at)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(He)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(He)==="false"}enableDebug(){this.sessionStorage.setItem(He,"true")}enableProfiling(){this.sessionStorage.setItem(at,"true")}disableDebug(){this.sessionStorage.setItem(He,"false")}disableProfiling(){this.sessionStorage.removeItem(at)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(lt,e)}disableLatencySim(){this.sessionStorage.removeItem(lt)}getLatencySim(){let e=this.sessionStorage.getItem(lt);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.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){this.owner(e,s=>$.exec(i,t,s,e))}execJSHookPush(e,t,i,s){this.withinOwners(e,n=>{$.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();Xi(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,Qt,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.")?Qi[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,`${he}:not([${ae}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);i.setHref(this.getHref()),i.join(),t.hasAttribute(vt)&&(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(),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&&requestAnimationFrame(()=>i(s)),a()})})}transitionRemoves(e){let t=this.binding("remove");e=e||d.all(document,`[${t}]`),e.forEach(i=>{this.execJS(i,i.getAttribute(t),"remove")})}isPhxView(e){return e.getAttribute&&e.getAttribute(te)!==null}newRootView(e,t,i){let s=new oi(e,this,null,t,i);return this.roots[s.id]=s,s}owner(e,t){let i=Z(e.closest(he),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(Ee);return Z(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(Ee));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.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(Hi)),l=t.key&&t.key.toLowerCase();if(a&&a.toLowerCase()!==l)return;let h=X({key:t.key},this.eventMeta(i,t,n));$.exec(i,r,s,n,["push",{data:h}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,s,n,r,o)=>{if(!o){let a=X({key:t.key},this.eventMeta(i,t,n));$.exec(i,r,s,n,["push",{data:a}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,s,n,r,o,a)=>{if(a==="window"){let l=this.eventMeta(i,t,n);$.exec(i,o,s,n,["push",{data:l}])}}),window.addEventListener("dragover",t=>t.preventDefault()),window.addEventListener("drop",t=>{t.preventDefault();let i=Z(Se(t.target,this.binding(xt)),r=>r.getAttribute(this.binding(xt))),s=i&&document.getElementById(i),n=Array.from(t.dataTransfer.files||[]);!s||s.disabled||n.length===0||!(s.files instanceof FileList)||(P.trackFiles(s,n,t.dataTransfer),s.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(ei,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);P.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("click",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click",!1),this.bindClick("mousedown","capture-click",!0)}bindClick(e,t,i){let s=this.binding(t);window.addEventListener(e,n=>{let r=null;if(i)r=n.target.matches(`[${s}]`)?n.target:n.target.querySelector(`[${s}]`);else{let a=this.clickStartedAtTarget||n.target;r=Se(a,s),this.dispatchClickAway(n,a),this.clickStartedAtTarget=null}let o=r&&r.getAttribute(s);if(!o){!i&&d.isNewPageClick(n,window.location)&&this.unload();return}r.getAttribute("href")==="#"&&n.preventDefault(),!r.hasAttribute(U)&&this.debounce(r,n,"click",()=>{this.withinOwners(r,a=>{$.exec("click",o,a,r,["push",{data:this.eventMeta("click",n,r)}])})})},i)}dispatchClickAway(e,t){let i=this.binding("click-away");d.all(document,`[${i}]`,s=>{s.isSameNode(t)||s.contains(t)||this.withinOwners(e.target,n=>{let r=s.getAttribute(i);$.isVisible(s)&&$.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=Se(t.target,it),s=i&&i.getAttribute(it);if(!s||!this.isConnected()||!this.main||d.wantsNewTab(t))return;let n=i.href,r=i.getAttribute(xi);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 ${it} 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())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())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=>{$.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:m,type:g}=d.private(r,"prev-iteration")||{};m===c-1&&i==="change"&&g==="input"||(d.putPrivate(r,"prev-iteration",{at:c,type:i}),this.debounce(r,s,i,()=>{this.withinOwners(h,f=>{d.putPrivate(r,pt,!0),d.isTextualInput(r)||this.setActiveElement(r),$.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(Xe));let n=Array.from(s.elements).find(r=>r.type==="reset");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(Di),r=this.binding(Oi),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)})}},ms=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 gs=document.querySelector("html").getAttribute("phx-socket")||"/live",vs=document.querySelector("meta[name='csrf-token']").getAttribute("content"),ie={},li={};ie.JsonEditor={mounted(){let e=this.el.getAttribute("data-input-id"),t=this;this.editor=new JSONEditor(this.el,{onChangeText:i=>{let s=document.getElementById(e);try{JSON.parse(i),s.value=i,s.dispatchEvent(new Event("change",{bubbles:!0}))}catch(n){}},onChange:()=>{try{let i=document.getElementById(e);json=t.editor.get(),i.value=JSON.stringify(json),i.dispatchEvent(new Event("change",{bubbles:!0}))}catch(i){}},onModeChange:i=>{t.mode=i},modes:["text","tree"]},JSON.parse(document.getElementById(e).value)),li[this.el.id]=this.editor}};ie.JsonEditorSource={updated(){try{let e=li[this.el.getAttribute("data-editor-id")];e.getMode()==="tree"?e.update(JSON.parse(this.el.value)):e.get()!==JSON.parse(this.el.value)&&e.setText(this.el.value)}catch(e){}}};ie.JsonView={updated(){let e=JSON.parse(this.el.getAttribute("data-json"));this.editor=new JSONEditor(this.el,{mode:"preview"},e)},mounted(){let e=JSON.parse(this.el.getAttribute("data-json"));this.editor=new JSONEditor(this.el,{mode:"preview"},e)}};var bs=e=>new EasyMDE({element:e,initialValue:e.getAttribute("value")});ie.MarkdownEditor={mounted(){let e=this.el.getAttribute("data-target-id"),t=document.getElementById(e),i=bs(t);i.codemirror.on("change",()=>{t.value=i.value(),t.dispatchEvent(new Event("change",{bubbles:!0}))})}};ie.Actor={mounted(){this.handleEvent("set_actor",e=>{document.cookie="actor_resource="+e.resource+";path=/",document.cookie="actor_primary_key="+e.primary_key+";path=/",document.cookie="actor_action="+e.action+";path=/",document.cookie="actor_api="+e.api+";path=/"}),this.handleEvent("clear_actor",()=>{document.cookie="actor_resource=;path=/",document.cookie="actor_primary_key=;path=/",document.cookie="actor_action;path=/",document.cookie="actor_api=;path=/",document.cookie="actor_authorizing=false;path=/",document.cookie="actor_paused=true;path=/"}),this.handleEvent("toggle_authorizing",e=>{document.cookie="actor_authorizing="+e.authorizing+";path=/"}),this.handleEvent("toggle_actor_paused",e=>{document.cookie="actor_paused="+e.actor_paused+";path=/"})}};ie.Tenant={mounted(){this.handleEvent("set_tenant",e=>{document.cookie="tenant="+e.tenant+";path=/"}),this.handleEvent("clear_tenant",()=>{document.cookie="tenant=;path=/"})}};ie.MaintainAttrs={attrs(){return this.el.getAttribute("data-attrs").split(", ")},beforeUpdate(){this.prevAttrs=this.attrs().map(e=>[e,this.el.getAttribute(e)])},updated(){this.prevAttrs.forEach(([e,t])=>this.el.setAttribute(e,t))}};function de(e){var t=new RegExp(e+"=([^;]+)"),i=t.exec(document.cookie);return i!=null?unescape(i[1]):null}var ys=()=>({_csrf_token:vs,actor_resource:de("actor_resource"),actor_primary_key:de("actor_primary_key"),actor_action:de("actor_action"),actor_api:de("actor_api"),actor_authorizing:de("actor_authorizing"),actor_paused:de("actor_paused")}),yt=new ai(gs,Tt,{params:ys,hooks:ie,dom:{onBeforeElUpdated(e,t){e._x_dataStack&&window.Alpine.clone(e,t)}}});ze.default.config({barColors:{0:"#29d"},shadowColor:"rgba(0, 0, 0, .3)"});window.addEventListener("phx:page-loading-start",e=>ze.default.show(300));window.addEventListener("phx:page-loading-stop",e=>ze.default.hide());yt.connect();yt.enableDebug();window.liveSocket=yt;})(); /** * @license MIT * topbar 2.0.0, 2023-02-04 * https://buunguyen.github.io/topbar * Copyright (c) 2021 Buu Nguyen */