(()=>{(function(){var t=e();function e(){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")),h=i("_csrf_token",n.getAttribute("data-csrf")),l=document.createElement("form"),d=document.createElement("input"),p=n.getAttribute("target");l.method=n.getAttribute("data-method")==="get"?"get":"post",l.action=o,l.style.display="none",p?l.target=p:r&&(l.target="_blank"),l.appendChild(h),l.appendChild(a),document.body.appendChild(l),d.type="submit",l.appendChild(d),d.click()}window.addEventListener("click",function(n){var r=n.target;if(!n.defaultPrevented)for(;r&&r.getAttribute;){var o=new t("phoenix.link.click",{bubbles:!0,cancelable:!0});if(!r.dispatchEvent(o))return n.preventDefault(),n.stopImmediatePropagation(),!1;if(r.getAttribute("data-method")&&r.getAttribute("data-to"))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 Pe=t=>typeof t=="function"?t:function(){return t},Ai=typeof self<"u"?self:null,ye=typeof window<"u"?window:null,q=Ai||ye||globalThis,ki="2.0.0",K={connecting:0,open:1,closing:2,closed:3},Ei=1e4,Si=1e3,j={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},ee={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},ht={longpoll:"longpoll",websocket:"websocket"},Ci={complete:4},lt="base64url.bearer.phx.",Be=class{constructor(t,e,i,s){this.channel=t,this.event=e,this.payload=i||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(t){this.timeout=t,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(t,e){return this.hasReceived(t)&&e(this.receivedResp.response),this.recHooks.push({status:t,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:t,response:e,_ref:i}){this.recHooks.filter(s=>s.status===t).forEach(s=>s.callback(e))}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,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,e){this.channel.trigger(this.refEvent,{status:t,response:e})}},Lt=class{constructor(t,e){this.callback=t,this.timerCalc=e,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))}},Ti=class{constructor(t,e,i){this.state=j.closed,this.topic=t,this.params=Pe(e||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Be(this,ee.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new Lt(()=>{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=j.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=j.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=j.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=j.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 Be(this,ee.leave,Pe({}),this.timeout).send(),this.state=j.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(ee.reply,(s,n)=>{this.trigger(this.replyEventName(n),s)})}join(t=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=t,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(t){this.on(ee.close,t)}onError(t){return this.on(ee.error,e=>t(e))}on(t,e){let i=this.bindingRef++;return this.bindings.push({event:t,ref:i,callback:e}),i}off(t,e){this.bindings=this.bindings.filter(i=>!(i.event===t&&(typeof e>"u"||e===i.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,e,i=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new Be(this,t,function(){return e},i);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=j.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(ee.close,"leave")},i=new Be(this,ee.leave,Pe({}),t);return i.receive("ok",()=>e()).receive("timeout",()=>e()),i.send(),this.canPush()||i.trigger("ok",{}),i}onMessage(t,e,i){return e}isMember(t,e,i,s){return this.topic!==t?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:e,payload:i,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=j.joining,this.joinPush.resend(t))}trigger(t,e,i,s){let n=this.onMessage(t,e,i,s);if(e&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let r=this.bindings.filter(o=>o.event===t);for(let o=0;o<r.length;o++)r[o].callback(n,i,s||this.joinRef())}replyEventName(t){return`chan_reply_${t}`}isClosed(){return this.state===j.closed}isErrored(){return this.state===j.errored}isJoined(){return this.state===j.joined}isJoining(){return this.state===j.joining}isLeaving(){return this.state===j.leaving}},Je=class{static request(t,e,i,s,n,r,o){if(q.XDomainRequest){let a=new q.XDomainRequest;return this.xdomainRequest(a,t,e,s,n,r,o)}else if(q.XMLHttpRequest){let a=new q.XMLHttpRequest;return this.xhrRequest(a,t,e,i,s,n,r,o)}else{if(q.fetch&&q.AbortController)return this.fetchRequest(t,e,i,s,n,r,o);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(t,e,i,s,n,r,o){let a={method:t,headers:i,body:s},h=null;if(n){h=new AbortController;let l=setTimeout(()=>h.abort(),n);a.signal=h.signal}return q.fetch(e,a).then(l=>l.text()).then(l=>this.parseJSON(l)).then(l=>o&&o(l)).catch(l=>{l.name==="AbortError"&&r?r():o&&o(null)}),h}static xdomainRequest(t,e,i,s,n,r,o){return t.timeout=n,t.open(e,i),t.onload=()=>{let a=this.parseJSON(t.responseText);o&&o(a)},r&&(t.ontimeout=r),t.onprogress=()=>{},t.send(s),t}static xhrRequest(t,e,i,s,n,r,o,a){t.open(e,i,!0),t.timeout=r;for(let[h,l]of Object.entries(s))t.setRequestHeader(h,l);return t.onerror=()=>a&&a(null),t.onreadystatechange=()=>{if(t.readyState===Ci.complete&&a){let h=this.parseJSON(t.responseText);a(h)}},o&&(t.ontimeout=o),t.send(n),t}static parseJSON(t){if(!t||t==="")return null;try{return JSON.parse(t)}catch{return console&&console.log("failed to parse JSON response",t),null}}static serialize(t,e){let i=[];for(var s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let n=e?`${e}[${s}]`:s,r=t[s];typeof r=="object"?i.push(this.serialize(r,n)):i.push(encodeURIComponent(n)+"="+encodeURIComponent(r))}return i.join("&")}static appendParams(t,e){if(Object.keys(e).length===0)return t;let i=t.match(/\?/)?"&":"?";return`${t}${i}${this.serialize(e)}`}},_i=t=>{let e="",i=new Uint8Array(t),s=i.byteLength;for(let n=0;n<s;n++)e+=String.fromCharCode(i[n]);return btoa(e)},we=class{constructor(t,e){e&&e.length===2&&e[1].startsWith(lt)&&(this.authToken=atob(e[1].slice(lt.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(t),this.readyState=K.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+ht.websocket),"$1/"+ht.longpoll)}endpointURL(){return Je.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,i){this.close(t,e,i),this.readyState=K.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===K.open||this.readyState===K.connecting}poll(){let t={Accept:"application/json"};this.authToken&&(t["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",t,null,()=>this.ontimeout(),e=>{if(e){var{status:i,token:s,messages:n}=e;if(i===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=s}else i=0;switch(i){case 200:n.forEach(r=>{setTimeout(()=>this.onmessage({data:r}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=K.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 ${i}`)}})}send(t){typeof t!="string"&&(t=_i(t)),this.currentBatch?this.currentBatch.push(t):this.awaitingBatchAck?this.batchBuffer.push(t):(this.currentBatch=[t],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(t){this.awaitingBatchAck=!0,this.ajax("POST",{"Content-Type":"application/x-ndjson"},t.join(`
`),()=>this.onerror("timeout"),e=>{this.awaitingBatchAck=!1,!e||e.status!==200?(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(t,e,i){for(let n of this.reqs)n.abort();this.readyState=K.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:t,reason:e,wasClean:i});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(t,e,i,s,n){let r,o=()=>{this.reqs.delete(r),s()};r=Je.request(t,this.endpointURL(),e,i,this.timeout,o,a=>{this.reqs.delete(r),this.isActive()&&n(a)}),this.reqs.add(r)}};var Ve={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(t,e){if(t.payload.constructor===ArrayBuffer)return e(this.binaryEncode(t));{let i=[t.join_ref,t.ref,t.topic,t.event,t.payload];return e(JSON.stringify(i))}},decode(t,e){if(t.constructor===ArrayBuffer)return e(this.binaryDecode(t));{let[i,s,n,r,o]=JSON.parse(t);return e({join_ref:i,ref:s,topic:n,event:r,payload:o})}},binaryEncode(t){let{join_ref:e,ref:i,event:s,topic:n,payload:r}=t,o=this.META_LENGTH+e.length+i.length+n.length+s.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),h=new DataView(a),l=0;h.setUint8(l++,this.KINDS.push),h.setUint8(l++,e.length),h.setUint8(l++,i.length),h.setUint8(l++,n.length),h.setUint8(l++,s.length),Array.from(e,p=>h.setUint8(l++,p.charCodeAt(0))),Array.from(i,p=>h.setUint8(l++,p.charCodeAt(0))),Array.from(n,p=>h.setUint8(l++,p.charCodeAt(0))),Array.from(s,p=>h.setUint8(l++,p.charCodeAt(0)));var d=new Uint8Array(a.byteLength+r.byteLength);return d.set(new Uint8Array(a),0),d.set(new Uint8Array(r),a.byteLength),d.buffer},binaryDecode(t){let e=new DataView(t),i=e.getUint8(0),s=new TextDecoder;switch(i){case this.KINDS.push:return this.decodePush(t,e,s);case this.KINDS.reply:return this.decodeReply(t,e,s);case this.KINDS.broadcast:return this.decodeBroadcast(t,e,s)}},decodePush(t,e,i){let s=e.getUint8(1),n=e.getUint8(2),r=e.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=i.decode(t.slice(o,o+s));o=o+s;let h=i.decode(t.slice(o,o+n));o=o+n;let l=i.decode(t.slice(o,o+r));o=o+r;let d=t.slice(o,t.byteLength);return{join_ref:a,ref:null,topic:h,event:l,payload:d}},decodeReply(t,e,i){let s=e.getUint8(1),n=e.getUint8(2),r=e.getUint8(3),o=e.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,h=i.decode(t.slice(a,a+s));a=a+s;let l=i.decode(t.slice(a,a+n));a=a+n;let d=i.decode(t.slice(a,a+r));a=a+r;let p=i.decode(t.slice(a,a+o));a=a+o;let g=t.slice(a,t.byteLength),m={status:p,response:g};return{join_ref:h,ref:l,topic:d,event:ee.reply,payload:m}},decodeBroadcast(t,e,i){let s=e.getUint8(1),n=e.getUint8(2),r=this.HEADER_LENGTH+2,o=i.decode(t.slice(r,r+s));r=r+s;let a=i.decode(t.slice(r,r+n));r=r+n;let h=t.slice(r,t.byteLength);return{join_ref:null,ref:null,topic:o,event:a,payload:h}}},Ot=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=e.timeout||Ei,this.transport=e.transport||q.WebSocket||we,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=e.sessionStorage||q&&q.sessionStorage,this.establishedConnections=0,this.defaultEncoder=Ve.encode.bind(Ve),this.defaultDecoder=Ve.decode.bind(Ve),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.transport!==we?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;ye&&ye.addEventListener&&(ye.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock)}),ye.addEventListener("pageshow",s=>{i===this.connectClock&&(i=null,this.connect())}),ye.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pageHidden=!0:(this.pageHidden=!1,!this.isConnected()&&!this.closeWasClean&&this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.rejoinAfterMs=s=>e.rejoinAfterMs?e.rejoinAfterMs(s):[1e3,2e3,5e3][s-1]||1e4,this.reconnectAfterMs=s=>e.reconnectAfterMs?e.reconnectAfterMs(s):[10,50,100,150,200,250,500,1e3,2e3][s-1]||5e3,this.logger=e.logger||null,!this.logger&&e.debug&&(this.logger=(s,n,r)=>{console.log(`${s}: ${n}`,r)}),this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=Pe(e.params||{}),this.endPoint=`${t}/${ht.websocket}`,this.vsn=e.vsn||ki,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new Lt(()=>{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(()=>this.connect())},this.reconnectAfterMs),this.authToken=e.authToken}getLongPollTransport(){return we}replaceTransport(t){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=t}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let t=Je.appendParams(Je.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return t.charAt(0)!=="/"?t:t.charAt(1)==="/"?`${this.protocol()}:${t}`:`${this.protocol()}://${location.host}${t}`}disconnect(t,e,i){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,t&&t()},e,i)}connect(t){t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=Pe(t)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==we?this.connectWithFallback(we,this.longPollFallbackMs):this.transportConnect())}log(t,e,i){this.logger&&this.logger(t,e,i)}hasLogger(){return this.logger!==null}onOpen(t){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,t]),e}onClose(t){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,t]),e}onError(t){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,t]),e}onMessage(t){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,t]),e}ping(t){if(!this.isConnected())return!1;let e=this.makeRef(),i=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let s=this.onMessage(n=>{n.ref===e&&(this.off([s]),t(Date.now()-i))});return!0}transportName(t){switch(t){case we:return"LongPoll";default:return t.name}}transportConnect(){this.connectClock++,this.closeWasClean=!1;let t;this.authToken&&(t=["phoenix",`${lt}${btoa(this.authToken).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),t),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(t){return this.sessionStore&&this.sessionStore.getItem(t)}storeSession(t,e){this.sessionStore&&this.sessionStore.setItem(t,e)}connectWithFallback(t,e=2500){clearTimeout(this.fallbackTimer);let i=!1,s=!0,n,r,o=this.transportName(t),a=h=>{this.log("transport",`falling back to ${o}...`,h),this.off([n,r]),s=!1,this.replaceTransport(t),this.transportConnect()};if(this.getSession(`phx:fallback:${o}`))return a("memorized");this.fallbackTimer=setTimeout(a,e),r=this.onError(h=>{this.log("transport","error",h),s&&!i&&(clearTimeout(this.fallbackTimer),a(h))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(i=!0,!s){let h=this.transportName(t);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${h}`,"true"),this.log("transport",`established ${h} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(a,e),this.ping(h=>{this.log("transport","connected to primary after",h),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`${this.transportName(this.transport)} connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,t])=>t())}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(),Si,"heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(t,e,i){if(!this.conn)return t&&t();let s=this.conn;this.waitForBufferDone(s,()=>{e?s.close(e,i||""):s.close(),this.waitForSocketClosed(s,()=>{this.conn===s&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),t&&t()})})}waitForBufferDone(t,e,i=1){if(i===5||!t.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(t,e,i+1)},150*i)}waitForSocketClosed(t,e,i=1){if(i===5||t.readyState===K.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(t,e,i+1)},150*i)}onConnClose(t){this.conn&&(this.conn.onclose=()=>{});let e=t&&t.code;this.hasLogger()&&this.log("transport","close",t),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&e!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,i])=>i(t))}onConnError(t){this.hasLogger()&&this.log("transport",t);let e=this.transport,i=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,s])=>{s(t,e,i)}),(e===this.transport||i>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(ee.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case K.connecting:return"connecting";case K.open:return"open";case K.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(t){this.off(t.stateChangeRefs),this.channels=this.channels.filter(e=>e!==t)}off(t){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([i])=>t.indexOf(i)===-1)}channel(t,e={}){let i=new Ti(t,e,this);return this.channels.push(i),i}push(t){if(this.hasLogger()){let{topic:e,event:i,payload:s,ref:n,join_ref:r}=t;this.log("push",`${e} ${i} (${r}, ${n})`,s)}this.isConnected()?this.encode(t,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(t,e=>this.conn.send(e)))}makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,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(t=>t()),this.sendBuffer=[])}onConnMessage(t){this.decode(t.data,e=>{let{topic:i,event:s,payload:n,ref:r,join_ref:o}=e;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;a<this.channels.length;a++){let h=this.channels[a];h.isMember(i,s,n,o)&&h.trigger(s,n,r,o)}for(let a=0;a<this.stateChangeCallbacks.message.length;a++){let[,h]=this.stateChangeCallbacks.message[a];h(e)}})}leaveOpenTopic(t){let e=this.channels.find(i=>i.topic===t&&(i.isJoined()||i.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${t}"`),e.leave())}};var ai="consecutive-reloads",Pi=10,Ri=5e3,xi=1e4,Ii=3e4,hi=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],ct="phx-drop-target-active",Y="data-phx-component",Te="data-phx-view",dt="data-phx-link",Li="track-static",Oi="data-phx-link-state",_e="data-phx-ref-loading",J="data-phx-ref-src",O="data-phx-ref-lock",Dt="phx-pending-refs",li="track-uploads",se="data-phx-upload-ref",Ct="data-phx-preflighted-refs",Di="data-phx-done-refs",Xe="drop-target",vt="data-phx-active-refs",Qe="phx:live-file:updated",ci="data-phx-skip",di="data-phx-id",Ht="data-phx-prune",Nt="phx-connected",le="phx-loading",Ae="phx-error",Mt="phx-client-error",Re="phx-server-error",pe="data-phx-parent-id",Tt="data-phx-main",ie="data-phx-root-id",bt="viewport-top",wt="viewport-bottom",Hi="viewport-overrun-target",Ni="trigger-action",it="phx-has-focused",Mi=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],ui=["checkbox","radio"],Me="phx-has-submitted",Q="data-phx-session",$e=`[${Q}]`,yt="data-phx-sticky",fe="data-phx-static",At="data-phx-readonly",Se="data-phx-disabled",$t="disable-with",st="data-phx-disable-with-restore",xe="hook",$i="debounce",Ui="throttle",nt="update",Ze="stream",Ie="data-phx-stream",_t="data-phx-portal",me="data-phx-teleported",he="data-phx-teleported-src",et="data-phx-runtime-hook",Fi="data-phx-pid",ji="key",z="phxPrivate",Ut="auto-recover",We="phx:live-socket:debug",ut="phx:live-socket:profiling",ft="phx:live-socket:latency-sim",qe="phx:nav-history-position",Bi="progress",Ft="mounted",jt="__phoenix_reload_status__",Vi=1,Bt=3,Ji=200,Xi=500,Wi="phx-",qi=3e4,Le="debounce-trigger",Oe="throttled",Vt="debounce-prev-key",Ki={debounce:300,throttle:300},Jt=[_e,J,O],V="s",pt="r",$="c",I="k",G="kc",Xt="e",Wt="r",qt="t",oe="p",ke="stream",zi=class{constructor(t,e,i){let{chunk_size:s,chunk_timeout:n}=e;this.liveSocket=i,this.entry=t,this.offset=0,this.chunkSize=s,this.chunkTimeout=n,this.chunkTimer=null,this.errored=!1,this.uploadChannel=i.channel(`lvu:${t.ref}`,{token:t.metadata()})}error(t){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),this.entry.error(t))}upload(){this.uploadChannel.onError(t=>this.error(t)),this.uploadChannel.join().receive("ok",t=>this.readNextChunk()).receive("error",t=>this.error(t))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let t=new window.FileReader,e=this.entry.file.slice(this.offset,this.chunkSize+this.offset);t.onload=i=>{if(i.target.error===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return P("Read error: "+i.target.error)},t.readAsArrayBuffer(e)}pushChunk(t){this.uploadChannel.isJoined()&&this.uploadChannel.push("chunk",t,this.chunkTimeout).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:e})=>this.error(e))}},P=(t,e)=>console.error&&console.error(t,e),te=t=>{let e=typeof t;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(t)};function Gi(){let t=new Set,e=document.querySelectorAll("*[id]");for(let i=0,s=e.length;i<s;i++)t.has(e[i].id)?console.error(`Multiple IDs detected: ${e[i].id}. Ensure unique element ids.`):t.add(e[i].id)}function Yi(t){let e=new Set;Object.keys(t).forEach(i=>{let s=document.getElementById(i);s&&s.parentElement&&s.parentElement.getAttribute("phx-update")!=="stream"&&e.add(`The stream container with id "${s.parentElement.id}" is missing the phx-update="stream" attribute. Ensure it is set for streams to work properly.`)}),e.forEach(i=>console.error(i))}var Qi=(t,e,i,s)=>{t.liveSocket.isDebugEnabled()&&console.log(`${t.id} ${e}: ${i} - `,s)},De=t=>typeof t=="function"?t:function(){return t},tt=t=>JSON.parse(JSON.stringify(t)),ue=(t,e,i)=>{do{if(t.matches(`[${e}]`)&&!t.disabled)return t;t=t.parentElement||t.parentNode}while(t!==null&&t.nodeType===1&&!(i&&i.isSameNode(t)||t.matches($e)));return null},Ee=t=>t!==null&&typeof t=="object"&&!(t instanceof Array),Zi=(t,e)=>JSON.stringify(t)===JSON.stringify(e),Kt=t=>{for(let e in t)return!1;return!0},Ce=(t,e)=>t&&e(t),es=function(t,e,i,s){t.forEach(n=>{new zi(n,i.config,s).upload()})},ts=t=>{if(t.dataTransfer.types){for(let e=0;e<t.dataTransfer.types.length;e++)if(t.dataTransfer.types[e]==="Files")return!0}return!1},is={canPushState(){return typeof history.pushState<"u"},dropLocal(t,e,i){return t.removeItem(this.localKey(e,i))},updateLocal(t,e,i,s,n){let r=this.getLocal(t,e,i),o=this.localKey(e,i),a=r===null?s:n(r);return t.setItem(o,JSON.stringify(a)),a},getLocal(t,e,i){return JSON.parse(t.getItem(this.localKey(e,i)))},updateCurrentState(t){this.canPushState()&&history.replaceState(t(history.state||{}),"",window.location.href)},pushState(t,e,i){if(this.canPushState()){if(i!==window.location.href){if(e.type=="redirect"&&e.scroll){let s=history.state||{};s.scroll=e.scroll,history.replaceState(s,"",window.location.href)}delete e.scroll,history[t+"State"](e,"",i||null),window.requestAnimationFrame(()=>{let s=this.getHashTargetEl(window.location.hash);s?s.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)})}}else this.redirect(i)},setCookie(t,e,i){let s=typeof i=="number"?` max-age=${i};`:"";document.cookie=`${t}=${e};${s} path=/`},getCookie(t){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${t}s*=s*([^;]*).*$)|^.*$`),"$1")},deleteCookie(t){document.cookie=`${t}=; max-age=-1; path=/`},redirect(t,e,i=s=>{window.location.href=s}){e&&this.setCookie("__phoenix_flash__",e,60),i(t)},localKey(t,e){return`${t}-${e}`},getHashTargetEl(t){let e=t.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},F=is,de={byId(t){return document.getElementById(t)||P(`no id found for ${t}`)},removeClass(t,e){t.classList.remove(e),t.classList.length===0&&t.removeAttribute("class")},all(t,e,i){if(!t)return[];let s=Array.from(t.querySelectorAll(e));return i&&s.forEach(i),s},childNodeLength(t){let e=document.createElement("template");return e.innerHTML=t,e.content.childElementCount},isUploadInput(t){return t.type==="file"&&t.getAttribute(se)!==null},isAutoUpload(t){return t.hasAttribute("data-phx-auto-upload")},findUploadInputs(t){let e=t.id,i=this.all(document,`input[type="file"][${se}][form="${e}"]`);return this.all(t,`input[type="file"][${se}]`).concat(i)},findComponentNodeList(t,e,i=document){return this.all(i,`[${Te}="${t}"][${Y}="${e}"]`)},isPhxDestroyed(t){return!!(t.id&&de.private(t,"destroyed"))},wantsNewTab(t){let e=t.ctrlKey||t.shiftKey||t.metaKey||t.button&&t.button===1,i=t.target instanceof HTMLAnchorElement&&t.target.hasAttribute("download"),s=t.target.hasAttribute("target")&&t.target.getAttribute("target").toLowerCase()==="_blank",n=t.target.hasAttribute("target")&&!t.target.getAttribute("target").startsWith("_");return e||s||i||n},isUnloadableFormSubmit(t){return t.target&&t.target.getAttribute("method")==="dialog"||t.submitter&&t.submitter.getAttribute("formmethod")==="dialog"?!1:!t.defaultPrevented&&!this.wantsNewTab(t)},isNewPageClick(t,e){let i=t.target instanceof HTMLAnchorElement?t.target.getAttribute("href"):null,s;if(t.defaultPrevented||i===null||this.wantsNewTab(t)||i.startsWith("mailto:")||i.startsWith("tel:")||t.target.isContentEditable)return!1;try{s=new URL(i)}catch{try{s=new URL(i,e)}catch{return!0}}return s.host===e.host&&s.protocol===e.protocol&&s.pathname===e.pathname&&s.search===e.search?s.hash===""&&!s.href.endsWith("#"):s.protocol.startsWith("http")},markPhxChildDestroyed(t){this.isPhxChild(t)&&t.setAttribute(Q,""),this.putPrivate(t,"destroyed",!0)},findPhxChildrenInFragment(t,e){let i=document.createElement("template");return i.innerHTML=t,this.findPhxChildren(i.content,e)},isIgnored(t,e){return(t.getAttribute(e)||t.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(t,e,i){return t.getAttribute&&i.indexOf(t.getAttribute(e))>=0},findPhxSticky(t){return this.all(t,`[${yt}]`)},findPhxChildren(t,e){return this.all(t,`${$e}[${pe}="${e}"]`)},findExistingParentCIDs(t,e){let i=new Set,s=new Set;return e.forEach(n=>{this.all(document,`[${Te}="${t}"][${Y}="${n}"]`).forEach(r=>{i.add(n),this.all(r,`[${Te}="${t}"][${Y}]`).map(o=>parseInt(o.getAttribute(Y))).forEach(o=>s.add(o))})}),s.forEach(n=>i.delete(n)),i},private(t,e){return t[z]&&t[z][e]},deletePrivate(t,e){t[z]&&delete t[z][e]},putPrivate(t,e,i){t[z]||(t[z]={}),t[z][e]=i},updatePrivate(t,e,i,s){let n=this.private(t,e);n===void 0?this.putPrivate(t,e,s(i)):this.putPrivate(t,e,s(n))},syncPendingAttrs(t,e){t.hasAttribute(J)&&(hi.forEach(i=>{t.classList.contains(i)&&e.classList.add(i)}),Jt.filter(i=>t.hasAttribute(i)).forEach(i=>{e.setAttribute(i,t.getAttribute(i))}))},copyPrivates(t,e){e[z]&&(t[z]=e[z])},putTitle(t){let e=document.querySelector("title");if(e){let{prefix:i,suffix:s,default:n}=e.dataset,r=typeof t!="string"||t.trim()==="";if(r&&typeof n!="string")return;let o=r?n:t;document.title=`${i||""}${o||""}${s||""}`}else document.title=t},debounce(t,e,i,s,n,r,o,a){let h=t.getAttribute(i),l=t.getAttribute(n);h===""&&(h=s),l===""&&(l=r);let d=h||l;switch(d){case null:return a();case"blur":this.incCycle(t,"debounce-blur-cycle",()=>{o()&&a()}),this.once(t,"debounce-blur")&&t.addEventListener("blur",()=>this.triggerCycle(t,"debounce-blur-cycle"));return;default:let p=parseInt(d),g=()=>l?this.deletePrivate(t,Oe):a(),m=this.incCycle(t,Le,g);if(isNaN(p))return P(`invalid throttle/debounce value: ${d}`);if(l){let v=!1;if(e.type==="keydown"){let w=this.private(t,Vt);this.putPrivate(t,Vt,e.key),v=w!==e.key}if(!v&&this.private(t,Oe))return!1;{a();let w=setTimeout(()=>{o()&&this.triggerCycle(t,Le)},p);this.putPrivate(t,Oe,w)}}else setTimeout(()=>{o()&&this.triggerCycle(t,Le,m)},p);let u=t.form;u&&this.once(u,"bind-debounce")&&u.addEventListener("submit",()=>{Array.from(new FormData(u).entries(),([v])=>{let w=u.elements.namedItem(v),D=w instanceof RadioNodeList?w[0]:w;D&&(this.incCycle(D,Le),this.deletePrivate(D,Oe))})}),this.once(t,"bind-debounce")&&t.addEventListener("blur",()=>{clearTimeout(this.private(t,Oe)),this.triggerCycle(t,Le)})}},triggerCycle(t,e,i){let[s,n]=this.private(t,e);i||(i=s),i===s&&(this.incCycle(t,e),n())},once(t,e){return this.private(t,e)===!0?!1:(this.putPrivate(t,e,!0),!0)},incCycle(t,e,i=function(){}){let[s]=this.private(t,e)||[0,i];return s++,this.putPrivate(t,e,[s,i]),s},maintainPrivateHooks(t,e,i,s){t.hasAttribute&&t.hasAttribute("data-phx-hook")&&!e.hasAttribute("data-phx-hook")&&e.setAttribute("data-phx-hook",t.getAttribute("data-phx-hook")),e.hasAttribute&&(e.hasAttribute(i)||e.hasAttribute(s))&&e.setAttribute("data-phx-hook","Phoenix.InfiniteScroll")},putCustomElHook(t,e){t.isConnected?t.setAttribute("data-phx-hook",""):console.error(`
hook attached to non-connected DOM element
ensure you are calling createHook within your connectedCallback. ${t.outerHTML}
`),this.putPrivate(t,"custom-el-hook",e)},getCustomElHook(t){return this.private(t,"custom-el-hook")},isUsedInput(t){return t.nodeType===Node.ELEMENT_NODE&&(this.private(t,it)||this.private(t,Me))},resetForm(t){Array.from(t.elements).forEach(e=>{this.deletePrivate(e,it),this.deletePrivate(e,Me)})},isPhxChild(t){return t.getAttribute&&t.getAttribute(pe)},isPhxSticky(t){return t.getAttribute&&t.getAttribute(yt)!==null},isChildOfAny(t,e){return!!e.find(i=>i.contains(t))},firstPhxChild(t){return this.isPhxChild(t)?t:this.all(t,`[${pe}]`)[0]},isPortalTemplate(t){return t.tagName==="TEMPLATE"&&t.hasAttribute(_t)},closestViewEl(t){let e=t.closest(`[${me}],${$e}`);return e?e.hasAttribute(me)?this.byId(e.getAttribute(me)):e.hasAttribute(Q)?e:null:null},dispatchEvent(t,e,i={}){let s=!0;t.nodeName==="INPUT"&&t.type==="file"&&e==="click"&&(s=!1);let o={bubbles:i.bubbles===void 0?s:!!i.bubbles,cancelable:!0,detail:i.detail||{}},a=e==="click"?new MouseEvent("click",o):new CustomEvent(e,o);t.dispatchEvent(a)},cloneNode(t,e){if(typeof e>"u")return t.cloneNode(!0);{let i=t.cloneNode(!1);return i.innerHTML=e,i}},mergeAttrs(t,e,i={}){let s=new Set(i.exclude||[]),n=i.isIgnored,r=e.attributes;for(let a=r.length-1;a>=0;a--){let h=r[a].name;if(s.has(h)){if(h==="value"){let l=e.value??e.getAttribute(h);t.value===l&&t.setAttribute("value",e.getAttribute(h))}}else{let l=e.getAttribute(h);t.getAttribute(h)!==l&&(!n||n&&h.startsWith("data-"))&&t.setAttribute(h,l)}}let o=t.attributes;for(let a=o.length-1;a>=0;a--){let h=o[a].name;n?h.startsWith("data-")&&!e.hasAttribute(h)&&!Jt.includes(h)&&t.removeAttribute(h):e.hasAttribute(h)||t.removeAttribute(h)}},mergeFocusedInput(t,e){t instanceof HTMLSelectElement||de.mergeAttrs(t,e,{exclude:["value"]}),e.readOnly?t.setAttribute("readonly",!0):t.removeAttribute("readonly")},hasSelectionRange(t){return t.setSelectionRange&&(t.type==="text"||t.type==="textarea")},restoreFocus(t,e,i){if(t instanceof HTMLSelectElement&&t.focus(),!de.isTextualInput(t))return;t.matches(":focus")||t.focus(),this.hasSelectionRange(t)&&t.setSelectionRange(e,i)},isFormInput(t){return t.localName&&customElements.get(t.localName)?customElements.get(t.localName).formAssociated:/^(?:input|select|textarea)$/i.test(t.tagName)&&t.type!=="button"},syncAttrsToProps(t){t instanceof HTMLInputElement&&ui.indexOf(t.type.toLocaleLowerCase())>=0&&(t.checked=t.getAttribute("checked")!==null)},isTextualInput(t){return Mi.indexOf(t.type)>=0},isNowTriggerFormExternal(t,e){return t.getAttribute&&t.getAttribute(e)!==null&&document.body.contains(t)},cleanChildNodes(t,e){if(de.isPhxUpdate(t,e,["append","prepend",Ze])){let i=[];t.childNodes.forEach(s=>{s.id||(!(s.nodeType===Node.TEXT_NODE&&s.nodeValue.trim()==="")&&s.nodeType!==Node.COMMENT_NODE&&P(`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(t,e,i){let s=new Set(["id",Q,fe,Tt,ie]);if(t.tagName.toLowerCase()===e.toLowerCase())return Array.from(t.attributes).filter(n=>!s.has(n.name.toLowerCase())).forEach(n=>t.removeAttribute(n.name)),Object.keys(i).filter(n=>!s.has(n.toLowerCase())).forEach(n=>t.setAttribute(n,i[n])),t;{let n=document.createElement(e);return Object.keys(i).forEach(r=>n.setAttribute(r,i[r])),s.forEach(r=>n.setAttribute(r,t.getAttribute(r))),n.innerHTML=t.innerHTML,t.replaceWith(n),n}},getSticky(t,e,i){let s=(de.private(t,"sticky")||[]).find(([n])=>e===n);if(s){let[n,r,o]=s;return o}else return typeof i=="function"?i():i},deleteSticky(t,e){this.updatePrivate(t,"sticky",[],i=>i.filter(([s,n])=>s!==e))},putSticky(t,e,i){let s=i(t);this.updatePrivate(t,"sticky",[],n=>{let r=n.findIndex(([o])=>e===o);return r>=0?n[r]=[e,i,s]:n.push([e,i,s]),n})},applyStickyOperations(t){let e=de.private(t,"sticky");e&&e.forEach(([i,s,n])=>this.putSticky(t,i,s))},isLocked(t){return t.hasAttribute&&t.hasAttribute(O)},attributeIgnored(t,e){return e.some(i=>t.name==i||i==="*"||i.includes("*")&&t.name.match(i)!=null)}},c=de,He=class{static isActive(t,e){let i=e._phxRef===void 0,n=t.getAttribute(vt).split(",").indexOf(H.genFileRef(e))>=0;return e.size>0&&(i||n)}static isPreflighted(t,e){return t.getAttribute(Ct).split(",").indexOf(H.genFileRef(e))>=0&&this.isActive(t,e)}static isPreflightInProgress(t){return t._preflightInProgress===!0}static markPreflightInProgress(t){t._preflightInProgress=!0}constructor(t,e,i,s){this.ref=H.genFileRef(e),this.fileEl=t,this.file=e,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(Qe,this._onElUpdated),this.autoUpload=s}metadata(){return this.meta}progress(t){this._progress=Math.floor(t),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{H.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}isCancelled(){return this._isCancelled}cancel(){this.file._preflightInProgress=!1,this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(t="failed"){this.fileEl.removeEventListener(Qe,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:t}),this.isAutoUpload()||H.clearFiles(this.fileEl)}isAutoUpload(){return this.autoUpload}onDone(t){this._onDone=()=>{this.fileEl.removeEventListener(Qe,this._onElUpdated),t()}}onElUpdated(){this.fileEl.getAttribute(vt).split(",").indexOf(this.ref)===-1&&(H.untrackFile(this.fileEl,this.file),this.cancel())}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(t){if(this.meta.uploader){let e=t[this.meta.uploader]||P(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:e}}else return{name:"channel",callback:es}}zipPostFlight(t){this.meta=t.entries[this.ref],this.meta||P(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:t})}},ss=0,H=class kt{static genFileRef(e){let i=e._phxRef;return i!==void 0?i:(e._phxRef=(ss++).toString(),e._phxRef)}static getEntryDataURL(e,i,s){let n=this.activeFiles(e).find(r=>this.genFileRef(r)===i);s(URL.createObjectURL(n))}static hasUploadsInProgress(e){let i=0;return c.findUploadInputs(e).forEach(s=>{s.getAttribute(Ct)!==s.getAttribute(Di)&&i++}),i>0}static serializeUploads(e){let i=this.activeFiles(e),s={};return i.forEach(n=>{let r={path:e.name},o=e.getAttribute(se);s[o]=s[o]||[],r.ref=this.genFileRef(n),r.last_modified=n.lastModified,r.name=n.name||r.ref,r.relative_path=n.webkitRelativePath,r.type=n.type,r.size=n.size,typeof n.meta=="function"&&(r.meta=n.meta()),s[o].push(r)}),s}static clearFiles(e){e.value=null,e.removeAttribute(se),c.putPrivate(e,"files",[])}static untrackFile(e,i){c.putPrivate(e,"files",c.private(e,"files").filter(s=>!Object.is(s,i)))}static trackFiles(e,i,s){if(e.getAttribute("multiple")!==null){let n=i.filter(r=>!this.activeFiles(e).find(o=>Object.is(o,r)));c.updatePrivate(e,"files",[],r=>r.concat(n)),e.value=null}else s&&s.files.length>0&&(e.files=s.files),c.putPrivate(e,"files",i)}static activeFileInputs(e){let i=c.findUploadInputs(e);return Array.from(i).filter(s=>s.files&&this.activeFiles(s).length>0)}static activeFiles(e){return(c.private(e,"files")||[]).filter(i=>He.isActive(e,i))}static inputsAwaitingPreflight(e){let i=c.findUploadInputs(e);return Array.from(i).filter(s=>this.filesAwaitingPreflight(s).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(i=>!He.isPreflighted(e,i)&&!He.isPreflightInProgress(i))}static markPreflightInProgress(e){e.forEach(i=>He.markPreflightInProgress(i.file))}constructor(e,i,s){this.autoUpload=c.isAutoUpload(e),this.view=i,this.onComplete=s,this._entries=Array.from(kt.filesAwaitingPreflight(e)||[]).map(n=>new He(e,n,i,this.autoUpload)),kt.markPreflightInProgress(this._entries),this.numEntriesInProgress=this._entries.length}isAutoUpload(){return this.autoUpload}entries(){return this._entries}initAdapterUpload(e,i,s){this._entries=this._entries.map(r=>(r.isCancelled()?(this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()):(r.zipPostFlight(e),r.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()})),r));let n=this._entries.reduce((r,o)=>{if(!o.meta)return r;let{name:a,callback:h}=o.uploader(s.uploaders);return r[a]=r[a]||{callback:h,entries:[]},r[a].entries.push(o),r},{});for(let r in n){let{callback:o,entries:a}=n[r];o(a,i,e,s)}}},ns={anyOf(t,e){return e.find(i=>t instanceof i)},isFocusable(t,e){return t instanceof HTMLAnchorElement&&t.rel!=="ignore"||t instanceof HTMLAreaElement&&t.href!==void 0||!t.disabled&&this.anyOf(t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||t instanceof HTMLIFrameElement||t.tabIndex>=0&&t.getAttribute("aria-hidden")!=="true"||!e&&t.getAttribute("tabindex")!==null&&t.getAttribute("aria-hidden")!=="true"},attemptFocus(t,e){if(this.isFocusable(t,e))try{t.focus()}catch{}return!!document.activeElement&&document.activeElement.isSameNode(t)},focusFirstInteractive(t){let e=t.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e))return!0;e=e.nextElementSibling}},focusFirst(t){let e=t.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(t){let e=t.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},B=ns,fi={LiveFileUpload:{activeRefs(){return this.el.getAttribute(vt)},preflightedRefs(){return this.el.getAttribute(Ct)},mounted(){this.js().ignoreAttributes(this.el,["value"]),this.preflightedWas=this.preflightedRefs()},updated(){let t=this.preflightedRefs();this.preflightedWas!==t&&(this.preflightedWas=t,t===""&&this.__view().cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(Qe))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(se)),H.getEntryDataURL(this.inputEl,this.ref,t=>{this.url=t,this.el.src=t})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",t=>{if(!t.relatedTarget||!this.el.contains(t.relatedTarget)){let e=t.target.nextElementSibling;B.attemptFocus(e)||B.focusFirst(e)}else B.focusLast(this.el)}),this.focusEnd.addEventListener("focus",t=>{if(!t.relatedTarget||!this.el.contains(t.relatedTarget)){let e=t.target.previousElementSibling;B.attemptFocus(e)||B.focusLast(e)}else B.focusFirst(this.el)}),this.el.contains(document.activeElement)||(this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&B.focusFirst(this.el))}}},pi=t=>["HTML","BODY"].indexOf(t.nodeName.toUpperCase())>=0?null:["scroll","auto"].indexOf(getComputedStyle(t).overflowY)>=0?t:pi(t.parentElement),zt=t=>t?t.scrollTop:document.documentElement.scrollTop||document.body.scrollTop,Pt=t=>t?t.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight,Rt=t=>t?t.getBoundingClientRect().top:0,rs=(t,e)=>{let i=t.getBoundingClientRect();return Math.ceil(i.top)>=Rt(e)&&Math.ceil(i.left)>=0&&Math.floor(i.top)<=Pt(e)},os=(t,e)=>{let i=t.getBoundingClientRect();return Math.ceil(i.bottom)>=Rt(e)&&Math.ceil(i.left)>=0&&Math.floor(i.bottom)<=Pt(e)},Gt=(t,e)=>{let i=t.getBoundingClientRect();return Math.ceil(i.top)>=Rt(e)&&Math.ceil(i.left)>=0&&Math.floor(i.top)<=Pt(e)};fi.InfiniteScroll={mounted(){this.scrollContainer=pi(this.el);let t=zt(this.scrollContainer),e=!1,i=500,s=null,n=this.throttle(i,(a,h)=>{s=()=>!0,this.liveSocket.js().push(this.el,a,{value:{id:h.id,_overran:!0},callback:()=>{s=null}})}),r=this.throttle(i,(a,h)=>{s=()=>h.scrollIntoView({block:"start"}),this.liveSocket.js().push(this.el,a,{value:{id:h.id},callback:()=>{s=null,window.requestAnimationFrame(()=>{Gt(h,this.scrollContainer)||h.scrollIntoView({block:"start"})})}})}),o=this.throttle(i,(a,h)=>{s=()=>h.scrollIntoView({block:"end"}),this.liveSocket.js().push(this.el,a,{value:{id:h.id},callback:()=>{s=null,window.requestAnimationFrame(()=>{Gt(h,this.scrollContainer)||h.scrollIntoView({block:"end"})})}})});this.onScroll=a=>{let h=zt(this.scrollContainer);if(s)return t=h,s();let l=this.findOverrunTarget(),d=this.el.getAttribute(this.liveSocket.binding("viewport-top")),p=this.el.getAttribute(this.liveSocket.binding("viewport-bottom")),g=this.el.lastElementChild,m=this.el.firstElementChild,u=h<t,v=h>t;u&&d&&!e&&l.top>=0?(e=!0,n(d,m)):v&&e&&l.top<=0&&(e=!1),d&&u&&rs(m,this.scrollContainer)?r(d,m):p&&v&&os(g,this.scrollContainer)&&o(p,g),t=h},this.scrollContainer?this.scrollContainer.addEventListener("scroll",this.onScroll):window.addEventListener("scroll",this.onScroll)},destroyed(){this.scrollContainer?this.scrollContainer.removeEventListener("scroll",this.onScroll):window.removeEventListener("scroll",this.onScroll)},throttle(t,e){let i=0,s;return(...n)=>{let r=Date.now(),o=t-(r-i);o<=0||o>t?(s&&(clearTimeout(s),s=null),i=r,e(...n)):s||(s=setTimeout(()=>{i=Date.now(),s=null,e(...n)},o))}},findOverrunTarget(){let t,e=this.el.getAttribute(this.liveSocket.binding(Hi));if(e){let i=document.getElementById(e);if(i)t=i.getBoundingClientRect();else throw new Error("did not find element with id "+e)}else t=this.el.getBoundingClientRect();return t}};var as=fi,Et=class{static onUnlock(t,e){if(!c.isLocked(t)&&!t.closest(`[${O}]`))return e();let i=t.closest(`[${O}]`),s=i.closest(`[${O}]`).getAttribute(O);i.addEventListener(`phx:undo-lock:${s}`,()=>{e()},{once:!0})}constructor(t){this.el=t,this.loadingRef=t.hasAttribute(_e)?parseInt(t.getAttribute(_e),10):null,this.lockRef=t.hasAttribute(O)?parseInt(t.getAttribute(O),10):null}maybeUndo(t,e,i){if(!this.isWithin(t)){c.updatePrivate(this.el,Dt,[],s=>(s.push(t),s));return}this.undoLocks(t,e,i),this.undoLoading(t,e),c.updatePrivate(this.el,Dt,[],s=>s.filter(n=>{let r={detail:{ref:n,event:e},bubbles:!0,cancelable:!1};return this.loadingRef&&this.loadingRef>n&&this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${n}`,r)),this.lockRef&&this.lockRef>n&&this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${n}`,r)),n>t})),this.isFullyResolvedBy(t)&&this.el.removeAttribute(J)}isWithin(t){return!(this.loadingRef!==null&&this.loadingRef>t&&this.lockRef!==null&&this.lockRef>t)}undoLocks(t,e,i){if(!this.isLockUndoneBy(t))return;let s=c.private(this.el,O);s&&(i(s),c.deletePrivate(this.el,O)),this.el.removeAttribute(O);let n={detail:{ref:t,event:e},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${this.lockRef}`,n))}undoLoading(t,e){if(!this.isLoadingUndoneBy(t)){this.canUndoLoading(t)&&this.el.classList.contains("phx-submit-loading")&&this.el.classList.remove("phx-change-loading");return}if(this.canUndoLoading(t)){this.el.removeAttribute(_e);let i=this.el.getAttribute(Se),s=this.el.getAttribute(At);s!==null&&(this.el.readOnly=s==="true",this.el.removeAttribute(At)),i!==null&&(this.el.disabled=i==="true",this.el.removeAttribute(Se));let n=this.el.getAttribute(st);n!==null&&(this.el.textContent=n,this.el.removeAttribute(st));let r={detail:{ref:t,event:e},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${this.loadingRef}`,r))}hi.forEach(i=>{(i!=="phx-submit-loading"||this.canUndoLoading(t))&&c.removeClass(this.el,i)})}isLoadingUndoneBy(t){return this.loadingRef===null?!1:this.loadingRef<=t}isLockUndoneBy(t){return this.lockRef===null?!1:this.lockRef<=t}isFullyResolvedBy(t){return(this.loadingRef===null||this.loadingRef<=t)&&(this.lockRef===null||this.lockRef<=t)}canUndoLoading(t){return this.lockRef===null||this.lockRef<=t}},hs=class{constructor(t,e,i){let s=new Set,n=new Set([...e.children].map(o=>o.id)),r=[];Array.from(t.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=e.id,this.updateType=i,this.elementsToModify=r,this.elementIdsToAdd=[...n].filter(o=>!s.has(o))}perform(){let t=c.byId(this.containerId);t&&(this.elementsToModify.forEach(e=>{e.previousElementId?Ce(document.getElementById(e.previousElementId),i=>{Ce(document.getElementById(e.elementId),s=>{s.previousElementSibling&&s.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",s)})}):Ce(document.getElementById(e.elementId),i=>{i.previousElementSibling==null||t.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(e=>{Ce(document.getElementById(e),i=>t.insertAdjacentElement("afterbegin",i))}))}},Yt=11;function ls(t,e){var i=e.attributes,s,n,r,o,a;if(!(e.nodeType===Yt||t.nodeType===Yt)){for(var h=i.length-1;h>=0;h--)s=i[h],n=s.name,r=s.namespaceURI,o=s.value,r?(n=s.localName||n,a=t.getAttributeNS(r,n),a!==o&&(s.prefix==="xmlns"&&(n=s.name),t.setAttributeNS(r,n,o))):(a=t.getAttribute(n),a!==o&&t.setAttribute(n,o));for(var l=t.attributes,d=l.length-1;d>=0;d--)s=l[d],n=s.name,r=s.namespaceURI,r?(n=s.localName||n,e.hasAttributeNS(r,n)||t.removeAttributeNS(r,n)):e.hasAttribute(n)||t.removeAttribute(n)}}var Ke,cs="http://www.w3.org/1999/xhtml",U=typeof document>"u"?void 0:document,ds=!!U&&"content"in U.createElement("template"),us=!!U&&U.createRange&&"createContextualFragment"in U.createRange();function fs(t){var e=U.createElement("template");return e.innerHTML=t,e.content.childNodes[0]}function ps(t){Ke||(Ke=U.createRange(),Ke.selectNode(U.body));var e=Ke.createContextualFragment(t);return e.childNodes[0]}function ms(t){var e=U.createElement("body");return e.innerHTML=t,e.childNodes[0]}function gs(t){return t=t.trim(),ds?fs(t):us?ps(t):ms(t)}function ze(t,e){var i=t.nodeName,s=e.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 vs(t,e){return!e||e===cs?U.createElement(t):U.createElementNS(e,t)}function bs(t,e){for(var i=t.firstChild;i;){var s=i.nextSibling;e.appendChild(i),i=s}return e}function mt(t,e,i){t[i]!==e[i]&&(t[i]=e[i],t[i]?t.setAttribute(i,""):t.removeAttribute(i))}var Qt={OPTION:function(t,e){var i=t.parentNode;if(i){var s=i.nodeName.toUpperCase();s==="OPTGROUP"&&(i=i.parentNode,s=i&&i.nodeName.toUpperCase()),s==="SELECT"&&!i.hasAttribute("multiple")&&(t.hasAttribute("selected")&&!e.selected&&(t.setAttribute("selected","selected"),t.removeAttribute("selected")),i.selectedIndex=-1)}mt(t,e,"selected")},INPUT:function(t,e){mt(t,e,"checked"),mt(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),e.hasAttribute("value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var i=e.value;t.value!==i&&(t.value=i);var s=t.firstChild;if(s){var n=s.nodeValue;if(n==i||!i&&n==t.placeholder)return;s.nodeValue=i}},SELECT:function(t,e){if(!e.hasAttribute("multiple")){for(var i=-1,s=0,n=t.firstChild,r,o;n;)if(o=n.nodeName&&n.nodeName.toUpperCase(),o==="OPTGROUP")r=n,n=r.firstChild,n||(n=r.nextSibling,r=null);else{if(o==="OPTION"){if(n.hasAttribute("selected")){i=s;break}s++}n=n.nextSibling,!n&&r&&(n=r.nextSibling,r=null)}t.selectedIndex=i}}},Ne=1,Zt=11,ei=3,ti=8;function ae(){}function ws(t){if(t)return t.getAttribute&&t.getAttribute("id")||t.id}function ys(t){return function(i,s,n){if(n||(n={}),typeof s=="string")if(i.nodeName==="#document"||i.nodeName==="HTML"){var r=s;s=U.createElement("html"),s.innerHTML=r}else if(i.nodeName==="BODY"){var o=s;s=U.createElement("html"),s.innerHTML=o;var a=s.querySelector("body");a&&(s=a)}else s=gs(s);else s.nodeType===Zt&&(s=s.firstElementChild);var h=n.getNodeKey||ws,l=n.onBeforeNodeAdded||ae,d=n.onNodeAdded||ae,p=n.onBeforeElUpdated||ae,g=n.onElUpdated||ae,m=n.onBeforeNodeDiscarded||ae,u=n.onNodeDiscarded||ae,v=n.onBeforeElChildrenUpdated||ae,w=n.skipFromChildren||ae,D=n.addChild||function(y,A){return y.appendChild(A)},X=n.childrenOnly===!0,k=Object.create(null),C=[];function R(y){C.push(y)}function N(y,A){if(y.nodeType===Ne)for(var L=y.firstChild;L;){var E=void 0;A&&(E=h(L))?R(E):(u(L),L.firstChild&&N(L,A)),L=L.nextSibling}}function f(y,A,L){m(y)!==!1&&(A&&A.removeChild(y),u(y),N(y,L))}function b(y){if(y.nodeType===Ne||y.nodeType===Zt)for(var A=y.firstChild;A;){var L=h(A);L&&(k[L]=A),b(A),A=A.nextSibling}}b(i);function M(y){d(y);for(var A=y.firstChild;A;){var L=A.nextSibling,E=h(A);if(E){var T=k[E];T&&ze(A,T)?(A.parentNode.replaceChild(T,A),x(T,A)):M(A)}else M(A);A=L}}function W(y,A,L){for(;A;){var E=A.nextSibling;(L=h(A))?R(L):f(A,y,!0),A=E}}function x(y,A,L){var E=h(A);if(E&&delete k[E],!L){var T=p(y,A);if(T===!1||(T instanceof HTMLElement&&(y=T,b(y)),t(y,A),g(y),v(y,A)===!1))return}y.nodeName!=="TEXTAREA"?ge(y,A):Qt.TEXTAREA(y,A)}function ge(y,A){var L=w(y,A),E=A.firstChild,T=y.firstChild,ve,Z,be,Fe,ne;e:for(;E;){for(Fe=E.nextSibling,ve=h(E);!L&&T;){if(be=T.nextSibling,E.isSameNode&&E.isSameNode(T)){E=Fe,T=be;continue e}Z=h(T);var je=T.nodeType,re=void 0;if(je===E.nodeType&&(je===Ne?(ve?ve!==Z&&((ne=k[ve])?be===ne?re=!1:(y.insertBefore(ne,T),Z?R(Z):f(T,y,!0),T=ne,Z=h(T)):re=!1):Z&&(re=!1),re=re!==!1&&ze(T,E),re&&x(T,E)):(je===ei||je==ti)&&(re=!0,T.nodeValue!==E.nodeValue&&(T.nodeValue=E.nodeValue))),re){E=Fe,T=be;continue e}Z?R(Z):f(T,y,!0),T=be}if(ve&&(ne=k[ve])&&ze(ne,E))L||D(y,ne),x(ne,E);else{var at=l(E);at!==!1&&(at&&(E=at),E.actualize&&(E=E.actualize(y.ownerDocument||U)),D(y,E),M(E))}E=Fe,T=be}W(y,T,Z);var It=Qt[y.nodeName];It&&It(y,A)}var _=i,Ue=_.nodeType,xt=s.nodeType;if(!X){if(Ue===Ne)xt===Ne?ze(i,s)||(u(i),_=bs(i,vs(s.nodeName,s.namespaceURI))):_=s;else if(Ue===ei||Ue===ti){if(xt===Ue)return _.nodeValue!==s.nodeValue&&(_.nodeValue=s.nodeValue),_;_=s}}if(_===s)u(i);else{if(s.isSameNode&&s.isSameNode(_))return;if(x(_,s,X),C)for(var rt=0,yi=C.length;rt<yi;rt++){var ot=k[C[rt]];ot&&f(ot,ot.parentNode,!1)}}return!X&&_!==i&&i.parentNode&&(_.actualize&&(_=_.actualize(i.ownerDocument||U)),i.parentNode.replaceChild(_,i)),_}}var As=ys(ls),St=As,Ge=class{constructor(t,e,i,s,n,r,o={}){this.view=t,this.liveSocket=t.liveSocket,this.container=e,this.id=i,this.rootID=t.root.id,this.html=s,this.streams=n,this.streamInserts={},this.streamComponentRestore={},this.targetCID=r,this.cidPatch=te(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.targetContainer=this.isCIDPatch()?this.targetCIDContainer(s):e,this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]},this.withChildren=o.withChildren||o.undoRef||!1,this.undoRef=o.undoRef}before(t,e){this.callbacks[`before${t}`].push(e)}after(t,e){this.callbacks[`after${t}`].push(e)}trackBefore(t,...e){this.callbacks[`before${t}`].forEach(i=>i(...e))}trackAfter(t,...e){this.callbacks[`after${t}`].forEach(i=>i(...e))}markPrunableContentForRemoval(){let t=this.liveSocket.binding(nt);c.all(this.container,`[${t}=append] > *, [${t}=prepend] > *`,e=>{e.setAttribute(Ht,"")})}perform(t){let{view:e,liveSocket:i,html:s,container:n}=this,r=this.targetContainer;if(this.isCIDPatch()&&!this.targetContainer)return;if(this.isCIDPatch()){let k=r.closest(`[${O}]`);if(k&&!k.isSameNode(r)){let C=c.private(k,O);C&&(r=C.querySelector(`[data-phx-component="${this.targetCID}"]`))}}let o=i.getActiveElement(),{selectionStart:a,selectionEnd:h}=o&&c.hasSelectionRange(o)?o:{},l=i.binding(nt),d=i.binding(bt),p=i.binding(wt),g=i.binding(Ni),m=[],u=[],v=[],w=[],D=null,X=(k,C,R=this.withChildren)=>{let N={childrenOnly:k.getAttribute(Y)===null&&!R,getNodeKey:f=>c.isPhxDestroyed(f)?null:t?f.id:f.id||f.getAttribute&&f.getAttribute(di),skipFromChildren:f=>f.getAttribute(l)===Ze,addChild:(f,b)=>{let{ref:M,streamAt:W}=this.getStreamInsert(b);if(M===void 0)return f.appendChild(b);if(this.setStreamRef(b,M),W===0)f.insertAdjacentElement("afterbegin",b);else if(W===-1){let x=f.lastElementChild;if(x&&!x.hasAttribute(Ie)){let ge=Array.from(f.children).find(_=>!_.hasAttribute(Ie));f.insertBefore(b,ge)}else f.appendChild(b)}else if(W>0){let x=Array.from(f.children)[W];f.insertBefore(b,x)}},onBeforeNodeAdded:f=>{if(this.getStreamInsert(f)?.updateOnly&&!this.streamComponentRestore[f.id])return!1;c.maintainPrivateHooks(f,f,d,p),this.trackBefore("added",f);let b=f;return this.streamComponentRestore[f.id]&&(b=this.streamComponentRestore[f.id],delete this.streamComponentRestore[f.id],X(b,f,!0)),b},onNodeAdded:f=>{f.getAttribute&&this.maybeReOrderStream(f,!0),c.isPortalTemplate(f)&&w.push(()=>this.teleport(f,X)),f instanceof HTMLImageElement&&f.srcset?f.srcset=f.srcset:f instanceof HTMLVideoElement&&f.autoplay&&f.play(),c.isNowTriggerFormExternal(f,g)&&(D=f),(c.isPhxChild(f)&&e.ownsElement(f)||c.isPhxSticky(f)&&e.ownsElement(f.parentNode))&&this.trackAfter("phxChildAdded",f),f.nodeName==="SCRIPT"&&f.hasAttribute(et)&&this.handleRuntimeHook(f,C),m.push(f)},onNodeDiscarded:f=>this.onNodeDiscarded(f),onBeforeNodeDiscarded:f=>{if(f.getAttribute&&f.getAttribute(Ht)!==null)return!0;if(f.parentElement!==null&&f.id&&c.isPhxUpdate(f.parentElement,l,[Ze,"append","prepend"])||f.getAttribute&&f.getAttribute(me)||this.maybePendingRemove(f)||this.skipCIDSibling(f))return!1;if(c.isPortalTemplate(f)){let b=document.getElementById(f.content.firstElementChild.id);b&&(b.remove(),N.onNodeDiscarded(b),this.view.dropPortalElementId(b.id))}return!0},onElUpdated:f=>{c.isNowTriggerFormExternal(f,g)&&(D=f),u.push(f),this.maybeReOrderStream(f,!1)},onBeforeElUpdated:(f,b)=>{if(f.id&&f.isSameNode(k)&&f.id!==b.id)return N.onNodeDiscarded(f),f.replaceWith(b),N.onNodeAdded(b);if(c.syncPendingAttrs(f,b),c.maintainPrivateHooks(f,b,d,p),c.cleanChildNodes(b,l),this.skipCIDSibling(b))return this.maybeReOrderStream(f),!1;if(c.isPhxSticky(f))return[Q,fe,ie].map(x=>[x,f.getAttribute(x),b.getAttribute(x)]).forEach(([x,ge,_])=>{_&&ge!==_&&f.setAttribute(x,_)}),!1;if(c.isIgnored(f,l)||f.form&&f.form.isSameNode(D))return this.trackBefore("updated",f,b),c.mergeAttrs(f,b,{isIgnored:c.isIgnored(f,l)}),u.push(f),c.applyStickyOperations(f),!1;if(f.type==="number"&&f.validity&&f.validity.badInput)return!1;let M=o&&f.isSameNode(o)&&c.isFormInput(f),W=M&&this.isChangedSelect(f,b);if(f.hasAttribute(J)){let x=new Et(f);if(x.lockRef&&(!this.undoRef||!x.isLockUndoneBy(this.undoRef))){c.applyStickyOperations(f);let _=f.hasAttribute(O)?c.private(f,O)||f.cloneNode(!0):null;_&&(c.putPrivate(f,O,_),M||(f=_))}}if(c.isPhxChild(b)){let x=f.getAttribute(Q);return c.mergeAttrs(f,b,{exclude:[fe]}),x!==""&&f.setAttribute(Q,x),f.setAttribute(ie,this.rootID),c.applyStickyOperations(f),!1}return this.undoRef&&c.private(b,O)&&c.putPrivate(f,O,c.private(b,O)),c.copyPrivates(b,f),c.isPortalTemplate(b)?(w.push(()=>this.teleport(b,X)),f.content.replaceChildren(b.content.cloneNode(!0)),!1):M&&f.type!=="hidden"&&!W?(this.trackBefore("updated",f,b),c.mergeFocusedInput(f,b),c.syncAttrsToProps(f),u.push(f),c.applyStickyOperations(f),!1):(W&&f.blur(),c.isPhxUpdate(b,l,["append","prepend"])&&v.push(new hs(f,b,b.getAttribute(l))),c.syncAttrsToProps(b),c.applyStickyOperations(b),this.trackBefore("updated",f,b),f)}};St(k,C,N)};if(this.trackBefore("added",n),this.trackBefore("updated",n,n),i.time("morphdom",()=>{this.streams.forEach(([C,R,N,f])=>{R.forEach(([b,M,W,x])=>{this.streamInserts[b]={ref:C,streamAt:M,limit:W,reset:f,updateOnly:x}}),f!==void 0&&c.all(document,`[${Ie}="${C}"]`,b=>{this.removeStreamChildElement(b)}),N.forEach(b=>{let M=document.getElementById(b);M&&this.removeStreamChildElement(M)})}),t&&c.all(this.container,`[${l}=${Ze}]`).filter(C=>this.view.ownsElement(C)).forEach(C=>{Array.from(C.children).forEach(R=>{this.removeStreamChildElement(R,!0)})}),X(r,s);let k=0;for(;w.length>0&&k<5;){let C=w.slice();w=[],C.forEach(R=>R()),k++}this.view.portalElementIds.forEach(C=>{let R=document.getElementById(C);R&&(document.getElementById(R.getAttribute(he))||(R.remove(),this.onNodeDiscarded(R),this.view.dropPortalElementId(C)))})}),i.isDebugEnabled()&&(Gi(),Yi(this.streamInserts),Array.from(document.querySelectorAll("input[name=id]")).forEach(k=>{k instanceof HTMLInputElement&&k.form&&console.error(`Detected an input with name="id" inside a form! This will cause problems when patching the DOM.
`,k)})),v.length>0&&i.time("post-morph append/prepend restoration",()=>{v.forEach(k=>k.perform())}),i.silenceEvents(()=>c.restoreFocus(o,a,h)),c.dispatchEvent(document,"phx:update"),m.forEach(k=>this.trackAfter("added",k)),u.forEach(k=>this.trackAfter("updated",k)),this.transitionPendingRemoves(),D){i.unload();let k=c.private(D,"submitter");if(k&&k.name&&r.contains(k)){let C=document.createElement("input");C.type="hidden";let R=k.getAttribute("form");R&&C.setAttribute("form",R),C.name=k.name,C.value=k.value,k.parentElement.insertBefore(C,k)}Object.getPrototypeOf(D).submit.call(D)}return!0}onNodeDiscarded(t){(c.isPhxChild(t)||c.isPhxSticky(t))&&this.liveSocket.destroyViewByEl(t),this.trackAfter("discarded",t)}maybePendingRemove(t){return t.getAttribute&&t.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(t),!0):!1}removeStreamChildElement(t,e=!1){!e&&!this.view.ownsElement(t)||(this.streamInserts[t.id]?(this.streamComponentRestore[t.id]=t,t.remove()):this.maybePendingRemove(t)||(t.remove(),this.onNodeDiscarded(t)))}getStreamInsert(t){return(t.id?this.streamInserts[t.id]:{})||{}}setStreamRef(t,e){c.putSticky(t,Ie,i=>i.setAttribute(Ie,e))}maybeReOrderStream(t,e){let{ref:i,streamAt:s,reset:n}=this.getStreamInsert(t);if(s!==void 0&&(this.setStreamRef(t,i),!(!n&&!e)&&t.parentElement)){if(s===0)t.parentElement.insertBefore(t,t.parentElement.firstElementChild);else if(s>0){let r=Array.from(t.parentElement.children),o=r.indexOf(t);if(s>=r.length-1)t.parentElement.appendChild(t);else{let a=r[s];o>s?t.parentElement.insertBefore(t,a):t.parentElement.insertBefore(t,a.nextElementSibling)}}this.maybeLimitStream(t)}}maybeLimitStream(t){let{limit:e}=this.getStreamInsert(t),i=e!==null&&Array.from(t.parentElement.children);e&&e<0&&i.length>e*-1?i.slice(0,i.length+e).forEach(s=>this.removeStreamChildElement(s)):e&&e>=0&&i.length>e&&i.slice(e).forEach(s=>this.removeStreamChildElement(s))}transitionPendingRemoves(){let{pendingRemoves:t,liveSocket:e}=this;t.length>0&&e.transitionRemoves(t,()=>{t.forEach(i=>{let s=c.firstPhxChild(i);s&&e.destroyViewByEl(s),i.remove()}),this.trackAfter("transitionsDiscarded",t)})}isChangedSelect(t,e){return!(t instanceof HTMLSelectElement)||t.multiple?!1:t.options.length!==e.options.length?!0:(e.value=t.value,!t.isEqualNode(e))}isCIDPatch(){return this.cidPatch}skipCIDSibling(t){return t.nodeType===Node.ELEMENT_NODE&&t.hasAttribute(ci)}targetCIDContainer(t){if(!this.isCIDPatch())return;let[e,...i]=c.findComponentNodeList(this.view.id,this.targetCID);return i.length===0&&c.childNodeLength(t)===1?e:e&&e.parentNode}indexOf(t,e){return Array.from(t.children).indexOf(e)}teleport(t,e){let i=t.getAttribute(_t),s=document.querySelector(i);if(!s)throw new Error("portal target with selector "+i+" not found");let n=t.content.firstElementChild;if(this.skipCIDSibling(n))return;if(!n?.id)throw new Error("phx-portal template must have a single root element with ID!");let r=document.getElementById(n.id),o;r?(s.contains(r)||s.appendChild(r),o=r):(o=document.createElement(n.tagName),s.appendChild(o)),n.setAttribute(me,this.view.id),n.setAttribute(he,t.id),e(o,n,!0),n.removeAttribute(me),n.removeAttribute(he),this.view.pushPortalElementId(n.id)}handleRuntimeHook(t,e){let i=t.getAttribute(et),s=t.hasAttribute("nonce")?t.getAttribute("nonce"):null;if(t.hasAttribute("nonce")){let r=document.createElement("template");r.innerHTML=e,s=r.content.querySelector(`script[${et}="${CSS.escape(i)}"]`).getAttribute("nonce")}let n=document.createElement("script");n.textContent=t.textContent,c.mergeAttrs(n,t,{isIgnored:!1}),s&&(n.nonce=s),t.replaceWith(n),t=n}},ks=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),Es=new Set(["'",'"']),ii=(t,e,i)=>{let s=0,n=!1,r,o,a,h,l,d,p=t.match(/^(\s*(?:<!--.*?-->\s*)*)<([^\s\/>]+)/);if(p===null)throw new Error(`malformed html ${t}`);for(s=p[0].length,r=p[1],a=p[2],h=s,s;s<t.length&&t.charAt(s)!==">";s++)if(t.charAt(s)==="="){let u=t.slice(s-3,s)===" id";s++;let v=t.charAt(s);if(Es.has(v)){let w=s;for(s++,s;s<t.length&&t.charAt(s)!==v;s++);if(u){l=t.slice(w+1,s);break}}}let g=t.length-1;for(n=!1;g>=r.length+a.length;){let u=t.charAt(g);if(n)u==="-"&&t.slice(g-3,g)==="<!-"?(n=!1,g-=4):g-=1;else if(u===">"&&t.slice(g-2,g)==="--")n=!0,g-=3;else{if(u===">")break;g-=1}}o=t.slice(g+1,t.length);let m=Object.keys(e).map(u=>e[u]===!0?u:`${u}="${e[u]}"`).join(" ");if(i){let u=l?` id="${l}"`:"";ks.has(a)?d=`<${a}${u}${m===""?"":" "}${m}/>`:d=`<${a}${u}${m===""?"":" "}${m}></${a}>`}else{let u=t.slice(h,g+1);d=`<${a}${m===""?"":" "}${m}${u}`}return[d,r,o]},si=class{static extract(t){let{[Wt]:e,[Xt]:i,[qt]:s}=t;return delete t[Wt],delete t[Xt],delete t[qt],{diff:t,title:s,reply:e||null,events:i||[]}}constructor(t,e){this.viewId=t,this.rendered={},this.magicId=0,this.mergeDiff(e)}parentViewId(){return this.viewId}toString(t){let{buffer:e,streams:i}=this.recursiveToString(this.rendered,this.rendered[$],t,!0,{});return{buffer:e,streams:i}}recursiveToString(t,e=t[$],i,s,n){i=i?new Set(i):null;let r={buffer:"",components:e,onlyCids:i,streams:new Set};return this.toOutputBuffer(t,null,r,s,n),{buffer:r.buffer,streams:r.streams}}componentCIDs(t){return Object.keys(t[$]||{}).map(e=>parseInt(e))}isComponentOnlyDiff(t){return t[$]?Object.keys(t).length===1:!1}getComponent(t,e){return t[$][e]}resetRender(t){this.rendered[$][t]&&(this.rendered[$][t].reset=!0)}mergeDiff(t){let e=t[$],i={};if(delete t[$],this.rendered=this.mutableMerge(this.rendered,t),this.rendered[$]=this.rendered[$]||{},e){let s=this.rendered[$];for(let n in e)e[n]=this.cachedFindComponent(n,e[n],s,e,i);for(let n in e)s[n]=e[n];t[$]=e}}cachedFindComponent(t,e,i,s,n){if(n[t])return n[t];{let r,o,a=e[V];if(te(a)){let h;a>0?h=this.cachedFindComponent(a,s[a],i,s,n):h=i[-a],o=h[V],r=this.cloneMerge(h,e,!0),r[V]=o}else r=e[V]!==void 0||i[t]===void 0?e:this.cloneMerge(i[t],e,!1);return n[t]=r,r}}mutableMerge(t,e){return e[V]!==void 0?e:(this.doMutableMerge(t,e),t)}doMutableMerge(t,e){if(e[I])this.mergeKeyed(t,e);else for(let i in e){let s=e[i],n=t[i];Ee(s)&&s[V]===void 0&&Ee(n)?this.doMutableMerge(n,s):t[i]=s}t[pt]&&(t.newRender=!0)}clone(t){return"structuredClone"in window?structuredClone(t):JSON.parse(JSON.stringify(t))}mergeKeyed(t,e){let i=this.clone(t);if(Object.entries(e[I]).forEach(([s,n])=>{if(s!==G)if(Array.isArray(n)){let[r,o]=n;t[I][s]=i[I][r],this.doMutableMerge(t[I][s],o)}else if(typeof n=="number"){let r=n;t[I][s]=i[I][r]}else typeof n=="object"&&(t[I][s]||(t[I][s]={}),this.doMutableMerge(t[I][s],n))}),e[I][G]<t[I][G])for(let s=e[I][G];s<t[I][G];s++)delete t[I][s];t[I][G]=e[I][G],e[ke]&&(t[ke]=e[ke]),e[oe]&&(t[oe]=e[oe])}cloneMerge(t,e,i){let s;if(e[I])s=this.clone(t),this.mergeKeyed(s,e);else{s={...t,...e};for(let n in s){let r=e[n],o=t[n];Ee(r)&&r[V]===void 0&&Ee(o)?s[n]=this.cloneMerge(o,r,i):r===void 0&&Ee(o)&&(s[n]=this.cloneMerge(o,{},i))}}return i?(delete s.magicId,delete s.newRender):t[pt]&&(s.newRender=!0),s}componentToString(t){let{buffer:e,streams:i}=this.recursiveCIDToString(this.rendered[$],t,null),[s,n,r]=ii(e,{});return{buffer:s,streams:i}}pruneCIDs(t){t.forEach(e=>delete this.rendered[$][e])}get(){return this.rendered}isNewFingerprint(t={}){return!!t[V]}templateStatic(t,e){return typeof t=="number"?e[t]:t}nextMagicID(){return this.magicId++,`m${this.magicId}-${this.parentViewId()}`}toOutputBuffer(t,e,i,s,n={}){if(t[I])return this.comprehensionToBuffer(t,e,i,s);t[oe]&&(e=t[oe],delete t[oe]);let{[V]:r}=t;r=this.templateStatic(r,e),t[V]=r;let o=t[pt],a=i.buffer;o&&(i.buffer=""),s&&o&&!t.magicId&&(t.newRender=!0,t.magicId=this.nextMagicID()),i.buffer+=r[0];for(let h=1;h<r.length;h++)this.dynamicToBuffer(t[h-1],e,i,s),i.buffer+=r[h];if(o){let h=!1,l;s||t.magicId?(h=s&&!t.newRender,l={[di]:t.magicId,...n}):l=n,h&&(l[ci]=!0);let[d,p,g]=ii(i.buffer,l,h);t.newRender=!1,i.buffer=a+p+d+g}}comprehensionToBuffer(t,e,i,s){let n=e||t[oe],r=this.templateStatic(t[V],e);t[V]=r,delete t[oe];for(let o=0;o<t[I][G];o++){i.buffer+=r[0];for(let a=1;a<r.length;a++)this.dynamicToBuffer(t[I][o][a-1],n,i,s),i.buffer+=r[a]}if(t[ke]){let o=t[ke],[a,h,l,d]=o||[null,{},[],null];o!==void 0&&(t[I][G]>0||l.length>0||d)&&(delete t[ke],t[I]={[G]:0},i.streams.add(o))}}dynamicToBuffer(t,e,i,s){if(typeof t=="number"){let{buffer:n,streams:r}=this.recursiveCIDToString(i.components,t,i.onlyCids);i.buffer+=n,i.streams=new Set([...i.streams,...r])}else Ee(t)?this.toOutputBuffer(t,e,i,s,{}):i.buffer+=t}recursiveCIDToString(t,e,i){let s=t[e]||P(`no component for CID ${e}`,t),n={[Y]:e,[Te]:this.viewId},r=i&&!i.has(e);s.newRender=!r,s.magicId=`c${e}-${this.parentViewId()}`;let o=!s.reset,{buffer:a,streams:h}=this.recursiveToString(s,t,i,o,n);return delete s.reset,{buffer:a,streams:h}}},ni=[],ri=200,Ss={exec(t,e,i,s,n,r){let[o,a]=r||[null,{callback:r&&r.callback}];(i.charAt(0)==="["?JSON.parse(i):[[o,a]]).forEach(([l,d])=>{l===o&&(d={...a,...d},d.callback=d.callback||a.callback),this.filterToEls(s.liveSocket,n,d).forEach(p=>{this[`exec_${l}`](t,e,i,s,n,p,d)})})},isVisible(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length>0)},isInViewport(t){let e=t.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight,s=window.innerWidth||document.documentElement.clientWidth;return e.right>0&&e.bottom>0&&e.left<s&&e.top<i},exec_exec(t,e,i,s,n,r,{attr:o,to:a}){let h=r.getAttribute(o);if(!h)throw new Error(`expected ${o} to contain JS command on "${a}"`);s.liveSocket.execJS(r,h,e)},exec_dispatch(t,e,i,s,n,r,{event:o,detail:a,bubbles:h,blocking:l}){if(a=a||{},a.dispatcher=n,l){let d=new Promise((p,g)=>{a.done=p});s.liveSocket.asyncTransition(d)}c.dispatchEvent(r,o,{detail:a,bubbles:h})},exec_push(t,e,i,s,n,r,o){let{event:a,data:h,target:l,page_loading:d,loading:p,value:g,dispatcher:m,callback:u}=o,v={loading:p,value:g,target:l,page_loading:!!d,originalEvent:t},w=e==="change"&&m?m:n,D=l||w.getAttribute(s.binding("target"))||w,X=(k,C)=>{if(k.isConnected())if(e==="change"){let{newCid:R,_target:N}=o;N=N||(c.isFormInput(n)?n.name:void 0),N&&(v._target=N),k.pushInput(n,C,R,a||i,v,u)}else if(e==="submit"){let{submitter:R}=o;k.submitForm(n,C,a||i,R,v,u)}else k.pushEvent(e,n,C,a||i,h,v,u)};o.targetView&&o.targetCtx?X(o.targetView,o.targetCtx):s.withinTargets(D,X)},exec_navigate(t,e,i,s,n,r,{href:o,replace:a}){s.liveSocket.historyRedirect(t,o,a?"replace":"push",null,n)},exec_patch(t,e,i,s,n,r,{href:o,replace:a}){s.liveSocket.pushHistoryPatch(t,o,a?"replace":"push",n)},exec_focus(t,e,i,s,n,r){B.attemptFocus(r),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>B.attemptFocus(r))})},exec_focus_first(t,e,i,s,n,r){B.focusFirstInteractive(r)||B.focusFirst(r),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>B.focusFirstInteractive(r)||B.focusFirst(r))})},exec_push_focus(t,e,i,s,n,r){ni.push(r||n)},exec_pop_focus(t,e,i,s,n,r){let o=ni.pop();o&&(o.focus(),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o.focus())}))},exec_add_class(t,e,i,s,n,r,{names:o,transition:a,time:h,blocking:l}){this.addOrRemoveClasses(r,o,[],a,h,s,l)},exec_remove_class(t,e,i,s,n,r,{names:o,transition:a,time:h,blocking:l}){this.addOrRemoveClasses(r,[],o,a,h,s,l)},exec_toggle_class(t,e,i,s,n,r,{names:o,transition:a,time:h,blocking:l}){this.toggleClasses(r,o,a,h,s,l)},exec_toggle_attr(t,e,i,s,n,r,{attr:[o,a,h]}){this.toggleAttr(r,o,a,h)},exec_ignore_attrs(t,e,i,s,n,r,{attrs:o}){this.ignoreAttrs(r,o)},exec_transition(t,e,i,s,n,r,{time:o,transition:a,blocking:h}){this.addOrRemoveClasses(r,[],[],a,o,s,h)},exec_toggle(t,e,i,s,n,r,{display:o,ins:a,outs:h,time:l,blocking:d}){this.toggle(e,s,r,o,a,h,l,d)},exec_show(t,e,i,s,n,r,{display:o,transition:a,time:h,blocking:l}){this.show(e,s,r,o,a,h,l)},exec_hide(t,e,i,s,n,r,{display:o,transition:a,time:h,blocking:l}){this.hide(e,s,r,o,a,h,l)},exec_set_attr(t,e,i,s,n,r,{attr:[o,a]}){this.setOrRemoveAttrs(r,[[o,a]],[])},exec_remove_attr(t,e,i,s,n,r,{attr:o}){this.setOrRemoveAttrs(r,[],[o])},ignoreAttrs(t,e){c.putPrivate(t,"JS:ignore_attrs",{apply:(i,s)=>{let n=Array.from(i.attributes),r=n.map(o=>o.name);Array.from(s.attributes).filter(o=>!r.includes(o.name)).forEach(o=>{c.attributeIgnored(o,e)&&s.removeAttribute(o.name)}),n.forEach(o=>{c.attributeIgnored(o,e)&&s.setAttribute(o.name,o.value)})}})},onBeforeElUpdated(t,e){let i=c.private(t,"JS:ignore_attrs");i&&i.apply(t,e)},show(t,e,i,s,n,r,o){this.isVisible(i)||this.toggle(t,e,i,s,n,null,r,o)},hide(t,e,i,s,n,r,o){this.isVisible(i)&&this.toggle(t,e,i,s,null,n,r,o)},toggle(t,e,i,s,n,r,o,a){o=o||ri;let[h,l,d]=n||[[],[],[]],[p,g,m]=r||[[],[],[]];if(h.length>0||p.length>0)if(this.isVisible(i)){let u=()=>{this.addOrRemoveClasses(i,g,h.concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,p,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,m,g))})},v=()=>{this.addOrRemoveClasses(i,[],p.concat(m)),c.putSticky(i,"toggle",w=>w.style.display="none"),i.dispatchEvent(new Event("phx:hide-end"))};i.dispatchEvent(new Event("phx:hide-start")),a===!1?(u(),setTimeout(v,o)):e.transition(o,u,v)}else{if(t==="remove")return;let u=()=>{this.addOrRemoveClasses(i,l,p.concat(g).concat(m));let w=s||this.defaultDisplay(i);window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,h,[]),window.requestAnimationFrame(()=>{c.putSticky(i,"toggle",D=>D.style.display=w),this.addOrRemoveClasses(i,d,l)})})},v=()=>{this.addOrRemoveClasses(i,[],h.concat(d)),i.dispatchEvent(new Event("phx:show-end"))};i.dispatchEvent(new Event("phx:show-start")),a===!1?(u(),setTimeout(v,o)):e.transition(o,u,v)}else this.isVisible(i)?window.requestAnimationFrame(()=>{i.dispatchEvent(new Event("phx:hide-start")),c.putSticky(i,"toggle",u=>u.style.display="none"),i.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{i.dispatchEvent(new Event("phx:show-start"));let u=s||this.defaultDisplay(i);c.putSticky(i,"toggle",v=>v.style.display=u),i.dispatchEvent(new Event("phx:show-end"))})},toggleClasses(t,e,i,s,n,r){window.requestAnimationFrame(()=>{let[o,a]=c.getSticky(t,"classes",[[],[]]),h=e.filter(d=>o.indexOf(d)<0&&!t.classList.contains(d)),l=e.filter(d=>a.indexOf(d)<0&&t.classList.contains(d));this.addOrRemoveClasses(t,h,l,i,s,n,r)})},toggleAttr(t,e,i,s){t.hasAttribute(e)?s!==void 0?t.getAttribute(e)===i?this.setOrRemoveAttrs(t,[[e,s]],[]):this.setOrRemoveAttrs(t,[[e,i]],[]):this.setOrRemoveAttrs(t,[],[e]):this.setOrRemoveAttrs(t,[[e,i]],[])},addOrRemoveClasses(t,e,i,s,n,r,o){n=n||ri;let[a,h,l]=s||[[],[],[]];if(a.length>0){let d=()=>{this.addOrRemoveClasses(t,h,[].concat(a).concat(l)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,l,h))})},p=()=>this.addOrRemoveClasses(t,e.concat(l),i.concat(a).concat(h));o===!1?(d(),setTimeout(p,n)):r.transition(n,d,p);return}window.requestAnimationFrame(()=>{let[d,p]=c.getSticky(t,"classes",[[],[]]),g=e.filter(w=>d.indexOf(w)<0&&!t.classList.contains(w)),m=i.filter(w=>p.indexOf(w)<0&&t.classList.contains(w)),u=d.filter(w=>i.indexOf(w)<0).concat(g),v=p.filter(w=>e.indexOf(w)<0).concat(m);c.putSticky(t,"classes",w=>(w.classList.remove(...v),w.classList.add(...u),[u,v]))})},setOrRemoveAttrs(t,e,i){let[s,n]=c.getSticky(t,"attrs",[[],[]]),r=e.map(([h,l])=>h).concat(i),o=s.filter(([h,l])=>!r.includes(h)).concat(e),a=n.filter(h=>!r.includes(h)).concat(i);c.putSticky(t,"attrs",h=>(a.forEach(l=>h.removeAttribute(l)),o.forEach(([l,d])=>h.setAttribute(l,d)),[o,a]))},hasAllClasses(t,e){return e.every(i=>t.classList.contains(i))},isToggledOut(t,e){return!this.isVisible(t)||this.hasAllClasses(t,e)},filterToEls(t,e,{to:i}){let s=()=>{if(typeof i=="string")return document.querySelectorAll(i);if(i.closest){let n=e.closest(i.closest);return n?[n]:[]}else if(i.inner)return e.querySelectorAll(i.inner)};return i?t.jsQuerySelectorAll(e,i,s):[e]},defaultDisplay(t){return{tr:"table-row",td:"table-cell"}[t.tagName.toLowerCase()]||"block"},transitionClasses(t){if(!t)return null;let[e,i,s]=Array.isArray(t)?t:[t.split(" "),[],[]];return e=Array.isArray(e)?e:e.split(" "),i=Array.isArray(i)?i:i.split(" "),s=Array.isArray(s)?s:s.split(" "),[e,i,s]}},S=Ss,mi=(t,e)=>({exec(i,s){t.execJS(i,s,e)},show(i,s={}){let n=t.owner(i);S.show(e,n,i,s.display,S.transitionClasses(s.transition),s.time,s.blocking)},hide(i,s={}){let n=t.owner(i);S.hide(e,n,i,null,S.transitionClasses(s.transition),s.time,s.blocking)},toggle(i,s={}){let n=t.owner(i),r=S.transitionClasses(s.in),o=S.transitionClasses(s.out);S.toggle(e,n,i,s.display,r,o,s.time,s.blocking)},addClass(i,s,n={}){let r=Array.isArray(s)?s:s.split(" "),o=t.owner(i);S.addOrRemoveClasses(i,r,[],S.transitionClasses(n.transition),n.time,o,n.blocking)},removeClass(i,s,n={}){let r=Array.isArray(s)?s:s.split(" "),o=t.owner(i);S.addOrRemoveClasses(i,[],r,S.transitionClasses(n.transition),n.time,o,n.blocking)},toggleClass(i,s,n={}){let r=Array.isArray(s)?s:s.split(" "),o=t.owner(i);S.toggleClasses(i,r,S.transitionClasses(n.transition),n.time,o,n.blocking)},transition(i,s,n={}){let r=t.owner(i);S.addOrRemoveClasses(i,[],[],S.transitionClasses(s),n.time,r,n.blocking)},setAttribute(i,s,n){S.setOrRemoveAttrs(i,[[s,n]],[])},removeAttribute(i,s){S.setOrRemoveAttrs(i,[],[s])},toggleAttribute(i,s,n,r){S.toggleAttr(i,s,n,r)},push(i,s,n={}){t.withinOwners(i,r=>{let o=n.value||{};delete n.value;let a=new CustomEvent("phx:exec",{detail:{sourceElement:i}});S.exec(a,e,s,r,i,["push",{data:o,...n}])})},navigate(i,s={}){let n=new CustomEvent("phx:exec");t.historyRedirect(n,i,s.replace?"replace":"push",null,null)},patch(i,s={}){let n=new CustomEvent("phx:exec");t.pushHistoryPatch(n,i,s.replace?"replace":"push",null)},ignoreAttributes(i,s){S.ignoreAttrs(i,Array.isArray(s)?s:[s])}}),gt="hookId",oi="deadHook",Cs=1,ce=class gi{get liveSocket(){return this.__liveSocket()}static makeID(){return Cs++}static elementID(e){return c.private(e,gt)}static deadHook(e){return c.private(e,oi)===!0}constructor(e,i,s){if(this.el=i,this.__attachView(e),this.__listeners=new Set,this.__isDisconnected=!1,c.putPrivate(this.el,gt,gi.makeID()),e&&e.isDead&&c.putPrivate(this.el,oi,!0),s){let n=new Set(["el","liveSocket","__view","__listeners","__isDisconnected","constructor","js","pushEvent","pushEventTo","handleEvent","removeHandleEvent","upload","uploadTo","__mounted","__updated","__beforeUpdate","__destroyed","__reconnected","__disconnected","__cleanup__"]);for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&(this[o]=s[o],n.has(o)&&console.warn(`Hook object for element #${i.id} overwrites core property '${o}'!`));["mounted","beforeUpdate","updated","destroyed","disconnected","reconnected"].forEach(o=>{s[o]&&typeof s[o]=="function"&&(this[o]=s[o])})}}__attachView(e){e?(this.__view=()=>e,this.__liveSocket=()=>e.liveSocket):(this.__view=()=>{throw new Error(`hook not yet attached to a live view: ${this.el.outerHTML}`)},this.__liveSocket=()=>{throw new Error(`hook not yet attached to a live view: ${this.el.outerHTML}`)})}mounted(){}beforeUpdate(){}updated(){}destroyed(){}disconnected(){}reconnected(){}__mounted(){this.mounted()}__updated(){this.updated()}__beforeUpdate(){this.beforeUpdate()}__destroyed(){this.destroyed(),c.deletePrivate(this.el,gt)}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected()}js(){return{...mi(this.__view().liveSocket,"hook"),exec:e=>{this.__view().liveSocket.execJS(this.el,e,"hook")}}}pushEvent(e,i,s){let n=this.__view().pushHookEvent(this.el,null,e,i||{});if(s===void 0)return n.then(({reply:r})=>r);n.then(({reply:r,ref:o})=>s(r,o)).catch(()=>{})}pushEventTo(e,i,s,n){if(n===void 0){let r=[];this.__view().withinTargets(e,(a,h)=>{r.push({view:a,targetCtx:h})});let o=r.map(({view:a,targetCtx:h})=>a.pushHookEvent(this.el,h,i,s||{}));return Promise.allSettled(o)}this.__view().withinTargets(e,(r,o)=>{r.pushHookEvent(this.el,o,i,s||{}).then(({reply:a,ref:h})=>n(a,h)).catch(()=>{})})}handleEvent(e,i){let s={event:e,callback:n=>i(n.detail)};return window.addEventListener(`phx:${e}`,s.callback),this.__listeners.add(s),s}removeHandleEvent(e){window.removeEventListener(`phx:${e.event}`,e.callback),this.__listeners.delete(e)}upload(e,i){return this.__view().dispatchUploads(null,e,i)}uploadTo(e,i,s){return this.__view().withinTargets(e,(n,r)=>{n.dispatchUploads(r,i,s)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}},Ts=(t,e)=>{let i=t.endsWith("[]"),s=i?t.slice(0,-2):t;return s=s.replace(/([^\[\]]+)(\]?$)/,`${e}$1$2`),i&&(s+="[]"),s},Ye=(t,e,i=[])=>{let{submitter:s}=e,n;if(s&&s.name){let d=document.createElement("input");d.type="hidden";let p=s.getAttribute("form");p&&d.setAttribute("form",p),d.name=s.name,d.value=s.value,s.parentElement.insertBefore(d,s),n=d}let r=new FormData(t),o=[];r.forEach((d,p,g)=>{d instanceof File&&o.push(p)}),o.forEach(d=>r.delete(d));let a=new URLSearchParams,{inputsUnused:h,onlyHiddenInputs:l}=Array.from(t.elements).reduce((d,p)=>{let{inputsUnused:g,onlyHiddenInputs:m}=d,u=p.name;if(!u)return d;g[u]===void 0&&(g[u]=!0),m[u]===void 0&&(m[u]=!0);let v=c.private(p,it)||c.private(p,Me),w=p.type==="hidden";return g[u]=g[u]&&!v,m[u]=m[u]&&w,d},{inputsUnused:{},onlyHiddenInputs:{}});for(let[d,p]of r.entries())if(i.length===0||i.indexOf(d)>=0){let g=h[d],m=l[d];g&&!(s&&s.name==d)&&!m&&a.append(Ts(d,"_unused_"),""),typeof p=="string"&&a.append(d,p)}return s&&n&&s.parentElement.removeChild(n),a.toString()},_s=class vi{static closestView(e){let i=e.closest($e);return i?c.private(i,"view"):null}constructor(e,i,s,n,r){this.isDead=!1,this.liveSocket=i,this.flash=n,this.parent=s,this.root=s?s.root:this,this.el=e;let o=c.private(this.el,"view");if(o!==void 0&&o.isDead!==!0)throw P(`The DOM element for this view has already been bound to a view.
An element can only ever be associated with a single view!
Please ensure that you are not trying to initialize multiple LiveSockets on the same page.
This could happen if you're accidentally trying to render your root layout more than once.
Ensure that the template set on the LiveView is different than the root layout.
`,{view:o}),new Error("Cannot bind multiple views to the same DOM element.");c.putPrivate(this.el,"view",this),this.id=this.el.id,this.el.setAttribute(ie,this.root.id),this.ref=0,this.lastAckRef=null,this.childJoins=0,this.loaderTimer=null,this.disconnectedTimer=null,this.pendingDiffs=[],this.pendingForms=new Set,this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinAttempts=0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(a){a&&a()},this.stopCallback=function(){},this.pendingJoinOps=[],this.viewHooks={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.formsForRecovery={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{let a=this.href&&this.expandURL(this.href);return{redirect:this.redirect?a:void 0,url:this.redirect?void 0:a||void 0,params:this.connectParams(r),session:this.getSession(),static:this.getStatic(),flash:this.flash,sticky:this.el.hasAttribute(yt)}}),this.portalElementIds=new Set}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(Tt)}connectParams(e){let i=this.liveSocket.params(this.el),s=c.all(document,`[${this.binding(Li)}]`).map(n=>n.src||n.href).filter(n=>typeof n=="string");return s.length>0&&(i._track_static=s),i._mounts=this.joinCount,i._mount_attempts=this.joinAttempts,i._live_referer=e,this.joinAttempts++,i}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(Q)}getStatic(){let e=this.el.getAttribute(fe);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyPortalElements(),this.destroyed=!0,c.deletePrivate(this.el,"view"),delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);let i=()=>{e();for(let s in this.viewHooks)this.destroyHook(this.viewHooks[s])};c.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",i).receive("error",i).receive("timeout",i)}setContainerClasses(...e){this.el.classList.remove(Nt,le,Ae,Mt,Re),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let i in this.viewHooks)this.viewHooks[i].__disconnected();this.setContainerClasses(le)}}execAll(e){c.all(this.el,`[${e}]`,i=>this.liveSocket.execJS(i,i.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),clearTimeout(this.disconnectedTimer),this.setContainerClasses(Nt),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,i){this.liveSocket.log(this,e,i)}transition(e,i,s=function(){}){this.liveSocket.transition(e,i,s)}withinTargets(e,i,s=document){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,n=>i(n,e));if(te(e))c.findComponentNodeList(this.id,e,s).length===0?P(`no component found matching phx-target of ${e}`):i(this,parseInt(e));else{let n=Array.from(s.querySelectorAll(e));n.length===0&&P(`nothing found matching the phx-target selector "${e}"`),n.forEach(r=>this.liveSocket.owner(r,o=>i(o,r)))}}applyDiff(e,i,s){this.log(e,()=>["",tt(i)]);let{diff:n,reply:r,events:o,title:a}=si.extract(i),h=o.reduce((d,p)=>(p.length===3&&p[2]==!0?d.pre.push(p.slice(0,-1)):d.post.push(p),d),{pre:[],post:[]});this.liveSocket.dispatchEvents(h.pre);let l=()=>{s({diff:n,reply:r,events:h.post}),(typeof a=="string"||e=="mount"&&this.isMain())&&window.requestAnimationFrame(()=>c.putTitle(a))};"onDocumentPatch"in this.liveSocket.domCallbacks?this.liveSocket.triggerDOM("onDocumentPatch",[l]):l()}onJoin(e){let{rendered:i,container:s,liveview_version:n,pid:r}=e;if(s){let[o,a]=s;this.el=c.replaceRootContainer(this.el,o,a)}this.childJoins=0,this.joinPending=!0,this.flash=null,this.root===this&&(this.formsForRecovery=this.getFormsForRecovery()),this.isMain()&&window.history.state===null&&F.pushState("replace",{type:"patch",id:this.id,position:this.liveSocket.currentHistoryPosition}),n!==this.liveSocket.version()&&console.warn(`LiveView asset version mismatch. JavaScript version ${this.liveSocket.version()} vs. server ${n}. To avoid issues, please ensure that your assets use the same version as the server.`),r&&this.el.setAttribute(Fi,r),F.dropLocal(this.liveSocket.localStorage,window.location.pathname,ai),this.applyDiff("mount",i,({diff:o,events:a})=>{this.rendered=new si(this.id,o);let[h,l]=this.renderContainer(null,"join");this.dropPendingRefs(),this.joinCount++,this.joinAttempts=0,this.maybeRecoverForms(h,()=>{this.onJoinComplete(e,h,l,a)})})}dropPendingRefs(){c.all(document,`[${J}="${this.refSrc()}"]`,e=>{e.removeAttribute(_e),e.removeAttribute(J),e.removeAttribute(O)})}onJoinComplete({live_patch:e},i,s,n){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,i,s,n);c.findPhxChildrenInFragment(i,this.id).filter(o=>{let a=o.id&&this.el.querySelector(`[id="${o.id}"]`),h=a&&a.getAttribute(fe);return h&&o.setAttribute(fe,h),a&&a.setAttribute(ie,this.root.id),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,i,s,n)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,i,s,n)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,i,s,n)])}attachTrueDocEl(){this.el=c.byId(this.id),this.el.setAttribute(ie,this.root.id)}execNewMounted(e=document){let i=this.binding(bt),s=this.binding(wt);this.all(e,`[${i}], [${s}]`,n=>{c.maintainPrivateHooks(n,n,i,s),this.maybeAddNewHook(n)}),this.all(e,`[${this.binding(xe)}], [data-phx-${xe}]`,n=>{this.maybeAddNewHook(n)}),this.all(e,`[${this.binding(Ft)}]`,n=>{this.maybeMounted(n)})}all(e,i,s){c.all(e,i,n=>{this.ownsElement(n)&&s(n)})}applyJoinPatch(e,i,s,n){this.joinCount>1&&this.pendingJoinOps.length&&(this.pendingJoinOps.forEach(o=>typeof o=="function"&&o()),this.pendingJoinOps=[]),this.attachTrueDocEl();let r=new Ge(this,this.el,this.id,i,s,null);if(r.markPrunableContentForRemoval(),this.performPatch(r,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(n),this.applyPendingUpdates(),e){let{kind:o,to:a}=e;this.liveSocket.historyPatch(a,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,i){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,i]);let s=this.getHook(e),n=s&&c.isIgnored(e,this.binding(nt));if(s&&!e.isEqualNode(i)&&!(n&&Zi(e.dataset,i.dataset)))return s.__beforeUpdate(),s}maybeMounted(e){let i=e.getAttribute(this.binding(Ft)),s=i&&c.private(e,"mounted");i&&!s&&(this.liveSocket.execJS(e,i),c.putPrivate(e,"mounted",!0))}maybeAddNewHook(e){let i=this.addHook(e);i&&i.__mounted()}performPatch(e,i,s=!1){let n=[],r=!1,o=new Set;return this.liveSocket.triggerDOM("onPatchStart",[e.targetContainer]),e.after("added",a=>{this.liveSocket.triggerDOM("onNodeAdded",[a]);let h=this.binding(bt),l=this.binding(wt);c.maintainPrivateHooks(a,a,h,l),this.maybeAddNewHook(a),a.getAttribute&&this.maybeMounted(a)}),e.after("phxChildAdded",a=>{c.isPhxSticky(a)?this.liveSocket.joinRootViews():r=!0}),e.before("updated",(a,h)=>{this.triggerBeforeUpdateHook(a,h)&&o.add(a.id),S.onBeforeElUpdated(a,h)}),e.after("updated",a=>{o.has(a.id)&&this.getHook(a).__updated()}),e.after("discarded",a=>{a.nodeType===Node.ELEMENT_NODE&&n.push(a)}),e.after("transitionsDiscarded",a=>this.afterElementsRemoved(a,i)),e.perform(s),this.afterElementsRemoved(n,i),this.liveSocket.triggerDOM("onPatchEnd",[e.targetContainer]),r}afterElementsRemoved(e,i){let s=[];e.forEach(n=>{let r=c.all(n,`[${Te}="${this.id}"][${Y}]`),o=c.all(n,`[${this.binding(xe)}], [data-phx-hook]`);r.concat(n).forEach(a=>{let h=this.componentID(a);te(h)&&s.indexOf(h)===-1&&a.getAttribute(Te)===this.id&&s.push(h)}),o.concat(n).forEach(a=>{let h=this.getHook(a);h&&this.destroyHook(h)})}),i&&this.maybePushComponentsDestroyed(s)}joinNewChildren(){c.findPhxChildren(document,this.id).forEach(e=>this.joinChild(e))}maybeRecoverForms(e,i){let s=this.binding("change"),n=this.root.formsForRecovery,r=document.createElement("template");r.innerHTML=e,c.all(r.content,`[${_t}]`).forEach(h=>{r.content.firstElementChild.appendChild(h.content.firstElementChild)});let o=r.content.firstElementChild;o.id=this.id,o.setAttribute(ie,this.root.id),o.setAttribute(Q,this.getSession()),o.setAttribute(fe,this.getStatic()),o.setAttribute(pe,this.parent?this.parent.id:null);let a=c.all(r.content,"form").filter(h=>h.id&&n[h.id]).filter(h=>!this.pendingForms.has(h.id)).filter(h=>n[h.id].getAttribute(s)===h.getAttribute(s)).map(h=>[n[h.id],h]);if(a.length===0)return i();a.forEach(([h,l],d)=>{this.pendingForms.add(l.id),this.pushFormRecovery(h,l,r.content.firstElementChild,()=>{this.pendingForms.delete(l.id),d===a.length-1&&i()})})}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){return e.id===this.id?this:this.children[e.getAttribute(pe)]?.[e.id]}destroyDescendent(e){for(let i in this.root.children)for(let s in this.root.children[i])if(s===e)return this.root.children[i][s].destroy()}joinChild(e){if(!this.getChildById(e.id)){let s=new vi(e,this.liveSocket,this);return this.root.children[this.id][s.id]=s,s.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(e){this.childJoins--,this.childJoins===0&&(this.parent?this.parent.ackJoin(this):this.onAllChildJoinsComplete())}onAllChildJoinsComplete(){this.pendingForms.clear(),this.formsForRecovery={},this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,i])=>{e.isDestroyed()||i()}),this.pendingJoinOps=[]})}update(e,i,s=!1){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return s||this.pendingDiffs.push({diff:e,events:i}),!1;this.rendered.mergeDiff(e);let n=!1;return this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{c.findExistingParentCIDs(this.id,this.rendered.componentCIDs(e)).forEach(o=>{this.componentPatch(this.rendered.getComponent(e,o),o)&&(n=!0)})}):Kt(e)||this.liveSocket.time("full patch complete",()=>{let[r,o]=this.renderContainer(e,"update"),a=new Ge(this,this.el,this.id,r,o,null);n=this.performPatch(a,!0)}),this.liveSocket.dispatchEvents(i),n&&this.joinNewChildren(),!0}renderContainer(e,i){return this.liveSocket.time(`toString diff (${i})`,()=>{let s=this.el.tagName,n=e?this.rendered.componentCIDs(e):null,{buffer:r,streams:o}=this.rendered.toString(n);return[`<${s}>${r}</${s}>`,o]})}componentPatch(e,i){if(Kt(e))return!1;let{buffer:s,streams:n}=this.rendered.componentToString(i),r=new Ge(this,this.el,this.id,s,n,i);return this.performPatch(r,!0)}getHook(e){return this.viewHooks[ce.elementID(e)]}addHook(e){let i=ce.elementID(e);if(!(e.getAttribute&&!this.ownsElement(e)))if(i&&!this.viewHooks[i]){if(ce.deadHook(e))return;let s=c.getCustomElHook(e)||P(`no hook found for custom element: ${e.id}`);return this.viewHooks[i]=s,s.__attachView(this),s}else{if(i||!e.getAttribute)return;{let s=e.getAttribute(`data-phx-${xe}`)||e.getAttribute(this.binding(xe));if(!s)return;let n=this.liveSocket.getHookDefinition(s);if(n){if(!e.id){P(`no DOM ID for hook "${s}". Hooks require a unique ID on each element.`,e);return}let r;try{if(typeof n=="function"&&n.prototype instanceof ce)r=new n(this,e);else if(typeof n=="object"&&n!==null)r=new ce(this,e,n);else{P(`Invalid hook definition for "${s}". Expected a class extending ViewHook or an object definition.`,e);return}}catch(o){let a=o instanceof Error?o.message:String(o);P(`Failed to create hook "${s}": ${a}`,e);return}return this.viewHooks[ce.elementID(r.el)]=r,r}else s!==null&&P(`unknown hook found for "${s}"`,e)}}}destroyHook(e){let i=ce.elementID(e.el);e.__destroyed(),e.__cleanup__(),delete this.viewHooks[i]}applyPendingUpdates(){this.pendingDiffs=this.pendingDiffs.filter(({diff:e,events:i})=>!this.update(e,i,!0)),this.eachChild(e=>e.applyPendingUpdates())}eachChild(e){let i=this.root.children[this.id]||{};for(let s in i)e(this.getChildById(s))}onChannel(e,i){this.liveSocket.onChannel(this.channel,e,s=>{this.isJoinPending()?this.joinCount>1?this.pendingJoinOps.push(()=>i(s)):this.root.pendingJoinOps.push([this,()=>i(s)]):this.liveSocket.requestDOMUpdate(()=>i(s))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:i,events:s})=>this.update(i,s))})}),this.onChannel("redirect",({to:e,flash:i})=>this.onRedirect({to:e,flash:i})),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:i,kind:s,flash:n}=e,r=this.expandURL(i),o=new CustomEvent("phx:server-navigate",{detail:{to:i,kind:s,flash:n}});this.liveSocket.historyRedirect(o,r,s,n)}onLivePatch(e){let{to:i,kind:s}=e;this.href=this.expandURL(i),this.liveSocket.historyPatch(i,s)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:i,reloadToken:s}){this.liveSocket.redirect(e,i,s)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}joinPush(){return this.joinPush=this.joinPush||this.channel.join(),this.joinPush}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=i=>{i=i||function(){},e?e(this.joinCount,i):i()},this.wrapPush(()=>this.channel.join(),{ok:i=>this.liveSocket.requestDOMUpdate(()=>this.onJoin(i)),error:i=>this.onJoinError(i),timeout:()=>this.onJoinError({reason:"timeout"})})}onJoinError(e){if(e.reason==="reload"){this.log("error",()=>[`failed mount with ${e.status}. Falling back to page reload`,e]),this.onRedirect({to:this.liveSocket.main.href,reloadToken:e.token});return}else if(e.reason==="unauthorized"||e.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.onRedirect({to:this.liveSocket.main.href,flash:this.flash});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);if(this.log("error",()=>["unable to join",e]),this.isMain())this.displayError([le,Ae,Re],{unstructuredError:e,errorKind:"server"}),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this);else{this.joinAttempts>=Bt&&(this.root.displayError([le,Ae,Re],{unstructuredError:e,errorKind:"server"}),this.log("error",()=>[`giving up trying to mount after ${Bt} tries`,e]),this.destroy());let i=c.byId(this.el.id);i?(c.mergeAttrs(i,this.el),this.displayError([le,Ae,Re],{unstructuredError:e,errorKind:"server"}),this.el=i):this.destroy()}}onClose(e){if(!this.isDestroyed()){if(this.isMain()&&this.liveSocket.hasPendingLink()&&e!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),this.liveSocket.isUnloaded()&&this.showLoader(Ji)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([le,Ae,Re],{unstructuredError:e,errorKind:"server"}):this.displayError([le,Ae,Mt],{unstructuredError:e,errorKind:"client"}))}displayError(e,i={}){this.isMain()&&c.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error",...i}}),this.showLoader(),this.setContainerClasses(...e),this.delayedDisconnected()}delayedDisconnected(){this.disconnectedTimer=setTimeout(()=>{this.execAll(this.binding("disconnected"))},this.liveSocket.disconnectedTimeout)}wrapPush(e,i){let s=this.liveSocket.getLatencySim(),n=s?r=>setTimeout(()=>!this.isDestroyed()&&r(),s):r=>!this.isDestroyed()&&r();n(()=>{e().receive("ok",r=>n(()=>i.ok&&i.ok(r))).receive("error",r=>n(()=>i.error&&i.error(r))).receive("timeout",()=>n(()=>i.timeout&&i.timeout()))})}pushWithReply(e,i,s){if(!this.isConnected())return Promise.reject(new Error("no connection"));let[n,[r],o]=e?e({payload:s}):[null,[],{}],a=this.joinCount,h=function(){};return o.page_loading&&(h=this.liveSocket.withPageLoading({kind:"element",target:r})),typeof s.cid!="number"&&delete s.cid,new Promise((l,d)=>{this.wrapPush(()=>this.channel.push(i,s,qi),{ok:p=>{n!==null&&(this.lastAckRef=n);let g=m=>{p.redirect&&this.onRedirect(p.redirect),p.live_patch&&this.onLivePatch(p.live_patch),p.live_redirect&&this.onLiveRedirect(p.live_redirect),h(),l({resp:p,reply:m,ref:n})};p.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",p.diff,({diff:m,reply:u,events:v})=>{n!==null&&this.undoRefs(n,s.event),this.update(m,v),g(u)})}):(n!==null&&this.undoRefs(n,s.event),g(null))},error:p=>d(new Error(`failed with reason: ${JSON.stringify(p)}`)),timeout:()=>{d(new Error("timeout")),this.joinCount===a&&this.liveSocket.reloadWithJitter(this,()=>{this.log("timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}})})}undoRefs(e,i,s){if(!this.isConnected())return;let n=`[${J}="${this.refSrc()}"]`;s?(s=new Set(s),c.all(document,n,r=>{s&&!s.has(r)||(c.all(r,n,o=>this.undoElRef(o,e,i)),this.undoElRef(r,e,i))})):c.all(document,n,r=>this.undoElRef(r,e,i))}undoElRef(e,i,s){new Et(e).maybeUndo(i,s,r=>{let o=new Ge(this,e,this.id,r,[],null,{undoRef:i}),a=this.performPatch(o,!0);c.all(e,`[${J}="${this.refSrc()}"]`,h=>this.undoElRef(h,i,s)),a&&this.joinNewChildren()})}refSrc(){return this.el.id}putRef(e,i,s,n={}){let r=this.ref++,o=this.binding($t);if(n.loading){let a=c.all(document,n.loading).map(h=>({el:h,lock:!0,loading:!0}));e=e.concat(a)}for(let{el:a,lock:h,loading:l}of e){if(!h&&!l)throw new Error("putRef requires lock or loading");if(a.setAttribute(J,this.refSrc()),l&&a.setAttribute(_e,r),h&&a.setAttribute(O,r),!l||n.submitter&&!(a===n.submitter||a===n.form))continue;let d=new Promise(u=>{a.addEventListener(`phx:undo-lock:${r}`,()=>u(m),{once:!0})}),p=new Promise(u=>{a.addEventListener(`phx:undo-loading:${r}`,()=>u(m),{once:!0})});a.classList.add(`phx-${s}-loading`);let g=a.getAttribute(o);g!==null&&(a.getAttribute(st)||a.setAttribute(st,a.textContent),g!==""&&(a.textContent=g),a.setAttribute(Se,a.getAttribute(Se)||a.disabled),a.setAttribute("disabled",""));let m={event:i,eventType:s,ref:r,isLoading:l,isLocked:h,lockElements:e.filter(({lock:u})=>u).map(({el:u})=>u),loadingElements:e.filter(({loading:u})=>u).map(({el:u})=>u),unlock:u=>{u=Array.isArray(u)?u:[u],this.undoRefs(r,i,u)},lockComplete:d,loadingComplete:p,lock:u=>new Promise(v=>{if(this.isAcked(r))return v(m);u.setAttribute(O,r),u.setAttribute(J,this.refSrc()),u.addEventListener(`phx:lock-stop:${r}`,()=>v(m),{once:!0})})};n.payload&&(m.payload=n.payload),n.target&&(m.target=n.target),n.originalEvent&&(m.originalEvent=n.originalEvent),a.dispatchEvent(new CustomEvent("phx:push",{detail:m,bubbles:!0,cancelable:!1})),i&&a.dispatchEvent(new CustomEvent(`phx:push:${i}`,{detail:m,bubbles:!0,cancelable:!1}))}return[r,e.map(({el:a})=>a),n]}isAcked(e){return this.lastAckRef!==null&&this.lastAckRef>=e}componentID(e){let i=e.getAttribute&&e.getAttribute(Y);return i?parseInt(i):null}targetComponentID(e,i,s={}){if(te(i))return i;let n=s.target||e.getAttribute(this.binding("target"));return te(n)?parseInt(n):i&&(n!==null||s.target)?this.closestComponentID(i):null}closestComponentID(e){return te(e)?e:e?Ce(e.closest(`[${Y}],[${he}]`),i=>{if(i.hasAttribute(Y))return this.ownsElement(i)&&this.componentID(i);if(i.hasAttribute(he)){let s=c.byId(i.getAttribute(he));return this.closestComponentID(s)}}):null}pushHookEvent(e,i,s,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",s,n]),Promise.reject(new Error("unable to push hook event. LiveView not connected"));let r=()=>this.putRef([{el:e,loading:!0,lock:!0}],s,"hook",{payload:n,target:i});return this.pushWithReply(r,"event",{type:"hook",event:s,value:n,cid:this.closestComponentID(i)}).then(({resp:o,reply:a,ref:h})=>({reply:a,ref:h}))}extractMeta(e,i,s){let n=this.binding("value-");for(let r=0;r<e.attributes.length;r++){i||(i={});let o=e.attributes[r].name;o.startsWith(n)&&(i[o.replace(n,"")]=e.getAttribute(o))}if(e.value!==void 0&&!(e instanceof HTMLFormElement)&&(i||(i={}),i.value=e.value,e.tagName==="INPUT"&&ui.indexOf(e.type)>=0&&!e.checked&&delete i.value),s){i||(i={});for(let r in s)i[r]=s[r]}return i}pushEvent(e,i,s,n,r,o={},a){this.pushWithReply(h=>this.putRef([{el:i,loading:!0,lock:!0}],n,e,{...o,payload:h?.payload}),"event",{type:e,event:n,value:this.extractMeta(i,r,o.value),cid:this.targetComponentID(i,s,o)}).then(({reply:h})=>a&&a(h)).catch(h=>P("Failed to push event",h))}pushFileProgress(e,i,s,n=function(){}){this.liveSocket.withinOwners(e.form,(r,o)=>{r.pushWithReply(null,"progress",{event:e.getAttribute(r.binding(Bi)),ref:e.getAttribute(se),entry_ref:i,progress:s,cid:r.targetComponentID(e.form,o)}).then(()=>n()).catch(a=>P("Failed to push file progress",a))})}pushInput(e,i,s,n,r,o){if(!e.form)throw new Error("form events require the input to be inside a form");let a,h=te(s)?s:this.targetComponentID(e.form,i,r),l=u=>this.putRef([{el:e,loading:!0,lock:!0},{el:e.form,loading:!0,lock:!0}],n,"change",{...r,payload:u?.payload}),d,p=this.extractMeta(e.form,{},r.value),g={};e instanceof HTMLButtonElement&&(g.submitter=e),e.getAttribute(this.binding("change"))?d=Ye(e.form,g,[e.name]):d=Ye(e.form,g),c.isUploadInput(e)&&e.files&&e.files.length>0&&H.trackFiles(e,Array.from(e.files)),a=H.serializeUploads(e);let m={type:"form",event:n,value:d,meta:{_target:r._target||"undefined",...p},uploads:a,cid:h};this.pushWithReply(l,"event",m).then(({resp:u})=>{c.isUploadInput(e)&&c.isAutoUpload(e)?Et.onUnlock(e,()=>{if(H.filesAwaitingPreflight(e).length>0){let[v,w]=l();this.undoRefs(v,n,[e.form]),this.uploadFiles(e.form,n,i,v,h,D=>{o&&o(u),this.triggerAwaitingSubmit(e.form,n),this.undoRefs(v,n)})}}):o&&o(u)}).catch(u=>P("Failed to push input event",u))}triggerAwaitingSubmit(e,i){let s=this.getScheduledSubmit(e);if(s){let[n,r,o,a]=s;this.cancelSubmit(e,i),a()}}getScheduledSubmit(e){return this.formSubmits.find(([i,s,n,r])=>i.isSameNode(e))}scheduleSubmit(e,i,s,n){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,i,s,n])}cancelSubmit(e,i){this.formSubmits=this.formSubmits.filter(([s,n,r,o])=>s.isSameNode(e)?(this.undoRefs(n,i),!1):!0)}disableForm(e,i,s={}){let n=u=>!(ue(u,`${this.binding(nt)}=ignore`,u.form)||ue(u,"data-phx-update=ignore",u.form)),r=u=>u.hasAttribute(this.binding($t)),o=u=>u.tagName=="BUTTON",a=u=>["INPUT","TEXTAREA","SELECT"].includes(u.tagName),h=Array.from(e.elements),l=h.filter(r),d=h.filter(o).filter(n),p=h.filter(a).filter(n);d.forEach(u=>{u.setAttribute(Se,u.disabled),u.disabled=!0}),p.forEach(u=>{u.setAttribute(At,u.readOnly),u.readOnly=!0,u.files&&(u.setAttribute(Se,u.disabled),u.disabled=!0)});let g=l.concat(d).concat(p).map(u=>({el:u,loading:!0,lock:!0})),m=[{el:e,loading:!0,lock:!1}].concat(g).reverse();return this.putRef(m,i,"submit",s)}pushFormSubmit(e,i,s,n,r,o){let a=l=>this.disableForm(e,s,{...r,form:e,payload:l?.payload,submitter:n});c.putPrivate(e,"submitter",n);let h=this.targetComponentID(e,i);if(H.hasUploadsInProgress(e)){let[l,d]=a(),p=()=>this.pushFormSubmit(e,i,s,n,r,o);return this.scheduleSubmit(e,l,r,p)}else if(H.inputsAwaitingPreflight(e).length>0){let[l,d]=a(),p=()=>[l,d,r];this.uploadFiles(e,s,i,l,h,g=>{if(H.inputsAwaitingPreflight(e).length>0)return this.undoRefs(l,s);let m=this.extractMeta(e,{},r.value),u=Ye(e,{submitter:n});this.pushWithReply(p,"event",{type:"form",event:s,value:u,meta:m,cid:h}).then(({resp:v})=>o(v)).catch(v=>P("Failed to push form submit",v))})}else if(!(e.hasAttribute(J)&&e.classList.contains("phx-submit-loading"))){let l=this.extractMeta(e,{},r.value),d=Ye(e,{submitter:n});this.pushWithReply(a,"event",{type:"form",event:s,value:d,meta:l,cid:h}).then(({resp:p})=>o(p)).catch(p=>P("Failed to push form submit",p))}}uploadFiles(e,i,s,n,r,o){let a=this.joinCount,h=H.activeFileInputs(e),l=h.length;h.forEach(d=>{let p=new H(d,this,()=>{l--,l===0&&o()}),g=p.entries().map(u=>u.toPreflightPayload());if(g.length===0){l--;return}let m={ref:d.getAttribute(se),entries:g,cid:this.targetComponentID(d.form,s)};this.log("upload",()=>["sending preflight request",m]),this.pushWithReply(null,"allow_upload",m).then(({resp:u})=>{if(this.log("upload",()=>["got preflight response",u]),p.entries().forEach(v=>{u.entries&&!u.entries[v.ref]&&this.handleFailedEntryPreflight(v.ref,"failed preflight",p)}),u.error||Object.keys(u.entries).length===0)this.undoRefs(n,i),(u.error||[]).map(([w,D])=>{this.handleFailedEntryPreflight(w,D,p)});else{let v=w=>{this.channel.onError(()=>{this.joinCount===a&&w()})};p.initAdapterUpload(u,v,this.liveSocket)}}).catch(u=>P("Failed to push upload",u))})}handleFailedEntryPreflight(e,i,s){if(s.isAutoUpload()){let n=s.entries().find(r=>r.ref===e.toString());n&&n.cancel()}else s.entries().map(n=>n.cancel());this.log("upload",()=>[`error for entry ${e}`,i])}dispatchUploads(e,i,s){let n=this.targetCtxElement(e)||this.el,r=c.findUploadInputs(n).filter(o=>o.name===i);r.length===0?P(`no live file inputs found matching the name "${i}"`):r.length>1?P(`duplicate live file inputs found matching the name "${i}"`):c.dispatchEvent(r[0],li,{detail:{files:s}})}targetCtxElement(e){if(te(e)){let[i]=c.findComponentNodeList(this.id,e);return i}else return e||null}pushFormRecovery(e,i,s,n){let r=this.binding("change"),o=i.getAttribute(this.binding("target"))||i,a=i.getAttribute(this.binding(Ut))||i.getAttribute(this.binding("change")),h=Array.from(e.elements).filter(p=>c.isFormInput(p)&&p.name&&!p.hasAttribute(r));if(h.length===0){n();return}h.forEach(p=>p.hasAttribute(se)&&H.clearFiles(p));let l=h.find(p=>p.type!=="hidden")||h[0],d=0;this.withinTargets(o,(p,g)=>{let m=this.targetComponentID(i,g);d++;let u=new CustomEvent("phx:form-recovery",{detail:{sourceElement:e}});S.exec(u,"change",a,this,l,["push",{_target:l.name,targetView:p,targetCtx:g,newCid:m,callback:()=>{d--,d===0&&n()}}])},s)}pushLinkPatch(e,i,s,n){let r=this.liveSocket.setPendingLink(i),o=e.isTrusted&&e.type!=="popstate",a=s?()=>this.putRef([{el:s,loading:o,lock:!0}],null,"click"):null,h=()=>this.liveSocket.redirect(window.location.href),l=i.startsWith("/")?`${location.protocol}//${location.host}${i}`:i;this.pushWithReply(a,"live_patch",{url:l}).then(({resp:d})=>{this.liveSocket.requestDOMUpdate(()=>{if(d.link_redirect)this.liveSocket.replaceMain(i,null,n,r);else{if(d.redirect)return;this.liveSocket.commitPendingLink(r)&&(this.href=i),this.applyPendingUpdates(),n&&n(r)}})},({error:d,timeout:p})=>h())}getFormsForRecovery(){if(this.joinCount===0)return{};let e=this.binding("change");return c.all(document,`#${CSS.escape(this.id)} form[${e}], [${me}="${CSS.escape(this.id)}"] form[${e}]`).filter(i=>i.id).filter(i=>i.elements.length>0).filter(i=>i.getAttribute(this.binding(Ut))!=="ignore").map(i=>{let s=i.cloneNode(!0);St(s,i,{onBeforeElUpdated:(r,o)=>(c.copyPrivates(r,o),r.getAttribute("form")===i.id?(r.parentNode.removeChild(r),!1):!0)});let n=document.querySelectorAll(`[form="${CSS.escape(i.id)}"]`);return Array.from(n).forEach(r=>{let o=r.cloneNode(!0);St(o,r),c.copyPrivates(o,r),o.removeAttribute("form"),s.appendChild(o)}),s}).reduce((i,s)=>(i[s.id]=s,i),{})}maybePushComponentsDestroyed(e){let i=e.filter(n=>c.findComponentNodeList(this.id,n).length===0),s=n=>{this.isDestroyed()||P("Failed to push components destroyed",n)};i.length>0&&(i.forEach(n=>this.rendered.resetRender(n)),this.pushWithReply(null,"cids_will_destroy",{cids:i}).then(()=>{this.liveSocket.requestDOMUpdate(()=>{let n=i.filter(r=>c.findComponentNodeList(this.id,r).length===0);n.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:n}).then(({resp:r})=>{this.rendered.pruneCIDs(r.cids)}).catch(s)})}).catch(s))}ownsElement(e){let i=c.closestViewEl(e);return e.getAttribute(pe)===this.id||i&&i.id===this.id||!i&&this.isDead}submitForm(e,i,s,n,r={}){c.putPrivate(e,Me,!0),Array.from(e.elements).forEach(a=>c.putPrivate(a,Me,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,i,s,n,r,()=>{this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}pushPortalElementId(e){this.portalElementIds.add(e)}dropPortalElementId(e){this.portalElementIds.delete(e)}destroyPortalElements(){this.liveSocket.unloaded||this.portalElementIds.forEach(e=>{let i=document.getElementById(e);i&&i.remove()})}};var Ps=class{constructor(t,e,i={}){if(this.unloaded=!1,!e||e.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 e(t,i),this.bindingPrefix=i.bindingPrefix||Wi,this.opts=i,this.params=De(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(tt(Ki),i.defaults||{}),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=tt(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Vi,this.disconnectedTimeout=i.disconnectedTimeout||Xi,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||Pi,this.reloadJitterMin=i.reloadJitterMin||Ri,this.reloadJitterMax=i.reloadJitterMax||xi,this.failsafeJitter=i.failsafeJitter||Ii,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.boundEventNames=new Set,this.blockPhxChangeWhileComposing=i.blockPhxChangeWhileComposing||!1,this.serverCloseRef=null,this.domCallbacks=Object.assign({jsQuerySelectorAll:null,onPatchStart:De(),onPatchEnd:De(),onNodeAdded:De(),onBeforeElUpdated:De()},i.dom||{}),this.transitions=new Rs,this.currentHistoryPosition=parseInt(this.sessionStorage.getItem(qe))||0,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}version(){return"1.1.28"}isProfileEnabled(){return this.sessionStorage.getItem(ut)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(We)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(We)==="false"}enableDebug(){this.sessionStorage.setItem(We,"true")}enableProfiling(){this.sessionStorage.setItem(ut,"true")}disableDebug(){this.sessionStorage.setItem(We,"false")}disableProfiling(){this.sessionStorage.removeItem(ut)}enableLatencySim(t){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(ft,t)}disableLatencySim(){this.sessionStorage.removeItem(ft)}getLatencySim(){let t=this.sessionStorage.getItem(ft);return t?parseInt(t):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let t=()=>{this.resetReloadStatus(),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?t():document.addEventListener("DOMContentLoaded",()=>t())}disconnect(t){clearTimeout(this.reloadWithJitterTimer),this.serverCloseRef&&(this.socket.off(this.serverCloseRef),this.serverCloseRef=null),this.socket.disconnect(t)}replaceTransport(t){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(t),this.connect()}execJS(t,e,i=null){let s=new CustomEvent("phx:exec",{detail:{sourceElement:t}});this.owner(t,n=>S.exec(s,i,e,n,t))}js(){return mi(this,"js")}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(t,e){this.domCallbacks[t](...e)}time(t,e){if(!this.isProfileEnabled()||!console.time)return e();console.time(t);let i=e();return console.timeEnd(t),i}log(t,e,i){if(this.viewLogger){let[s,n]=i();this.viewLogger(t,e,s,n)}else if(this.isDebugEnabled()){let[s,n]=i();Qi(t,e,s,n)}}requestDOMUpdate(t){this.transitions.after(t)}asyncTransition(t){this.transitions.addAsyncTransition(t)}transition(t,e,i=function(){}){this.transitions.addTransition(t,e,i)}onChannel(t,e,i){t.on(e,s=>{let n=this.getLatencySim();n?setTimeout(()=>i(s),n):i(s)})}reloadWithJitter(t,e){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,s=this.reloadJitterMax,n=Math.floor(Math.random()*(s-i+1))+i,r=F.updateLocal(this.localStorage,window.location.pathname,ai,0,o=>o+1);r>=this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{t.isDestroyed()||t.isConnected()||(t.destroy(),e?e():this.log(t,"join",()=>[`encountered ${r} consecutive reloads`]),r>=this.maxReloads&&this.log(t,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},n)}getHookDefinition(t){if(t)return this.maybeInternalHook(t)||this.hooks[t]||this.maybeRuntimeHook(t)}maybeInternalHook(t){return t&&t.startsWith("Phoenix.")&&as[t.split(".")[1]]}maybeRuntimeHook(t){let e=document.querySelector(`script[${et}="${CSS.escape(t)}"]`);if(!e)return;let i=window[`phx_hook_${t}`];if(!i||typeof i!="function"){P("a runtime hook must be a function",e);return}let s=i();if(s&&(typeof s=="object"||typeof s=="function"))return s;P("runtime hook must return an object with hook callbacks or an instance of ViewHook",e)}isUnloaded(){return this.unloaded}isConnected(){return this.socket.isConnected()}getBindingPrefix(){return this.bindingPrefix}binding(t){return`${this.getBindingPrefix()}${t}`}channel(t,e){return this.socket.channel(t,e)}joinDeadView(){let t=document.body;if(t&&!this.isPhxView(t)&&!this.isPhxView(document.firstElementChild)){let e=this.newRootView(t);e.setHref(this.getHref()),e.joinDead(),this.main||(this.main=e),window.requestAnimationFrame(()=>{e.execNewMounted(),this.maybeScroll(history.state?.scroll)})}}joinRootViews(){let t=!1;return c.all(document,`${$e}:not([${pe}])`,e=>{if(!this.getRootById(e.id)){let i=this.newRootView(e);c.isPhxSticky(e)||i.setHref(this.getHref()),i.join(),e.hasAttribute(Tt)&&(this.main=i)}t=!0}),t}redirect(t,e,i){i&&F.setCookie(jt,i,60),this.unload(),F.redirect(t,e)}replaceMain(t,e,i=null,s=this.setPendingLink(t)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let r=c.findPhxSticky(document)||[],o=c.all(this.outgoingMainEl,`[${this.binding("remove")}]`).filter(h=>!c.isChildOfAny(h,r)),a=c.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(a,e,n),this.main.setRedirect(t),this.transitionRemoves(o),this.main.join((h,l)=>{h===1&&this.commitPendingLink(s)&&this.requestDOMUpdate(()=>{o.forEach(d=>d.remove()),r.forEach(d=>a.appendChild(d)),this.outgoingMainEl.replaceWith(a),this.outgoingMainEl=null,i&&i(s),l()})})}transitionRemoves(t,e){let i=this.binding("remove"),s=n=>{n.preventDefault(),n.stopImmediatePropagation()};t.forEach(n=>{for(let r of this.boundEventNames)n.addEventListener(r,s,!0);this.execJS(n,n.getAttribute(i),"remove")}),this.requestDOMUpdate(()=>{t.forEach(n=>{for(let r of this.boundEventNames)n.removeEventListener(r,s,!0)}),e&&e()})}isPhxView(t){return t.getAttribute&&t.getAttribute(Q)!==null}newRootView(t,e,i){let s=new _s(t,this,null,e,i);return this.roots[s.id]=s,s}owner(t,e){let i,s=c.closestViewEl(t);if(s)i=this.getViewByEl(s);else{if(!t.isConnected)return null;i=this.main}return i&&e?e(i):i}withinOwners(t,e){this.owner(t,i=>e(i,t))}getViewByEl(t){let e=t.getAttribute(ie);return Ce(this.getRootById(e),i=>i.getDescendentByEl(t))}getRootById(t){return this.roots[t]}destroyAllViews(){for(let t in this.roots)this.roots[t].destroy(),delete this.roots[t];this.main=null}destroyViewByEl(t){let e=this.getRootById(t.getAttribute(ie));e&&e.id===t.id?(e.destroy(),delete this.roots[e.id]):e&&e.destroyDescendent(t.id)}getActiveElement(){return document.activeElement}dropActiveElement(t){this.prevActive&&t.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive instanceof HTMLElement&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive instanceof HTMLElement&&this.prevActive.blur()}bindTopLevelEvents({dead:t}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.serverCloseRef=this.socket.onClose(e=>{if(e&&e.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",e=>{e.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),t||this.bindNav(),this.bindClicks(),t||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(e,i,s,n,r,o)=>{let a=n.getAttribute(this.binding(ji)),h=e.key&&e.key.toLowerCase();if(a&&a.toLowerCase()!==h)return;let l={key:e.key,...this.eventMeta(i,e,n)};S.exec(e,i,r,s,n,["push",{data:l}])}),this.bind({blur:"focusout",focus:"focusin"},(e,i,s,n,r,o)=>{if(!o){let a={key:e.key,...this.eventMeta(i,e,n)};S.exec(e,i,r,s,n,["push",{data:a}])}}),this.bind({blur:"blur",focus:"focus"},(e,i,s,n,r,o)=>{if(o==="window"){let a=this.eventMeta(i,e,n);S.exec(e,i,r,s,n,["push",{data:a}])}}),this.on("dragover",e=>e.preventDefault()),this.on("dragenter",e=>{let i=ue(e.target,this.binding(Xe));!i||!(i instanceof HTMLElement)||ts(e)&&this.js().addClass(i,ct)}),this.on("dragleave",e=>{let i=ue(e.target,this.binding(Xe));if(!i||!(i instanceof HTMLElement))return;let s=i.getBoundingClientRect();(e.clientX<=s.left||e.clientX>=s.right||e.clientY<=s.top||e.clientY>=s.bottom)&&this.js().removeClass(i,ct)}),this.on("drop",e=>{e.preventDefault();let i=ue(e.target,this.binding(Xe));if(!i||!(i instanceof HTMLElement))return;this.js().removeClass(i,ct);let s=i.getAttribute(this.binding(Xe)),n=s&&document.getElementById(s),r=Array.from(e.dataTransfer.files||[]);!n||!(n instanceof HTMLInputElement)||n.disabled||r.length===0||!(n.files instanceof FileList)||(H.trackFiles(n,r,e.dataTransfer),n.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(li,e=>{let i=e.target;if(!c.isUploadInput(i))return;let s=Array.from(e.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);H.trackFiles(i,s),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(t,e,i){let s=this.metadataCallbacks[t];return s?s(e,i):{}}setPendingLink(t){return this.linkRef++,this.pendingLink=t,this.resetReloadStatus(),this.linkRef}resetReloadStatus(){F.deleteCookie(jt)}commitPendingLink(t){return this.linkRef!==t?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(t,e){for(let i in t){let s=t[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,h=>{e(n,i,h,n.target,a,null)})}):c.all(document,`[${o}]`,h=>{let l=h.getAttribute(o);this.debounce(h,n,s,()=>{this.withinOwners(h,d=>{e(n,i,d,h,l,"window")})})})})}}bindClicks(){this.on("mousedown",t=>this.clickStartedAtTarget=t.target),this.bindClick("click","click")}bindClick(t,e){let i=this.binding(e);window.addEventListener(t,s=>{let n=null;s.detail===0&&(this.clickStartedAtTarget=s.target);let r=this.clickStartedAtTarget||s.target;n=ue(s.target,i),this.dispatchClickAway(s,r),this.clickStartedAtTarget=null;let o=n&&n.getAttribute(i);if(!o){c.isNewPageClick(s,window.location)&&this.unload();return}n.getAttribute("href")==="#"&&s.preventDefault(),!n.hasAttribute(J)&&this.debounce(n,s,"click",()=>{this.withinOwners(n,a=>{S.exec(s,"click",o,a,n,["push",{data:this.eventMeta("click",s,n)}])})})},!1)}dispatchClickAway(t,e){let i=this.binding("click-away"),s=e.closest(`[${he}]`),n=s&&c.byId(s.getAttribute(he));c.all(document,`[${i}]`,r=>{let o=e;s&&!s.contains(r)&&(o=n),r.isSameNode(o)||r.contains(o)||!S.isVisible(e)||this.withinOwners(r,a=>{let h=r.getAttribute(i);S.isVisible(r)&&S.isInViewport(r)&&S.exec(t,"click",h,a,r,["push",{data:this.eventMeta("click",t,t.target)}])})})}bindNav(){if(!F.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let t=null;window.addEventListener("scroll",e=>{clearTimeout(t),t=setTimeout(()=>{F.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",e=>{if(!this.registerNewLocation(window.location))return;let{type:i,backType:s,id:n,scroll:r,position:o}=e.state||{},a=window.location.href,h=o>this.currentHistoryPosition,l=h?i:s||i;this.currentHistoryPosition=o||0,this.sessionStorage.setItem(qe,this.currentHistoryPosition.toString()),c.dispatchEvent(window,"phx:navigate",{detail:{href:a,patch:l==="patch",pop:!0,direction:h?"forward":"backward"}}),this.requestDOMUpdate(()=>{let d=()=>{this.maybeScroll(r)};this.main.isConnected()&&l==="patch"&&n===this.main.id?this.main.pushLinkPatch(e,a,null,d):this.replaceMain(a,null,d)})},!1),window.addEventListener("click",e=>{let i=ue(e.target,dt),s=i&&i.getAttribute(dt);if(!s||!this.isConnected()||!this.main||c.wantsNewTab(e))return;let n=i.href instanceof SVGAnimatedString?i.href.baseVal:i.href,r=i.getAttribute(Oi);e.preventDefault(),e.stopImmediatePropagation(),this.pendingLink!==n&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(e,n,r,i);else if(s==="redirect")this.historyRedirect(e,n,r,null,i);else throw new Error(`expected ${dt} to be "patch" or "redirect", got: ${s}`);let o=i.getAttribute(this.binding("click"));o&&this.requestDOMUpdate(()=>this.execJS(i,o,"click"))})},!1)}maybeScroll(t){typeof t=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,t)})}dispatchEvent(t,e={}){c.dispatchEvent(window,`phx:${t}`,{detail:e})}dispatchEvents(t){t.forEach(([e,i])=>this.dispatchEvent(e,i))}withPageLoading(t,e){c.dispatchEvent(window,"phx:page-loading-start",{detail:t});let i=()=>c.dispatchEvent(window,"phx:page-loading-stop",{detail:t});return e?e(i):i}pushHistoryPatch(t,e,i,s){if(!this.isConnected()||!this.main.isMain())return F.redirect(e);this.withPageLoading({to:e,kind:"patch"},n=>{this.main.pushLinkPatch(t,e,s,r=>{this.historyPatch(e,i,r),n()})})}historyPatch(t,e,i=this.setPendingLink(t)){this.commitPendingLink(i)&&(this.currentHistoryPosition++,this.sessionStorage.setItem(qe,this.currentHistoryPosition.toString()),F.updateCurrentState(s=>({...s,backType:"patch"})),F.pushState(e,{type:"patch",id:this.main.id,position:this.currentHistoryPosition},t),c.dispatchEvent(window,"phx:navigate",{detail:{patch:!0,href:t,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location))}historyRedirect(t,e,i,s,n){let r=n&&t.isTrusted&&t.type!=="popstate";if(r&&n.classList.add("phx-click-loading"),!this.isConnected()||!this.main.isMain())return F.redirect(e,s);if(/^\/$|^\/[^\/]+.*$/.test(e)){let{protocol:a,host:h}=window.location;e=`${a}//${h}${e}`}let o=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},a=>{this.replaceMain(e,s,h=>{h===this.linkRef&&(this.currentHistoryPosition++,this.sessionStorage.setItem(qe,this.currentHistoryPosition.toString()),F.updateCurrentState(l=>({...l,backType:"redirect"})),F.pushState(i,{type:"redirect",id:this.main.id,scroll:o,position:this.currentHistoryPosition},e),c.dispatchEvent(window,"phx:navigate",{detail:{href:e,patch:!1,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location)),r&&n.classList.remove("phx-click-loading"),a()})})}registerNewLocation(t){let{pathname:e,search:i}=this.currentLocation;return e+i===t.pathname+t.search?!1:(this.currentLocation=tt(t),!0)}bindForms(){let t=0,e=!1;this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit")),n=i.target.getAttribute(this.binding("change"));!e&&n&&!s&&(e=!0,i.preventDefault(),this.withinOwners(i.target,r=>{r.disableForm(i.target),window.requestAnimationFrame(()=>{c.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))}),this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit"));if(!s){c.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{S.exec(i,"submit",s,n,i.target,["push",{submitter:i.submitter}])})});for(let i of["change","input"])this.on(i,s=>{if(s instanceof CustomEvent&&(s.target instanceof HTMLInputElement||s.target instanceof HTMLSelectElement||s.target instanceof HTMLTextAreaElement)&&s.target.form===void 0){if(s.detail&&s.detail.dispatcher)throw new Error(`dispatching a custom ${i} event is only supported on input elements inside a form`);return}let n=this.binding("change"),r=s.target;if(this.blockPhxChangeWhileComposing&&s.isComposing){let m=`composition-listener-${i}`;c.private(r,m)||(c.putPrivate(r,m,!0),r.addEventListener("compositionend",()=>{r.dispatchEvent(new Event(i,{bubbles:!0})),c.deletePrivate(r,m)},{once:!0}));return}let o=r.getAttribute(n),a=r.form&&r.form.getAttribute(n),h=o||a;if(!h||r.type==="number"&&r.validity&&r.validity.badInput)return;let l=o?r:r.form,d=t;t++;let{at:p,type:g}=c.private(r,"prev-iteration")||{};p===d-1&&i==="change"&&g==="input"||(c.putPrivate(r,"prev-iteration",{at:d,type:i}),this.debounce(r,s,i,()=>{this.withinOwners(l,m=>{c.putPrivate(r,it,!0),S.exec(s,"change",h,m,r,["push",{_target:s.target.name,dispatcher:l}])})}))});this.on("reset",i=>{let s=i.target;c.resetForm(s);let n=Array.from(s.elements).find(r=>r.type==="reset");n&&window.requestAnimationFrame(()=>{n.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(t,e,i,s){if(i==="blur"||i==="focusout")return s();let n=this.binding($i),r=this.binding(Ui),o=this.defaults.debounce.toString(),a=this.defaults.throttle.toString();this.withinOwners(t,h=>{let l=()=>!h.isDestroyed()&&document.body.contains(t);c.debounce(t,e,n,o,r,a,l,()=>{s()})})}silenceEvents(t){this.silenced=!0,t(),this.silenced=!1}on(t,e){this.boundEventNames.add(t),window.addEventListener(t,i=>{this.silenced||e(i)})}jsQuerySelectorAll(t,e,i){let s=this.domCallbacks.jsQuerySelectorAll;return s?s(t,e,i):i()}},Rs=class{constructor(){this.transitions=new Set,this.promises=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(t=>{clearTimeout(t),this.transitions.delete(t)}),this.promises.clear(),this.flushPendingOps()}after(t){this.size()===0?t():this.pushPendingOp(t)}addTransition(t,e,i){e();let s=setTimeout(()=>{this.transitions.delete(s),i(),this.flushPendingOps()},t);this.transitions.add(s)}addAsyncTransition(t){this.promises.add(t),t.then(()=>{this.promises.delete(t),this.flushPendingOps()})}pushPendingOp(t){this.pendingOps.push(t)}size(){return this.transitions.size+this.promises.size}flushPendingOps(){if(this.size()>0)return;let t=this.pendingOps.shift();t&&(t(),this.flushPendingOps())}},bi=Ps;var xs=document.querySelector("meta[name='csrf-token']")?.getAttribute("content"),Is={CopyToClipboard:{mounted(){this.el.addEventListener("click",()=>{let t=this.el.dataset.copyText||this.el.textContent.trim();navigator.clipboard.writeText(t).catch(()=>{})})}}},wi=new bi("/live",Ot,{params:{_csrf_token:xs},hooks:Is});wi.connect();window.liveSocket=wi;})();