phoenix_live_view 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/js/phoenix_live_view/dom_patch.js +1 -1
- package/assets/js/phoenix_live_view/hooks.js +6 -3
- package/assets/js/phoenix_live_view/js.js +9 -13
- package/assets/js/phoenix_live_view/live_socket.js +15 -11
- package/package.json +1 -1
- package/priv/static/phoenix_live_view.cjs.js +29 -30
- package/priv/static/phoenix_live_view.cjs.js.map +3 -3
- package/priv/static/phoenix_live_view.esm.js +29 -30
- package/priv/static/phoenix_live_view.esm.js.map +3 -3
- package/priv/static/phoenix_live_view.js +29 -30
- package/priv/static/phoenix_live_view.min.js +4 -4
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var LiveView=(()=>{var Ye=Object.defineProperty,yi=Object.defineProperties,Pi=Object.getOwnPropertyDescriptor,ki=Object.getOwnPropertyDescriptors,Ci=Object.getOwnPropertyNames,ze=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable;var Ut=(s,e,t)=>e in s?Ye(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,L=(s,e)=>{for(var t in e||(e={}))mt.call(e,t)&&Ut(s,t,e[t]);if(ze)for(var t of ze(e))Xt.call(e,t)&&Ut(s,t,e[t]);return s},Ne=(s,e)=>yi(s,ki(e));var $t=(s,e)=>{var t={};for(var i in s)mt.call(s,i)&&e.indexOf(i)<0&&(t[i]=s[i]);if(s!=null&&ze)for(var i of ze(s))e.indexOf(i)<0&&Xt.call(s,i)&&(t[i]=s[i]);return t};var Ri=(s,e)=>{for(var t in e)Ye(s,t,{get:e[t],enumerable:!0})},xi=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ci(e))!mt.call(s,r)&&r!==t&&Ye(s,r,{get:()=>e[r],enumerable:!(i=Pi(e,r))||i.enumerable});return s};var Ti=s=>xi(Ye({},"__esModule",{value:!0}),s);var ns={};Ri(ns,{LiveSocket:()=>qe,createHook:()=>rs,isUsedInput:()=>wi});var Qe="consecutive-reloads";var Ze=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],$="data-phx-component",et="data-phx-link",Bt="track-static",Vt="data-phx-link-state",ae="data-phx-ref-loading",O="data-phx-ref-src",x="data-phx-ref-lock",tt="track-uploads",B="data-phx-upload-ref",we="data-phx-preflighted-refs",jt="data-phx-done-refs",gt="drop-target",Fe="data-phx-active-refs",Ee="phx:live-file:updated",it="data-phx-skip",st="data-phx-id",vt="data-phx-prune",bt="phx-connected",he="phx-loading",fe="phx-error",At="phx-client-error",ye="phx-server-error",ee="data-phx-parent-id",Pe="data-phx-main",J="data-phx-root-id",Me="viewport-top",Ue="viewport-bottom",Jt="trigger-action",pe="phx-has-focused",Wt=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],rt=["checkbox","radio"],me="phx-has-submitted",M="data-phx-session",K=`[${M}]`,St="data-phx-sticky",te="data-phx-static",Xe="data-phx-readonly",de="data-phx-disabled",_t="disable-with",ke="data-phx-disable-with-restore",Ce="hook",qt="debounce",Kt="throttle",Re="update",nt="stream",xe="data-phx-stream",Gt="key",G="phxPrivate",wt="auto-recover",$e="phx:live-socket:debug",ot="phx:live-socket:profiling",lt="phx:live-socket:latency-sim",Be="phx:nav-history-position",zt="progress",Et="mounted",yt="__phoenix_reload_status__",Yt=1,Pt=3,Qt=200,Zt="phx-",ei=3e4;var Te="debounce-trigger",Ie="throttled",kt="debounce-prev-key",ti={debounce:300,throttle:300},Ct=[ae,O,x],Ve="d",z="s",at="r",D="c",Rt="e",xt="r",Tt="t",ii="p",It="stream";var je=class{constructor(e,t,i){let{chunk_size:r,chunk_timeout:n}=t;this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=r,this.chunkTimeout=n,this.chunkTimer=null,this.errored=!1,this.uploadChannel=i.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),this.entry.error(e))}upload(){this.uploadChannel.onError(e=>this.error(e)),this.uploadChannel.join().receive("ok",e=>this.readNextChunk()).receive("error",e=>this.error(e))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let e=new window.FileReader,t=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=i=>{if(i.target.error===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return I("Read error: "+i.target.error)},e.readAsArrayBuffer(t)}pushChunk(e){this.uploadChannel.isJoined()&&this.uploadChannel.push("chunk",e,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:t})=>this.error(t))}};var I=(s,e)=>console.error&&console.error(s,e),W=s=>{let e=typeof s;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(s)};function si(){let s=new Set,e=document.querySelectorAll("*[id]");for(let t=0,i=e.length;t<i;t++)s.has(e[t].id)?console.error(`Multiple IDs detected: ${e[t].id}. Ensure unique element ids.`):s.add(e[t].id)}function ri(s){let e=new Set;Object.keys(s).forEach(t=>{let i=document.getElementById(t);i&&i.parentElement&&i.parentElement.getAttribute("phx-update")!=="stream"&&e.add(`The stream container with id "${i.parentElement.id}" is missing the phx-update="stream" attribute. Ensure it is set for streams to work properly.`)}),e.forEach(t=>console.error(t))}var ni=(s,e,t,i)=>{s.liveSocket.isDebugEnabled()&&console.log(`${s.id} ${e}: ${t} - `,i)},Le=s=>typeof s=="function"?s:function(){return s},Oe=s=>JSON.parse(JSON.stringify(s)),ge=(s,e,t)=>{do{if(s.matches(`[${e}]`)&&!s.disabled)return s;s=s.parentElement||s.parentNode}while(s!==null&&s.nodeType===1&&!(t&&t.isSameNode(s)||s.matches(K)));return null},ve=s=>s!==null&&typeof s=="object"&&!(s instanceof Array),oi=(s,e)=>JSON.stringify(s)===JSON.stringify(e),Lt=s=>{for(let e in s)return!1;return!0},Y=(s,e)=>s&&e(s),li=function(s,e,t,i){s.forEach(r=>{new je(r,t.config,i).upload()})};var Ii={canPushState(){return typeof history.pushState!="undefined"},dropLocal(s,e,t){return s.removeItem(this.localKey(e,t))},updateLocal(s,e,t,i,r){let n=this.getLocal(s,e,t),o=this.localKey(e,t),l=n===null?i:r(n);return s.setItem(o,JSON.stringify(l)),l},getLocal(s,e,t){return JSON.parse(s.getItem(this.localKey(e,t)))},updateCurrentState(s){this.canPushState()&&history.replaceState(s(history.state||{}),"",window.location.href)},pushState(s,e,t){if(this.canPushState()){if(t!==window.location.href){if(e.type=="redirect"&&e.scroll){let i=history.state||{};i.scroll=e.scroll,history.replaceState(i,"",window.location.href)}delete e.scroll,history[s+"State"](e,"",t||null),window.requestAnimationFrame(()=>{let i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)})}}else this.redirect(t)},setCookie(s,e,t){let i=typeof t=="number"?` max-age=${t};`:"";document.cookie=`${s}=${e};${i} path=/`},getCookie(s){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${s}s*=s*([^;]*).*$)|^.*$`),"$1")},deleteCookie(s){document.cookie=`${s}=; max-age=-1; path=/`},redirect(s,e){e&&this.setCookie("__phoenix_flash__",e,60),window.location=s},localKey(s,e){return`${s}-${e}`},getHashTargetEl(s){let e=s.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},H=Ii;var be={byId(s){return document.getElementById(s)||I(`no id found for ${s}`)},removeClass(s,e){s.classList.remove(e),s.classList.length===0&&s.removeAttribute("class")},all(s,e,t){if(!s)return[];let i=Array.from(s.querySelectorAll(e));return t?i.forEach(t):i},childNodeLength(s){let e=document.createElement("template");return e.innerHTML=s,e.content.childElementCount},isUploadInput(s){return s.type==="file"&&s.getAttribute(B)!==null},isAutoUpload(s){return s.hasAttribute("data-phx-auto-upload")},findUploadInputs(s){let e=s.id,t=this.all(document,`input[type="file"][${B}][form="${e}"]`);return this.all(s,`input[type="file"][${B}]`).concat(t)},findComponentNodeList(s,e){return this.filterWithinSameLiveView(this.all(s,`[${$}="${e}"]`),s)},isPhxDestroyed(s){return!!(s.id&&be.private(s,"destroyed"))},wantsNewTab(s){let e=s.ctrlKey||s.shiftKey||s.metaKey||s.button&&s.button===1,t=s.target instanceof HTMLAnchorElement&&s.target.hasAttribute("download"),i=s.target.hasAttribute("target")&&s.target.getAttribute("target").toLowerCase()==="_blank",r=s.target.hasAttribute("target")&&!s.target.getAttribute("target").startsWith("_");return e||i||t||r},isUnloadableFormSubmit(s){return s.target&&s.target.getAttribute("method")==="dialog"||s.submitter&&s.submitter.getAttribute("formmethod")==="dialog"?!1:!s.defaultPrevented&&!this.wantsNewTab(s)},isNewPageClick(s,e){let t=s.target instanceof HTMLAnchorElement?s.target.getAttribute("href"):null,i;if(s.defaultPrevented||t===null||this.wantsNewTab(s)||t.startsWith("mailto:")||t.startsWith("tel:")||s.target.isContentEditable)return!1;try{i=new URL(t)}catch(r){try{i=new URL(t,e)}catch(n){return!0}}return i.host===e.host&&i.protocol===e.protocol&&i.pathname===e.pathname&&i.search===e.search?i.hash===""&&!i.href.endsWith("#"):i.protocol.startsWith("http")},markPhxChildDestroyed(s){this.isPhxChild(s)&&s.setAttribute(M,""),this.putPrivate(s,"destroyed",!0)},findPhxChildrenInFragment(s,e){let t=document.createElement("template");return t.innerHTML=s,this.findPhxChildren(t.content,e)},isIgnored(s,e){return(s.getAttribute(e)||s.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(s,e,t){return s.getAttribute&&t.indexOf(s.getAttribute(e))>=0},findPhxSticky(s){return this.all(s,`[${St}]`)},findPhxChildren(s,e){return this.all(s,`${K}[${ee}="${e}"]`)},findExistingParentCIDs(s,e){let t=new Set,i=new Set;return e.forEach(r=>{this.filterWithinSameLiveView(this.all(s,`[${$}="${r}"]`),s).forEach(n=>{t.add(r),this.filterWithinSameLiveView(this.all(n,`[${$}]`),n).map(o=>parseInt(o.getAttribute($))).forEach(o=>i.add(o))})}),i.forEach(r=>t.delete(r)),t},filterWithinSameLiveView(s,e){return e.querySelector(K)?s.filter(t=>this.withinSameLiveView(t,e)):s},withinSameLiveView(s,e){for(;s=s.parentNode;){if(s.isSameNode(e))return!0;if(s.getAttribute(M)!==null)return!1}},private(s,e){return s[G]&&s[G][e]},deletePrivate(s,e){s[G]&&delete s[G][e]},putPrivate(s,e,t){s[G]||(s[G]={}),s[G][e]=t},updatePrivate(s,e,t,i){let r=this.private(s,e);r===void 0?this.putPrivate(s,e,i(t)):this.putPrivate(s,e,i(r))},syncPendingAttrs(s,e){s.hasAttribute(O)&&(Ze.forEach(t=>{s.classList.contains(t)&&e.classList.add(t)}),Ct.filter(t=>s.hasAttribute(t)).forEach(t=>{e.setAttribute(t,s.getAttribute(t))}))},copyPrivates(s,e){e[G]&&(s[G]=e[G])},putTitle(s){let e=document.querySelector("title");if(e){let{prefix:t,suffix:i,default:r}=e.dataset,n=typeof s!="string"||s.trim()==="";if(n&&typeof r!="string")return;let o=n?r:s;document.title=`${t||""}${o||""}${i||""}`}else document.title=s},debounce(s,e,t,i,r,n,o,l){let a=s.getAttribute(t),d=s.getAttribute(r);a===""&&(a=i),d===""&&(d=n);let f=a||d;switch(f){case null:return l();case"blur":this.once(s,"debounce-blur")&&s.addEventListener("blur",()=>{o()&&l()});return;default:let p=parseInt(f),m=()=>d?this.deletePrivate(s,Ie):l(),g=this.incCycle(s,Te,m);if(isNaN(p))return I(`invalid throttle/debounce value: ${f}`);if(d){let v=!1;if(e.type==="keydown"){let b=this.private(s,kt);this.putPrivate(s,kt,e.key),v=b!==e.key}if(!v&&this.private(s,Ie))return!1;{l();let b=setTimeout(()=>{o()&&this.triggerCycle(s,Te)},p);this.putPrivate(s,Ie,b)}}else setTimeout(()=>{o()&&this.triggerCycle(s,Te,g)},p);let u=s.form;u&&this.once(u,"bind-debounce")&&u.addEventListener("submit",()=>{Array.from(new FormData(u).entries(),([v])=>{let b=u.querySelector(`[name="${v}"]`);this.incCycle(b,Te),this.deletePrivate(b,Ie)})}),this.once(s,"bind-debounce")&&s.addEventListener("blur",()=>{clearTimeout(this.private(s,Ie)),this.triggerCycle(s,Te)})}},triggerCycle(s,e,t){let[i,r]=this.private(s,e);t||(t=i),t===i&&(this.incCycle(s,e),r())},once(s,e){return this.private(s,e)===!0?!1:(this.putPrivate(s,e,!0),!0)},incCycle(s,e,t=function(){}){let[i]=this.private(s,e)||[0,t];return i++,this.putPrivate(s,e,[i,t]),i},maintainPrivateHooks(s,e,t,i){s.hasAttribute&&s.hasAttribute("data-phx-hook")&&!e.hasAttribute("data-phx-hook")&&e.setAttribute("data-phx-hook",s.getAttribute("data-phx-hook")),e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute(i))&&e.setAttribute("data-phx-hook","Phoenix.InfiniteScroll")},putCustomElHook(s,e){s.isConnected?s.setAttribute("data-phx-hook",""):console.error(`
|
|
1
|
+
var LiveView=(()=>{var Ye=Object.defineProperty,yi=Object.defineProperties,Pi=Object.getOwnPropertyDescriptor,ki=Object.getOwnPropertyDescriptors,Ci=Object.getOwnPropertyNames,ze=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable;var Ut=(s,e,t)=>e in s?Ye(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,L=(s,e)=>{for(var t in e||(e={}))mt.call(e,t)&&Ut(s,t,e[t]);if(ze)for(var t of ze(e))Xt.call(e,t)&&Ut(s,t,e[t]);return s},Ne=(s,e)=>yi(s,ki(e));var $t=(s,e)=>{var t={};for(var i in s)mt.call(s,i)&&e.indexOf(i)<0&&(t[i]=s[i]);if(s!=null&&ze)for(var i of ze(s))e.indexOf(i)<0&&Xt.call(s,i)&&(t[i]=s[i]);return t};var Ri=(s,e)=>{for(var t in e)Ye(s,t,{get:e[t],enumerable:!0})},xi=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ci(e))!mt.call(s,r)&&r!==t&&Ye(s,r,{get:()=>e[r],enumerable:!(i=Pi(e,r))||i.enumerable});return s};var Ti=s=>xi(Ye({},"__esModule",{value:!0}),s);var ns={};Ri(ns,{LiveSocket:()=>qe,createHook:()=>rs,isUsedInput:()=>wi});var Qe="consecutive-reloads";var Ze=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],$="data-phx-component",et="data-phx-link",Bt="track-static",Vt="data-phx-link-state",ae="data-phx-ref-loading",O="data-phx-ref-src",x="data-phx-ref-lock",tt="track-uploads",B="data-phx-upload-ref",we="data-phx-preflighted-refs",jt="data-phx-done-refs",gt="drop-target",Fe="data-phx-active-refs",Ee="phx:live-file:updated",it="data-phx-skip",st="data-phx-id",vt="data-phx-prune",bt="phx-connected",he="phx-loading",fe="phx-error",At="phx-client-error",ye="phx-server-error",ee="data-phx-parent-id",Pe="data-phx-main",J="data-phx-root-id",Me="viewport-top",Ue="viewport-bottom",Jt="trigger-action",pe="phx-has-focused",Wt=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],rt=["checkbox","radio"],me="phx-has-submitted",M="data-phx-session",K=`[${M}]`,St="data-phx-sticky",te="data-phx-static",Xe="data-phx-readonly",de="data-phx-disabled",_t="disable-with",ke="data-phx-disable-with-restore",Ce="hook",qt="debounce",Kt="throttle",Re="update",nt="stream",xe="data-phx-stream",Gt="key",G="phxPrivate",wt="auto-recover",$e="phx:live-socket:debug",ot="phx:live-socket:profiling",lt="phx:live-socket:latency-sim",Be="phx:nav-history-position",zt="progress",Et="mounted",yt="__phoenix_reload_status__",Yt=1,Pt=3,Qt=200,Zt="phx-",ei=3e4;var Te="debounce-trigger",Ie="throttled",kt="debounce-prev-key",ti={debounce:300,throttle:300},Ct=[ae,O,x],Ve="d",z="s",at="r",D="c",Rt="e",xt="r",Tt="t",ii="p",It="stream";var je=class{constructor(e,t,i){let{chunk_size:r,chunk_timeout:n}=t;this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=r,this.chunkTimeout=n,this.chunkTimer=null,this.errored=!1,this.uploadChannel=i.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),this.entry.error(e))}upload(){this.uploadChannel.onError(e=>this.error(e)),this.uploadChannel.join().receive("ok",e=>this.readNextChunk()).receive("error",e=>this.error(e))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let e=new window.FileReader,t=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=i=>{if(i.target.error===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return I("Read error: "+i.target.error)},e.readAsArrayBuffer(t)}pushChunk(e){this.uploadChannel.isJoined()&&this.uploadChannel.push("chunk",e,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:t})=>this.error(t))}};var I=(s,e)=>console.error&&console.error(s,e),W=s=>{let e=typeof s;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(s)};function si(){let s=new Set,e=document.querySelectorAll("*[id]");for(let t=0,i=e.length;t<i;t++)s.has(e[t].id)?console.error(`Multiple IDs detected: ${e[t].id}. Ensure unique element ids.`):s.add(e[t].id)}function ri(s){let e=new Set;Object.keys(s).forEach(t=>{let i=document.getElementById(t);i&&i.parentElement&&i.parentElement.getAttribute("phx-update")!=="stream"&&e.add(`The stream container with id "${i.parentElement.id}" is missing the phx-update="stream" attribute. Ensure it is set for streams to work properly.`)}),e.forEach(t=>console.error(t))}var ni=(s,e,t,i)=>{s.liveSocket.isDebugEnabled()&&console.log(`${s.id} ${e}: ${t} - `,i)},Le=s=>typeof s=="function"?s:function(){return s},Oe=s=>JSON.parse(JSON.stringify(s)),ge=(s,e,t)=>{do{if(s.matches(`[${e}]`)&&!s.disabled)return s;s=s.parentElement||s.parentNode}while(s!==null&&s.nodeType===1&&!(t&&t.isSameNode(s)||s.matches(K)));return null},ve=s=>s!==null&&typeof s=="object"&&!(s instanceof Array),oi=(s,e)=>JSON.stringify(s)===JSON.stringify(e),Lt=s=>{for(let e in s)return!1;return!0},Y=(s,e)=>s&&e(s),li=function(s,e,t,i){s.forEach(r=>{new je(r,t.config,i).upload()})};var Ii={canPushState(){return typeof history.pushState!="undefined"},dropLocal(s,e,t){return s.removeItem(this.localKey(e,t))},updateLocal(s,e,t,i,r){let n=this.getLocal(s,e,t),o=this.localKey(e,t),l=n===null?i:r(n);return s.setItem(o,JSON.stringify(l)),l},getLocal(s,e,t){return JSON.parse(s.getItem(this.localKey(e,t)))},updateCurrentState(s){this.canPushState()&&history.replaceState(s(history.state||{}),"",window.location.href)},pushState(s,e,t){if(this.canPushState()){if(t!==window.location.href){if(e.type=="redirect"&&e.scroll){let i=history.state||{};i.scroll=e.scroll,history.replaceState(i,"",window.location.href)}delete e.scroll,history[s+"State"](e,"",t||null),window.requestAnimationFrame(()=>{let i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)})}}else this.redirect(t)},setCookie(s,e,t){let i=typeof t=="number"?` max-age=${t};`:"";document.cookie=`${s}=${e};${i} path=/`},getCookie(s){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${s}s*=s*([^;]*).*$)|^.*$`),"$1")},deleteCookie(s){document.cookie=`${s}=; max-age=-1; path=/`},redirect(s,e){e&&this.setCookie("__phoenix_flash__",e,60),window.location=s},localKey(s,e){return`${s}-${e}`},getHashTargetEl(s){let e=s.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},H=Ii;var be={byId(s){return document.getElementById(s)||I(`no id found for ${s}`)},removeClass(s,e){s.classList.remove(e),s.classList.length===0&&s.removeAttribute("class")},all(s,e,t){if(!s)return[];let i=Array.from(s.querySelectorAll(e));return t?i.forEach(t):i},childNodeLength(s){let e=document.createElement("template");return e.innerHTML=s,e.content.childElementCount},isUploadInput(s){return s.type==="file"&&s.getAttribute(B)!==null},isAutoUpload(s){return s.hasAttribute("data-phx-auto-upload")},findUploadInputs(s){let e=s.id,t=this.all(document,`input[type="file"][${B}][form="${e}"]`);return this.all(s,`input[type="file"][${B}]`).concat(t)},findComponentNodeList(s,e){return this.filterWithinSameLiveView(this.all(s,`[${$}="${e}"]`),s)},isPhxDestroyed(s){return!!(s.id&&be.private(s,"destroyed"))},wantsNewTab(s){let e=s.ctrlKey||s.shiftKey||s.metaKey||s.button&&s.button===1,t=s.target instanceof HTMLAnchorElement&&s.target.hasAttribute("download"),i=s.target.hasAttribute("target")&&s.target.getAttribute("target").toLowerCase()==="_blank",r=s.target.hasAttribute("target")&&!s.target.getAttribute("target").startsWith("_");return e||i||t||r},isUnloadableFormSubmit(s){return s.target&&s.target.getAttribute("method")==="dialog"||s.submitter&&s.submitter.getAttribute("formmethod")==="dialog"?!1:!s.defaultPrevented&&!this.wantsNewTab(s)},isNewPageClick(s,e){let t=s.target instanceof HTMLAnchorElement?s.target.getAttribute("href"):null,i;if(s.defaultPrevented||t===null||this.wantsNewTab(s)||t.startsWith("mailto:")||t.startsWith("tel:")||s.target.isContentEditable)return!1;try{i=new URL(t)}catch(r){try{i=new URL(t,e)}catch(n){return!0}}return i.host===e.host&&i.protocol===e.protocol&&i.pathname===e.pathname&&i.search===e.search?i.hash===""&&!i.href.endsWith("#"):i.protocol.startsWith("http")},markPhxChildDestroyed(s){this.isPhxChild(s)&&s.setAttribute(M,""),this.putPrivate(s,"destroyed",!0)},findPhxChildrenInFragment(s,e){let t=document.createElement("template");return t.innerHTML=s,this.findPhxChildren(t.content,e)},isIgnored(s,e){return(s.getAttribute(e)||s.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(s,e,t){return s.getAttribute&&t.indexOf(s.getAttribute(e))>=0},findPhxSticky(s){return this.all(s,`[${St}]`)},findPhxChildren(s,e){return this.all(s,`${K}[${ee}="${e}"]`)},findExistingParentCIDs(s,e){let t=new Set,i=new Set;return e.forEach(r=>{this.filterWithinSameLiveView(this.all(s,`[${$}="${r}"]`),s).forEach(n=>{t.add(r),this.filterWithinSameLiveView(this.all(n,`[${$}]`),n).map(o=>parseInt(o.getAttribute($))).forEach(o=>i.add(o))})}),i.forEach(r=>t.delete(r)),t},filterWithinSameLiveView(s,e){return e.querySelector(K)?s.filter(t=>this.withinSameLiveView(t,e)):s},withinSameLiveView(s,e){for(;s=s.parentNode;){if(s.isSameNode(e))return!0;if(s.getAttribute(M)!==null)return!1}},private(s,e){return s[G]&&s[G][e]},deletePrivate(s,e){s[G]&&delete s[G][e]},putPrivate(s,e,t){s[G]||(s[G]={}),s[G][e]=t},updatePrivate(s,e,t,i){let r=this.private(s,e);r===void 0?this.putPrivate(s,e,i(t)):this.putPrivate(s,e,i(r))},syncPendingAttrs(s,e){s.hasAttribute(O)&&(Ze.forEach(t=>{s.classList.contains(t)&&e.classList.add(t)}),Ct.filter(t=>s.hasAttribute(t)).forEach(t=>{e.setAttribute(t,s.getAttribute(t))}))},copyPrivates(s,e){e[G]&&(s[G]=e[G])},putTitle(s){let e=document.querySelector("title");if(e){let{prefix:t,suffix:i,default:r}=e.dataset,n=typeof s!="string"||s.trim()==="";if(n&&typeof r!="string")return;let o=n?r:s;document.title=`${t||""}${o||""}${i||""}`}else document.title=s},debounce(s,e,t,i,r,n,o,l){let a=s.getAttribute(t),d=s.getAttribute(r);a===""&&(a=i),d===""&&(d=n);let f=a||d;switch(f){case null:return l();case"blur":this.once(s,"debounce-blur")&&s.addEventListener("blur",()=>{o()&&l()});return;default:let p=parseInt(f),m=()=>d?this.deletePrivate(s,Ie):l(),g=this.incCycle(s,Te,m);if(isNaN(p))return I(`invalid throttle/debounce value: ${f}`);if(d){let v=!1;if(e.type==="keydown"){let b=this.private(s,kt);this.putPrivate(s,kt,e.key),v=b!==e.key}if(!v&&this.private(s,Ie))return!1;{l();let b=setTimeout(()=>{o()&&this.triggerCycle(s,Te)},p);this.putPrivate(s,Ie,b)}}else setTimeout(()=>{o()&&this.triggerCycle(s,Te,g)},p);let c=s.form;c&&this.once(c,"bind-debounce")&&c.addEventListener("submit",()=>{Array.from(new FormData(c).entries(),([v])=>{let b=c.querySelector(`[name="${v}"]`);this.incCycle(b,Te),this.deletePrivate(b,Ie)})}),this.once(s,"bind-debounce")&&s.addEventListener("blur",()=>{clearTimeout(this.private(s,Ie)),this.triggerCycle(s,Te)})}},triggerCycle(s,e,t){let[i,r]=this.private(s,e);t||(t=i),t===i&&(this.incCycle(s,e),r())},once(s,e){return this.private(s,e)===!0?!1:(this.putPrivate(s,e,!0),!0)},incCycle(s,e,t=function(){}){let[i]=this.private(s,e)||[0,t];return i++,this.putPrivate(s,e,[i,t]),i},maintainPrivateHooks(s,e,t,i){s.hasAttribute&&s.hasAttribute("data-phx-hook")&&!e.hasAttribute("data-phx-hook")&&e.setAttribute("data-phx-hook",s.getAttribute("data-phx-hook")),e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute(i))&&e.setAttribute("data-phx-hook","Phoenix.InfiniteScroll")},putCustomElHook(s,e){s.isConnected?s.setAttribute("data-phx-hook",""):console.error(`
|
|
2
2
|
hook attached to non-connected DOM element
|
|
3
3
|
ensure you are calling createHook within your connectedCallback. ${s.outerHTML}
|
|
4
4
|
`),this.putPrivate(s,"custom-el-hook",e)},getCustomElHook(s){return this.private(s,"custom-el-hook")},isUsedInput(s){return s.nodeType===Node.ELEMENT_NODE&&(this.private(s,pe)||this.private(s,me))},resetForm(s){Array.from(s.elements).forEach(e=>{this.deletePrivate(e,pe),this.deletePrivate(e,me)})},isPhxChild(s){return s.getAttribute&&s.getAttribute(ee)},isPhxSticky(s){return s.getAttribute&&s.getAttribute(St)!==null},isChildOfAny(s,e){return!!e.find(t=>t.contains(s))},firstPhxChild(s){return this.isPhxChild(s)?s:this.all(s,`[${ee}]`)[0]},dispatchEvent(s,e,t={}){let i=!0;s.nodeName==="INPUT"&&s.type==="file"&&e==="click"&&(i=!1);let o={bubbles:t.bubbles===void 0?i:!!t.bubbles,cancelable:!0,detail:t.detail||{}},l=e==="click"?new MouseEvent("click",o):new CustomEvent(e,o);s.dispatchEvent(l)},cloneNode(s,e){if(typeof e=="undefined")return s.cloneNode(!0);{let t=s.cloneNode(!1);return t.innerHTML=e,t}},mergeAttrs(s,e,t={}){let i=new Set(t.exclude||[]),r=t.isIgnored,n=e.attributes;for(let l=n.length-1;l>=0;l--){let a=n[l].name;if(i.has(a))a==="value"&&s.value===e.value&&s.setAttribute("value",e.getAttribute(a));else{let d=e.getAttribute(a);s.getAttribute(a)!==d&&(!r||r&&a.startsWith("data-"))&&s.setAttribute(a,d)}}let o=s.attributes;for(let l=o.length-1;l>=0;l--){let a=o[l].name;r?a.startsWith("data-")&&!e.hasAttribute(a)&&!Ct.includes(a)&&s.removeAttribute(a):e.hasAttribute(a)||s.removeAttribute(a)}},mergeFocusedInput(s,e){s instanceof HTMLSelectElement||be.mergeAttrs(s,e,{exclude:["value"]}),e.readOnly?s.setAttribute("readonly",!0):s.removeAttribute("readonly")},hasSelectionRange(s){return s.setSelectionRange&&(s.type==="text"||s.type==="textarea")},restoreFocus(s,e,t){if(s instanceof HTMLSelectElement&&s.focus(),!be.isTextualInput(s))return;s.matches(":focus")||s.focus(),this.hasSelectionRange(s)&&s.setSelectionRange(e,t)},isFormInput(s){return/^(?:input|select|textarea)$/i.test(s.tagName)&&s.type!=="button"},syncAttrsToProps(s){s instanceof HTMLInputElement&&rt.indexOf(s.type.toLocaleLowerCase())>=0&&(s.checked=s.getAttribute("checked")!==null)},isTextualInput(s){return Wt.indexOf(s.type)>=0},isNowTriggerFormExternal(s,e){return s.getAttribute&&s.getAttribute(e)!==null&&document.body.contains(s)},cleanChildNodes(s,e){if(be.isPhxUpdate(s,e,["append","prepend"])){let t=[];s.childNodes.forEach(i=>{i.id||(!(i.nodeType===Node.TEXT_NODE&&i.nodeValue.trim()==="")&&i.nodeType!==Node.COMMENT_NODE&&I(`only HTML element tags with an id are allowed inside containers with phx-update.
|
|
5
5
|
|
|
6
6
|
removing illegal node: "${(i.outerHTML||i.nodeValue).trim()}"
|
|
7
7
|
|
|
8
|
-
`),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(s,e,t){let i=new Set(["id",M,te,Pe,J]);if(s.tagName.toLowerCase()===e.toLowerCase())return Array.from(s.attributes).filter(r=>!i.has(r.name.toLowerCase())).forEach(r=>s.removeAttribute(r.name)),Object.keys(t).filter(r=>!i.has(r.toLowerCase())).forEach(r=>s.setAttribute(r,t[r])),s;{let r=document.createElement(e);return Object.keys(t).forEach(n=>r.setAttribute(n,t[n])),i.forEach(n=>r.setAttribute(n,s.getAttribute(n))),r.innerHTML=s.innerHTML,s.replaceWith(r),r}},getSticky(s,e,t){let i=(be.private(s,"sticky")||[]).find(([r])=>e===r);if(i){let[r,n,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(s,e){this.updatePrivate(s,"sticky",[],t=>t.filter(([i,r])=>i!==e))},putSticky(s,e,t){let i=t(s);this.updatePrivate(s,"sticky",[],r=>{let n=r.findIndex(([o])=>e===o);return n>=0?r[n]=[e,t,i]:r.push([e,t,i]),r})},applyStickyOperations(s){let e=be.private(s,"sticky");e&&e.forEach(([t,i,r])=>this.putSticky(s,t,i))},isLocked(s){return s.hasAttribute&&s.hasAttribute(x)}},h=be;var re=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(Fe).split(",").indexOf(C.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(we).split(",").indexOf(C.genFileRef(t))>=0&&this.isActive(e,t)}static isPreflightInProgress(e){return e._preflightInProgress===!0}static markPreflightInProgress(e){e._preflightInProgress=!0}constructor(e,t,i,r){this.ref=C.genFileRef(t),this.fileEl=e,this.file=t,this.view=i,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(Ee,this._onElUpdated),this.autoUpload=r}metadata(){return this.meta}progress(e){this._progress=Math.floor(e),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{C.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}isCancelled(){return this._isCancelled}cancel(){this.file._preflightInProgress=!1,this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(Ee,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),this.isAutoUpload()||C.clearFiles(this.fileEl)}isAutoUpload(){return this.autoUpload}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(Ee,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(Fe).split(",").indexOf(this.ref)===-1&&(C.untrackFile(this.fileEl,this.file),this.cancel())}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||I(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:li}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||I(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var Li=0,C=class s{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(Li++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let r=this.activeFiles(e).find(n=>this.genFileRef(n)===t);i(URL.createObjectURL(r))}static hasUploadsInProgress(e){let t=0;return h.findUploadInputs(e).forEach(i=>{i.getAttribute(we)!==i.getAttribute(jt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(r=>{let n={path:e.name},o=e.getAttribute(B);i[o]=i[o]||[],n.ref=this.genFileRef(r),n.last_modified=r.lastModified,n.name=r.name||n.ref,n.relative_path=r.webkitRelativePath,n.type=r.type,n.size=r.size,typeof r.meta=="function"&&(n.meta=r.meta()),i[o].push(n)}),i}static clearFiles(e){e.value=null,e.removeAttribute(B),h.putPrivate(e,"files",[])}static untrackFile(e,t){h.putPrivate(e,"files",h.private(e,"files").filter(i=>!Object.is(i,t)))}static trackFiles(e,t,i){if(e.getAttribute("multiple")!==null){let r=t.filter(n=>!this.activeFiles(e).find(o=>Object.is(o,n)));h.updatePrivate(e,"files",[],n=>n.concat(r)),e.value=null}else i&&i.files.length>0&&(e.files=i.files),h.putPrivate(e,"files",t)}static activeFileInputs(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(h.private(e,"files")||[]).filter(t=>re.isActive(e,t))}static inputsAwaitingPreflight(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!re.isPreflighted(e,t)&&!re.isPreflightInProgress(t))}static markPreflightInProgress(e){e.forEach(t=>re.markPreflightInProgress(t.file))}constructor(e,t,i){this.autoUpload=h.isAutoUpload(e),this.view=t,this.onComplete=i,this._entries=Array.from(s.filesAwaitingPreflight(e)||[]).map(r=>new re(e,r,t,this.autoUpload)),s.markPreflightInProgress(this._entries),this.numEntriesInProgress=this._entries.length}isAutoUpload(){return this.autoUpload}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(n=>(n.isCancelled()?(this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()):(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()})),n));let r=this._entries.reduce((n,o)=>{if(!o.meta)return n;let{name:l,callback:a}=o.uploader(i.uploaders);return n[l]=n[l]||{callback:a,entries:[]},n[l].entries.push(o),n},{});for(let n in r){let{callback:o,entries:l}=r[n];o(l,t,e,i)}}};var Oi={anyOf(s,e){return e.find(t=>s instanceof t)},isFocusable(s,e){return s instanceof HTMLAnchorElement&&s.rel!=="ignore"||s instanceof HTMLAreaElement&&s.href!==void 0||!s.disabled&&this.anyOf(s,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||s instanceof HTMLIFrameElement||s.tabIndex>0||!e&&s.getAttribute("tabindex")!==null&&s.getAttribute("aria-hidden")!=="true"},attemptFocus(s,e){if(this.isFocusable(s,e))try{s.focus()}catch(t){}return!!document.activeElement&&document.activeElement.isSameNode(s)},focusFirstInteractive(s){let e=s.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e,!0))return!0;e=e.nextElementSibling}},focusFirst(s){let e=s.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(s){let e=s.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},q=Oi;var di={LiveFileUpload:{activeRefs(){return this.el.getAttribute(Fe)},preflightedRefs(){return this.el.getAttribute(we)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let s=this.preflightedRefs();this.preflightedWas!==s&&(this.preflightedWas=s,s===""&&this.__view().cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(Ee))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(B)),C.getEntryDataURL(this.inputEl,this.ref,s=>{this.url=s,this.el.src=s})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",s=>{if(!s.relatedTarget||!this.el.contains(s.relatedTarget)){let e=s.target.nextElementSibling;q.attemptFocus(e)||q.focusFirst(e)}else q.focusLast(this.el)}),this.focusEnd.addEventListener("focus",s=>{if(!s.relatedTarget||!this.el.contains(s.relatedTarget)){let e=s.target.previousElementSibling;q.attemptFocus(e)||q.focusLast(e)}else q.focusFirst(this.el)}),this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&q.focusFirst(this.el)}}},ui=s=>["HTML","BODY"].indexOf(s.nodeName.toUpperCase())>=0?null:["scroll","auto"].indexOf(getComputedStyle(s).overflowY)>=0?s:ui(s.parentElement),ai=s=>s?s.scrollTop:document.documentElement.scrollTop||document.body.scrollTop,Ot=s=>s?s.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight,Dt=s=>s?s.getBoundingClientRect().top:0,Di=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.top)>=Dt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.top)<=Ot(e)},Hi=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.bottom)>=Dt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.bottom)<=Ot(e)},hi=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.top)>=Dt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.top)<=Ot(e)};di.InfiniteScroll={mounted(){this.scrollContainer=ui(this.el);let s=ai(this.scrollContainer),e=!1,t=500,i=null,r=this.throttle(t,(l,a)=>{i=()=>!0,this.liveSocket.execJSHookPush(this.el,l,{id:a.id,_overran:!0},()=>{i=null})}),n=this.throttle(t,(l,a)=>{i=()=>a.scrollIntoView({block:"start"}),this.liveSocket.execJSHookPush(this.el,l,{id:a.id},()=>{i=null,window.requestAnimationFrame(()=>{hi(a,this.scrollContainer)||a.scrollIntoView({block:"start"})})})}),o=this.throttle(t,(l,a)=>{i=()=>a.scrollIntoView({block:"end"}),this.liveSocket.execJSHookPush(this.el,l,{id:a.id},()=>{i=null,window.requestAnimationFrame(()=>{hi(a,this.scrollContainer)||a.scrollIntoView({block:"end"})})})});this.onScroll=l=>{let a=ai(this.scrollContainer);if(i)return s=a,i();let d=this.el.getBoundingClientRect(),f=this.el.getAttribute(this.liveSocket.binding("viewport-top")),p=this.el.getAttribute(this.liveSocket.binding("viewport-bottom")),m=this.el.lastElementChild,g=this.el.firstElementChild,u=a<s,v=a>s;u&&f&&!e&&d.top>=0?(e=!0,r(f,g)):v&&e&&d.top<=0&&(e=!1),f&&u&&Di(g,this.scrollContainer)?n(f,g):p&&v&&Hi(m,this.scrollContainer)&&o(p,m),s=a},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(s,e){let t=0,i;return(...r)=>{let n=Date.now(),o=s-(n-t);o<=0||o>s?(i&&(clearTimeout(i),i=null),t=n,e(...r)):i||(i=setTimeout(()=>{t=Date.now(),i=null,e(...r)},o))}}};var ci=di;var De=class{static onUnlock(e,t){if(!h.isLocked(e)&&!e.closest(`[${x}]`))return t();let i=e.closest(`[${x}]`),r=i.closest(`[${x}]`).getAttribute(x);i.addEventListener(`phx:undo-lock:${r}`,()=>{t()},{once:!0})}constructor(e){this.el=e,this.loadingRef=e.hasAttribute(ae)?parseInt(e.getAttribute(ae),10):null,this.lockRef=e.hasAttribute(x)?parseInt(e.getAttribute(x),10):null}maybeUndo(e,t,i){this.isWithin(e)&&(this.undoLocks(e,t,i),this.undoLoading(e,t),this.isFullyResolvedBy(e)&&this.el.removeAttribute(O))}isWithin(e){return!(this.loadingRef!==null&&this.loadingRef>e&&this.lockRef!==null&&this.lockRef>e)}undoLocks(e,t,i){if(!this.isLockUndoneBy(e))return;let r=h.private(this.el,x);r&&(i(r),h.deletePrivate(this.el,x)),this.el.removeAttribute(x);let n={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${this.lockRef}`,n))}undoLoading(e,t){if(!this.isLoadingUndoneBy(e)){this.canUndoLoading(e)&&this.el.classList.contains("phx-submit-loading")&&this.el.classList.remove("phx-change-loading");return}if(this.canUndoLoading(e)){this.el.removeAttribute(ae);let i=this.el.getAttribute(de),r=this.el.getAttribute(Xe);r!==null&&(this.el.readOnly=r==="true",this.el.removeAttribute(Xe)),i!==null&&(this.el.disabled=i==="true",this.el.removeAttribute(de));let n=this.el.getAttribute(ke);n!==null&&(this.el.innerText=n,this.el.removeAttribute(ke));let o={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${this.loadingRef}`,o))}Ze.forEach(i=>{(i!=="phx-submit-loading"||this.canUndoLoading(e))&&h.removeClass(this.el,i)})}isLoadingUndoneBy(e){return this.loadingRef===null?!1:this.loadingRef<=e}isLockUndoneBy(e){return this.lockRef===null?!1:this.lockRef<=e}isFullyResolvedBy(e){return(this.loadingRef===null||this.loadingRef<=e)&&(this.lockRef===null||this.lockRef<=e)}canUndoLoading(e){return this.lockRef===null||this.lockRef<=e}};var Je=class{constructor(e,t,i){let r=new Set,n=new Set([...t.children].map(l=>l.id)),o=[];Array.from(e.children).forEach(l=>{if(l.id&&(r.add(l.id),n.has(l.id))){let a=l.previousElementSibling&&l.previousElementSibling.id;o.push({elementId:l.id,previousElementId:a})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(l=>!r.has(l))}perform(){let e=h.byId(this.containerId);this.elementsToModify.forEach(t=>{t.previousElementId?Y(document.getElementById(t.previousElementId),i=>{Y(document.getElementById(t.elementId),r=>{r.previousElementSibling&&r.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",r)})}):Y(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{Y(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}};var fi=11;function Ni(s,e){var t=e.attributes,i,r,n,o,l;if(!(e.nodeType===fi||s.nodeType===fi)){for(var a=t.length-1;a>=0;a--)i=t[a],r=i.name,n=i.namespaceURI,o=i.value,n?(r=i.localName||r,l=s.getAttributeNS(n,r),l!==o&&(i.prefix==="xmlns"&&(r=i.name),s.setAttributeNS(n,r,o))):(l=s.getAttribute(r),l!==o&&s.setAttribute(r,o));for(var d=s.attributes,f=d.length-1;f>=0;f--)i=d[f],r=i.name,n=i.namespaceURI,n?(r=i.localName||r,e.hasAttributeNS(n,r)||s.removeAttributeNS(n,r)):e.hasAttribute(r)||s.removeAttribute(r)}}var ht,Fi="http://www.w3.org/1999/xhtml",U=typeof document=="undefined"?void 0:document,Mi=!!U&&"content"in U.createElement("template"),Ui=!!U&&U.createRange&&"createContextualFragment"in U.createRange();function Xi(s){var e=U.createElement("template");return e.innerHTML=s,e.content.childNodes[0]}function $i(s){ht||(ht=U.createRange(),ht.selectNode(U.body));var e=ht.createContextualFragment(s);return e.childNodes[0]}function Bi(s){var e=U.createElement("body");return e.innerHTML=s,e.childNodes[0]}function Vi(s){return s=s.trim(),Mi?Xi(s):Ui?$i(s):Bi(s)}function dt(s,e){var t=s.nodeName,i=e.nodeName,r,n;return t===i?!0:(r=t.charCodeAt(0),n=i.charCodeAt(0),r<=90&&n>=97?t===i.toUpperCase():n<=90&&r>=97?i===t.toUpperCase():!1)}function ji(s,e){return!e||e===Fi?U.createElement(s):U.createElementNS(e,s)}function Ji(s,e){for(var t=s.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function Ht(s,e,t){s[t]!==e[t]&&(s[t]=e[t],s[t]?s.setAttribute(t,""):s.removeAttribute(t))}var pi={OPTION:function(s,e){var t=s.parentNode;if(t){var i=t.nodeName.toUpperCase();i==="OPTGROUP"&&(t=t.parentNode,i=t&&t.nodeName.toUpperCase()),i==="SELECT"&&!t.hasAttribute("multiple")&&(s.hasAttribute("selected")&&!e.selected&&(s.setAttribute("selected","selected"),s.removeAttribute("selected")),t.selectedIndex=-1)}Ht(s,e,"selected")},INPUT:function(s,e){Ht(s,e,"checked"),Ht(s,e,"disabled"),s.value!==e.value&&(s.value=e.value),e.hasAttribute("value")||s.removeAttribute("value")},TEXTAREA:function(s,e){var t=e.value;s.value!==t&&(s.value=t);var i=s.firstChild;if(i){var r=i.nodeValue;if(r==t||!t&&r==s.placeholder)return;i.nodeValue=t}},SELECT:function(s,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,r=s.firstChild,n,o;r;)if(o=r.nodeName&&r.nodeName.toUpperCase(),o==="OPTGROUP")n=r,r=n.firstChild;else{if(o==="OPTION"){if(r.hasAttribute("selected")){t=i;break}i++}r=r.nextSibling,!r&&n&&(r=n.nextSibling,n=null)}s.selectedIndex=t}}},We=1,mi=11,gi=3,vi=8;function ue(){}function Wi(s){if(s)return s.getAttribute&&s.getAttribute("id")||s.id}function qi(s){return function(t,i,r){if(r||(r={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var n=i;i=U.createElement("html"),i.innerHTML=n}else i=Vi(i);else i.nodeType===mi&&(i=i.firstElementChild);var o=r.getNodeKey||Wi,l=r.onBeforeNodeAdded||ue,a=r.onNodeAdded||ue,d=r.onBeforeElUpdated||ue,f=r.onElUpdated||ue,p=r.onBeforeNodeDiscarded||ue,m=r.onNodeDiscarded||ue,g=r.onBeforeElChildrenUpdated||ue,u=r.skipFromChildren||ue,v=r.addChild||function(S,_){return S.appendChild(_)},b=r.childrenOnly===!0,T=Object.create(null),Z=[];function P(S){Z.push(S)}function V(S,_){if(S.nodeType===We)for(var R=S.firstChild;R;){var w=void 0;_&&(w=o(R))?P(w):(m(R),R.firstChild&&V(R,_)),R=R.nextSibling}}function F(S,_,R){p(S)!==!1&&(_&&_.removeChild(S),m(S),V(S,R))}function N(S){if(S.nodeType===We||S.nodeType===mi)for(var _=S.firstChild;_;){var R=o(_);R&&(T[R]=_),N(_),_=_.nextSibling}}N(t);function c(S){a(S);for(var _=S.firstChild;_;){var R=_.nextSibling,w=o(_);if(w){var k=T[w];k&&dt(_,k)?(_.parentNode.replaceChild(k,_),X(k,_)):c(_)}else c(_);_=R}}function A(S,_,R){for(;_;){var w=_.nextSibling;(R=o(_))?P(R):F(_,S,!0),_=w}}function X(S,_,R){var w=o(_);if(w&&delete T[w],!R){var k=d(S,_);if(k===!1||(k instanceof HTMLElement&&(S=k,N(S)),s(S,_),f(S),g(S,_)===!1))return}S.nodeName!=="TEXTAREA"?ie(S,_):pi.TEXTAREA(S,_)}function ie(S,_){var R=u(S,_),w=_.firstChild,k=S.firstChild,Se,se,_e,Ke,oe;e:for(;w;){for(Ke=w.nextSibling,Se=o(w);!R&&k;){if(_e=k.nextSibling,w.isSameNode&&w.isSameNode(k)){w=Ke,k=_e;continue e}se=o(k);var Ge=k.nodeType,le=void 0;if(Ge===w.nodeType&&(Ge===We?(Se?Se!==se&&((oe=T[Se])?_e===oe?le=!1:(S.insertBefore(oe,k),se?P(se):F(k,S,!0),k=oe,se=o(k)):le=!1):se&&(le=!1),le=le!==!1&&dt(k,w),le&&X(k,w)):(Ge===gi||Ge==vi)&&(le=!0,k.nodeValue!==w.nodeValue&&(k.nodeValue=w.nodeValue))),le){w=Ke,k=_e;continue e}se?P(se):F(k,S,!0),k=_e}if(Se&&(oe=T[Se])&&dt(oe,w))R||v(S,oe),X(oe,w);else{var pt=l(w);pt!==!1&&(pt&&(w=pt),w.actualize&&(w=w.actualize(S.ownerDocument||U)),v(S,w),c(w))}w=Ke,k=_e}A(S,k,se);var Mt=pi[S.nodeName];Mt&&Mt(S,_)}var E=t,j=E.nodeType,ne=i.nodeType;if(!b){if(j===We)ne===We?dt(t,i)||(m(t),E=Ji(t,ji(i.nodeName,i.namespaceURI))):E=i;else if(j===gi||j===vi){if(ne===j)return E.nodeValue!==i.nodeValue&&(E.nodeValue=i.nodeValue),E;E=i}}if(E===i)m(t);else{if(i.isSameNode&&i.isSameNode(E))return;if(X(E,i,b),Z)for(var ct=0,Ei=Z.length;ct<Ei;ct++){var ft=T[Z[ct]];ft&&F(ft,ft.parentNode,!1)}}return!b&&E!==t&&t.parentNode&&(E.actualize&&(E=E.actualize(t.ownerDocument||U)),t.parentNode.replaceChild(E,t)),E}}var Ki=qi(Ni),bi=Ki;var ce=class{constructor(e,t,i,r,n,o,l={}){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=r,this.streams=n,this.streamInserts={},this.streamComponentRestore={},this.targetCID=o,this.cidPatch=W(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.targetContainer=this.isCIDPatch()?this.targetCIDContainer(r):t,this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]},this.withChildren=l.withChildren||l.undoRef||!1,this.undoRef=l.undoRef}before(e,t){this.callbacks[`before${e}`].push(t)}after(e,t){this.callbacks[`after${e}`].push(t)}trackBefore(e,...t){this.callbacks[`before${e}`].forEach(i=>i(...t))}trackAfter(e,...t){this.callbacks[`after${e}`].forEach(i=>i(...t))}markPrunableContentForRemoval(){let e=this.liveSocket.binding(Re);h.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(vt,"")})}perform(e){let{view:t,liveSocket:i,html:r,container:n,targetContainer:o}=this;if(this.isCIDPatch()&&!o)return;let l=i.getActiveElement(),{selectionStart:a,selectionEnd:d}=l&&h.hasSelectionRange(l)?l:{},f=i.binding(Re),p=i.binding(Me),m=i.binding(Ue),g=i.binding(Jt),u=[],v=[],b=[],T=null;function Z(P,V,F=this.withChildren){let N={childrenOnly:P.getAttribute($)===null&&!F,getNodeKey:c=>h.isPhxDestroyed(c)?null:e?c.id:c.id||c.getAttribute&&c.getAttribute(st),skipFromChildren:c=>c.getAttribute(f)===nt,addChild:(c,A)=>{let{ref:X,streamAt:ie}=this.getStreamInsert(A);if(X===void 0)return c.appendChild(A);if(this.setStreamRef(A,X),ie===0)c.insertAdjacentElement("afterbegin",A);else if(ie===-1){let E=c.lastElementChild;if(E&&!E.hasAttribute(xe)){let j=Array.from(c.children).find(ne=>!ne.hasAttribute(xe));c.insertBefore(A,j)}else c.appendChild(A)}else if(ie>0){let E=Array.from(c.children)[ie];c.insertBefore(A,E)}},onBeforeNodeAdded:c=>{h.maintainPrivateHooks(c,c,p,m),this.trackBefore("added",c);let A=c;return this.streamComponentRestore[c.id]&&(A=this.streamComponentRestore[c.id],delete this.streamComponentRestore[c.id],Z.call(this,A,c,!0)),A},onNodeAdded:c=>{c.getAttribute&&this.maybeReOrderStream(c,!0),c instanceof HTMLImageElement&&c.srcset?c.srcset=c.srcset:c instanceof HTMLVideoElement&&c.autoplay&&c.play(),h.isNowTriggerFormExternal(c,g)&&(T=c),(h.isPhxChild(c)&&t.ownsElement(c)||h.isPhxSticky(c)&&t.ownsElement(c.parentNode))&&this.trackAfter("phxChildAdded",c),u.push(c)},onNodeDiscarded:c=>this.onNodeDiscarded(c),onBeforeNodeDiscarded:c=>c.getAttribute&&c.getAttribute(vt)!==null?!0:!(c.parentElement!==null&&c.id&&h.isPhxUpdate(c.parentElement,f,[nt,"append","prepend"])||this.maybePendingRemove(c)||this.skipCIDSibling(c)),onElUpdated:c=>{h.isNowTriggerFormExternal(c,g)&&(T=c),v.push(c),this.maybeReOrderStream(c,!1)},onBeforeElUpdated:(c,A)=>{if(c.id&&c.isSameNode(P)&&c.id!==A.id)return N.onNodeDiscarded(c),c.replaceWith(A),N.onNodeAdded(A);if(h.syncPendingAttrs(c,A),h.maintainPrivateHooks(c,A,p,m),h.cleanChildNodes(A,f),this.skipCIDSibling(A))return this.maybeReOrderStream(c),!1;if(h.isPhxSticky(c))return[M,te,J].map(E=>[E,c.getAttribute(E),A.getAttribute(E)]).forEach(([E,j,ne])=>{ne&&j!==ne&&c.setAttribute(E,ne)}),!1;if(h.isIgnored(c,f)||c.form&&c.form.isSameNode(T))return this.trackBefore("updated",c,A),h.mergeAttrs(c,A,{isIgnored:h.isIgnored(c,f)}),v.push(c),h.applyStickyOperations(c),!1;if(c.type==="number"&&c.validity&&c.validity.badInput)return!1;let X=l&&c.isSameNode(l)&&h.isFormInput(c),ie=X&&this.isChangedSelect(c,A);if(c.hasAttribute(O)&&c.getAttribute(x)!=this.undoRef){h.isUploadInput(c)&&(h.mergeAttrs(c,A,{isIgnored:!0}),this.trackBefore("updated",c,A),v.push(c)),h.applyStickyOperations(c);let j=c.hasAttribute(x)?h.private(c,x)||c.cloneNode(!0):null;j&&(h.putPrivate(c,x,j),X||(c=j))}if(h.isPhxChild(A)){let E=c.getAttribute(M);return h.mergeAttrs(c,A,{exclude:[te]}),E!==""&&c.setAttribute(M,E),c.setAttribute(J,this.rootID),h.applyStickyOperations(c),!1}return h.copyPrivates(A,c),X&&c.type!=="hidden"&&!ie?(this.trackBefore("updated",c,A),h.mergeFocusedInput(c,A),h.syncAttrsToProps(c),v.push(c),h.applyStickyOperations(c),!1):(ie&&c.blur(),h.isPhxUpdate(A,f,["append","prepend"])&&b.push(new Je(c,A,A.getAttribute(f))),h.syncAttrsToProps(A),h.applyStickyOperations(A),this.trackBefore("updated",c,A),c)}};bi(P,V,N)}return this.trackBefore("added",n),this.trackBefore("updated",n,n),i.time("morphdom",()=>{this.streams.forEach(([P,V,F,N])=>{V.forEach(([c,A,X])=>{this.streamInserts[c]={ref:P,streamAt:A,limit:X,reset:N}}),N!==void 0&&h.all(n,`[${xe}="${P}"]`,c=>{this.removeStreamChildElement(c)}),F.forEach(c=>{let A=n.querySelector(`[id="${c}"]`);A&&this.removeStreamChildElement(A)})}),e&&h.all(this.container,`[${f}=${nt}]`,P=>{this.liveSocket.owner(P,V=>{V===this.view&&Array.from(P.children).forEach(F=>{this.removeStreamChildElement(F)})})}),Z.call(this,o,r)}),i.isDebugEnabled()&&(si(),ri(this.streamInserts),Array.from(document.querySelectorAll("input[name=id]")).forEach(P=>{P.form&&console.error(`Detected an input with name="id" inside a form! This will cause problems when patching the DOM.
|
|
9
|
-
`,P)})),b.length>0&&i.time("post-morph append/prepend restoration",()=>{b.forEach(P=>P.perform())}),i.silenceEvents(()=>h.restoreFocus(l,a,d)),h.dispatchEvent(document,"phx:update"),u.forEach(P=>this.trackAfter("added",P)),v.forEach(P=>this.trackAfter("updated",P)),this.transitionPendingRemoves(),T&&(i.unload(),Object.getPrototypeOf(T).submit.call(T)),!0}onNodeDiscarded(e){(h.isPhxChild(e)||h.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfter("discarded",e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}removeStreamChildElement(e){this.streamInserts[e.id]?(this.streamComponentRestore[e.id]=e,e.remove()):this.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}setStreamRef(e,t){h.putSticky(e,xe,i=>i.setAttribute(xe,t))}maybeReOrderStream(e,t){let{ref:i,streamAt:r,reset:n}=this.getStreamInsert(e);if(r!==void 0&&(this.setStreamRef(e,i),!(!n&&!t)&&e.parentElement)){if(r===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(r>0){let o=Array.from(e.parentElement.children),l=o.indexOf(e);if(r>=o.length-1)e.parentElement.appendChild(e);else{let a=o[r];l>r?e.parentElement.insertBefore(e,a):e.parentElement.insertBefore(e,a.nextElementSibling)}}this.maybeLimitStream(e)}}maybeLimitStream(e){let{limit:t}=this.getStreamInsert(e),i=t!==null&&Array.from(e.parentElement.children);t&&t<0&&i.length>t*-1?i.slice(0,i.length+t).forEach(r=>this.removeStreamChildElement(r)):t&&t>=0&&i.length>t&&i.slice(t).forEach(r=>this.removeStreamChildElement(r))}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:t}=this;e.length>0&&t.transitionRemoves(e,!1,()=>{e.forEach(i=>{let r=h.firstPhxChild(i);r&&t.destroyViewByEl(r),i.remove()}),this.trackAfter("transitionsDiscarded",e)})}isChangedSelect(e,t){return!(e instanceof HTMLSelectElement)||e.multiple?!1:e.options.length!==t.options.length?!0:(t.value=e.value,!e.isEqualNode(t))}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(it)}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=h.findComponentNodeList(this.container,this.targetCID);return i.length===0&&h.childNodeLength(e)===1?t:t&&t.parentNode}indexOf(e,t){return Array.from(e.children).indexOf(t)}};var Gi=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),zi=new Set(["'",'"']),Ai=(s,e,t)=>{let i=0,r=!1,n,o,l,a,d,f,p=s.match(/^(\s*(?:<!--.*?-->\s*)*)<([^\s\/>]+)/);if(p===null)throw new Error(`malformed html ${s}`);for(i=p[0].length,n=p[1],l=p[2],a=i,i;i<s.length&&s.charAt(i)!==">";i++)if(s.charAt(i)==="="){let u=s.slice(i-3,i)===" id";i++;let v=s.charAt(i);if(zi.has(v)){let b=i;for(i++,i;i<s.length&&s.charAt(i)!==v;i++);if(u){d=s.slice(b+1,i);break}}}let m=s.length-1;for(r=!1;m>=n.length+l.length;){let u=s.charAt(m);if(r)u==="-"&&s.slice(m-3,m)==="<!-"?(r=!1,m-=4):m-=1;else if(u===">"&&s.slice(m-2,m)==="--")r=!0,m-=3;else{if(u===">")break;m-=1}}o=s.slice(m+1,s.length);let g=Object.keys(e).map(u=>e[u]===!0?u:`${u}="${e[u]}"`).join(" ");if(t){let u=d?` id="${d}"`:"";Gi.has(l)?f=`<${l}${u}${g===""?"":" "}${g}/>`:f=`<${l}${u}${g===""?"":" "}${g}></${l}>`}else{let u=s.slice(a,m+1);f=`<${l}${g===""?"":" "}${g}${u}`}return[f,n,o]},He=class{static extract(e){let{[xt]:t,[Rt]:i,[Tt]:r}=e;return delete e[xt],delete e[Rt],delete e[Tt],{diff:e,title:r,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.magicId=0,this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){let[t,i]=this.recursiveToString(this.rendered,this.rendered[D],e,!0,{});return[t,i]}recursiveToString(e,t=e[D],i,r,n){i=i?new Set(i):null;let o={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,o,r,n),[o.buffer,o.streams]}componentCIDs(e){return Object.keys(e[D]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[D]?Object.keys(e).length===1:!1}getComponent(e,t){return e[D][t]}resetRender(e){this.rendered[D][e]&&(this.rendered[D][e].reset=!0)}mergeDiff(e){let t=e[D],i={};if(delete e[D],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[D]=this.rendered[D]||{},t){let r=this.rendered[D];for(let n in t)t[n]=this.cachedFindComponent(n,t[n],r,t,i);for(let n in t)r[n]=t[n];e[D]=t}}cachedFindComponent(e,t,i,r,n){if(n[e])return n[e];{let o,l,a=t[z];if(W(a)){let d;a>0?d=this.cachedFindComponent(a,r[a],i,r,n):d=i[-a],l=d[z],o=this.cloneMerge(d,t,!0),o[z]=l}else o=t[z]!==void 0||i[e]===void 0?t:this.cloneMerge(i[e],t,!1);return n[e]=o,o}}mutableMerge(e,t){return t[z]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let r=t[i],n=e[i];ve(r)&&r[z]===void 0&&ve(n)?this.doMutableMerge(n,r):e[i]=r}e[at]&&(e.newRender=!0)}cloneMerge(e,t,i){let r=L(L({},e),t);for(let n in r){let o=t[n],l=e[n];ve(o)&&o[z]===void 0&&ve(l)?r[n]=this.cloneMerge(l,o,i):o===void 0&&ve(l)&&(r[n]=this.cloneMerge(l,{},i))}return i?(delete r.magicId,delete r.newRender):e[at]&&(r.newRender=!0),r}componentToString(e){let[t,i]=this.recursiveCIDToString(this.rendered[D],e,null),[r,n,o]=Ai(t,{});return[r,i]}pruneCIDs(e){e.forEach(t=>delete this.rendered[D][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[z]}templateStatic(e,t){return typeof e=="number"?t[e]:e}nextMagicID(){return this.magicId++,`m${this.magicId}-${this.parentViewId()}`}toOutputBuffer(e,t,i,r,n={}){if(e[Ve])return this.comprehensionToBuffer(e,t,i);let{[z]:o}=e;o=this.templateStatic(o,t);let l=e[at],a=i.buffer;l&&(i.buffer=""),r&&l&&!e.magicId&&(e.newRender=!0,e.magicId=this.nextMagicID()),i.buffer+=o[0];for(let d=1;d<o.length;d++)this.dynamicToBuffer(e[d-1],t,i,r),i.buffer+=o[d];if(l){let d=!1,f;r||e.magicId?(d=r&&!e.newRender,f=L({[st]:e.magicId},n)):f=n,d&&(f[it]=!0);let[p,m,g]=Ai(i.buffer,f,d);e.newRender=!1,i.buffer=a+m+p+g}}comprehensionToBuffer(e,t,i){let{[Ve]:r,[z]:n,[It]:o}=e,[l,a,d,f]=o||[null,{},[],null];n=this.templateStatic(n,t);let p=t||e[ii];for(let m=0;m<r.length;m++){let g=r[m];i.buffer+=n[0];for(let u=1;u<n.length;u++)this.dynamicToBuffer(g[u-1],p,i,!1),i.buffer+=n[u]}o!==void 0&&(e[Ve].length>0||d.length>0||f)&&(delete e[It],e[Ve]=[],i.streams.add(o))}dynamicToBuffer(e,t,i,r){if(typeof e=="number"){let[n,o]=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=n,i.streams=new Set([...i.streams,...o])}else ve(e)?this.toOutputBuffer(e,t,i,r,{}):i.buffer+=e}recursiveCIDToString(e,t,i){let r=e[t]||I(`no component for CID ${t}`,e),n={[$]:t},o=i&&!i.has(t);r.newRender=!o,r.magicId=`c${t}-${this.parentViewId()}`;let l=!r.reset,[a,d]=this.recursiveToString(r,e,i,l,n);return delete r.reset,[a,d]}};var Si=[],_i=200,Yi={exec(s,e,t,i,r,n){let[o,l]=n||[null,{callback:n&&n.callback}];(t.charAt(0)==="["?JSON.parse(t):[[o,l]]).forEach(([d,f])=>{d===o&&(f=L(L({},l),f),f.callback=f.callback||l.callback),this.filterToEls(i.liveSocket,r,f).forEach(p=>{this[`exec_${d}`](s,e,t,i,r,p,f)})})},isVisible(s){return!!(s.offsetWidth||s.offsetHeight||s.getClientRects().length>0)},isInViewport(s){let e=s.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight,i=window.innerWidth||document.documentElement.clientWidth;return e.right>0&&e.bottom>0&&e.left<i&&e.top<t},exec_exec(s,e,t,i,r,n,{attr:o,to:l}){(l?h.all(document,l):[r]).forEach(d=>{let f=d.getAttribute(o);if(!f)throw new Error(`expected ${o} to contain JS command on "${l}"`);i.liveSocket.execJS(d,f,e)})},exec_dispatch(s,e,t,i,r,n,{event:o,detail:l,bubbles:a}){l=l||{},l.dispatcher=r,h.dispatchEvent(n,o,{detail:l,bubbles:a})},exec_push(s,e,t,i,r,n,o){let{event:l,data:a,target:d,page_loading:f,loading:p,value:m,dispatcher:g,callback:u}=o,v={loading:p,value:m,target:d,page_loading:!!f},b=e==="change"&&g?g:r,T=d||b.getAttribute(i.binding("target"))||b,Z=(P,V)=>{if(P.isConnected())if(e==="change"){let{newCid:F,_target:N}=o;N=N||(h.isFormInput(r)?r.name:void 0),N&&(v._target=N),P.pushInput(r,V,F,l||t,v,u)}else if(e==="submit"){let{submitter:F}=o;P.submitForm(r,V,l||t,F,v,u)}else P.pushEvent(e,r,V,l||t,a,v,u)};o.targetView&&o.targetCtx?Z(o.targetView,o.targetCtx):i.withinTargets(T,Z)},exec_navigate(s,e,t,i,r,n,{href:o,replace:l}){i.liveSocket.historyRedirect(s,o,l?"replace":"push",null,r)},exec_patch(s,e,t,i,r,n,{href:o,replace:l}){i.liveSocket.pushHistoryPatch(s,o,l?"replace":"push",r)},exec_focus(s,e,t,i,r,n){window.requestAnimationFrame(()=>q.attemptFocus(n))},exec_focus_first(s,e,t,i,r,n){window.requestAnimationFrame(()=>q.focusFirstInteractive(n)||q.focusFirst(n))},exec_push_focus(s,e,t,i,r,n){window.requestAnimationFrame(()=>Si.push(n||r))},exec_pop_focus(s,e,t,i,r,n){window.requestAnimationFrame(()=>{let o=Si.pop();o&&o.focus()})},exec_add_class(s,e,t,i,r,n,{names:o,transition:l,time:a,blocking:d}){this.addOrRemoveClasses(n,o,[],l,a,i,d)},exec_remove_class(s,e,t,i,r,n,{names:o,transition:l,time:a,blocking:d}){this.addOrRemoveClasses(n,[],o,l,a,i,d)},exec_toggle_class(s,e,t,i,r,n,{names:o,transition:l,time:a,blocking:d}){this.toggleClasses(n,o,l,a,i,d)},exec_toggle_attr(s,e,t,i,r,n,{attr:[o,l,a]}){this.toggleAttr(n,o,l,a)},exec_transition(s,e,t,i,r,n,{time:o,transition:l,blocking:a}){this.addOrRemoveClasses(n,[],[],l,o,i,a)},exec_toggle(s,e,t,i,r,n,{display:o,ins:l,outs:a,time:d,blocking:f}){this.toggle(e,i,n,o,l,a,d,f)},exec_show(s,e,t,i,r,n,{display:o,transition:l,time:a,blocking:d}){this.show(e,i,n,o,l,a,d)},exec_hide(s,e,t,i,r,n,{display:o,transition:l,time:a,blocking:d}){this.hide(e,i,n,o,l,a,d)},exec_set_attr(s,e,t,i,r,n,{attr:[o,l]}){this.setOrRemoveAttrs(n,[[o,l]],[])},exec_remove_attr(s,e,t,i,r,n,{attr:o}){this.setOrRemoveAttrs(n,[],[o])},show(s,e,t,i,r,n,o){this.isVisible(t)||this.toggle(s,e,t,i,r,null,n,o)},hide(s,e,t,i,r,n,o){this.isVisible(t)&&this.toggle(s,e,t,i,null,r,n,o)},toggle(s,e,t,i,r,n,o,l){o=o||_i;let[a,d,f]=r||[[],[],[]],[p,m,g]=n||[[],[],[]];if(a.length>0||p.length>0)if(this.isVisible(t)){let u=()=>{this.addOrRemoveClasses(t,m,a.concat(d).concat(f)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,p,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,g,m))})},v=()=>{this.addOrRemoveClasses(t,[],p.concat(g)),h.putSticky(t,"toggle",b=>b.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))};t.dispatchEvent(new Event("phx:hide-start")),l===!1?(u(),setTimeout(v,o)):e.transition(o,u,v)}else{if(s==="remove")return;let u=()=>{this.addOrRemoveClasses(t,d,p.concat(m).concat(g));let b=i||this.defaultDisplay(t);h.putSticky(t,"toggle",T=>T.style.display=b),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,f,d))})},v=()=>{this.addOrRemoveClasses(t,[],a.concat(f)),t.dispatchEvent(new Event("phx:show-end"))};t.dispatchEvent(new Event("phx:show-start")),l===!1?(u(),setTimeout(v,o)):e.transition(o,u,v)}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),h.putSticky(t,"toggle",u=>u.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start"));let u=i||this.defaultDisplay(t);h.putSticky(t,"toggle",v=>v.style.display=u),t.dispatchEvent(new Event("phx:show-end"))})},toggleClasses(s,e,t,i,r,n){window.requestAnimationFrame(()=>{let[o,l]=h.getSticky(s,"classes",[[],[]]),a=e.filter(f=>o.indexOf(f)<0&&!s.classList.contains(f)),d=e.filter(f=>l.indexOf(f)<0&&s.classList.contains(f));this.addOrRemoveClasses(s,a,d,t,i,r,n)})},toggleAttr(s,e,t,i){s.hasAttribute(e)?i!==void 0?s.getAttribute(e)===t?this.setOrRemoveAttrs(s,[[e,i]],[]):this.setOrRemoveAttrs(s,[[e,t]],[]):this.setOrRemoveAttrs(s,[],[e]):this.setOrRemoveAttrs(s,[[e,t]],[])},addOrRemoveClasses(s,e,t,i,r,n,o){r=r||_i;let[l,a,d]=i||[[],[],[]];if(l.length>0){let f=()=>{this.addOrRemoveClasses(s,a,[].concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(s,l,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(s,d,a))})},p=()=>this.addOrRemoveClasses(s,e.concat(d),t.concat(l).concat(a));o===!1?(f(),setTimeout(p,r)):n.transition(r,f,p);return}window.requestAnimationFrame(()=>{let[f,p]=h.getSticky(s,"classes",[[],[]]),m=e.filter(b=>f.indexOf(b)<0&&!s.classList.contains(b)),g=t.filter(b=>p.indexOf(b)<0&&s.classList.contains(b)),u=f.filter(b=>t.indexOf(b)<0).concat(m),v=p.filter(b=>e.indexOf(b)<0).concat(g);h.putSticky(s,"classes",b=>(b.classList.remove(...v),b.classList.add(...u),[u,v]))})},setOrRemoveAttrs(s,e,t){let[i,r]=h.getSticky(s,"attrs",[[],[]]),n=e.map(([a,d])=>a).concat(t),o=i.filter(([a,d])=>!n.includes(a)).concat(e),l=r.filter(a=>!n.includes(a)).concat(t);h.putSticky(s,"attrs",a=>(l.forEach(d=>a.removeAttribute(d)),o.forEach(([d,f])=>a.setAttribute(d,f)),[o,l]))},hasAllClasses(s,e){return e.every(t=>s.classList.contains(t))},isToggledOut(s,e){return!this.isVisible(s)||this.hasAllClasses(s,e)},filterToEls(s,e,{to:t}){let i=()=>{if(typeof t=="string")return document.querySelectorAll(t);if(t.closest){let r=e.closest(t.closest);return r?[r]:[]}else if(t.inner)return e.querySelectorAll(t.inner)};return t?s.jsQuerySelectorAll(e,t,i):[e]},defaultDisplay(s){return{tr:"table-row",td:"table-cell"}[s.tagName.toLowerCase()]||"block"},transitionClasses(s){if(!s)return null;let[e,t,i]=Array.isArray(s)?s:[s.split(" "),[],[]];return e=Array.isArray(e)?e:e.split(" "),t=Array.isArray(t)?t:t.split(" "),i=Array.isArray(i)?i:i.split(" "),[e,t,i]}},y=Yi;var Nt="hookId",Qi=1,Q=class{static makeID(){return Qi++}static elementID(e){return h.private(e,Nt)}constructor(e,t,i){this.el=t,this.__attachView(e),this.__callbacks=i,this.__listeners=new Set,this.__isDisconnected=!1,h.putPrivate(this.el,Nt,this.constructor.makeID());for(let r in this.__callbacks)this[r]=this.__callbacks[r]}__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=null)}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed(),h.deletePrivate(this.el,Nt)}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}js(){let e=this;return{exec(t){e.__view().liveSocket.execJS(e.el,t,"hook")},show(t,i={}){let r=e.__view().liveSocket.owner(t);y.show("hook",r,t,i.display,i.transition,i.time,i.blocking)},hide(t,i={}){let r=e.__view().liveSocket.owner(t);y.hide("hook",r,t,null,i.transition,i.time,i.blocking)},toggle(t,i={}){let r=e.__view().liveSocket.owner(t);i.in=y.transitionClasses(i.in),i.out=y.transitionClasses(i.out),y.toggle("hook",r,t,i.display,i.in,i.out,i.time,i.blocking)},addClass(t,i,r={}){i=Array.isArray(i)?i:i.split(" ");let n=e.__view().liveSocket.owner(t);y.addOrRemoveClasses(t,i,[],r.transition,r.time,n,r.blocking)},removeClass(t,i,r={}){r.transition=y.transitionClasses(r.transition),i=Array.isArray(i)?i:i.split(" ");let n=e.__view().liveSocket.owner(t);y.addOrRemoveClasses(t,[],i,r.transition,r.time,n,r.blocking)},toggleClass(t,i,r={}){r.transition=y.transitionClasses(r.transition),i=Array.isArray(i)?i:i.split(" ");let n=e.__view().liveSocket.owner(t);y.toggleClasses(t,i,r.transition,r.time,n,r.blocking)},transition(t,i,r={}){let n=e.__view().liveSocket.owner(t);y.addOrRemoveClasses(t,[],[],y.transitionClasses(i),r.time,n,r.blocking)},setAttribute(t,i,r){y.setOrRemoveAttrs(t,[[i,r]],[])},removeAttribute(t,i){y.setOrRemoveAttrs(t,[],[i])},toggleAttribute(t,i,r,n){y.toggleAttr(t,i,r,n)}}}pushEvent(e,t={},i){return i===void 0?new Promise((r,n)=>{try{this.__view().pushHookEvent(this.el,null,e,t,(l,a)=>r(l))===!1&&n(new Error("unable to push hook event. LiveView not connected"))}catch(o){n(o)}}):this.__view().pushHookEvent(this.el,null,e,t,i)}pushEventTo(e,t,i={},r){return r===void 0?new Promise((n,o)=>{try{this.__view().withinTargets(e,(l,a)=>{l.pushHookEvent(this.el,a,t,i,(f,p)=>n(f))===!1&&o(new Error("unable to push hook event. LiveView not connected"))})}catch(l){o(l)}}):this.__view().withinTargets(e,(n,o)=>n.pushHookEvent(this.el,o,t,i,r))}handleEvent(e,t){let i=(r,n)=>n?e:t(r.detail);return window.addEventListener(`phx:${e}`,i),this.__listeners.add(i),i}removeHandleEvent(e){let t=e(null,!0);window.removeEventListener(`phx:${t}`,e),this.__listeners.delete(e)}upload(e,t){return this.__view().dispatchUploads(null,e,t)}uploadTo(e,t,i){return this.__view().withinTargets(e,(r,n)=>{r.dispatchUploads(n,t,i)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var Zi=(s,e)=>{let t=s.endsWith("[]"),i=t?s.slice(0,-2):s;return i=i.replace(/([^\[\]]+)(\]?$)/,`${e}$1$2`),t&&(i+="[]"),i},ut=(s,e,t=[])=>{let f=e,{submitter:i}=f,r=$t(f,["submitter"]),n;if(i&&i.name){let p=document.createElement("input");p.type="hidden";let m=i.getAttribute("form");m&&p.setAttribute("form",m),p.name=i.name,p.value=i.value,i.parentElement.insertBefore(p,i),n=p}let o=new FormData(s),l=[];o.forEach((p,m,g)=>{p instanceof File&&l.push(m)}),l.forEach(p=>o.delete(p));let a=new URLSearchParams,d=Array.from(s.elements);for(let[p,m]of o.entries())if(t.length===0||t.indexOf(p)>=0){let g=d.filter(b=>b.name===p),u=!g.some(b=>h.private(b,pe)||h.private(b,me)),v=g.every(b=>b.type==="hidden");u&&!(i&&i.name==p)&&!v&&a.append(Zi(p,"_unused_"),""),a.append(p,m)}i&&n&&i.parentElement.removeChild(n);for(let p in r)a.append(p,r[p]);return a.toString()},Ae=class s{static closestView(e){let t=e.closest(K);return t?h.private(t,"view"):null}constructor(e,t,i,r,n){this.isDead=!1,this.liveSocket=t,this.flash=r,this.parent=i,this.root=i?i.root:this,this.el=e,h.putPrivate(this.el,"view",this),this.id=this.el.id,this.ref=0,this.lastAckRef=null,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],this.pendingForms=new Set,this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinAttempts=0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(o){o&&o()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.formsForRecovery={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{let o=this.href&&this.expandURL(this.href);return{redirect:this.redirect?o:void 0,url:this.redirect?void 0:o||void 0,params:this.connectParams(n),session:this.getSession(),static:this.getStatic(),flash:this.flash}})}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(Pe)}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding(Bt)}]`).map(r=>r.src||r.href).filter(r=>typeof r=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._mount_attempts=this.joinAttempts,t._live_referer=e,this.joinAttempts++,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(M)}getStatic(){let e=this.el.getAttribute(te);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyed=!0,delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);let t=()=>{e();for(let i in this.viewHooks)this.destroyHook(this.viewHooks[i])};h.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",t).receive("error",t).receive("timeout",t)}setContainerClasses(...e){this.el.classList.remove(bt,he,fe,At,ye),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let t in this.viewHooks)this.viewHooks[t].__disconnected();this.setContainerClasses(he)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(bt),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,t){this.liveSocket.log(this,e,t)}transition(e,t,i=function(){}){this.liveSocket.transition(e,t,i)}withinTargets(e,t,i=document,r){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,n=>t(n,e));if(W(e))h.findComponentNodeList(r||this.el,e).length===0?I(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let n=Array.from(i.querySelectorAll(e));n.length===0&&I(`nothing found matching the phx-target selector "${e}"`),n.forEach(o=>this.liveSocket.owner(o,l=>t(l,o)))}}applyDiff(e,t,i){this.log(e,()=>["",Oe(t)]);let{diff:r,reply:n,events:o,title:l}=He.extract(t);i({diff:r,reply:n,events:o}),(typeof l=="string"||e=="mount")&&window.requestAnimationFrame(()=>h.putTitle(l))}onJoin(e){let{rendered:t,container:i,liveview_version:r}=e;if(i){let[n,o]=i;this.el=h.replaceRootContainer(this.el,n,o)}this.childJoins=0,this.joinPending=!0,this.flash=null,this.root===this&&(this.formsForRecovery=this.getFormsForRecovery()),this.isMain()&&window.history.state===null&&H.pushState("replace",{type:"patch",id:this.id,position:this.liveSocket.currentHistoryPosition}),r!==this.liveSocket.version()&&console.error(`LiveView asset version mismatch. JavaScript version ${this.liveSocket.version()} vs. server ${r}. To avoid issues, please ensure that your assets use the same version as the server.`),H.dropLocal(this.liveSocket.localStorage,window.location.pathname,Qe),this.applyDiff("mount",t,({diff:n,events:o})=>{this.rendered=new He(this.id,n);let[l,a]=this.renderContainer(null,"join");this.dropPendingRefs(),this.joinCount++,this.joinAttempts=0,this.maybeRecoverForms(l,()=>{this.onJoinComplete(e,l,a,o)})})}dropPendingRefs(){h.all(document,`[${O}="${this.refSrc()}"]`,e=>{e.removeAttribute(ae),e.removeAttribute(O),e.removeAttribute(x)})}onJoinComplete({live_patch:e},t,i,r){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i,r);h.findPhxChildrenInFragment(t,this.id).filter(o=>{let l=o.id&&this.el.querySelector(`[id="${o.id}"]`),a=l&&l.getAttribute(te);return a&&o.setAttribute(te,a),l&&l.setAttribute(J,this.root.id),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,r)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i,r)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,r)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(J,this.root.id)}execNewMounted(e=this.el){let t=this.binding(Me),i=this.binding(Ue);h.all(e,`[${t}], [${i}]`,r=>{this.ownsElement(r)&&(h.maintainPrivateHooks(r,r,t,i),this.maybeAddNewHook(r))}),h.all(e,`[${this.binding(Ce)}], [data-phx-${Ce}]`,r=>{this.ownsElement(r)&&this.maybeAddNewHook(r)}),h.all(e,`[${this.binding(Et)}]`,r=>{this.ownsElement(r)&&this.maybeMounted(r)})}applyJoinPatch(e,t,i,r){this.attachTrueDocEl();let n=new ce(this,this.el,this.id,t,i,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(r),this.applyPendingUpdates(),e){let{kind:o,to:l}=e;this.liveSocket.historyPatch(l,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),r=i&&h.isIgnored(e,this.binding(Re));if(i&&!e.isEqualNode(t)&&!(r&&oi(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(Et)),i=t&&h.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),h.putPrivate(e,"mounted",!0))}maybeAddNewHook(e){let t=this.addHook(e);t&&t.__mounted()}performPatch(e,t,i=!1){let r=[],n=!1,o=new Set;return this.liveSocket.triggerDOM("onPatchStart",[e.targetContainer]),e.after("added",l=>{this.liveSocket.triggerDOM("onNodeAdded",[l]);let a=this.binding(Me),d=this.binding(Ue);h.maintainPrivateHooks(l,l,a,d),this.maybeAddNewHook(l),l.getAttribute&&this.maybeMounted(l)}),e.after("phxChildAdded",l=>{h.isPhxSticky(l)?this.liveSocket.joinRootViews():n=!0}),e.before("updated",(l,a)=>{this.triggerBeforeUpdateHook(l,a)&&o.add(l.id)}),e.after("updated",l=>{o.has(l.id)&&this.getHook(l).__updated()}),e.after("discarded",l=>{l.nodeType===Node.ELEMENT_NODE&&r.push(l)}),e.after("transitionsDiscarded",l=>this.afterElementsRemoved(l,t)),e.perform(i),this.afterElementsRemoved(r,t),this.liveSocket.triggerDOM("onPatchEnd",[e.targetContainer]),n}afterElementsRemoved(e,t){let i=[];e.forEach(r=>{let n=h.all(r,`[${$}]`),o=h.all(r,`[${this.binding(Ce)}], [data-phx-hook]`);n.concat(r).forEach(l=>{let a=this.componentID(l);W(a)&&i.indexOf(a)===-1&&i.push(a)}),o.concat(r).forEach(l=>{let a=this.getHook(l);a&&this.destroyHook(a)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){h.findPhxChildren(this.el,this.id).forEach(e=>this.joinChild(e))}maybeRecoverForms(e,t){let i=this.binding("change"),r=this.root.formsForRecovery,n=document.createElement("template");n.innerHTML=e;let o=n.content.firstElementChild;o.id=this.id,o.setAttribute(J,this.root.id),o.setAttribute(M,this.getSession()),o.setAttribute(te,this.getStatic()),o.setAttribute(ee,this.parent?this.parent.id:null);let l=h.all(n.content,"form").filter(a=>a.id&&r[a.id]).filter(a=>!this.pendingForms.has(a.id)).filter(a=>r[a.id].getAttribute(i)===a.getAttribute(i)).map(a=>[r[a.id],a]);if(l.length===0)return t();l.forEach(([a,d],f)=>{this.pendingForms.add(d.id),this.pushFormRecovery(a,d,n.content.firstElementChild,()=>{this.pendingForms.delete(d.id),f===l.length-1&&t()})})}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){var t;return e.id===this.id?this:(t=this.children[e.getAttribute(ee)])==null?void 0:t[e.id]}destroyDescendent(e){for(let t in this.root.children)for(let i in this.root.children[t])if(i===e)return this.root.children[t][i].destroy()}joinChild(e){if(!this.getChildById(e.id)){let i=new s(e,this.liveSocket,this);return this.root.children[this.id][i.id]=i,i.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(e){this.childJoins--,this.childJoins===0&&(this.parent?this.parent.ackJoin(this):this.onAllChildJoinsComplete())}onAllChildJoinsComplete(){this.pendingForms.clear(),this.formsForRecovery={},this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,t])=>{e.isDestroyed()||t()}),this.pendingJoinOps=[]})}update(e,t){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:t});this.rendered.mergeDiff(e);let i=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{h.findExistingParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(i=!0)})}):Lt(e)||this.liveSocket.time("full patch complete",()=>{let[r,n]=this.renderContainer(e,"update"),o=new ce(this,this.el,this.id,r,n,null);i=this.performPatch(o,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,r=e?this.rendered.componentCIDs(e):null,[n,o]=this.rendered.toString(r);return[`<${i}>${n}</${i}>`,o]})}componentPatch(e,t){if(Lt(e))return!1;let[i,r]=this.rendered.componentToString(t),n=new ce(this,this.el,this.id,i,r,t);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[Q.elementID(e)]}addHook(e){let t=Q.elementID(e);if(!(e.getAttribute&&!this.ownsElement(e)))if(t&&!this.viewHooks[t]){let i=h.getCustomElHook(e)||I(`no hook found for custom element: ${e.id}`);return this.viewHooks[t]=i,i.__attachView(this),i}else{if(t||!e.getAttribute)return;{let i=e.getAttribute(`data-phx-${Ce}`)||e.getAttribute(this.binding(Ce)),r=this.liveSocket.getHookCallbacks(i);if(r){e.id||I(`no DOM ID for hook "${i}". Hooks require a unique ID on each element.`,e);let n=new Q(this,e,r);return this.viewHooks[Q.elementID(n.el)]=n,n}else i!==null&&I(`unknown hook found for "${i}"`,e)}}}destroyHook(e){let t=Q.elementID(e.el);e.__destroyed(),e.__cleanup__(),delete this.viewHooks[t]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates())}eachChild(e){let t=this.root.children[this.id]||{};for(let i in t)e(this.getChildById(i))}onChannel(e,t){this.liveSocket.onChannel(this.channel,e,i=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>t(i)]):this.liveSocket.requestDOMUpdate(()=>t(i))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:t,events:i})=>this.update(t,i))})}),this.onChannel("redirect",({to:e,flash:t})=>this.onRedirect({to:e,flash:t})),this.onChannel("live_patch",e=>this.onLivePatch(e)),this.onChannel("live_redirect",e=>this.onLiveRedirect(e)),this.channel.onError(e=>this.onError(e)),this.channel.onClose(e=>this.onClose(e))}destroyAllChildren(){this.eachChild(e=>e.destroy())}onLiveRedirect(e){let{to:t,kind:i,flash:r}=e,n=this.expandURL(t),o=new CustomEvent("phx:server-navigate",{detail:{to:t,kind:i,flash:r}});this.liveSocket.historyRedirect(o,n,i,r)}onLivePatch(e){let{to:t,kind:i}=e;this.href=this.expandURL(t),this.liveSocket.historyPatch(t,i)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:t,reloadToken:i}){this.liveSocket.redirect(e,t,i)}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=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.wrapPush(()=>this.channel.join(),{ok:t=>this.liveSocket.requestDOMUpdate(()=>this.onJoin(t)),error:t=>this.onJoinError(t),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.root.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.root.href});return}if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);if(this.log("error",()=>["unable to join",e]),this.isMain())this.displayError([he,fe,ye]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this);else{this.joinAttempts>=Pt&&(this.root.displayError([he,fe,ye]),this.log("error",()=>[`giving up trying to mount after ${Pt} tries`,e]),this.destroy());let t=h.byId(this.el.id);t?(h.mergeAttrs(t,this.el),this.displayError([he,fe,ye]),this.el=t):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),document.activeElement&&document.activeElement.blur(),this.liveSocket.isUnloaded()&&this.showLoader(Qt)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([he,fe,ye]):this.displayError([he,fe,At]))}displayError(e){this.isMain()&&h.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(...e),this.execAll(this.binding("disconnected"))}wrapPush(e,t){let i=this.liveSocket.getLatencySim(),r=i?n=>setTimeout(()=>!this.isDestroyed()&&n(),i):n=>!this.isDestroyed()&&n();r(()=>{e().receive("ok",n=>r(()=>t.ok&&t.ok(n))).receive("error",n=>r(()=>t.error&&t.error(n))).receive("timeout",()=>r(()=>t.timeout&&t.timeout()))})}pushWithReply(e,t,i){if(!this.isConnected())return Promise.reject({error:"noconnection"});let[r,[n],o]=e?e():[null,[],{}],l=this.joinCount,a=function(){};return o.page_loading&&(a=this.liveSocket.withPageLoading({kind:"element",target:n})),typeof i.cid!="number"&&delete i.cid,new Promise((d,f)=>{this.wrapPush(()=>this.channel.push(t,i,ei),{ok:p=>{r!==null&&(this.lastAckRef=r);let m=g=>{p.redirect&&this.onRedirect(p.redirect),p.live_patch&&this.onLivePatch(p.live_patch),p.live_redirect&&this.onLiveRedirect(p.live_redirect),a(),d({resp:p,reply:g})};p.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",p.diff,({diff:g,reply:u,events:v})=>{r!==null&&this.undoRefs(r,i.event),this.update(g,v),m(u)})}):(r!==null&&this.undoRefs(r,i.event),m(null))},error:p=>f({error:p}),timeout:()=>{f({timeout:!0}),this.joinCount===l&&this.liveSocket.reloadWithJitter(this,()=>{this.log("timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}})})}undoRefs(e,t,i){if(!this.isConnected())return;let r=`[${O}="${this.refSrc()}"]`;i?(i=new Set(i),h.all(document,r,n=>{i&&!i.has(n)||(h.all(n,r,o=>this.undoElRef(o,e,t)),this.undoElRef(n,e,t))})):h.all(document,r,n=>this.undoElRef(n,e,t))}undoElRef(e,t,i){new De(e).maybeUndo(t,i,n=>{let o=new ce(this,e,this.id,n,[],null,{undoRef:t}),l=this.performPatch(o,!0);h.all(e,`[${O}="${this.refSrc()}"]`,a=>this.undoElRef(a,t,i)),l&&this.joinNewChildren()})}refSrc(){return this.el.id}putRef(e,t,i,r={}){let n=this.ref++,o=this.binding(_t);if(r.loading){let l=h.all(document,r.loading).map(a=>({el:a,lock:!0,loading:!0}));e=e.concat(l)}for(let{el:l,lock:a,loading:d}of e){if(!a&&!d)throw new Error("putRef requires lock or loading");if(l.setAttribute(O,this.refSrc()),d&&l.setAttribute(ae,n),a&&l.setAttribute(x,n),!d||r.submitter&&!(l===r.submitter||l===r.form))continue;let f=new Promise(u=>{l.addEventListener(`phx:undo-lock:${n}`,()=>u(g),{once:!0})}),p=new Promise(u=>{l.addEventListener(`phx:undo-loading:${n}`,()=>u(g),{once:!0})});l.classList.add(`phx-${i}-loading`);let m=l.getAttribute(o);m!==null&&(l.getAttribute(ke)||l.setAttribute(ke,l.innerText),m!==""&&(l.innerText=m),l.setAttribute(de,l.getAttribute(de)||l.disabled),l.setAttribute("disabled",""));let g={event:t,eventType:i,ref:n,isLoading:d,isLocked:a,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(n,t,u)},lockComplete:f,loadingComplete:p,lock:u=>new Promise(v=>{if(this.isAcked(n))return v(g);u.setAttribute(x,n),u.setAttribute(O,this.refSrc()),u.addEventListener(`phx:lock-stop:${n}`,()=>v(g),{once:!0})})};l.dispatchEvent(new CustomEvent("phx:push",{detail:g,bubbles:!0,cancelable:!1})),t&&l.dispatchEvent(new CustomEvent(`phx:push:${t}`,{detail:g,bubbles:!0,cancelable:!1}))}return[n,e.map(({el:l})=>l),r]}isAcked(e){return this.lastAckRef!==null&&this.lastAckRef>=e}componentID(e){let t=e.getAttribute&&e.getAttribute($);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(W(t))return t;let r=i.target||e.getAttribute(this.binding("target"));return W(r)?parseInt(r):t&&(r!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return W(e)?e:e?Y(e.closest(`[${$}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,r,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",i,r]),!1;let[o,l,a]=this.putRef([{el:e,loading:!0,lock:!0}],i,"hook");return this.pushWithReply(()=>[o,l,a],"event",{type:"hook",event:i,value:r,cid:this.closestComponentID(t)}).then(({resp:d,reply:f})=>n(f,o)),o}extractMeta(e,t,i){let r=this.binding("value-");for(let n=0;n<e.attributes.length;n++){t||(t={});let o=e.attributes[n].name;o.startsWith(r)&&(t[o.replace(r,"")]=e.getAttribute(o))}if(e.value!==void 0&&!(e instanceof HTMLFormElement)&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&rt.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let n in i)t[n]=i[n]}return t}pushEvent(e,t,i,r,n,o={},l){this.pushWithReply(()=>this.putRef([{el:t,loading:!0,lock:!0}],r,e,o),"event",{type:e,event:r,value:this.extractMeta(t,n,o.value),cid:this.targetComponentID(t,i,o)}).then(({reply:a})=>l&&l(a))}pushFileProgress(e,t,i,r=function(){}){this.liveSocket.withinOwners(e.form,(n,o)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(zt)),ref:e.getAttribute(B),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,o)}).then(({resp:l})=>r(l))})}pushInput(e,t,i,r,n,o){if(!e.form)throw new Error("form events require the input to be inside a form");let l,a=W(i)?i:this.targetComponentID(e.form,t,n),d=()=>this.putRef([{el:e,loading:!0,lock:!0},{el:e.form,loading:!0,lock:!0}],r,"change",n),f,p=this.extractMeta(e.form);e instanceof HTMLButtonElement&&(p.submitter=e),e.getAttribute(this.binding("change"))?f=ut(e.form,L({_target:n._target},p),[e.name]):f=ut(e.form,L({_target:n._target},p)),h.isUploadInput(e)&&e.files&&e.files.length>0&&C.trackFiles(e,Array.from(e.files)),l=C.serializeUploads(e);let m={type:"form",event:r,value:f,uploads:l,cid:a};this.pushWithReply(d,"event",m).then(({resp:g})=>{h.isUploadInput(e)&&h.isAutoUpload(e)?De.onUnlock(e,()=>{if(C.filesAwaitingPreflight(e).length>0){let[u,v]=d();this.undoRefs(u,r,[e.form]),this.uploadFiles(e.form,r,t,u,a,b=>{o&&o(g),this.triggerAwaitingSubmit(e.form,r),this.undoRefs(u,r)})}}):o&&o(g)})}triggerAwaitingSubmit(e,t){let i=this.getScheduledSubmit(e);if(i){let[r,n,o,l]=i;this.cancelSubmit(e,t),l()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,r,n])=>t.isSameNode(e))}scheduleSubmit(e,t,i,r){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,r])}cancelSubmit(e,t){this.formSubmits=this.formSubmits.filter(([i,r,n,o])=>i.isSameNode(e)?(this.undoRefs(r,t),!1):!0)}disableForm(e,t,i={}){let r=u=>!(ge(u,`${this.binding(Re)}=ignore`,u.form)||ge(u,"data-phx-update=ignore",u.form)),n=u=>u.hasAttribute(this.binding(_t)),o=u=>u.tagName=="BUTTON",l=u=>["INPUT","TEXTAREA","SELECT"].includes(u.tagName),a=Array.from(e.elements),d=a.filter(n),f=a.filter(o).filter(r),p=a.filter(l).filter(r);f.forEach(u=>{u.setAttribute(de,u.disabled),u.disabled=!0}),p.forEach(u=>{u.setAttribute(Xe,u.readOnly),u.readOnly=!0,u.files&&(u.setAttribute(de,u.disabled),u.disabled=!0)});let m=d.concat(f).concat(p).map(u=>({el:u,loading:!0,lock:!0})),g=[{el:e,loading:!0,lock:!1}].concat(m).reverse();return this.putRef(g,t,"submit",i)}pushFormSubmit(e,t,i,r,n,o){let l=()=>this.disableForm(e,i,Ne(L({},n),{form:e,submitter:r})),a=this.targetComponentID(e,t);if(C.hasUploadsInProgress(e)){let[d,f]=l(),p=()=>this.pushFormSubmit(e,t,i,r,n,o);return this.scheduleSubmit(e,d,n,p)}else if(C.inputsAwaitingPreflight(e).length>0){let[d,f]=l(),p=()=>[d,f,n];this.uploadFiles(e,i,t,d,a,m=>{if(C.inputsAwaitingPreflight(e).length>0)return this.undoRefs(d,i);let g=this.extractMeta(e),u=ut(e,L({submitter:r},g));this.pushWithReply(p,"event",{type:"form",event:i,value:u,cid:a}).then(({resp:v})=>o(v))})}else if(!(e.hasAttribute(O)&&e.classList.contains("phx-submit-loading"))){let d=this.extractMeta(e),f=ut(e,L({submitter:r},d));this.pushWithReply(l,"event",{type:"form",event:i,value:f,cid:a}).then(({resp:p})=>o(p))}}uploadFiles(e,t,i,r,n,o){let l=this.joinCount,a=C.activeFileInputs(e),d=a.length;a.forEach(f=>{let p=new C(f,this,()=>{d--,d===0&&o()}),m=p.entries().map(u=>u.toPreflightPayload());if(m.length===0){d--;return}let g={ref:f.getAttribute(B),entries:m,cid:this.targetComponentID(f.form,i)};this.log("upload",()=>["sending preflight request",g]),this.pushWithReply(null,"allow_upload",g).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(r,t),(u.error||[]).map(([b,T])=>{this.handleFailedEntryPreflight(b,T,p)});else{let v=b=>{this.channel.onError(()=>{this.joinCount===l&&b()})};p.initAdapterUpload(u,v,this.liveSocket)}})})}handleFailedEntryPreflight(e,t,i){if(i.isAutoUpload()){let r=i.entries().find(n=>n.ref===e.toString());r&&r.cancel()}else i.entries().map(r=>r.cancel());this.log("upload",()=>[`error for entry ${e}`,t])}dispatchUploads(e,t,i){let r=this.targetCtxElement(e)||this.el,n=h.findUploadInputs(r).filter(o=>o.name===t);n.length===0?I(`no live file inputs found matching the name "${t}"`):n.length>1?I(`duplicate live file inputs found matching the name "${t}"`):h.dispatchEvent(n[0],tt,{detail:{files:i}})}targetCtxElement(e){if(W(e)){let[t]=h.findComponentNodeList(this.el,e);return t}else return e||null}pushFormRecovery(e,t,i,r){let n=this.binding("change"),o=t.getAttribute(this.binding("target"))||t,l=t.getAttribute(this.binding(wt))||t.getAttribute(this.binding("change")),a=Array.from(e.elements).filter(p=>h.isFormInput(p)&&p.name&&!p.hasAttribute(n));if(a.length===0)return;a.forEach(p=>p.hasAttribute(B)&&C.clearFiles(p));let d=a.find(p=>p.type!=="hidden")||a[0],f=0;this.withinTargets(o,(p,m)=>{let g=this.targetComponentID(t,m);f++;let u=new CustomEvent("phx:form-recovery",{detail:{sourceElement:e}});y.exec(u,"change",l,this,d,["push",{_target:d.name,targetView:p,targetCtx:m,newCid:g,callback:()=>{f--,f===0&&r()}}])},i,i)}pushLinkPatch(e,t,i,r){let n=this.liveSocket.setPendingLink(t),o=e.isTrusted&&e.type!=="popstate",l=i?()=>this.putRef([{el:i,loading:o,lock:!0}],null,"click"):null,a=()=>this.liveSocket.redirect(window.location.href),d=t.startsWith("/")?`${location.protocol}//${location.host}${t}`:t;this.pushWithReply(l,"live_patch",{url:d}).then(({resp:f})=>{this.liveSocket.requestDOMUpdate(()=>{f.link_redirect?this.liveSocket.replaceMain(t,null,r,n):(this.liveSocket.commitPendingLink(n)&&(this.href=t),this.applyPendingUpdates(),r&&r(n))})},({error:f,timeout:p})=>a())}getFormsForRecovery(){if(this.joinCount===0)return{};let e=this.binding("change");return h.all(this.el,`form[${e}]`).filter(t=>t.id).filter(t=>t.elements.length>0).filter(t=>t.getAttribute(this.binding(wt))!=="ignore").map(t=>t.cloneNode(!0)).reduce((t,i)=>(t[i.id]=i,t),{})}maybePushComponentsDestroyed(e){let t=e.filter(i=>h.findComponentNodeList(this.el,i).length===0);t.length>0&&(t.forEach(i=>this.rendered.resetRender(i)),this.pushWithReply(null,"cids_will_destroy",{cids:t}).then(()=>{this.liveSocket.requestDOMUpdate(()=>{let i=t.filter(r=>h.findComponentNodeList(this.el,r).length===0);i.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:i}).then(({resp:r})=>{this.rendered.pruneCIDs(r.cids)})})}))}ownsElement(e){let t=e.closest(K);return e.getAttribute(ee)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,r,n={}){h.putPrivate(e,me,!0),Array.from(e.elements).forEach(l=>h.putPrivate(l,me,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,r,n,()=>{this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}};var wi=s=>h.isUsedInput(s),qe=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(`
|
|
8
|
+
`),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(s,e,t){let i=new Set(["id",M,te,Pe,J]);if(s.tagName.toLowerCase()===e.toLowerCase())return Array.from(s.attributes).filter(r=>!i.has(r.name.toLowerCase())).forEach(r=>s.removeAttribute(r.name)),Object.keys(t).filter(r=>!i.has(r.toLowerCase())).forEach(r=>s.setAttribute(r,t[r])),s;{let r=document.createElement(e);return Object.keys(t).forEach(n=>r.setAttribute(n,t[n])),i.forEach(n=>r.setAttribute(n,s.getAttribute(n))),r.innerHTML=s.innerHTML,s.replaceWith(r),r}},getSticky(s,e,t){let i=(be.private(s,"sticky")||[]).find(([r])=>e===r);if(i){let[r,n,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(s,e){this.updatePrivate(s,"sticky",[],t=>t.filter(([i,r])=>i!==e))},putSticky(s,e,t){let i=t(s);this.updatePrivate(s,"sticky",[],r=>{let n=r.findIndex(([o])=>e===o);return n>=0?r[n]=[e,t,i]:r.push([e,t,i]),r})},applyStickyOperations(s){let e=be.private(s,"sticky");e&&e.forEach(([t,i,r])=>this.putSticky(s,t,i))},isLocked(s){return s.hasAttribute&&s.hasAttribute(x)}},h=be;var re=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(Fe).split(",").indexOf(C.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(we).split(",").indexOf(C.genFileRef(t))>=0&&this.isActive(e,t)}static isPreflightInProgress(e){return e._preflightInProgress===!0}static markPreflightInProgress(e){e._preflightInProgress=!0}constructor(e,t,i,r){this.ref=C.genFileRef(t),this.fileEl=e,this.file=t,this.view=i,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(Ee,this._onElUpdated),this.autoUpload=r}metadata(){return this.meta}progress(e){this._progress=Math.floor(e),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{C.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}isCancelled(){return this._isCancelled}cancel(){this.file._preflightInProgress=!1,this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(Ee,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),this.isAutoUpload()||C.clearFiles(this.fileEl)}isAutoUpload(){return this.autoUpload}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(Ee,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(Fe).split(",").indexOf(this.ref)===-1&&(C.untrackFile(this.fileEl,this.file),this.cancel())}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||I(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:li}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||I(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var Li=0,C=class s{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(Li++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let r=this.activeFiles(e).find(n=>this.genFileRef(n)===t);i(URL.createObjectURL(r))}static hasUploadsInProgress(e){let t=0;return h.findUploadInputs(e).forEach(i=>{i.getAttribute(we)!==i.getAttribute(jt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(r=>{let n={path:e.name},o=e.getAttribute(B);i[o]=i[o]||[],n.ref=this.genFileRef(r),n.last_modified=r.lastModified,n.name=r.name||n.ref,n.relative_path=r.webkitRelativePath,n.type=r.type,n.size=r.size,typeof r.meta=="function"&&(n.meta=r.meta()),i[o].push(n)}),i}static clearFiles(e){e.value=null,e.removeAttribute(B),h.putPrivate(e,"files",[])}static untrackFile(e,t){h.putPrivate(e,"files",h.private(e,"files").filter(i=>!Object.is(i,t)))}static trackFiles(e,t,i){if(e.getAttribute("multiple")!==null){let r=t.filter(n=>!this.activeFiles(e).find(o=>Object.is(o,n)));h.updatePrivate(e,"files",[],n=>n.concat(r)),e.value=null}else i&&i.files.length>0&&(e.files=i.files),h.putPrivate(e,"files",t)}static activeFileInputs(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(h.private(e,"files")||[]).filter(t=>re.isActive(e,t))}static inputsAwaitingPreflight(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!re.isPreflighted(e,t)&&!re.isPreflightInProgress(t))}static markPreflightInProgress(e){e.forEach(t=>re.markPreflightInProgress(t.file))}constructor(e,t,i){this.autoUpload=h.isAutoUpload(e),this.view=t,this.onComplete=i,this._entries=Array.from(s.filesAwaitingPreflight(e)||[]).map(r=>new re(e,r,t,this.autoUpload)),s.markPreflightInProgress(this._entries),this.numEntriesInProgress=this._entries.length}isAutoUpload(){return this.autoUpload}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(n=>(n.isCancelled()?(this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()):(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()})),n));let r=this._entries.reduce((n,o)=>{if(!o.meta)return n;let{name:l,callback:a}=o.uploader(i.uploaders);return n[l]=n[l]||{callback:a,entries:[]},n[l].entries.push(o),n},{});for(let n in r){let{callback:o,entries:l}=r[n];o(l,t,e,i)}}};var Oi={anyOf(s,e){return e.find(t=>s instanceof t)},isFocusable(s,e){return s instanceof HTMLAnchorElement&&s.rel!=="ignore"||s instanceof HTMLAreaElement&&s.href!==void 0||!s.disabled&&this.anyOf(s,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||s instanceof HTMLIFrameElement||s.tabIndex>0||!e&&s.getAttribute("tabindex")!==null&&s.getAttribute("aria-hidden")!=="true"},attemptFocus(s,e){if(this.isFocusable(s,e))try{s.focus()}catch(t){}return!!document.activeElement&&document.activeElement.isSameNode(s)},focusFirstInteractive(s){let e=s.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e,!0))return!0;e=e.nextElementSibling}},focusFirst(s){let e=s.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(s){let e=s.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},q=Oi;var di={LiveFileUpload:{activeRefs(){return this.el.getAttribute(Fe)},preflightedRefs(){return this.el.getAttribute(we)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let s=this.preflightedRefs();this.preflightedWas!==s&&(this.preflightedWas=s,s===""&&this.__view().cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(Ee))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(B)),C.getEntryDataURL(this.inputEl,this.ref,s=>{this.url=s,this.el.src=s})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",s=>{if(!s.relatedTarget||!this.el.contains(s.relatedTarget)){let e=s.target.nextElementSibling;q.attemptFocus(e)||q.focusFirst(e)}else q.focusLast(this.el)}),this.focusEnd.addEventListener("focus",s=>{if(!s.relatedTarget||!this.el.contains(s.relatedTarget)){let e=s.target.previousElementSibling;q.attemptFocus(e)||q.focusLast(e)}else q.focusFirst(this.el)}),this.el.contains(document.activeElement)||(this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&q.focusFirst(this.el))}}},ci=s=>["HTML","BODY"].indexOf(s.nodeName.toUpperCase())>=0?null:["scroll","auto"].indexOf(getComputedStyle(s).overflowY)>=0?s:ci(s.parentElement),ai=s=>s?s.scrollTop:document.documentElement.scrollTop||document.body.scrollTop,Ot=s=>s?s.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight,Dt=s=>s?s.getBoundingClientRect().top:0,Di=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.top)>=Dt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.top)<=Ot(e)},Hi=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.bottom)>=Dt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.bottom)<=Ot(e)},hi=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.top)>=Dt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.top)<=Ot(e)};di.InfiniteScroll={mounted(){this.scrollContainer=ci(this.el);let s=ai(this.scrollContainer),e=!1,t=500,i=null,r=this.throttle(t,(l,a)=>{i=()=>!0,this.liveSocket.execJSHookPush(this.el,l,{id:a.id,_overran:!0},()=>{i=null})}),n=this.throttle(t,(l,a)=>{i=()=>a.scrollIntoView({block:"start"}),this.liveSocket.execJSHookPush(this.el,l,{id:a.id},()=>{i=null,window.requestAnimationFrame(()=>{hi(a,this.scrollContainer)||a.scrollIntoView({block:"start"})})})}),o=this.throttle(t,(l,a)=>{i=()=>a.scrollIntoView({block:"end"}),this.liveSocket.execJSHookPush(this.el,l,{id:a.id},()=>{i=null,window.requestAnimationFrame(()=>{hi(a,this.scrollContainer)||a.scrollIntoView({block:"end"})})})});this.onScroll=l=>{let a=ai(this.scrollContainer);if(i)return s=a,i();let d=this.el.getBoundingClientRect(),f=this.el.getAttribute(this.liveSocket.binding("viewport-top")),p=this.el.getAttribute(this.liveSocket.binding("viewport-bottom")),m=this.el.lastElementChild,g=this.el.firstElementChild,c=a<s,v=a>s;c&&f&&!e&&d.top>=0?(e=!0,r(f,g)):v&&e&&d.top<=0&&(e=!1),f&&c&&Di(g,this.scrollContainer)?n(f,g):p&&v&&Hi(m,this.scrollContainer)&&o(p,m),s=a},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(s,e){let t=0,i;return(...r)=>{let n=Date.now(),o=s-(n-t);o<=0||o>s?(i&&(clearTimeout(i),i=null),t=n,e(...r)):i||(i=setTimeout(()=>{t=Date.now(),i=null,e(...r)},o))}}};var ui=di;var De=class{static onUnlock(e,t){if(!h.isLocked(e)&&!e.closest(`[${x}]`))return t();let i=e.closest(`[${x}]`),r=i.closest(`[${x}]`).getAttribute(x);i.addEventListener(`phx:undo-lock:${r}`,()=>{t()},{once:!0})}constructor(e){this.el=e,this.loadingRef=e.hasAttribute(ae)?parseInt(e.getAttribute(ae),10):null,this.lockRef=e.hasAttribute(x)?parseInt(e.getAttribute(x),10):null}maybeUndo(e,t,i){this.isWithin(e)&&(this.undoLocks(e,t,i),this.undoLoading(e,t),this.isFullyResolvedBy(e)&&this.el.removeAttribute(O))}isWithin(e){return!(this.loadingRef!==null&&this.loadingRef>e&&this.lockRef!==null&&this.lockRef>e)}undoLocks(e,t,i){if(!this.isLockUndoneBy(e))return;let r=h.private(this.el,x);r&&(i(r),h.deletePrivate(this.el,x)),this.el.removeAttribute(x);let n={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${this.lockRef}`,n))}undoLoading(e,t){if(!this.isLoadingUndoneBy(e)){this.canUndoLoading(e)&&this.el.classList.contains("phx-submit-loading")&&this.el.classList.remove("phx-change-loading");return}if(this.canUndoLoading(e)){this.el.removeAttribute(ae);let i=this.el.getAttribute(de),r=this.el.getAttribute(Xe);r!==null&&(this.el.readOnly=r==="true",this.el.removeAttribute(Xe)),i!==null&&(this.el.disabled=i==="true",this.el.removeAttribute(de));let n=this.el.getAttribute(ke);n!==null&&(this.el.innerText=n,this.el.removeAttribute(ke));let o={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${this.loadingRef}`,o))}Ze.forEach(i=>{(i!=="phx-submit-loading"||this.canUndoLoading(e))&&h.removeClass(this.el,i)})}isLoadingUndoneBy(e){return this.loadingRef===null?!1:this.loadingRef<=e}isLockUndoneBy(e){return this.lockRef===null?!1:this.lockRef<=e}isFullyResolvedBy(e){return(this.loadingRef===null||this.loadingRef<=e)&&(this.lockRef===null||this.lockRef<=e)}canUndoLoading(e){return this.lockRef===null||this.lockRef<=e}};var Je=class{constructor(e,t,i){let r=new Set,n=new Set([...t.children].map(l=>l.id)),o=[];Array.from(e.children).forEach(l=>{if(l.id&&(r.add(l.id),n.has(l.id))){let a=l.previousElementSibling&&l.previousElementSibling.id;o.push({elementId:l.id,previousElementId:a})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(l=>!r.has(l))}perform(){let e=h.byId(this.containerId);this.elementsToModify.forEach(t=>{t.previousElementId?Y(document.getElementById(t.previousElementId),i=>{Y(document.getElementById(t.elementId),r=>{r.previousElementSibling&&r.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",r)})}):Y(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{Y(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}};var fi=11;function Ni(s,e){var t=e.attributes,i,r,n,o,l;if(!(e.nodeType===fi||s.nodeType===fi)){for(var a=t.length-1;a>=0;a--)i=t[a],r=i.name,n=i.namespaceURI,o=i.value,n?(r=i.localName||r,l=s.getAttributeNS(n,r),l!==o&&(i.prefix==="xmlns"&&(r=i.name),s.setAttributeNS(n,r,o))):(l=s.getAttribute(r),l!==o&&s.setAttribute(r,o));for(var d=s.attributes,f=d.length-1;f>=0;f--)i=d[f],r=i.name,n=i.namespaceURI,n?(r=i.localName||r,e.hasAttributeNS(n,r)||s.removeAttributeNS(n,r)):e.hasAttribute(r)||s.removeAttribute(r)}}var ht,Fi="http://www.w3.org/1999/xhtml",U=typeof document=="undefined"?void 0:document,Mi=!!U&&"content"in U.createElement("template"),Ui=!!U&&U.createRange&&"createContextualFragment"in U.createRange();function Xi(s){var e=U.createElement("template");return e.innerHTML=s,e.content.childNodes[0]}function $i(s){ht||(ht=U.createRange(),ht.selectNode(U.body));var e=ht.createContextualFragment(s);return e.childNodes[0]}function Bi(s){var e=U.createElement("body");return e.innerHTML=s,e.childNodes[0]}function Vi(s){return s=s.trim(),Mi?Xi(s):Ui?$i(s):Bi(s)}function dt(s,e){var t=s.nodeName,i=e.nodeName,r,n;return t===i?!0:(r=t.charCodeAt(0),n=i.charCodeAt(0),r<=90&&n>=97?t===i.toUpperCase():n<=90&&r>=97?i===t.toUpperCase():!1)}function ji(s,e){return!e||e===Fi?U.createElement(s):U.createElementNS(e,s)}function Ji(s,e){for(var t=s.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function Ht(s,e,t){s[t]!==e[t]&&(s[t]=e[t],s[t]?s.setAttribute(t,""):s.removeAttribute(t))}var pi={OPTION:function(s,e){var t=s.parentNode;if(t){var i=t.nodeName.toUpperCase();i==="OPTGROUP"&&(t=t.parentNode,i=t&&t.nodeName.toUpperCase()),i==="SELECT"&&!t.hasAttribute("multiple")&&(s.hasAttribute("selected")&&!e.selected&&(s.setAttribute("selected","selected"),s.removeAttribute("selected")),t.selectedIndex=-1)}Ht(s,e,"selected")},INPUT:function(s,e){Ht(s,e,"checked"),Ht(s,e,"disabled"),s.value!==e.value&&(s.value=e.value),e.hasAttribute("value")||s.removeAttribute("value")},TEXTAREA:function(s,e){var t=e.value;s.value!==t&&(s.value=t);var i=s.firstChild;if(i){var r=i.nodeValue;if(r==t||!t&&r==s.placeholder)return;i.nodeValue=t}},SELECT:function(s,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,r=s.firstChild,n,o;r;)if(o=r.nodeName&&r.nodeName.toUpperCase(),o==="OPTGROUP")n=r,r=n.firstChild;else{if(o==="OPTION"){if(r.hasAttribute("selected")){t=i;break}i++}r=r.nextSibling,!r&&n&&(r=n.nextSibling,n=null)}s.selectedIndex=t}}},We=1,mi=11,gi=3,vi=8;function ce(){}function Wi(s){if(s)return s.getAttribute&&s.getAttribute("id")||s.id}function qi(s){return function(t,i,r){if(r||(r={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var n=i;i=U.createElement("html"),i.innerHTML=n}else i=Vi(i);else i.nodeType===mi&&(i=i.firstElementChild);var o=r.getNodeKey||Wi,l=r.onBeforeNodeAdded||ce,a=r.onNodeAdded||ce,d=r.onBeforeElUpdated||ce,f=r.onElUpdated||ce,p=r.onBeforeNodeDiscarded||ce,m=r.onNodeDiscarded||ce,g=r.onBeforeElChildrenUpdated||ce,c=r.skipFromChildren||ce,v=r.addChild||function(S,_){return S.appendChild(_)},b=r.childrenOnly===!0,T=Object.create(null),Z=[];function P(S){Z.push(S)}function V(S,_){if(S.nodeType===We)for(var R=S.firstChild;R;){var w=void 0;_&&(w=o(R))?P(w):(m(R),R.firstChild&&V(R,_)),R=R.nextSibling}}function F(S,_,R){p(S)!==!1&&(_&&_.removeChild(S),m(S),V(S,R))}function N(S){if(S.nodeType===We||S.nodeType===mi)for(var _=S.firstChild;_;){var R=o(_);R&&(T[R]=_),N(_),_=_.nextSibling}}N(t);function u(S){a(S);for(var _=S.firstChild;_;){var R=_.nextSibling,w=o(_);if(w){var k=T[w];k&&dt(_,k)?(_.parentNode.replaceChild(k,_),X(k,_)):u(_)}else u(_);_=R}}function A(S,_,R){for(;_;){var w=_.nextSibling;(R=o(_))?P(R):F(_,S,!0),_=w}}function X(S,_,R){var w=o(_);if(w&&delete T[w],!R){var k=d(S,_);if(k===!1||(k instanceof HTMLElement&&(S=k,N(S)),s(S,_),f(S),g(S,_)===!1))return}S.nodeName!=="TEXTAREA"?ie(S,_):pi.TEXTAREA(S,_)}function ie(S,_){var R=c(S,_),w=_.firstChild,k=S.firstChild,Se,se,_e,Ke,oe;e:for(;w;){for(Ke=w.nextSibling,Se=o(w);!R&&k;){if(_e=k.nextSibling,w.isSameNode&&w.isSameNode(k)){w=Ke,k=_e;continue e}se=o(k);var Ge=k.nodeType,le=void 0;if(Ge===w.nodeType&&(Ge===We?(Se?Se!==se&&((oe=T[Se])?_e===oe?le=!1:(S.insertBefore(oe,k),se?P(se):F(k,S,!0),k=oe,se=o(k)):le=!1):se&&(le=!1),le=le!==!1&&dt(k,w),le&&X(k,w)):(Ge===gi||Ge==vi)&&(le=!0,k.nodeValue!==w.nodeValue&&(k.nodeValue=w.nodeValue))),le){w=Ke,k=_e;continue e}se?P(se):F(k,S,!0),k=_e}if(Se&&(oe=T[Se])&&dt(oe,w))R||v(S,oe),X(oe,w);else{var pt=l(w);pt!==!1&&(pt&&(w=pt),w.actualize&&(w=w.actualize(S.ownerDocument||U)),v(S,w),u(w))}w=Ke,k=_e}A(S,k,se);var Mt=pi[S.nodeName];Mt&&Mt(S,_)}var E=t,j=E.nodeType,ne=i.nodeType;if(!b){if(j===We)ne===We?dt(t,i)||(m(t),E=Ji(t,ji(i.nodeName,i.namespaceURI))):E=i;else if(j===gi||j===vi){if(ne===j)return E.nodeValue!==i.nodeValue&&(E.nodeValue=i.nodeValue),E;E=i}}if(E===i)m(t);else{if(i.isSameNode&&i.isSameNode(E))return;if(X(E,i,b),Z)for(var ut=0,Ei=Z.length;ut<Ei;ut++){var ft=T[Z[ut]];ft&&F(ft,ft.parentNode,!1)}}return!b&&E!==t&&t.parentNode&&(E.actualize&&(E=E.actualize(t.ownerDocument||U)),t.parentNode.replaceChild(E,t)),E}}var Ki=qi(Ni),bi=Ki;var ue=class{constructor(e,t,i,r,n,o,l={}){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=r,this.streams=n,this.streamInserts={},this.streamComponentRestore={},this.targetCID=o,this.cidPatch=W(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.targetContainer=this.isCIDPatch()?this.targetCIDContainer(r):t,this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]},this.withChildren=l.withChildren||l.undoRef||!1,this.undoRef=l.undoRef}before(e,t){this.callbacks[`before${e}`].push(t)}after(e,t){this.callbacks[`after${e}`].push(t)}trackBefore(e,...t){this.callbacks[`before${e}`].forEach(i=>i(...t))}trackAfter(e,...t){this.callbacks[`after${e}`].forEach(i=>i(...t))}markPrunableContentForRemoval(){let e=this.liveSocket.binding(Re);h.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(vt,"")})}perform(e){let{view:t,liveSocket:i,html:r,container:n,targetContainer:o}=this;if(this.isCIDPatch()&&!o)return;let l=i.getActiveElement(),{selectionStart:a,selectionEnd:d}=l&&h.hasSelectionRange(l)?l:{},f=i.binding(Re),p=i.binding(Me),m=i.binding(Ue),g=i.binding(Jt),c=[],v=[],b=[],T=null;function Z(P,V,F=this.withChildren){let N={childrenOnly:P.getAttribute($)===null&&!F,getNodeKey:u=>h.isPhxDestroyed(u)?null:e?u.id:u.id||u.getAttribute&&u.getAttribute(st),skipFromChildren:u=>u.getAttribute(f)===nt,addChild:(u,A)=>{let{ref:X,streamAt:ie}=this.getStreamInsert(A);if(X===void 0)return u.appendChild(A);if(this.setStreamRef(A,X),ie===0)u.insertAdjacentElement("afterbegin",A);else if(ie===-1){let E=u.lastElementChild;if(E&&!E.hasAttribute(xe)){let j=Array.from(u.children).find(ne=>!ne.hasAttribute(xe));u.insertBefore(A,j)}else u.appendChild(A)}else if(ie>0){let E=Array.from(u.children)[ie];u.insertBefore(A,E)}},onBeforeNodeAdded:u=>{h.maintainPrivateHooks(u,u,p,m),this.trackBefore("added",u);let A=u;return this.streamComponentRestore[u.id]&&(A=this.streamComponentRestore[u.id],delete this.streamComponentRestore[u.id],Z.call(this,A,u,!0)),A},onNodeAdded:u=>{u.getAttribute&&this.maybeReOrderStream(u,!0),u instanceof HTMLImageElement&&u.srcset?u.srcset=u.srcset:u instanceof HTMLVideoElement&&u.autoplay&&u.play(),h.isNowTriggerFormExternal(u,g)&&(T=u),(h.isPhxChild(u)&&t.ownsElement(u)||h.isPhxSticky(u)&&t.ownsElement(u.parentNode))&&this.trackAfter("phxChildAdded",u),c.push(u)},onNodeDiscarded:u=>this.onNodeDiscarded(u),onBeforeNodeDiscarded:u=>u.getAttribute&&u.getAttribute(vt)!==null?!0:!(u.parentElement!==null&&u.id&&h.isPhxUpdate(u.parentElement,f,[nt,"append","prepend"])||this.maybePendingRemove(u)||this.skipCIDSibling(u)),onElUpdated:u=>{h.isNowTriggerFormExternal(u,g)&&(T=u),v.push(u),this.maybeReOrderStream(u,!1)},onBeforeElUpdated:(u,A)=>{if(u.id&&u.isSameNode(P)&&u.id!==A.id)return N.onNodeDiscarded(u),u.replaceWith(A),N.onNodeAdded(A);if(h.syncPendingAttrs(u,A),h.maintainPrivateHooks(u,A,p,m),h.cleanChildNodes(A,f),this.skipCIDSibling(A))return this.maybeReOrderStream(u),!1;if(h.isPhxSticky(u))return[M,te,J].map(E=>[E,u.getAttribute(E),A.getAttribute(E)]).forEach(([E,j,ne])=>{ne&&j!==ne&&u.setAttribute(E,ne)}),!1;if(h.isIgnored(u,f)||u.form&&u.form.isSameNode(T))return this.trackBefore("updated",u,A),h.mergeAttrs(u,A,{isIgnored:h.isIgnored(u,f)}),v.push(u),h.applyStickyOperations(u),!1;if(u.type==="number"&&u.validity&&u.validity.badInput)return!1;let X=l&&u.isSameNode(l)&&h.isFormInput(u),ie=X&&this.isChangedSelect(u,A);if(u.hasAttribute(O)&&u.getAttribute(x)!=this.undoRef){h.isUploadInput(u)&&(h.mergeAttrs(u,A,{isIgnored:!0}),this.trackBefore("updated",u,A),v.push(u)),h.applyStickyOperations(u);let j=u.hasAttribute(x)?h.private(u,x)||u.cloneNode(!0):null;j&&(h.putPrivate(u,x,j),X||(u=j))}if(h.isPhxChild(A)){let E=u.getAttribute(M);return h.mergeAttrs(u,A,{exclude:[te]}),E!==""&&u.setAttribute(M,E),u.setAttribute(J,this.rootID),h.applyStickyOperations(u),!1}return h.copyPrivates(A,u),X&&u.type!=="hidden"&&!ie?(this.trackBefore("updated",u,A),h.mergeFocusedInput(u,A),h.syncAttrsToProps(u),v.push(u),h.applyStickyOperations(u),!1):(ie&&u.blur(),h.isPhxUpdate(A,f,["append","prepend"])&&b.push(new Je(u,A,A.getAttribute(f))),h.syncAttrsToProps(A),h.applyStickyOperations(A),this.trackBefore("updated",u,A),u)}};bi(P,V,N)}return this.trackBefore("added",n),this.trackBefore("updated",n,n),i.time("morphdom",()=>{this.streams.forEach(([P,V,F,N])=>{V.forEach(([u,A,X])=>{this.streamInserts[u]={ref:P,streamAt:A,limit:X,reset:N}}),N!==void 0&&h.all(n,`[${xe}="${P}"]`,u=>{this.removeStreamChildElement(u)}),F.forEach(u=>{let A=n.querySelector(`[id="${u}"]`);A&&this.removeStreamChildElement(A)})}),e&&h.all(this.container,`[${f}=${nt}]`,P=>{this.liveSocket.owner(P,V=>{V===this.view&&Array.from(P.children).forEach(F=>{this.removeStreamChildElement(F)})})}),Z.call(this,o,r)}),i.isDebugEnabled()&&(si(),ri(this.streamInserts),Array.from(document.querySelectorAll("input[name=id]")).forEach(P=>{P.form&&console.error(`Detected an input with name="id" inside a form! This will cause problems when patching the DOM.
|
|
9
|
+
`,P)})),b.length>0&&i.time("post-morph append/prepend restoration",()=>{b.forEach(P=>P.perform())}),i.silenceEvents(()=>h.restoreFocus(l,a,d)),h.dispatchEvent(document,"phx:update"),c.forEach(P=>this.trackAfter("added",P)),v.forEach(P=>this.trackAfter("updated",P)),this.transitionPendingRemoves(),T&&(i.unload(),Object.getPrototypeOf(T).submit.call(T)),!0}onNodeDiscarded(e){(h.isPhxChild(e)||h.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfter("discarded",e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}removeStreamChildElement(e){this.streamInserts[e.id]?(this.streamComponentRestore[e.id]=e,e.remove()):this.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}setStreamRef(e,t){h.putSticky(e,xe,i=>i.setAttribute(xe,t))}maybeReOrderStream(e,t){let{ref:i,streamAt:r,reset:n}=this.getStreamInsert(e);if(r!==void 0&&(this.setStreamRef(e,i),!(!n&&!t)&&e.parentElement)){if(r===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(r>0){let o=Array.from(e.parentElement.children),l=o.indexOf(e);if(r>=o.length-1)e.parentElement.appendChild(e);else{let a=o[r];l>r?e.parentElement.insertBefore(e,a):e.parentElement.insertBefore(e,a.nextElementSibling)}}this.maybeLimitStream(e)}}maybeLimitStream(e){let{limit:t}=this.getStreamInsert(e),i=t!==null&&Array.from(e.parentElement.children);t&&t<0&&i.length>t*-1?i.slice(0,i.length+t).forEach(r=>this.removeStreamChildElement(r)):t&&t>=0&&i.length>t&&i.slice(t).forEach(r=>this.removeStreamChildElement(r))}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:t}=this;e.length>0&&t.transitionRemoves(e,()=>{e.forEach(i=>{let r=h.firstPhxChild(i);r&&t.destroyViewByEl(r),i.remove()}),this.trackAfter("transitionsDiscarded",e)})}isChangedSelect(e,t){return!(e instanceof HTMLSelectElement)||e.multiple?!1:e.options.length!==t.options.length?!0:(t.value=e.value,!e.isEqualNode(t))}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(it)}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=h.findComponentNodeList(this.container,this.targetCID);return i.length===0&&h.childNodeLength(e)===1?t:t&&t.parentNode}indexOf(e,t){return Array.from(e.children).indexOf(t)}};var Gi=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),zi=new Set(["'",'"']),Ai=(s,e,t)=>{let i=0,r=!1,n,o,l,a,d,f,p=s.match(/^(\s*(?:<!--.*?-->\s*)*)<([^\s\/>]+)/);if(p===null)throw new Error(`malformed html ${s}`);for(i=p[0].length,n=p[1],l=p[2],a=i,i;i<s.length&&s.charAt(i)!==">";i++)if(s.charAt(i)==="="){let c=s.slice(i-3,i)===" id";i++;let v=s.charAt(i);if(zi.has(v)){let b=i;for(i++,i;i<s.length&&s.charAt(i)!==v;i++);if(c){d=s.slice(b+1,i);break}}}let m=s.length-1;for(r=!1;m>=n.length+l.length;){let c=s.charAt(m);if(r)c==="-"&&s.slice(m-3,m)==="<!-"?(r=!1,m-=4):m-=1;else if(c===">"&&s.slice(m-2,m)==="--")r=!0,m-=3;else{if(c===">")break;m-=1}}o=s.slice(m+1,s.length);let g=Object.keys(e).map(c=>e[c]===!0?c:`${c}="${e[c]}"`).join(" ");if(t){let c=d?` id="${d}"`:"";Gi.has(l)?f=`<${l}${c}${g===""?"":" "}${g}/>`:f=`<${l}${c}${g===""?"":" "}${g}></${l}>`}else{let c=s.slice(a,m+1);f=`<${l}${g===""?"":" "}${g}${c}`}return[f,n,o]},He=class{static extract(e){let{[xt]:t,[Rt]:i,[Tt]:r}=e;return delete e[xt],delete e[Rt],delete e[Tt],{diff:e,title:r,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.magicId=0,this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){let[t,i]=this.recursiveToString(this.rendered,this.rendered[D],e,!0,{});return[t,i]}recursiveToString(e,t=e[D],i,r,n){i=i?new Set(i):null;let o={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,o,r,n),[o.buffer,o.streams]}componentCIDs(e){return Object.keys(e[D]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[D]?Object.keys(e).length===1:!1}getComponent(e,t){return e[D][t]}resetRender(e){this.rendered[D][e]&&(this.rendered[D][e].reset=!0)}mergeDiff(e){let t=e[D],i={};if(delete e[D],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[D]=this.rendered[D]||{},t){let r=this.rendered[D];for(let n in t)t[n]=this.cachedFindComponent(n,t[n],r,t,i);for(let n in t)r[n]=t[n];e[D]=t}}cachedFindComponent(e,t,i,r,n){if(n[e])return n[e];{let o,l,a=t[z];if(W(a)){let d;a>0?d=this.cachedFindComponent(a,r[a],i,r,n):d=i[-a],l=d[z],o=this.cloneMerge(d,t,!0),o[z]=l}else o=t[z]!==void 0||i[e]===void 0?t:this.cloneMerge(i[e],t,!1);return n[e]=o,o}}mutableMerge(e,t){return t[z]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let r=t[i],n=e[i];ve(r)&&r[z]===void 0&&ve(n)?this.doMutableMerge(n,r):e[i]=r}e[at]&&(e.newRender=!0)}cloneMerge(e,t,i){let r=L(L({},e),t);for(let n in r){let o=t[n],l=e[n];ve(o)&&o[z]===void 0&&ve(l)?r[n]=this.cloneMerge(l,o,i):o===void 0&&ve(l)&&(r[n]=this.cloneMerge(l,{},i))}return i?(delete r.magicId,delete r.newRender):e[at]&&(r.newRender=!0),r}componentToString(e){let[t,i]=this.recursiveCIDToString(this.rendered[D],e,null),[r,n,o]=Ai(t,{});return[r,i]}pruneCIDs(e){e.forEach(t=>delete this.rendered[D][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[z]}templateStatic(e,t){return typeof e=="number"?t[e]:e}nextMagicID(){return this.magicId++,`m${this.magicId}-${this.parentViewId()}`}toOutputBuffer(e,t,i,r,n={}){if(e[Ve])return this.comprehensionToBuffer(e,t,i);let{[z]:o}=e;o=this.templateStatic(o,t);let l=e[at],a=i.buffer;l&&(i.buffer=""),r&&l&&!e.magicId&&(e.newRender=!0,e.magicId=this.nextMagicID()),i.buffer+=o[0];for(let d=1;d<o.length;d++)this.dynamicToBuffer(e[d-1],t,i,r),i.buffer+=o[d];if(l){let d=!1,f;r||e.magicId?(d=r&&!e.newRender,f=L({[st]:e.magicId},n)):f=n,d&&(f[it]=!0);let[p,m,g]=Ai(i.buffer,f,d);e.newRender=!1,i.buffer=a+m+p+g}}comprehensionToBuffer(e,t,i){let{[Ve]:r,[z]:n,[It]:o}=e,[l,a,d,f]=o||[null,{},[],null];n=this.templateStatic(n,t);let p=t||e[ii];for(let m=0;m<r.length;m++){let g=r[m];i.buffer+=n[0];for(let c=1;c<n.length;c++)this.dynamicToBuffer(g[c-1],p,i,!1),i.buffer+=n[c]}o!==void 0&&(e[Ve].length>0||d.length>0||f)&&(delete e[It],e[Ve]=[],i.streams.add(o))}dynamicToBuffer(e,t,i,r){if(typeof e=="number"){let[n,o]=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=n,i.streams=new Set([...i.streams,...o])}else ve(e)?this.toOutputBuffer(e,t,i,r,{}):i.buffer+=e}recursiveCIDToString(e,t,i){let r=e[t]||I(`no component for CID ${t}`,e),n={[$]:t},o=i&&!i.has(t);r.newRender=!o,r.magicId=`c${t}-${this.parentViewId()}`;let l=!r.reset,[a,d]=this.recursiveToString(r,e,i,l,n);return delete r.reset,[a,d]}};var Si=[],_i=200,Yi={exec(s,e,t,i,r,n){let[o,l]=n||[null,{callback:n&&n.callback}];(t.charAt(0)==="["?JSON.parse(t):[[o,l]]).forEach(([d,f])=>{d===o&&(f=L(L({},l),f),f.callback=f.callback||l.callback),this.filterToEls(i.liveSocket,r,f).forEach(p=>{this[`exec_${d}`](s,e,t,i,r,p,f)})})},isVisible(s){return!!(s.offsetWidth||s.offsetHeight||s.getClientRects().length>0)},isInViewport(s){let e=s.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight,i=window.innerWidth||document.documentElement.clientWidth;return e.right>0&&e.bottom>0&&e.left<i&&e.top<t},exec_exec(s,e,t,i,r,n,{attr:o,to:l}){(l?h.all(document,l):[r]).forEach(d=>{let f=d.getAttribute(o);if(!f)throw new Error(`expected ${o} to contain JS command on "${l}"`);i.liveSocket.execJS(d,f,e)})},exec_dispatch(s,e,t,i,r,n,{event:o,detail:l,bubbles:a}){l=l||{},l.dispatcher=r,h.dispatchEvent(n,o,{detail:l,bubbles:a})},exec_push(s,e,t,i,r,n,o){let{event:l,data:a,target:d,page_loading:f,loading:p,value:m,dispatcher:g,callback:c}=o,v={loading:p,value:m,target:d,page_loading:!!f},b=e==="change"&&g?g:r,T=d||b.getAttribute(i.binding("target"))||b,Z=(P,V)=>{if(P.isConnected())if(e==="change"){let{newCid:F,_target:N}=o;N=N||(h.isFormInput(r)?r.name:void 0),N&&(v._target=N),P.pushInput(r,V,F,l||t,v,c)}else if(e==="submit"){let{submitter:F}=o;P.submitForm(r,V,l||t,F,v,c)}else P.pushEvent(e,r,V,l||t,a,v,c)};o.targetView&&o.targetCtx?Z(o.targetView,o.targetCtx):i.withinTargets(T,Z)},exec_navigate(s,e,t,i,r,n,{href:o,replace:l}){i.liveSocket.historyRedirect(s,o,l?"replace":"push",null,r)},exec_patch(s,e,t,i,r,n,{href:o,replace:l}){i.liveSocket.pushHistoryPatch(s,o,l?"replace":"push",r)},exec_focus(s,e,t,i,r,n){q.attemptFocus(n)},exec_focus_first(s,e,t,i,r,n){q.focusFirstInteractive(n)||q.focusFirst(n)},exec_push_focus(s,e,t,i,r,n){window.requestAnimationFrame(()=>Si.push(n||r))},exec_pop_focus(s,e,t,i,r,n){window.requestAnimationFrame(()=>{let o=Si.pop();o&&o.focus()})},exec_add_class(s,e,t,i,r,n,{names:o,transition:l,time:a,blocking:d}){this.addOrRemoveClasses(n,o,[],l,a,i,d)},exec_remove_class(s,e,t,i,r,n,{names:o,transition:l,time:a,blocking:d}){this.addOrRemoveClasses(n,[],o,l,a,i,d)},exec_toggle_class(s,e,t,i,r,n,{names:o,transition:l,time:a,blocking:d}){this.toggleClasses(n,o,l,a,i,d)},exec_toggle_attr(s,e,t,i,r,n,{attr:[o,l,a]}){this.toggleAttr(n,o,l,a)},exec_transition(s,e,t,i,r,n,{time:o,transition:l,blocking:a}){this.addOrRemoveClasses(n,[],[],l,o,i,a)},exec_toggle(s,e,t,i,r,n,{display:o,ins:l,outs:a,time:d,blocking:f}){this.toggle(e,i,n,o,l,a,d,f)},exec_show(s,e,t,i,r,n,{display:o,transition:l,time:a,blocking:d}){this.show(e,i,n,o,l,a,d)},exec_hide(s,e,t,i,r,n,{display:o,transition:l,time:a,blocking:d}){this.hide(e,i,n,o,l,a,d)},exec_set_attr(s,e,t,i,r,n,{attr:[o,l]}){this.setOrRemoveAttrs(n,[[o,l]],[])},exec_remove_attr(s,e,t,i,r,n,{attr:o}){this.setOrRemoveAttrs(n,[],[o])},show(s,e,t,i,r,n,o){this.isVisible(t)||this.toggle(s,e,t,i,r,null,n,o)},hide(s,e,t,i,r,n,o){this.isVisible(t)&&this.toggle(s,e,t,i,null,r,n,o)},toggle(s,e,t,i,r,n,o,l){o=o||_i;let[a,d,f]=r||[[],[],[]],[p,m,g]=n||[[],[],[]];if(a.length>0||p.length>0)if(this.isVisible(t)){let c=()=>{this.addOrRemoveClasses(t,m,a.concat(d).concat(f)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,p,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,g,m))})},v=()=>{this.addOrRemoveClasses(t,[],p.concat(g)),h.putSticky(t,"toggle",b=>b.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))};t.dispatchEvent(new Event("phx:hide-start")),l===!1?(c(),setTimeout(v,o)):e.transition(o,c,v)}else{if(s==="remove")return;let c=()=>{this.addOrRemoveClasses(t,d,p.concat(m).concat(g));let b=i||this.defaultDisplay(t);h.putSticky(t,"toggle",T=>T.style.display=b),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,f,d))})},v=()=>{this.addOrRemoveClasses(t,[],a.concat(f)),t.dispatchEvent(new Event("phx:show-end"))};t.dispatchEvent(new Event("phx:show-start")),l===!1?(c(),setTimeout(v,o)):e.transition(o,c,v)}else if(this.isVisible(t))t.dispatchEvent(new Event("phx:hide-start")),h.putSticky(t,"toggle",c=>c.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"));else{t.dispatchEvent(new Event("phx:show-start"));let c=i||this.defaultDisplay(t);h.putSticky(t,"toggle",v=>v.style.display=c),t.dispatchEvent(new Event("phx:show-end"))}},toggleClasses(s,e,t,i,r,n){window.requestAnimationFrame(()=>{let[o,l]=h.getSticky(s,"classes",[[],[]]),a=e.filter(f=>o.indexOf(f)<0&&!s.classList.contains(f)),d=e.filter(f=>l.indexOf(f)<0&&s.classList.contains(f));this.addOrRemoveClasses(s,a,d,t,i,r,n)})},toggleAttr(s,e,t,i){s.hasAttribute(e)?i!==void 0?s.getAttribute(e)===t?this.setOrRemoveAttrs(s,[[e,i]],[]):this.setOrRemoveAttrs(s,[[e,t]],[]):this.setOrRemoveAttrs(s,[],[e]):this.setOrRemoveAttrs(s,[[e,t]],[])},addOrRemoveClasses(s,e,t,i,r,n,o){r=r||_i;let[l,a,d]=i||[[],[],[]];if(l.length>0){let f=()=>{this.addOrRemoveClasses(s,a,[].concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(s,l,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(s,d,a))})},p=()=>this.addOrRemoveClasses(s,e.concat(d),t.concat(l).concat(a));o===!1?(f(),setTimeout(p,r)):n.transition(r,f,p);return}window.requestAnimationFrame(()=>{let[f,p]=h.getSticky(s,"classes",[[],[]]),m=e.filter(b=>f.indexOf(b)<0&&!s.classList.contains(b)),g=t.filter(b=>p.indexOf(b)<0&&s.classList.contains(b)),c=f.filter(b=>t.indexOf(b)<0).concat(m),v=p.filter(b=>e.indexOf(b)<0).concat(g);h.putSticky(s,"classes",b=>(b.classList.remove(...v),b.classList.add(...c),[c,v]))})},setOrRemoveAttrs(s,e,t){let[i,r]=h.getSticky(s,"attrs",[[],[]]),n=e.map(([a,d])=>a).concat(t),o=i.filter(([a,d])=>!n.includes(a)).concat(e),l=r.filter(a=>!n.includes(a)).concat(t);h.putSticky(s,"attrs",a=>(l.forEach(d=>a.removeAttribute(d)),o.forEach(([d,f])=>a.setAttribute(d,f)),[o,l]))},hasAllClasses(s,e){return e.every(t=>s.classList.contains(t))},isToggledOut(s,e){return!this.isVisible(s)||this.hasAllClasses(s,e)},filterToEls(s,e,{to:t}){let i=()=>{if(typeof t=="string")return document.querySelectorAll(t);if(t.closest){let r=e.closest(t.closest);return r?[r]:[]}else if(t.inner)return e.querySelectorAll(t.inner)};return t?s.jsQuerySelectorAll(e,t,i):[e]},defaultDisplay(s){return{tr:"table-row",td:"table-cell"}[s.tagName.toLowerCase()]||"block"},transitionClasses(s){if(!s)return null;let[e,t,i]=Array.isArray(s)?s:[s.split(" "),[],[]];return e=Array.isArray(e)?e:e.split(" "),t=Array.isArray(t)?t:t.split(" "),i=Array.isArray(i)?i:i.split(" "),[e,t,i]}},y=Yi;var Nt="hookId",Qi=1,Q=class{static makeID(){return Qi++}static elementID(e){return h.private(e,Nt)}constructor(e,t,i){this.el=t,this.__attachView(e),this.__callbacks=i,this.__listeners=new Set,this.__isDisconnected=!1,h.putPrivate(this.el,Nt,this.constructor.makeID());for(let r in this.__callbacks)this[r]=this.__callbacks[r]}__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=null)}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed(),h.deletePrivate(this.el,Nt)}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}js(){let e=this;return{exec(t){e.__view().liveSocket.execJS(e.el,t,"hook")},show(t,i={}){let r=e.__view().liveSocket.owner(t);y.show("hook",r,t,i.display,i.transition,i.time,i.blocking)},hide(t,i={}){let r=e.__view().liveSocket.owner(t);y.hide("hook",r,t,null,i.transition,i.time,i.blocking)},toggle(t,i={}){let r=e.__view().liveSocket.owner(t);i.in=y.transitionClasses(i.in),i.out=y.transitionClasses(i.out),y.toggle("hook",r,t,i.display,i.in,i.out,i.time,i.blocking)},addClass(t,i,r={}){i=Array.isArray(i)?i:i.split(" ");let n=e.__view().liveSocket.owner(t);y.addOrRemoveClasses(t,i,[],r.transition,r.time,n,r.blocking)},removeClass(t,i,r={}){r.transition=y.transitionClasses(r.transition),i=Array.isArray(i)?i:i.split(" ");let n=e.__view().liveSocket.owner(t);y.addOrRemoveClasses(t,[],i,r.transition,r.time,n,r.blocking)},toggleClass(t,i,r={}){r.transition=y.transitionClasses(r.transition),i=Array.isArray(i)?i:i.split(" ");let n=e.__view().liveSocket.owner(t);y.toggleClasses(t,i,r.transition,r.time,n,r.blocking)},transition(t,i,r={}){let n=e.__view().liveSocket.owner(t);y.addOrRemoveClasses(t,[],[],y.transitionClasses(i),r.time,n,r.blocking)},setAttribute(t,i,r){y.setOrRemoveAttrs(t,[[i,r]],[])},removeAttribute(t,i){y.setOrRemoveAttrs(t,[],[i])},toggleAttribute(t,i,r,n){y.toggleAttr(t,i,r,n)}}}pushEvent(e,t={},i){return i===void 0?new Promise((r,n)=>{try{this.__view().pushHookEvent(this.el,null,e,t,(l,a)=>r(l))===!1&&n(new Error("unable to push hook event. LiveView not connected"))}catch(o){n(o)}}):this.__view().pushHookEvent(this.el,null,e,t,i)}pushEventTo(e,t,i={},r){return r===void 0?new Promise((n,o)=>{try{this.__view().withinTargets(e,(l,a)=>{l.pushHookEvent(this.el,a,t,i,(f,p)=>n(f))===!1&&o(new Error("unable to push hook event. LiveView not connected"))})}catch(l){o(l)}}):this.__view().withinTargets(e,(n,o)=>n.pushHookEvent(this.el,o,t,i,r))}handleEvent(e,t){let i=(r,n)=>n?e:t(r.detail);return window.addEventListener(`phx:${e}`,i),this.__listeners.add(i),i}removeHandleEvent(e){let t=e(null,!0);window.removeEventListener(`phx:${t}`,e),this.__listeners.delete(e)}upload(e,t){return this.__view().dispatchUploads(null,e,t)}uploadTo(e,t,i){return this.__view().withinTargets(e,(r,n)=>{r.dispatchUploads(n,t,i)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var Zi=(s,e)=>{let t=s.endsWith("[]"),i=t?s.slice(0,-2):s;return i=i.replace(/([^\[\]]+)(\]?$)/,`${e}$1$2`),t&&(i+="[]"),i},ct=(s,e,t=[])=>{let f=e,{submitter:i}=f,r=$t(f,["submitter"]),n;if(i&&i.name){let p=document.createElement("input");p.type="hidden";let m=i.getAttribute("form");m&&p.setAttribute("form",m),p.name=i.name,p.value=i.value,i.parentElement.insertBefore(p,i),n=p}let o=new FormData(s),l=[];o.forEach((p,m,g)=>{p instanceof File&&l.push(m)}),l.forEach(p=>o.delete(p));let a=new URLSearchParams,d=Array.from(s.elements);for(let[p,m]of o.entries())if(t.length===0||t.indexOf(p)>=0){let g=d.filter(b=>b.name===p),c=!g.some(b=>h.private(b,pe)||h.private(b,me)),v=g.every(b=>b.type==="hidden");c&&!(i&&i.name==p)&&!v&&a.append(Zi(p,"_unused_"),""),a.append(p,m)}i&&n&&i.parentElement.removeChild(n);for(let p in r)a.append(p,r[p]);return a.toString()},Ae=class s{static closestView(e){let t=e.closest(K);return t?h.private(t,"view"):null}constructor(e,t,i,r,n){this.isDead=!1,this.liveSocket=t,this.flash=r,this.parent=i,this.root=i?i.root:this,this.el=e,h.putPrivate(this.el,"view",this),this.id=this.el.id,this.ref=0,this.lastAckRef=null,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],this.pendingForms=new Set,this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinAttempts=0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(o){o&&o()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.formsForRecovery={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{let o=this.href&&this.expandURL(this.href);return{redirect:this.redirect?o:void 0,url:this.redirect?void 0:o||void 0,params:this.connectParams(n),session:this.getSession(),static:this.getStatic(),flash:this.flash}})}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(Pe)}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding(Bt)}]`).map(r=>r.src||r.href).filter(r=>typeof r=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._mount_attempts=this.joinAttempts,t._live_referer=e,this.joinAttempts++,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(M)}getStatic(){let e=this.el.getAttribute(te);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyed=!0,delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);let t=()=>{e();for(let i in this.viewHooks)this.destroyHook(this.viewHooks[i])};h.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",t).receive("error",t).receive("timeout",t)}setContainerClasses(...e){this.el.classList.remove(bt,he,fe,At,ye),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let t in this.viewHooks)this.viewHooks[t].__disconnected();this.setContainerClasses(he)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(bt),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,t){this.liveSocket.log(this,e,t)}transition(e,t,i=function(){}){this.liveSocket.transition(e,t,i)}withinTargets(e,t,i=document,r){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,n=>t(n,e));if(W(e))h.findComponentNodeList(r||this.el,e).length===0?I(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let n=Array.from(i.querySelectorAll(e));n.length===0&&I(`nothing found matching the phx-target selector "${e}"`),n.forEach(o=>this.liveSocket.owner(o,l=>t(l,o)))}}applyDiff(e,t,i){this.log(e,()=>["",Oe(t)]);let{diff:r,reply:n,events:o,title:l}=He.extract(t);i({diff:r,reply:n,events:o}),(typeof l=="string"||e=="mount")&&window.requestAnimationFrame(()=>h.putTitle(l))}onJoin(e){let{rendered:t,container:i,liveview_version:r}=e;if(i){let[n,o]=i;this.el=h.replaceRootContainer(this.el,n,o)}this.childJoins=0,this.joinPending=!0,this.flash=null,this.root===this&&(this.formsForRecovery=this.getFormsForRecovery()),this.isMain()&&window.history.state===null&&H.pushState("replace",{type:"patch",id:this.id,position:this.liveSocket.currentHistoryPosition}),r!==this.liveSocket.version()&&console.error(`LiveView asset version mismatch. JavaScript version ${this.liveSocket.version()} vs. server ${r}. To avoid issues, please ensure that your assets use the same version as the server.`),H.dropLocal(this.liveSocket.localStorage,window.location.pathname,Qe),this.applyDiff("mount",t,({diff:n,events:o})=>{this.rendered=new He(this.id,n);let[l,a]=this.renderContainer(null,"join");this.dropPendingRefs(),this.joinCount++,this.joinAttempts=0,this.maybeRecoverForms(l,()=>{this.onJoinComplete(e,l,a,o)})})}dropPendingRefs(){h.all(document,`[${O}="${this.refSrc()}"]`,e=>{e.removeAttribute(ae),e.removeAttribute(O),e.removeAttribute(x)})}onJoinComplete({live_patch:e},t,i,r){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i,r);h.findPhxChildrenInFragment(t,this.id).filter(o=>{let l=o.id&&this.el.querySelector(`[id="${o.id}"]`),a=l&&l.getAttribute(te);return a&&o.setAttribute(te,a),l&&l.setAttribute(J,this.root.id),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,r)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i,r)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,r)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(J,this.root.id)}execNewMounted(e=this.el){let t=this.binding(Me),i=this.binding(Ue);h.all(e,`[${t}], [${i}]`,r=>{this.ownsElement(r)&&(h.maintainPrivateHooks(r,r,t,i),this.maybeAddNewHook(r))}),h.all(e,`[${this.binding(Ce)}], [data-phx-${Ce}]`,r=>{this.ownsElement(r)&&this.maybeAddNewHook(r)}),h.all(e,`[${this.binding(Et)}]`,r=>{this.ownsElement(r)&&this.maybeMounted(r)})}applyJoinPatch(e,t,i,r){this.attachTrueDocEl();let n=new ue(this,this.el,this.id,t,i,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(r),this.applyPendingUpdates(),e){let{kind:o,to:l}=e;this.liveSocket.historyPatch(l,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),r=i&&h.isIgnored(e,this.binding(Re));if(i&&!e.isEqualNode(t)&&!(r&&oi(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(Et)),i=t&&h.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),h.putPrivate(e,"mounted",!0))}maybeAddNewHook(e){let t=this.addHook(e);t&&t.__mounted()}performPatch(e,t,i=!1){let r=[],n=!1,o=new Set;return this.liveSocket.triggerDOM("onPatchStart",[e.targetContainer]),e.after("added",l=>{this.liveSocket.triggerDOM("onNodeAdded",[l]);let a=this.binding(Me),d=this.binding(Ue);h.maintainPrivateHooks(l,l,a,d),this.maybeAddNewHook(l),l.getAttribute&&this.maybeMounted(l)}),e.after("phxChildAdded",l=>{h.isPhxSticky(l)?this.liveSocket.joinRootViews():n=!0}),e.before("updated",(l,a)=>{this.triggerBeforeUpdateHook(l,a)&&o.add(l.id)}),e.after("updated",l=>{o.has(l.id)&&this.getHook(l).__updated()}),e.after("discarded",l=>{l.nodeType===Node.ELEMENT_NODE&&r.push(l)}),e.after("transitionsDiscarded",l=>this.afterElementsRemoved(l,t)),e.perform(i),this.afterElementsRemoved(r,t),this.liveSocket.triggerDOM("onPatchEnd",[e.targetContainer]),n}afterElementsRemoved(e,t){let i=[];e.forEach(r=>{let n=h.all(r,`[${$}]`),o=h.all(r,`[${this.binding(Ce)}], [data-phx-hook]`);n.concat(r).forEach(l=>{let a=this.componentID(l);W(a)&&i.indexOf(a)===-1&&i.push(a)}),o.concat(r).forEach(l=>{let a=this.getHook(l);a&&this.destroyHook(a)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){h.findPhxChildren(this.el,this.id).forEach(e=>this.joinChild(e))}maybeRecoverForms(e,t){let i=this.binding("change"),r=this.root.formsForRecovery,n=document.createElement("template");n.innerHTML=e;let o=n.content.firstElementChild;o.id=this.id,o.setAttribute(J,this.root.id),o.setAttribute(M,this.getSession()),o.setAttribute(te,this.getStatic()),o.setAttribute(ee,this.parent?this.parent.id:null);let l=h.all(n.content,"form").filter(a=>a.id&&r[a.id]).filter(a=>!this.pendingForms.has(a.id)).filter(a=>r[a.id].getAttribute(i)===a.getAttribute(i)).map(a=>[r[a.id],a]);if(l.length===0)return t();l.forEach(([a,d],f)=>{this.pendingForms.add(d.id),this.pushFormRecovery(a,d,n.content.firstElementChild,()=>{this.pendingForms.delete(d.id),f===l.length-1&&t()})})}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){var t;return e.id===this.id?this:(t=this.children[e.getAttribute(ee)])==null?void 0:t[e.id]}destroyDescendent(e){for(let t in this.root.children)for(let i in this.root.children[t])if(i===e)return this.root.children[t][i].destroy()}joinChild(e){if(!this.getChildById(e.id)){let i=new s(e,this.liveSocket,this);return this.root.children[this.id][i.id]=i,i.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(e){this.childJoins--,this.childJoins===0&&(this.parent?this.parent.ackJoin(this):this.onAllChildJoinsComplete())}onAllChildJoinsComplete(){this.pendingForms.clear(),this.formsForRecovery={},this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,t])=>{e.isDestroyed()||t()}),this.pendingJoinOps=[]})}update(e,t){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:t});this.rendered.mergeDiff(e);let i=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{h.findExistingParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(i=!0)})}):Lt(e)||this.liveSocket.time("full patch complete",()=>{let[r,n]=this.renderContainer(e,"update"),o=new ue(this,this.el,this.id,r,n,null);i=this.performPatch(o,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,r=e?this.rendered.componentCIDs(e):null,[n,o]=this.rendered.toString(r);return[`<${i}>${n}</${i}>`,o]})}componentPatch(e,t){if(Lt(e))return!1;let[i,r]=this.rendered.componentToString(t),n=new ue(this,this.el,this.id,i,r,t);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[Q.elementID(e)]}addHook(e){let t=Q.elementID(e);if(!(e.getAttribute&&!this.ownsElement(e)))if(t&&!this.viewHooks[t]){let i=h.getCustomElHook(e)||I(`no hook found for custom element: ${e.id}`);return this.viewHooks[t]=i,i.__attachView(this),i}else{if(t||!e.getAttribute)return;{let i=e.getAttribute(`data-phx-${Ce}`)||e.getAttribute(this.binding(Ce)),r=this.liveSocket.getHookCallbacks(i);if(r){e.id||I(`no DOM ID for hook "${i}". Hooks require a unique ID on each element.`,e);let n=new Q(this,e,r);return this.viewHooks[Q.elementID(n.el)]=n,n}else i!==null&&I(`unknown hook found for "${i}"`,e)}}}destroyHook(e){let t=Q.elementID(e.el);e.__destroyed(),e.__cleanup__(),delete this.viewHooks[t]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates())}eachChild(e){let t=this.root.children[this.id]||{};for(let i in t)e(this.getChildById(i))}onChannel(e,t){this.liveSocket.onChannel(this.channel,e,i=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>t(i)]):this.liveSocket.requestDOMUpdate(()=>t(i))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:t,events:i})=>this.update(t,i))})}),this.onChannel("redirect",({to:e,flash:t})=>this.onRedirect({to:e,flash:t})),this.onChannel("live_patch",e=>this.onLivePatch(e)),this.onChannel("live_redirect",e=>this.onLiveRedirect(e)),this.channel.onError(e=>this.onError(e)),this.channel.onClose(e=>this.onClose(e))}destroyAllChildren(){this.eachChild(e=>e.destroy())}onLiveRedirect(e){let{to:t,kind:i,flash:r}=e,n=this.expandURL(t),o=new CustomEvent("phx:server-navigate",{detail:{to:t,kind:i,flash:r}});this.liveSocket.historyRedirect(o,n,i,r)}onLivePatch(e){let{to:t,kind:i}=e;this.href=this.expandURL(t),this.liveSocket.historyPatch(t,i)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:t,reloadToken:i}){this.liveSocket.redirect(e,t,i)}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=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.wrapPush(()=>this.channel.join(),{ok:t=>this.liveSocket.requestDOMUpdate(()=>this.onJoin(t)),error:t=>this.onJoinError(t),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.root.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.root.href});return}if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);if(this.log("error",()=>["unable to join",e]),this.isMain())this.displayError([he,fe,ye]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this);else{this.joinAttempts>=Pt&&(this.root.displayError([he,fe,ye]),this.log("error",()=>[`giving up trying to mount after ${Pt} tries`,e]),this.destroy());let t=h.byId(this.el.id);t?(h.mergeAttrs(t,this.el),this.displayError([he,fe,ye]),this.el=t):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),document.activeElement&&document.activeElement.blur(),this.liveSocket.isUnloaded()&&this.showLoader(Qt)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([he,fe,ye]):this.displayError([he,fe,At]))}displayError(e){this.isMain()&&h.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(...e),this.execAll(this.binding("disconnected"))}wrapPush(e,t){let i=this.liveSocket.getLatencySim(),r=i?n=>setTimeout(()=>!this.isDestroyed()&&n(),i):n=>!this.isDestroyed()&&n();r(()=>{e().receive("ok",n=>r(()=>t.ok&&t.ok(n))).receive("error",n=>r(()=>t.error&&t.error(n))).receive("timeout",()=>r(()=>t.timeout&&t.timeout()))})}pushWithReply(e,t,i){if(!this.isConnected())return Promise.reject({error:"noconnection"});let[r,[n],o]=e?e():[null,[],{}],l=this.joinCount,a=function(){};return o.page_loading&&(a=this.liveSocket.withPageLoading({kind:"element",target:n})),typeof i.cid!="number"&&delete i.cid,new Promise((d,f)=>{this.wrapPush(()=>this.channel.push(t,i,ei),{ok:p=>{r!==null&&(this.lastAckRef=r);let m=g=>{p.redirect&&this.onRedirect(p.redirect),p.live_patch&&this.onLivePatch(p.live_patch),p.live_redirect&&this.onLiveRedirect(p.live_redirect),a(),d({resp:p,reply:g})};p.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",p.diff,({diff:g,reply:c,events:v})=>{r!==null&&this.undoRefs(r,i.event),this.update(g,v),m(c)})}):(r!==null&&this.undoRefs(r,i.event),m(null))},error:p=>f({error:p}),timeout:()=>{f({timeout:!0}),this.joinCount===l&&this.liveSocket.reloadWithJitter(this,()=>{this.log("timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}})})}undoRefs(e,t,i){if(!this.isConnected())return;let r=`[${O}="${this.refSrc()}"]`;i?(i=new Set(i),h.all(document,r,n=>{i&&!i.has(n)||(h.all(n,r,o=>this.undoElRef(o,e,t)),this.undoElRef(n,e,t))})):h.all(document,r,n=>this.undoElRef(n,e,t))}undoElRef(e,t,i){new De(e).maybeUndo(t,i,n=>{let o=new ue(this,e,this.id,n,[],null,{undoRef:t}),l=this.performPatch(o,!0);h.all(e,`[${O}="${this.refSrc()}"]`,a=>this.undoElRef(a,t,i)),l&&this.joinNewChildren()})}refSrc(){return this.el.id}putRef(e,t,i,r={}){let n=this.ref++,o=this.binding(_t);if(r.loading){let l=h.all(document,r.loading).map(a=>({el:a,lock:!0,loading:!0}));e=e.concat(l)}for(let{el:l,lock:a,loading:d}of e){if(!a&&!d)throw new Error("putRef requires lock or loading");if(l.setAttribute(O,this.refSrc()),d&&l.setAttribute(ae,n),a&&l.setAttribute(x,n),!d||r.submitter&&!(l===r.submitter||l===r.form))continue;let f=new Promise(c=>{l.addEventListener(`phx:undo-lock:${n}`,()=>c(g),{once:!0})}),p=new Promise(c=>{l.addEventListener(`phx:undo-loading:${n}`,()=>c(g),{once:!0})});l.classList.add(`phx-${i}-loading`);let m=l.getAttribute(o);m!==null&&(l.getAttribute(ke)||l.setAttribute(ke,l.innerText),m!==""&&(l.innerText=m),l.setAttribute(de,l.getAttribute(de)||l.disabled),l.setAttribute("disabled",""));let g={event:t,eventType:i,ref:n,isLoading:d,isLocked:a,lockElements:e.filter(({lock:c})=>c).map(({el:c})=>c),loadingElements:e.filter(({loading:c})=>c).map(({el:c})=>c),unlock:c=>{c=Array.isArray(c)?c:[c],this.undoRefs(n,t,c)},lockComplete:f,loadingComplete:p,lock:c=>new Promise(v=>{if(this.isAcked(n))return v(g);c.setAttribute(x,n),c.setAttribute(O,this.refSrc()),c.addEventListener(`phx:lock-stop:${n}`,()=>v(g),{once:!0})})};l.dispatchEvent(new CustomEvent("phx:push",{detail:g,bubbles:!0,cancelable:!1})),t&&l.dispatchEvent(new CustomEvent(`phx:push:${t}`,{detail:g,bubbles:!0,cancelable:!1}))}return[n,e.map(({el:l})=>l),r]}isAcked(e){return this.lastAckRef!==null&&this.lastAckRef>=e}componentID(e){let t=e.getAttribute&&e.getAttribute($);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(W(t))return t;let r=i.target||e.getAttribute(this.binding("target"));return W(r)?parseInt(r):t&&(r!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return W(e)?e:e?Y(e.closest(`[${$}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,r,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",i,r]),!1;let[o,l,a]=this.putRef([{el:e,loading:!0,lock:!0}],i,"hook");return this.pushWithReply(()=>[o,l,a],"event",{type:"hook",event:i,value:r,cid:this.closestComponentID(t)}).then(({resp:d,reply:f})=>n(f,o)),o}extractMeta(e,t,i){let r=this.binding("value-");for(let n=0;n<e.attributes.length;n++){t||(t={});let o=e.attributes[n].name;o.startsWith(r)&&(t[o.replace(r,"")]=e.getAttribute(o))}if(e.value!==void 0&&!(e instanceof HTMLFormElement)&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&rt.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let n in i)t[n]=i[n]}return t}pushEvent(e,t,i,r,n,o={},l){this.pushWithReply(()=>this.putRef([{el:t,loading:!0,lock:!0}],r,e,o),"event",{type:e,event:r,value:this.extractMeta(t,n,o.value),cid:this.targetComponentID(t,i,o)}).then(({reply:a})=>l&&l(a))}pushFileProgress(e,t,i,r=function(){}){this.liveSocket.withinOwners(e.form,(n,o)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(zt)),ref:e.getAttribute(B),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,o)}).then(({resp:l})=>r(l))})}pushInput(e,t,i,r,n,o){if(!e.form)throw new Error("form events require the input to be inside a form");let l,a=W(i)?i:this.targetComponentID(e.form,t,n),d=()=>this.putRef([{el:e,loading:!0,lock:!0},{el:e.form,loading:!0,lock:!0}],r,"change",n),f,p=this.extractMeta(e.form);e instanceof HTMLButtonElement&&(p.submitter=e),e.getAttribute(this.binding("change"))?f=ct(e.form,L({_target:n._target},p),[e.name]):f=ct(e.form,L({_target:n._target},p)),h.isUploadInput(e)&&e.files&&e.files.length>0&&C.trackFiles(e,Array.from(e.files)),l=C.serializeUploads(e);let m={type:"form",event:r,value:f,uploads:l,cid:a};this.pushWithReply(d,"event",m).then(({resp:g})=>{h.isUploadInput(e)&&h.isAutoUpload(e)?De.onUnlock(e,()=>{if(C.filesAwaitingPreflight(e).length>0){let[c,v]=d();this.undoRefs(c,r,[e.form]),this.uploadFiles(e.form,r,t,c,a,b=>{o&&o(g),this.triggerAwaitingSubmit(e.form,r),this.undoRefs(c,r)})}}):o&&o(g)})}triggerAwaitingSubmit(e,t){let i=this.getScheduledSubmit(e);if(i){let[r,n,o,l]=i;this.cancelSubmit(e,t),l()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,r,n])=>t.isSameNode(e))}scheduleSubmit(e,t,i,r){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,r])}cancelSubmit(e,t){this.formSubmits=this.formSubmits.filter(([i,r,n,o])=>i.isSameNode(e)?(this.undoRefs(r,t),!1):!0)}disableForm(e,t,i={}){let r=c=>!(ge(c,`${this.binding(Re)}=ignore`,c.form)||ge(c,"data-phx-update=ignore",c.form)),n=c=>c.hasAttribute(this.binding(_t)),o=c=>c.tagName=="BUTTON",l=c=>["INPUT","TEXTAREA","SELECT"].includes(c.tagName),a=Array.from(e.elements),d=a.filter(n),f=a.filter(o).filter(r),p=a.filter(l).filter(r);f.forEach(c=>{c.setAttribute(de,c.disabled),c.disabled=!0}),p.forEach(c=>{c.setAttribute(Xe,c.readOnly),c.readOnly=!0,c.files&&(c.setAttribute(de,c.disabled),c.disabled=!0)});let m=d.concat(f).concat(p).map(c=>({el:c,loading:!0,lock:!0})),g=[{el:e,loading:!0,lock:!1}].concat(m).reverse();return this.putRef(g,t,"submit",i)}pushFormSubmit(e,t,i,r,n,o){let l=()=>this.disableForm(e,i,Ne(L({},n),{form:e,submitter:r})),a=this.targetComponentID(e,t);if(C.hasUploadsInProgress(e)){let[d,f]=l(),p=()=>this.pushFormSubmit(e,t,i,r,n,o);return this.scheduleSubmit(e,d,n,p)}else if(C.inputsAwaitingPreflight(e).length>0){let[d,f]=l(),p=()=>[d,f,n];this.uploadFiles(e,i,t,d,a,m=>{if(C.inputsAwaitingPreflight(e).length>0)return this.undoRefs(d,i);let g=this.extractMeta(e),c=ct(e,L({submitter:r},g));this.pushWithReply(p,"event",{type:"form",event:i,value:c,cid:a}).then(({resp:v})=>o(v))})}else if(!(e.hasAttribute(O)&&e.classList.contains("phx-submit-loading"))){let d=this.extractMeta(e),f=ct(e,L({submitter:r},d));this.pushWithReply(l,"event",{type:"form",event:i,value:f,cid:a}).then(({resp:p})=>o(p))}}uploadFiles(e,t,i,r,n,o){let l=this.joinCount,a=C.activeFileInputs(e),d=a.length;a.forEach(f=>{let p=new C(f,this,()=>{d--,d===0&&o()}),m=p.entries().map(c=>c.toPreflightPayload());if(m.length===0){d--;return}let g={ref:f.getAttribute(B),entries:m,cid:this.targetComponentID(f.form,i)};this.log("upload",()=>["sending preflight request",g]),this.pushWithReply(null,"allow_upload",g).then(({resp:c})=>{if(this.log("upload",()=>["got preflight response",c]),p.entries().forEach(v=>{c.entries&&!c.entries[v.ref]&&this.handleFailedEntryPreflight(v.ref,"failed preflight",p)}),c.error||Object.keys(c.entries).length===0)this.undoRefs(r,t),(c.error||[]).map(([b,T])=>{this.handleFailedEntryPreflight(b,T,p)});else{let v=b=>{this.channel.onError(()=>{this.joinCount===l&&b()})};p.initAdapterUpload(c,v,this.liveSocket)}})})}handleFailedEntryPreflight(e,t,i){if(i.isAutoUpload()){let r=i.entries().find(n=>n.ref===e.toString());r&&r.cancel()}else i.entries().map(r=>r.cancel());this.log("upload",()=>[`error for entry ${e}`,t])}dispatchUploads(e,t,i){let r=this.targetCtxElement(e)||this.el,n=h.findUploadInputs(r).filter(o=>o.name===t);n.length===0?I(`no live file inputs found matching the name "${t}"`):n.length>1?I(`duplicate live file inputs found matching the name "${t}"`):h.dispatchEvent(n[0],tt,{detail:{files:i}})}targetCtxElement(e){if(W(e)){let[t]=h.findComponentNodeList(this.el,e);return t}else return e||null}pushFormRecovery(e,t,i,r){let n=this.binding("change"),o=t.getAttribute(this.binding("target"))||t,l=t.getAttribute(this.binding(wt))||t.getAttribute(this.binding("change")),a=Array.from(e.elements).filter(p=>h.isFormInput(p)&&p.name&&!p.hasAttribute(n));if(a.length===0)return;a.forEach(p=>p.hasAttribute(B)&&C.clearFiles(p));let d=a.find(p=>p.type!=="hidden")||a[0],f=0;this.withinTargets(o,(p,m)=>{let g=this.targetComponentID(t,m);f++;let c=new CustomEvent("phx:form-recovery",{detail:{sourceElement:e}});y.exec(c,"change",l,this,d,["push",{_target:d.name,targetView:p,targetCtx:m,newCid:g,callback:()=>{f--,f===0&&r()}}])},i,i)}pushLinkPatch(e,t,i,r){let n=this.liveSocket.setPendingLink(t),o=e.isTrusted&&e.type!=="popstate",l=i?()=>this.putRef([{el:i,loading:o,lock:!0}],null,"click"):null,a=()=>this.liveSocket.redirect(window.location.href),d=t.startsWith("/")?`${location.protocol}//${location.host}${t}`:t;this.pushWithReply(l,"live_patch",{url:d}).then(({resp:f})=>{this.liveSocket.requestDOMUpdate(()=>{f.link_redirect?this.liveSocket.replaceMain(t,null,r,n):(this.liveSocket.commitPendingLink(n)&&(this.href=t),this.applyPendingUpdates(),r&&r(n))})},({error:f,timeout:p})=>a())}getFormsForRecovery(){if(this.joinCount===0)return{};let e=this.binding("change");return h.all(this.el,`form[${e}]`).filter(t=>t.id).filter(t=>t.elements.length>0).filter(t=>t.getAttribute(this.binding(wt))!=="ignore").map(t=>t.cloneNode(!0)).reduce((t,i)=>(t[i.id]=i,t),{})}maybePushComponentsDestroyed(e){let t=e.filter(i=>h.findComponentNodeList(this.el,i).length===0);t.length>0&&(t.forEach(i=>this.rendered.resetRender(i)),this.pushWithReply(null,"cids_will_destroy",{cids:t}).then(()=>{this.liveSocket.requestDOMUpdate(()=>{let i=t.filter(r=>h.findComponentNodeList(this.el,r).length===0);i.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:i}).then(({resp:r})=>{this.rendered.pruneCIDs(r.cids)})})}))}ownsElement(e){let t=e.closest(K);return e.getAttribute(ee)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,r,n={}){h.putPrivate(e,me,!0),Array.from(e.elements).forEach(l=>h.putPrivate(l,me,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,r,n,()=>{this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}};var wi=s=>h.isUsedInput(s),qe=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(`
|
|
10
10
|
a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example:
|
|
11
11
|
|
|
12
12
|
import {Socket} from "phoenix"
|
|
13
13
|
import {LiveSocket} from "phoenix_live_view"
|
|
14
14
|
let liveSocket = new LiveSocket("/live", Socket, {...})
|
|
15
|
-
`);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||Zt,this.opts=i,this.params=Le(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(Oe(ti),i.defaults||{}),this.activeElement=null,this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=Oe(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Yt,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||10,this.reloadJitterMin=i.reloadJitterMin||5e3,this.reloadJitterMax=i.reloadJitterMax||1e4,this.failsafeJitter=i.failsafeJitter||3e4,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.boundEventNames=new Set,this.serverCloseRef=null,this.domCallbacks=Object.assign({jsQuerySelectorAll:null,onPatchStart:Le(),onPatchEnd:Le(),onNodeAdded:Le(),onBeforeElUpdated:Le()},i.dom||{}),this.transitions=new Ft,this.currentHistoryPosition=parseInt(this.sessionStorage.getItem(Be))||0,window.addEventListener("pagehide",r=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}version(){return"1.0.3"}isProfileEnabled(){return this.sessionStorage.getItem(ot)==="true"}isDebugEnabled(){return this.sessionStorage.getItem($e)==="true"}isDebugDisabled(){return this.sessionStorage.getItem($e)==="false"}enableDebug(){this.sessionStorage.setItem($e,"true")}enableProfiling(){this.sessionStorage.setItem(ot,"true")}disableDebug(){this.sessionStorage.setItem($e,"false")}disableProfiling(){this.sessionStorage.removeItem(ot)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(lt,e)}disableLatencySim(){this.sessionStorage.removeItem(lt)}getLatencySim(){let e=this.sessionStorage.getItem(lt);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let e=()=>{this.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?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.serverCloseRef&&(this.socket.off(this.serverCloseRef),this.serverCloseRef=null),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){let r=new CustomEvent("phx:exec",{detail:{sourceElement:e}});this.owner(e,n=>y.exec(r,i,t,n,e))}execJSHookPush(e,t,i,r){this.withinOwners(e,n=>{let o=new CustomEvent("phx:exec",{detail:{sourceElement:e}});y.exec(o,"hook",t,n,e,["push",{data:i,callback:r}])})}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(e,t){this.domCallbacks[e](...t)}time(e,t){if(!this.isProfileEnabled()||!console.time)return t();console.time(e);let i=t();return console.timeEnd(e),i}log(e,t,i){if(this.viewLogger){let[r,n]=i();this.viewLogger(e,t,r,n)}else if(this.isDebugEnabled()){let[r,n]=i();ni(e,t,r,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,r=>{let n=this.getLatencySim();n?setTimeout(()=>i(r),n):i(r)})}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,r=this.reloadJitterMax,n=Math.floor(Math.random()*(r-i+1))+i,o=H.updateLocal(this.localStorage,window.location.pathname,Qe,0,l=>l+1);o>=this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{e.isDestroyed()||e.isConnected()||(e.destroy(),t?t():this.log(e,"join",()=>[`encountered ${o} consecutive reloads`]),o>=this.maxReloads&&this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?ci[e.split(".")[1]]:this.hooks[e]}isUnloaded(){return this.unloaded}isConnected(){return this.socket.isConnected()}getBindingPrefix(){return this.bindingPrefix}binding(e){return`${this.getBindingPrefix()}${e}`}channel(e,t){return this.socket.channel(e,t)}joinDeadView(){let e=document.body;if(e&&!this.isPhxView(e)&&!this.isPhxView(document.firstElementChild)){let t=this.newRootView(e);t.setHref(this.getHref()),t.joinDead(),this.main||(this.main=t),window.requestAnimationFrame(()=>{var i;t.execNewMounted(),this.maybeScroll((i=history.state)==null?void 0:i.scroll)})}}joinRootViews(){let e=!1;return h.all(document,`${K}:not([${ee}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);h.isPhxSticky(t)||i.setHref(this.getHref()),i.join(),t.hasAttribute(Pe)&&(this.main=i)}e=!0}),e}redirect(e,t,i){i&&H.setCookie(yt,i,60),this.unload(),H.redirect(e,t)}replaceMain(e,t,i=null,r=this.setPendingLink(e)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=h.all(this.outgoingMainEl,`[${this.binding("remove")}]`),l=h.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(l,t,n),this.main.setRedirect(e),this.transitionRemoves(o,!0),this.main.join((a,d)=>{a===1&&this.commitPendingLink(r)&&this.requestDOMUpdate(()=>{o.forEach(f=>f.remove()),h.findPhxSticky(document).forEach(f=>l.appendChild(f)),this.outgoingMainEl.replaceWith(l),this.outgoingMainEl=null,i&&i(r),d()})})}transitionRemoves(e,t,i){let r=this.binding("remove");if(t){let o=h.findPhxSticky(document)||[];e=e.filter(l=>!h.isChildOfAny(l,o))}let n=o=>{o.preventDefault(),o.stopImmediatePropagation()};e.forEach(o=>{for(let l of this.boundEventNames)o.addEventListener(l,n,!0);this.execJS(o,o.getAttribute(r),"remove")}),this.requestDOMUpdate(()=>{e.forEach(o=>{for(let l of this.boundEventNames)o.removeEventListener(l,n,!0)}),i&&i()})}isPhxView(e){return e.getAttribute&&e.getAttribute(M)!==null}newRootView(e,t,i){let r=new Ae(e,this,null,t,i);return this.roots[r.id]=r,r}owner(e,t){let i=Y(e.closest(K),r=>this.getViewByEl(r))||this.main;return i&&t?t(i):i}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(J);return Y(this.getRootById(t),i=>i.getDescendentByEl(e))}getRootById(e){return this.roots[e]}destroyAllViews(){for(let e in this.roots)this.roots[e].destroy(),delete this.roots[e];this.main=null}destroyViewByEl(e){let t=this.getRootById(e.getAttribute(J));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}getActiveElement(){return document.activeElement}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents({dead:e}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.serverCloseRef=this.socket.onClose(t=>{if(t&&t.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",t=>{t.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),e||this.bindNav(),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(t,i,r,n,o,l)=>{let a=n.getAttribute(this.binding(Gt)),d=t.key&&t.key.toLowerCase();if(a&&a.toLowerCase()!==d)return;let f=L({key:t.key},this.eventMeta(i,t,n));y.exec(t,i,o,r,n,["push",{data:f}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,r,n,o,l)=>{if(!l){let a=L({key:t.key},this.eventMeta(i,t,n));y.exec(t,i,o,r,n,["push",{data:a}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,r,n,o,l)=>{if(l==="window"){let a=this.eventMeta(i,t,n);y.exec(t,i,o,r,n,["push",{data:a}])}}),this.on("dragover",t=>t.preventDefault()),this.on("drop",t=>{t.preventDefault();let i=Y(ge(t.target,this.binding(gt)),o=>o.getAttribute(this.binding(gt))),r=i&&document.getElementById(i),n=Array.from(t.dataTransfer.files||[]);!r||r.disabled||n.length===0||!(r.files instanceof FileList)||(C.trackFiles(r,n,t.dataTransfer),r.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(tt,t=>{let i=t.target;if(!h.isUploadInput(i))return;let r=Array.from(t.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);C.trackFiles(i,r),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let r=this.metadataCallbacks[e];return r?r(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.resetReloadStatus(),this.linkRef}resetReloadStatus(){H.deleteCookie(yt)}commitPendingLink(e){return this.linkRef!==e?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(e,t){for(let i in e){let r=e[i];this.on(r,n=>{let o=this.binding(i),l=this.binding(`window-${i}`),a=n.target.getAttribute&&n.target.getAttribute(o);a?this.debounce(n.target,n,r,()=>{this.withinOwners(n.target,d=>{t(n,i,d,n.target,a,null)})}):h.all(document,`[${l}]`,d=>{let f=d.getAttribute(l);this.debounce(d,n,r,()=>{this.withinOwners(d,p=>{t(n,i,p,d,f,"window")})})})})}}bindClicks(){this.on("mousedown",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click")}bindClick(e,t){let i=this.binding(t);window.addEventListener(e,r=>{let n=null;r.detail===0&&(this.clickStartedAtTarget=r.target);let o=this.clickStartedAtTarget||r.target;n=ge(r.target,i),this.dispatchClickAway(r,o),this.clickStartedAtTarget=null;let l=n&&n.getAttribute(i);if(!l){h.isNewPageClick(r,window.location)&&this.unload();return}n.getAttribute("href")==="#"&&r.preventDefault(),!n.hasAttribute(O)&&this.debounce(n,r,"click",()=>{this.withinOwners(n,a=>{y.exec(r,"click",l,a,n,["push",{data:this.eventMeta("click",r,n)}])})})},!1)}dispatchClickAway(e,t){let i=this.binding("click-away");h.all(document,`[${i}]`,r=>{r.isSameNode(t)||r.contains(t)||this.withinOwners(r,n=>{let o=r.getAttribute(i);y.isVisible(r)&&y.isInViewport(r)&&y.exec(e,"click",o,n,r,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!H.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{H.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,backType:r,id:n,scroll:o,position:l}=t.state||{},a=window.location.href,d=l>this.currentHistoryPosition;i=d?i:r||i,this.currentHistoryPosition=l||0,this.sessionStorage.setItem(Be,this.currentHistoryPosition.toString()),h.dispatchEvent(window,"phx:navigate",{detail:{href:a,patch:i==="patch",pop:!0,direction:d?"forward":"backward"}}),this.requestDOMUpdate(()=>{let f=()=>{this.maybeScroll(o)};this.main.isConnected()&&i==="patch"&&n===this.main.id?this.main.pushLinkPatch(t,a,null,f):this.replaceMain(a,null,f)})},!1),window.addEventListener("click",t=>{let i=ge(t.target,et),r=i&&i.getAttribute(et);if(!r||!this.isConnected()||!this.main||h.wantsNewTab(t))return;let n=i.href instanceof SVGAnimatedString?i.href.baseVal:i.href,o=i.getAttribute(Vt);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==n&&this.requestDOMUpdate(()=>{if(r==="patch")this.pushHistoryPatch(t,n,o,i);else if(r==="redirect")this.historyRedirect(t,n,o,null,i);else throw new Error(`expected ${et} to be "patch" or "redirect", got: ${r}`);let l=i.getAttribute(this.binding("click"));l&&this.requestDOMUpdate(()=>this.execJS(i,l,"click"))})},!1)}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i,r){if(!this.isConnected()||!this.main.isMain())return H.redirect(t);this.withPageLoading({to:t,kind:"patch"},n=>{this.main.pushLinkPatch(e,t,r,o=>{this.historyPatch(t,i,o),n()})})}historyPatch(e,t,i=this.setPendingLink(e)){this.commitPendingLink(i)&&(this.currentHistoryPosition++,this.sessionStorage.setItem(Be,this.currentHistoryPosition.toString()),H.updateCurrentState(r=>Ne(L({},r),{backType:"patch"})),H.pushState(t,{type:"patch",id:this.main.id,position:this.currentHistoryPosition},e),h.dispatchEvent(window,"phx:navigate",{detail:{patch:!0,href:e,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location))}historyRedirect(e,t,i,r,n){if(n&&e.isTrusted&&e.type!=="popstate"&&n.classList.add("phx-click-loading"),!this.isConnected()||!this.main.isMain())return H.redirect(t,r);if(/^\/$|^\/[^\/]+.*$/.test(t)){let{protocol:l,host:a}=window.location;t=`${l}//${a}${t}`}let o=window.scrollY;this.withPageLoading({to:t,kind:"redirect"},l=>{this.replaceMain(t,r,a=>{a===this.linkRef&&(this.currentHistoryPosition++,this.sessionStorage.setItem(Be,this.currentHistoryPosition.toString()),H.updateCurrentState(d=>Ne(L({},d),{backType:"redirect"})),H.pushState(i,{type:"redirect",id:this.main.id,scroll:o,position:this.currentHistoryPosition},t),h.dispatchEvent(window,"phx:navigate",{detail:{href:t,patch:!1,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location)),l()})})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=Oe(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{let r=i.target.getAttribute(this.binding("submit")),n=i.target.getAttribute(this.binding("change"));!t&&n&&!r&&(t=!0,i.preventDefault(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>{h.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))}),this.on("submit",i=>{let r=i.target.getAttribute(this.binding("submit"));if(!r){h.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{y.exec(i,"submit",r,n,i.target,["push",{submitter:i.submitter}])})});for(let i of["change","input"])this.on(i,r=>{if(r instanceof CustomEvent&&r.target.form===void 0){if(r.detail&&r.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"),o=r.target;if(r.isComposing){let u=`composition-listener-${i}`;h.private(o,u)||(h.putPrivate(o,u,!0),o.addEventListener("compositionend",()=>{o.dispatchEvent(new Event(i,{bubbles:!0})),h.deletePrivate(o,u)},{once:!0}));return}let l=o.getAttribute(n),a=o.form&&o.form.getAttribute(n),d=l||a;if(!d||o.type==="number"&&o.validity&&o.validity.badInput)return;let f=l?o:o.form,p=e;e++;let{at:m,type:g}=h.private(o,"prev-iteration")||{};m===p-1&&i==="change"&&g==="input"||(h.putPrivate(o,"prev-iteration",{at:p,type:i}),this.debounce(o,r,i,()=>{this.withinOwners(f,u=>{h.putPrivate(o,pe,!0),y.exec(r,"change",d,u,o,["push",{_target:r.target.name,dispatcher:f}])})}))});this.on("reset",i=>{let r=i.target;h.resetForm(r);let n=Array.from(r.elements).find(o=>o.type==="reset");n&&window.requestAnimationFrame(()=>{n.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,t,i,r){if(i==="blur"||i==="focusout")return r();let n=this.binding(qt),o=this.binding(Kt),l=this.defaults.debounce.toString(),a=this.defaults.throttle.toString();this.withinOwners(e,d=>{let f=()=>!d.isDestroyed()&&document.body.contains(e);h.debounce(e,t,n,l,o,a,f,()=>{r()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){this.boundEventNames.add(e),window.addEventListener(e,i=>{this.silenced||t(i)})}jsQuerySelectorAll(e,t,i){let r=this.domCallbacks.jsQuerySelectorAll;return r?r(e,t,i):i()}},Ft=class{constructor(){this.transitions=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let r=setTimeout(()=>{this.transitions.delete(r),i(),this.flushPendingOps()},e);this.transitions.add(r)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){if(this.size()>0)return;let e=this.pendingOps.shift();e&&(e(),this.flushPendingOps())}};var rs=(s,e={})=>{let t=h.getCustomElHook(s);if(t)return t;let i=new Q(Ae.closestView(s),s,e);return h.putCustomElHook(s,i),i};return Ti(ns);})();
|
|
15
|
+
`);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||Zt,this.opts=i,this.params=Le(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(Oe(ti),i.defaults||{}),this.activeElement=null,this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=Oe(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Yt,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||10,this.reloadJitterMin=i.reloadJitterMin||5e3,this.reloadJitterMax=i.reloadJitterMax||1e4,this.failsafeJitter=i.failsafeJitter||3e4,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.boundEventNames=new Set,this.serverCloseRef=null,this.domCallbacks=Object.assign({jsQuerySelectorAll:null,onPatchStart:Le(),onPatchEnd:Le(),onNodeAdded:Le(),onBeforeElUpdated:Le()},i.dom||{}),this.transitions=new Ft,this.currentHistoryPosition=parseInt(this.sessionStorage.getItem(Be))||0,window.addEventListener("pagehide",r=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}version(){return"1.0.4"}isProfileEnabled(){return this.sessionStorage.getItem(ot)==="true"}isDebugEnabled(){return this.sessionStorage.getItem($e)==="true"}isDebugDisabled(){return this.sessionStorage.getItem($e)==="false"}enableDebug(){this.sessionStorage.setItem($e,"true")}enableProfiling(){this.sessionStorage.setItem(ot,"true")}disableDebug(){this.sessionStorage.setItem($e,"false")}disableProfiling(){this.sessionStorage.removeItem(ot)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(lt,e)}disableLatencySim(){this.sessionStorage.removeItem(lt)}getLatencySim(){let e=this.sessionStorage.getItem(lt);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let e=()=>{this.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?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.serverCloseRef&&(this.socket.off(this.serverCloseRef),this.serverCloseRef=null),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){let r=new CustomEvent("phx:exec",{detail:{sourceElement:e}});this.owner(e,n=>y.exec(r,i,t,n,e))}execJSHookPush(e,t,i,r){this.withinOwners(e,n=>{let o=new CustomEvent("phx:exec",{detail:{sourceElement:e}});y.exec(o,"hook",t,n,e,["push",{data:i,callback:r}])})}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(e,t){this.domCallbacks[e](...t)}time(e,t){if(!this.isProfileEnabled()||!console.time)return t();console.time(e);let i=t();return console.timeEnd(e),i}log(e,t,i){if(this.viewLogger){let[r,n]=i();this.viewLogger(e,t,r,n)}else if(this.isDebugEnabled()){let[r,n]=i();ni(e,t,r,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,r=>{let n=this.getLatencySim();n?setTimeout(()=>i(r),n):i(r)})}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,r=this.reloadJitterMax,n=Math.floor(Math.random()*(r-i+1))+i,o=H.updateLocal(this.localStorage,window.location.pathname,Qe,0,l=>l+1);o>=this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{e.isDestroyed()||e.isConnected()||(e.destroy(),t?t():this.log(e,"join",()=>[`encountered ${o} consecutive reloads`]),o>=this.maxReloads&&this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?ui[e.split(".")[1]]:this.hooks[e]}isUnloaded(){return this.unloaded}isConnected(){return this.socket.isConnected()}getBindingPrefix(){return this.bindingPrefix}binding(e){return`${this.getBindingPrefix()}${e}`}channel(e,t){return this.socket.channel(e,t)}joinDeadView(){let e=document.body;if(e&&!this.isPhxView(e)&&!this.isPhxView(document.firstElementChild)){let t=this.newRootView(e);t.setHref(this.getHref()),t.joinDead(),this.main||(this.main=t),window.requestAnimationFrame(()=>{var i;t.execNewMounted(),this.maybeScroll((i=history.state)==null?void 0:i.scroll)})}}joinRootViews(){let e=!1;return h.all(document,`${K}:not([${ee}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);h.isPhxSticky(t)||i.setHref(this.getHref()),i.join(),t.hasAttribute(Pe)&&(this.main=i)}e=!0}),e}redirect(e,t,i){i&&H.setCookie(yt,i,60),this.unload(),H.redirect(e,t)}replaceMain(e,t,i=null,r=this.setPendingLink(e)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=h.findPhxSticky(document)||[],l=h.all(this.outgoingMainEl,`[${this.binding("remove")}]`).filter(d=>!h.isChildOfAny(d,o)),a=h.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(a,t,n),this.main.setRedirect(e),this.transitionRemoves(l),this.main.join((d,f)=>{d===1&&this.commitPendingLink(r)&&this.requestDOMUpdate(()=>{l.forEach(p=>p.remove()),o.forEach(p=>a.appendChild(p)),this.outgoingMainEl.replaceWith(a),this.outgoingMainEl=null,i&&i(r),f()})})}transitionRemoves(e,t){let i=this.binding("remove"),r=n=>{n.preventDefault(),n.stopImmediatePropagation()};e.forEach(n=>{for(let o of this.boundEventNames)n.addEventListener(o,r,!0);this.execJS(n,n.getAttribute(i),"remove")}),this.requestDOMUpdate(()=>{e.forEach(n=>{for(let o of this.boundEventNames)n.removeEventListener(o,r,!0)}),t&&t()})}isPhxView(e){return e.getAttribute&&e.getAttribute(M)!==null}newRootView(e,t,i){let r=new Ae(e,this,null,t,i);return this.roots[r.id]=r,r}owner(e,t){let i=Y(e.closest(K),r=>this.getViewByEl(r))||this.main;return i&&t?t(i):i}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(J);return Y(this.getRootById(t),i=>i.getDescendentByEl(e))}getRootById(e){return this.roots[e]}destroyAllViews(){for(let e in this.roots)this.roots[e].destroy(),delete this.roots[e];this.main=null}destroyViewByEl(e){let t=this.getRootById(e.getAttribute(J));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}getActiveElement(){return document.activeElement}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents({dead:e}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.serverCloseRef=this.socket.onClose(t=>{if(t&&t.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",t=>{t.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),e||this.bindNav(),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(t,i,r,n,o,l)=>{let a=n.getAttribute(this.binding(Gt)),d=t.key&&t.key.toLowerCase();if(a&&a.toLowerCase()!==d)return;let f=L({key:t.key},this.eventMeta(i,t,n));y.exec(t,i,o,r,n,["push",{data:f}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,r,n,o,l)=>{if(!l){let a=L({key:t.key},this.eventMeta(i,t,n));y.exec(t,i,o,r,n,["push",{data:a}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,r,n,o,l)=>{if(l==="window"){let a=this.eventMeta(i,t,n);y.exec(t,i,o,r,n,["push",{data:a}])}}),this.on("dragover",t=>t.preventDefault()),this.on("drop",t=>{t.preventDefault();let i=Y(ge(t.target,this.binding(gt)),o=>o.getAttribute(this.binding(gt))),r=i&&document.getElementById(i),n=Array.from(t.dataTransfer.files||[]);!r||r.disabled||n.length===0||!(r.files instanceof FileList)||(C.trackFiles(r,n,t.dataTransfer),r.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(tt,t=>{let i=t.target;if(!h.isUploadInput(i))return;let r=Array.from(t.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);C.trackFiles(i,r),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let r=this.metadataCallbacks[e];return r?r(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.resetReloadStatus(),this.linkRef}resetReloadStatus(){H.deleteCookie(yt)}commitPendingLink(e){return this.linkRef!==e?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(e,t){for(let i in e){let r=e[i];this.on(r,n=>{let o=this.binding(i),l=this.binding(`window-${i}`),a=n.target.getAttribute&&n.target.getAttribute(o);a?this.debounce(n.target,n,r,()=>{this.withinOwners(n.target,d=>{t(n,i,d,n.target,a,null)})}):h.all(document,`[${l}]`,d=>{let f=d.getAttribute(l);this.debounce(d,n,r,()=>{this.withinOwners(d,p=>{t(n,i,p,d,f,"window")})})})})}}bindClicks(){this.on("mousedown",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click")}bindClick(e,t){let i=this.binding(t);window.addEventListener(e,r=>{let n=null;r.detail===0&&(this.clickStartedAtTarget=r.target);let o=this.clickStartedAtTarget||r.target;n=ge(r.target,i),this.dispatchClickAway(r,o),this.clickStartedAtTarget=null;let l=n&&n.getAttribute(i);if(!l){h.isNewPageClick(r,window.location)&&this.unload();return}n.getAttribute("href")==="#"&&r.preventDefault(),!n.hasAttribute(O)&&this.debounce(n,r,"click",()=>{this.withinOwners(n,a=>{y.exec(r,"click",l,a,n,["push",{data:this.eventMeta("click",r,n)}])})})},!1)}dispatchClickAway(e,t){let i=this.binding("click-away");h.all(document,`[${i}]`,r=>{r.isSameNode(t)||r.contains(t)||this.withinOwners(r,n=>{let o=r.getAttribute(i);y.isVisible(r)&&y.isInViewport(r)&&y.exec(e,"click",o,n,r,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!H.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{H.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,backType:r,id:n,scroll:o,position:l}=t.state||{},a=window.location.href,d=l>this.currentHistoryPosition;i=d?i:r||i,this.currentHistoryPosition=l||0,this.sessionStorage.setItem(Be,this.currentHistoryPosition.toString()),h.dispatchEvent(window,"phx:navigate",{detail:{href:a,patch:i==="patch",pop:!0,direction:d?"forward":"backward"}}),this.requestDOMUpdate(()=>{let f=()=>{this.maybeScroll(o)};this.main.isConnected()&&i==="patch"&&n===this.main.id?this.main.pushLinkPatch(t,a,null,f):this.replaceMain(a,null,f)})},!1),window.addEventListener("click",t=>{let i=ge(t.target,et),r=i&&i.getAttribute(et);if(!r||!this.isConnected()||!this.main||h.wantsNewTab(t))return;let n=i.href instanceof SVGAnimatedString?i.href.baseVal:i.href,o=i.getAttribute(Vt);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==n&&this.requestDOMUpdate(()=>{if(r==="patch")this.pushHistoryPatch(t,n,o,i);else if(r==="redirect")this.historyRedirect(t,n,o,null,i);else throw new Error(`expected ${et} to be "patch" or "redirect", got: ${r}`);let l=i.getAttribute(this.binding("click"));l&&this.requestDOMUpdate(()=>this.execJS(i,l,"click"))})},!1)}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i,r){if(!this.isConnected()||!this.main.isMain())return H.redirect(t);this.withPageLoading({to:t,kind:"patch"},n=>{this.main.pushLinkPatch(e,t,r,o=>{this.historyPatch(t,i,o),n()})})}historyPatch(e,t,i=this.setPendingLink(e)){this.commitPendingLink(i)&&(this.currentHistoryPosition++,this.sessionStorage.setItem(Be,this.currentHistoryPosition.toString()),H.updateCurrentState(r=>Ne(L({},r),{backType:"patch"})),H.pushState(t,{type:"patch",id:this.main.id,position:this.currentHistoryPosition},e),h.dispatchEvent(window,"phx:navigate",{detail:{patch:!0,href:e,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location))}historyRedirect(e,t,i,r,n){let o=n&&e.isTrusted&&e.type!=="popstate";if(o&&n.classList.add("phx-click-loading"),!this.isConnected()||!this.main.isMain())return H.redirect(t,r);if(/^\/$|^\/[^\/]+.*$/.test(t)){let{protocol:a,host:d}=window.location;t=`${a}//${d}${t}`}let l=window.scrollY;this.withPageLoading({to:t,kind:"redirect"},a=>{this.replaceMain(t,r,d=>{d===this.linkRef&&(this.currentHistoryPosition++,this.sessionStorage.setItem(Be,this.currentHistoryPosition.toString()),H.updateCurrentState(f=>Ne(L({},f),{backType:"redirect"})),H.pushState(i,{type:"redirect",id:this.main.id,scroll:l,position:this.currentHistoryPosition},t),h.dispatchEvent(window,"phx:navigate",{detail:{href:t,patch:!1,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location)),o&&n.classList.remove("phx-click-loading"),a()})})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=Oe(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{let r=i.target.getAttribute(this.binding("submit")),n=i.target.getAttribute(this.binding("change"));!t&&n&&!r&&(t=!0,i.preventDefault(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>{h.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))}),this.on("submit",i=>{let r=i.target.getAttribute(this.binding("submit"));if(!r){h.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{y.exec(i,"submit",r,n,i.target,["push",{submitter:i.submitter}])})});for(let i of["change","input"])this.on(i,r=>{if(r instanceof CustomEvent&&r.target.form===void 0){if(r.detail&&r.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"),o=r.target;if(r.isComposing){let c=`composition-listener-${i}`;h.private(o,c)||(h.putPrivate(o,c,!0),o.addEventListener("compositionend",()=>{o.dispatchEvent(new Event(i,{bubbles:!0})),h.deletePrivate(o,c)},{once:!0}));return}let l=o.getAttribute(n),a=o.form&&o.form.getAttribute(n),d=l||a;if(!d||o.type==="number"&&o.validity&&o.validity.badInput)return;let f=l?o:o.form,p=e;e++;let{at:m,type:g}=h.private(o,"prev-iteration")||{};m===p-1&&i==="change"&&g==="input"||(h.putPrivate(o,"prev-iteration",{at:p,type:i}),this.debounce(o,r,i,()=>{this.withinOwners(f,c=>{h.putPrivate(o,pe,!0),y.exec(r,"change",d,c,o,["push",{_target:r.target.name,dispatcher:f}])})}))});this.on("reset",i=>{let r=i.target;h.resetForm(r);let n=Array.from(r.elements).find(o=>o.type==="reset");n&&window.requestAnimationFrame(()=>{n.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,t,i,r){if(i==="blur"||i==="focusout")return r();let n=this.binding(qt),o=this.binding(Kt),l=this.defaults.debounce.toString(),a=this.defaults.throttle.toString();this.withinOwners(e,d=>{let f=()=>!d.isDestroyed()&&document.body.contains(e);h.debounce(e,t,n,l,o,a,f,()=>{r()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){this.boundEventNames.add(e),window.addEventListener(e,i=>{this.silenced||t(i)})}jsQuerySelectorAll(e,t,i){let r=this.domCallbacks.jsQuerySelectorAll;return r?r(e,t,i):i()}},Ft=class{constructor(){this.transitions=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let r=setTimeout(()=>{this.transitions.delete(r),i(),this.flushPendingOps()},e);this.transitions.add(r)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){if(this.size()>0)return;let e=this.pendingOps.shift();e&&(e(),this.flushPendingOps())}};var rs=(s,e={})=>{let t=h.getCustomElHook(s);if(t)return t;let i=new Q(Ae.closestView(s),s,e);return h.putCustomElHook(s,i),i};return Ti(ns);})();
|