phoenix_live_view 1.2.0-rc.3 → 1.2.0
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/README.md +5 -5
- package/assets/js/phoenix_live_view/README.md +1 -1
- package/assets/js/phoenix_live_view/index.ts +2 -2
- package/assets/js/phoenix_live_view/live_socket.ts +5 -5
- package/assets/js/phoenix_live_view/view.ts +4 -0
- package/assets/js/phoenix_live_view/view_hook.ts +22 -14
- package/package.json +1 -1
- package/priv/static/phoenix_live_view.cjs.js +8 -5
- package/priv/static/phoenix_live_view.cjs.js.map +2 -2
- package/priv/static/phoenix_live_view.esm.js +8 -5
- package/priv/static/phoenix_live_view.esm.js.map +2 -2
- package/priv/static/phoenix_live_view.js +8 -5
- package/priv/static/phoenix_live_view.min.js +6 -6
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var LiveView=(()=>{var ct=Object.defineProperty,Ni=Object.defineProperties,Ui=Object.getOwnPropertyDescriptor,Xi=Object.getOwnPropertyDescriptors,$i=Object.getOwnPropertyNames,Qt=Object.getOwnPropertySymbols;var ei=Object.prototype.hasOwnProperty,Vi=Object.prototype.propertyIsEnumerable;var Zt=(s,e,t)=>e in s?ct(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,D=(s,e)=>{for(var t in e||(e={}))ei.call(e,t)&&Zt(s,t,e[t]);if(Qt)for(var t of Qt(e))Vi.call(e,t)&&Zt(s,t,e[t]);return s},le=(s,e)=>Ni(s,Xi(e));var Bi=(s,e)=>{for(var t in e)ct(s,t,{get:e[t],enumerable:!0})},ji=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $i(e))!ei.call(s,n)&&n!==t&&ct(s,n,{get:()=>e[n],enumerable:!(i=Ui(e,n))||i.enumerable});return s};var Ji=s=>ji(ct({},"__esModule",{value:!0}),s);var _n={};Bi(_n,{LiveSocket:()=>at,ViewHook:()=>Q,createHook:()=>Tn,getFileURLForUpload:()=>wn,isUsedInput:()=>Mi});var ht="consecutive-reloads";var ut=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],ft="phx-drop-target-active",K="data-phx-component",de="data-phx-view",pt="data-phx-link",ti="track-static",Pt="data-phx-link-state",ve="data-phx-ref-loading",U="data-phx-ref-src",C="data-phx-ref-lock",Ct="phx-pending-refs",mt="track-uploads",G="data-phx-upload-ref",He="data-phx-preflighted-refs",ii="data-phx-done-refs",qe="drop-target",Ge="data-phx-active-refs",Ie="phx:live-file:updated",gt="data-phx-skip",ze="data-phx-id",Rt="data-phx-prune",xt="phx-connected",be="phx-loading",ke="phx-error",Lt="phx-client-error",Oe="phx-server-error",ne="data-phx-parent-id",De="data-phx-main",z="data-phx-root-id",Ye="viewport-top",Qe="viewport-bottom",ni="viewport-overrun-target",si="trigger-action",Te="phx-has-focused",ri=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],vt=["checkbox","radio"],we="phx-has-submitted",q="data-phx-session",ce=`[${q}]`,Ze="data-phx-sticky",se="data-phx-static",et="data-phx-readonly",Ee="data-phx-disabled",Ht="disable-with",Me="data-phx-disable-with-restore",Fe="hook",oi="debounce",ai="throttle",Ne="update",Ue="stream",Xe="data-phx-stream",$e="data-phx-portal",re="data-phx-teleported",Z="data-phx-teleported-src",Ve="data-phx-runtime-hook",li="data-phx-pid",di="key",ee="phxPrivate",It="auto-recover",Ot="no-unused-field",tt="phx:live-socket:debug",bt="phx:live-socket:profiling",Et="phx:live-socket:latency-sim",it="phx:nav-history-position",ci="progress",Dt="mounted",Mt="__phoenix_reload_status__",hi=1,Ft=3,ui=200,fi=500,pi="phx-",mi=3e4;var Be="debounce-trigger",je="throttled",Nt="debounce-prev-key",gi={debounce:300,throttle:300},Ut=[ve,U,C],Y="s",yt="r",$="c",x="k",te="kc",Xt="e",$t="r",Vt="t",he="p",_e="stream";var nt=class{constructor(e,t,i){let{chunk_size:n,chunk_timeout:r}=t;this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=n,this.chunkTimeout=r,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,this.chunkTimer!=null&&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",({reason: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=>{var n,r;if(((n=i.target)==null?void 0:n.error)===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return T("Read error: "+((r=i.target)==null?void 0:r.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 T=(s,e)=>console.error&&console.error(s,e),Bt=(s,e)=>{let t;try{t=new URL(s,window.location.href)}catch(i){throw new Error(`expected ${e} destination to be a valid URL, got: ${s}`)}if(t.origin!==window.location.origin)throw new Error(`cannot ${e} to "${s}" because its origin does not match the current origin "${window.location.origin}". Use window.location directly for cross-origin navigation.`)},oe=s=>{let e=typeof s;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(s)};function vi(){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 bi(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 Ei=(s,e,t,i)=>{s.liveSocket.isDebugEnabled()&&console.log(`${s.id} ${e}: ${t} - `,i)},Je=s=>typeof s=="function"?s:function(){return s},We=s=>JSON.parse(JSON.stringify(s)),ue=(s,e,t)=>{let i=s;do{if(i.matches(`[${e}]`)&&!("disabled"in i&&i.disabled))return i;i=i.parentElement}while(i!==null&&i.nodeType===1&&!(t&&t.isSameNode(i)||i.matches(ce)));return null},Pe=s=>s!==null&&typeof s=="object"&&!(s instanceof Array),yi=(s,e)=>JSON.stringify(s)===JSON.stringify(e),jt=s=>{for(let e in s)return!1;return!0},fe=(s,e)=>s&&e(s),Ai=function(s,e,t,i){s.forEach(n=>{new nt(n,t.config,i).upload()})},Si=s=>{if(s.dataTransfer.types){for(let e=0;e<s.dataTransfer.types.length;e++)if(s.dataTransfer.types[e]==="Files")return!0}return!1};var Wi={canPushState(){return typeof history.pushState!="undefined"},dropLocal(s,e,t){return s.removeItem(this.localKey(e,t))},updateLocal(s,e,t,i,n){let r=this.getLocal(s,e,t),o=this.localKey(e,t),a=r===null?i:n(r);return s.setItem(o,JSON.stringify(a)),a},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 t&&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=null,t=i=>{window.location.href=i}){e&&this.setCookie("__phoenix_flash__",e,60),t(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}"]`)}},V=Wi;var Ce={byId(s){return document.getElementById(s)||T(`no id found for ${s}`)},elementFromTarget(s){return s instanceof Node?s.nodeType===Node.ELEMENT_NODE?s:s.parentElement:null},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(G)!==null},isAutoUpload(s){return s.hasAttribute("data-phx-auto-upload")},findUploadInputs(s){let e=s.id,t=this.all(document,`input[type="file"][${G}][form="${e}"]`);return this.all(s,`input[type="file"][${G}]`).concat(t)},findComponent(s,e,t=document){return t.querySelector(`[${de}="${s}"][${K}="${e}"]`)},getComponent(s,e,t=document){let i=this.findComponent(s,e,t);if(!i)throw new Error(`no component found matching viewId ${s} and cid ${e}`);return i},isPhxDestroyed(s){return!!(s.id&&Ce.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",n=s.target.hasAttribute("target")&&!s.target.getAttribute("target").startsWith("_");return e||i||t||n},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(n){try{i=new URL(t,e)}catch(r){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(q,""),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,`[${Ze}]`)},findPhxChildren(s,e){return this.all(s,`${ce}[${ne}="${e}"]`)},findExistingParentCIDs(s,e){let t=new Set,i=new Set;return e.forEach(n=>{this.all(document,`[${de}="${s}"][${K}="${n}"]`).forEach(r=>{t.add(n),this.all(r,`[${de}="${s}"][${K}]`).map(o=>parseInt(o.getAttribute(K))).forEach(o=>i.add(o))})}),i.forEach(n=>t.delete(n)),t},private(s,e){return s[ee]&&s[ee][e]},deletePrivate(s,e){s[ee]&&delete s[ee][e]},putPrivate(s,e,t){s[ee]||(s[ee]={}),s[ee][e]=t},updatePrivate(s,e,t,i){let n=this.private(s,e);n===void 0?this.putPrivate(s,e,i(t)):this.putPrivate(s,e,i(n))},syncPendingAttrs(s,e){s.hasAttribute(U)&&(ut.forEach(t=>{s.classList.contains(t)&&e.classList.add(t)}),Ut.filter(t=>s.hasAttribute(t)).forEach(t=>{e.setAttribute(t,s.getAttribute(t))}))},copyPrivates(s,e){e[ee]&&(s[ee]=e[ee])},putTitle(s){let e=document.querySelector("title");if(e){let{prefix:t,suffix:i,default:n}=e.dataset,r=typeof s!="string"||s.trim()==="";if(r&&typeof n!="string")return;let o=r?n:s;document.title=`${t||""}${o||""}${i||""}`}else document.title=s},debounce(s,e,t,i,n,r,o,a){let l=s.getAttribute(t),c=s.getAttribute(n);l===""&&(l=i),c===""&&(c=r);let u=l||c;switch(u){case null:return a();case"blur":this.incCycle(s,"debounce-blur-cycle",()=>{o()&&a()}),this.once(s,"debounce-blur")&&s.addEventListener("blur",()=>this.triggerCycle(s,"debounce-blur-cycle"));return;default:let p=parseInt(u),m=()=>c?this.deletePrivate(s,je):a(),g=this.incCycle(s,Be,m);if(isNaN(p))return T(`invalid throttle/debounce value: ${u}`);if(c){let v=!1;if(e.type==="keydown"){let E=this.private(s,Nt);this.putPrivate(s,Nt,e.key),v=E!==e.key}if(!v&&this.private(s,je))return!1;{a();let E=setTimeout(()=>{o()&&this.triggerCycle(s,Be)},p);this.putPrivate(s,je,E)}}else setTimeout(()=>{o()&&this.triggerCycle(s,Be,g)},p);let h=s.form;h&&this.once(h,"bind-debounce")&&h.addEventListener("submit",()=>{Array.from(new FormData(h).entries(),([v])=>{let E=h.elements.namedItem(v),M=E instanceof RadioNodeList?E[0]:E;M&&(this.incCycle(M,Be),this.deletePrivate(M,je))})}),this.once(s,"bind-debounce")&&s.addEventListener("blur",()=>{clearTimeout(this.private(s,je)),this.triggerCycle(s,Be)})}},triggerCycle(s,e,t){let[i,n]=this.private(s,e);t||(t=i),t===i&&(this.incCycle(s,e),n())},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 ct=Object.defineProperty,Ni=Object.defineProperties,Ui=Object.getOwnPropertyDescriptor,Xi=Object.getOwnPropertyDescriptors,$i=Object.getOwnPropertyNames,Qt=Object.getOwnPropertySymbols;var ei=Object.prototype.hasOwnProperty,Vi=Object.prototype.propertyIsEnumerable;var Zt=(s,e,t)=>e in s?ct(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,D=(s,e)=>{for(var t in e||(e={}))ei.call(e,t)&&Zt(s,t,e[t]);if(Qt)for(var t of Qt(e))Vi.call(e,t)&&Zt(s,t,e[t]);return s},le=(s,e)=>Ni(s,Xi(e));var Bi=(s,e)=>{for(var t in e)ct(s,t,{get:e[t],enumerable:!0})},Ji=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $i(e))!ei.call(s,n)&&n!==t&&ct(s,n,{get:()=>e[n],enumerable:!(i=Ui(e,n))||i.enumerable});return s};var ji=s=>Ji(ct({},"__esModule",{value:!0}),s);var _n={};Bi(_n,{LiveSocket:()=>at,ViewHook:()=>Q,createHook:()=>wn,getFileURLForUpload:()=>Tn,isUsedInput:()=>Mi});var ht="consecutive-reloads";var ut=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],ft="phx-drop-target-active",K="data-phx-component",de="data-phx-view",pt="data-phx-link",ti="track-static",Pt="data-phx-link-state",ve="data-phx-ref-loading",U="data-phx-ref-src",C="data-phx-ref-lock",Ct="phx-pending-refs",mt="track-uploads",G="data-phx-upload-ref",He="data-phx-preflighted-refs",ii="data-phx-done-refs",qe="drop-target",Ge="data-phx-active-refs",Ie="phx:live-file:updated",gt="data-phx-skip",ze="data-phx-id",Rt="data-phx-prune",xt="phx-connected",Ee="phx-loading",ke="phx-error",Lt="phx-client-error",Oe="phx-server-error",ne="data-phx-parent-id",De="data-phx-main",z="data-phx-root-id",Ye="viewport-top",Qe="viewport-bottom",ni="viewport-overrun-target",si="trigger-action",we="phx-has-focused",ri=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],vt=["checkbox","radio"],Te="phx-has-submitted",q="data-phx-session",ce=`[${q}]`,Ze="data-phx-sticky",se="data-phx-static",et="data-phx-readonly",be="data-phx-disabled",Ht="disable-with",Me="data-phx-disable-with-restore",Fe="hook",oi="debounce",ai="throttle",Ne="update",Ue="stream",Xe="data-phx-stream",$e="data-phx-portal",re="data-phx-teleported",Z="data-phx-teleported-src",Ve="data-phx-runtime-hook",li="data-phx-pid",di="key",ee="phxPrivate",It="auto-recover",Ot="no-unused-field",tt="phx:live-socket:debug",Et="phx:live-socket:profiling",bt="phx:live-socket:latency-sim",it="phx:nav-history-position",ci="progress",Dt="mounted",Mt="__phoenix_reload_status__",hi=1,Ft=3,ui=200,fi=500,pi="phx-",mi=3e4;var Be="debounce-trigger",Je="throttled",Nt="debounce-prev-key",gi={debounce:300,throttle:300},Ut=[ve,U,C],Y="s",yt="r",$="c",x="k",te="kc",Xt="e",$t="r",Vt="t",he="p",_e="stream";var nt=class{constructor(e,t,i){let{chunk_size:n,chunk_timeout:r}=t;this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=n,this.chunkTimeout=r,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,this.chunkTimer!=null&&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",({reason: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=>{var n,r;if(((n=i.target)==null?void 0:n.error)===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return w("Read error: "+((r=i.target)==null?void 0:r.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 w=(s,e)=>console.error&&console.error(s,e),Bt=(s,e)=>{let t;try{t=new URL(s,window.location.href)}catch(i){throw new Error(`expected ${e} destination to be a valid URL, got: ${s}`)}if(t.origin!==window.location.origin)throw new Error(`cannot ${e} to "${s}" because its origin does not match the current origin "${window.location.origin}". Use window.location directly for cross-origin navigation.`)},oe=s=>{let e=typeof s;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(s)};function vi(){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 Ei(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 bi=(s,e,t,i)=>{s.liveSocket.isDebugEnabled()&&console.log(`${s.id} ${e}: ${t} - `,i)},je=s=>typeof s=="function"?s:function(){return s},We=s=>JSON.parse(JSON.stringify(s)),ue=(s,e,t)=>{let i=s;do{if(i.matches(`[${e}]`)&&!("disabled"in i&&i.disabled))return i;i=i.parentElement}while(i!==null&&i.nodeType===1&&!(t&&t.isSameNode(i)||i.matches(ce)));return null},Pe=s=>s!==null&&typeof s=="object"&&!(s instanceof Array),yi=(s,e)=>JSON.stringify(s)===JSON.stringify(e),Jt=s=>{for(let e in s)return!1;return!0},fe=(s,e)=>s&&e(s),Ai=function(s,e,t,i){s.forEach(n=>{new nt(n,t.config,i).upload()})},Si=s=>{if(s.dataTransfer.types){for(let e=0;e<s.dataTransfer.types.length;e++)if(s.dataTransfer.types[e]==="Files")return!0}return!1};var Wi={canPushState(){return typeof history.pushState!="undefined"},dropLocal(s,e,t){return s.removeItem(this.localKey(e,t))},updateLocal(s,e,t,i,n){let r=this.getLocal(s,e,t),o=this.localKey(e,t),a=r===null?i:n(r);return s.setItem(o,JSON.stringify(a)),a},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 t&&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=null,t=i=>{window.location.href=i}){e&&this.setCookie("__phoenix_flash__",e,60),t(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}"]`)}},V=Wi;var Ce={byId(s){return document.getElementById(s)||w(`no id found for ${s}`)},elementFromTarget(s){return s instanceof Node?s.nodeType===Node.ELEMENT_NODE?s:s.parentElement:null},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(G)!==null},isAutoUpload(s){return s.hasAttribute("data-phx-auto-upload")},findUploadInputs(s){let e=s.id,t=this.all(document,`input[type="file"][${G}][form="${e}"]`);return this.all(s,`input[type="file"][${G}]`).concat(t)},findComponent(s,e,t=document){return t.querySelector(`[${de}="${s}"][${K}="${e}"]`)},getComponent(s,e,t=document){let i=this.findComponent(s,e,t);if(!i)throw new Error(`no component found matching viewId ${s} and cid ${e}`);return i},isPhxDestroyed(s){return!!(s.id&&Ce.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",n=s.target.hasAttribute("target")&&!s.target.getAttribute("target").startsWith("_");return e||i||t||n},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(n){try{i=new URL(t,e)}catch(r){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(q,""),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,`[${Ze}]`)},findPhxChildren(s,e){return this.all(s,`${ce}[${ne}="${e}"]`)},findExistingParentCIDs(s,e){let t=new Set,i=new Set;return e.forEach(n=>{this.all(document,`[${de}="${s}"][${K}="${n}"]`).forEach(r=>{t.add(n),this.all(r,`[${de}="${s}"][${K}]`).map(o=>parseInt(o.getAttribute(K))).forEach(o=>i.add(o))})}),i.forEach(n=>t.delete(n)),t},private(s,e){return s[ee]&&s[ee][e]},deletePrivate(s,e){s[ee]&&delete s[ee][e]},putPrivate(s,e,t){s[ee]||(s[ee]={}),s[ee][e]=t},updatePrivate(s,e,t,i){let n=this.private(s,e);n===void 0?this.putPrivate(s,e,i(t)):this.putPrivate(s,e,i(n))},syncPendingAttrs(s,e){s.hasAttribute(U)&&(ut.forEach(t=>{s.classList.contains(t)&&e.classList.add(t)}),Ut.filter(t=>s.hasAttribute(t)).forEach(t=>{e.setAttribute(t,s.getAttribute(t))}))},copyPrivates(s,e){e[ee]&&(s[ee]=e[ee])},putTitle(s){let e=document.querySelector("title");if(e){let{prefix:t,suffix:i,default:n}=e.dataset,r=typeof s!="string"||s.trim()==="";if(r&&typeof n!="string")return;let o=r?n:s;document.title=`${t||""}${o||""}${i||""}`}else document.title=s},debounce(s,e,t,i,n,r,o,a){let l=s.getAttribute(t),c=s.getAttribute(n);l===""&&(l=i),c===""&&(c=r);let u=l||c;switch(u){case null:return a();case"blur":this.incCycle(s,"debounce-blur-cycle",()=>{o()&&a()}),this.once(s,"debounce-blur")&&s.addEventListener("blur",()=>this.triggerCycle(s,"debounce-blur-cycle"));return;default:let p=parseInt(u),m=()=>c?this.deletePrivate(s,Je):a(),g=this.incCycle(s,Be,m);if(isNaN(p))return w(`invalid throttle/debounce value: ${u}`);if(c){let v=!1;if(e.type==="keydown"){let b=this.private(s,Nt);this.putPrivate(s,Nt,e.key),v=b!==e.key}if(!v&&this.private(s,Je))return!1;{a();let b=setTimeout(()=>{o()&&this.triggerCycle(s,Be)},p);this.putPrivate(s,Je,b)}}else setTimeout(()=>{o()&&this.triggerCycle(s,Be,g)},p);let h=s.form;h&&this.once(h,"bind-debounce")&&h.addEventListener("submit",()=>{Array.from(new FormData(h).entries(),([v])=>{let b=h.elements.namedItem(v),M=b instanceof RadioNodeList?b[0]:b;M&&(this.incCycle(M,Be),this.deletePrivate(M,Je))})}),this.once(s,"bind-debounce")&&s.addEventListener("blur",()=>{clearTimeout(this.private(s,Je)),this.triggerCycle(s,Be)})}},triggerCycle(s,e,t){let[i,n]=this.private(s,e);t||(t=i),t===i&&(this.incCycle(s,e),n())},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
|
-
`),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,
|
|
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,we)||this.private(s,Te))},resetForm(s){Array.from(s.elements).forEach(e=>{this.deletePrivate(e,we),this.deletePrivate(e,Te)})},isPhxChild(s){return s.getAttribute&&s.getAttribute(ne)},isPhxSticky(s){return s.getAttribute&&s.getAttribute(Ze)!==null},isChildOfAny(s,e){return!!e.find(t=>t.contains(s))},firstPhxChild(s){return this.isPhxChild(s)?s:this.all(s,`[${ne}]`)[0]},isPortalTemplate(s){return s.tagName==="TEMPLATE"&&s.hasAttribute($e)},closestViewEl(s){let e=s.closest(`[${re}],${ce}`);return e?e.hasAttribute(re)?this.byId(e.getAttribute(re)):e.hasAttribute(q)?e:null:null},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||{}},a=e==="click"?new MouseEvent("click",o):new CustomEvent(e,o);s.dispatchEvent(a)},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={}){var a;let i=new Set(t.exclude||[]),n=t.isIgnored,r=e.attributes;for(let l=r.length-1;l>=0;l--){let c=r[l].name;if(i.has(c)){if(c==="value"){let u=(a=e.value)!=null?a:e.getAttribute(c);s.value===u&&s.setAttribute("value",e.getAttribute(c))}}else{let u=e.getAttribute(c);s.getAttribute(c)!==u&&(!n||n&&c.startsWith("data-"))&&s.setAttribute(c,u)}}let o=s.attributes;for(let l=o.length-1;l>=0;l--){let c=o[l].name;n?c.startsWith("data-")&&!e.hasAttribute(c)&&!Ut.includes(c)&&s.removeAttribute(c):e.hasAttribute(c)||s.removeAttribute(c)}},mergeFocusedInput(s,e){s instanceof HTMLSelectElement||Ce.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(),!Ce.isTextualInput(s))return;s.matches(":focus")||s.focus(),this.hasSelectionRange(s)&&s.setSelectionRange(e,t)},isEditableInput(s){return this.isFormAssociated(s)&&!(s instanceof HTMLButtonElement)&&!(s instanceof HTMLInputElement&&s.type==="button")},isFormAssociated(s){if(!(s instanceof HTMLElement))return!1;if(s.localName){let e=customElements.get(s.localName);if(e)return e.formAssociated===!0}return s instanceof HTMLInputElement||s instanceof HTMLSelectElement||s instanceof HTMLTextAreaElement||s instanceof HTMLButtonElement},syncAttrsToProps(s){s instanceof HTMLInputElement&&vt.indexOf(s.type.toLocaleLowerCase())>=0&&(s.checked=s.getAttribute("checked")!==null)},isTextualInput(s){return ri.indexOf(s.type)>=0},isNowTriggerFormExternal(s,e){return s.getAttribute&&s.getAttribute(e)!==null&&document.body.contains(s)},cleanChildNodes(s,e){if(Ce.isPhxUpdate(s,e,["append","prepend",Ue])){let t=[];s.childNodes.forEach(i=>{(!("id"in i)||!i.id)&&(!(i.nodeType===Node.TEXT_NODE&&i.nodeValue&&i.nodeValue.trim()==="")&&i.nodeType!==Node.COMMENT_NODE&&w(`only HTML element tags with an id are allowed inside containers with phx-update.
|
|
5
5
|
|
|
6
6
|
removing illegal node: "${("outerHTML"in i&&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",q,se,De,z]);if(s.tagName.toLowerCase()===e.toLowerCase())return Array.from(s.attributes).filter(n=>!i.has(n.name.toLowerCase())).forEach(n=>s.removeAttribute(n.name)),Object.keys(t).filter(n=>!i.has(n.toLowerCase())).forEach(n=>s.setAttribute(n,t[n])),s;{let n=document.createElement(e);return Object.keys(t).forEach(r=>n.setAttribute(r,t[r])),i.forEach(r=>{let o=s.getAttribute(r);o!==null&&n.setAttribute(r,o)}),n.innerHTML=s.innerHTML,s.replaceWith(n),n}},getSticky(s,e,t){let i=(Ce.private(s,"sticky")||[]).find(([n])=>e===n);if(i){let[n,r,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(s,e){this.updatePrivate(s,"sticky",[],t=>t.filter(([i,n])=>i!==e))},putSticky(s,e,t){let i=t(s);this.updatePrivate(s,"sticky",[],n=>{let r=n.findIndex(([o])=>e===o);return r>=0?n[r]=[e,t,i]:n.push([e,t,i]),n})},applyStickyOperations(s){let e=Ce.private(s,"sticky");e&&e.forEach(([t,i,n])=>this.putSticky(s,t,i))},isLocked(s){return s.hasAttribute&&s.hasAttribute(C)},attributeIgnored(s,e){return e.some(t=>s.name==t||t==="*"||t.includes("*")&&s.name.match(t)!=null)}},d=Ce;var pe=class{static isActive(e,t){let i=t._phxRef===void 0,r=e.getAttribute(Ge).split(",").indexOf(R.genFileRef(t))>=0;return t.size>0&&(i||r)}static isPreflighted(e,t){return e.getAttribute(He).split(",").indexOf(R.genFileRef(t))>=0&&this.isActive(e,t)}static isPreflightInProgress(e){return e._preflightInProgress===!0}static markPreflightInProgress(e){e._preflightInProgress=!0}constructor(e,t,i,n){this.ref=R.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(Ie,this._onElUpdated),this.autoUpload=n}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,()=>{R.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(Ie,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),this.isAutoUpload()||R.clearFiles(this.fileEl)}isAutoUpload(){return this.autoUpload}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(Ie,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(Ge).split(",").indexOf(this.ref)===-1&&(R.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]||T(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:Ai}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||T(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var Ki=0,R=class s{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(Ki++).toString(),e._phxRef)}static getEntryDataURL(e,t){let i=this.activeFiles(e).find(n=>this.genFileRef(n)===t);return i?URL.createObjectURL(i):null}static hasUploadsInProgress(e){let t=0;return d.findUploadInputs(e).forEach(i=>{i.getAttribute(He)!==i.getAttribute(ii)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(n=>{let r={path:e.name},o=e.getAttribute(G);i[o]=i[o]||[],r.ref=this.genFileRef(n),r.last_modified=n.lastModified,r.name=n.name||r.ref,r.relative_path=n.webkitRelativePath,r.type=n.type,r.size=n.size,typeof n.meta=="function"&&(r.meta=n.meta()),i[o].push(r)}),i}static clearFiles(e){e.value=null,e.removeAttribute(G),d.putPrivate(e,"files",[])}static untrackFile(e,t){d.putPrivate(e,"files",d.private(e,"files").filter(i=>!Object.is(i,t)))}static trackFiles(e,t,i){if(e.getAttribute("multiple")!==null){let n=t.filter(r=>!this.activeFiles(e).find(o=>Object.is(o,r)));d.updatePrivate(e,"files",[],r=>r.concat(n)),e.value=""}else i&&i.files.length>0&&(e.files=i.files),d.putPrivate(e,"files",t)}static activeFileInputs(e){let t=d.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(d.private(e,"files")||[]).filter(t=>pe.isActive(e,t))}static inputsAwaitingPreflight(e){let t=d.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!pe.isPreflighted(e,t)&&!pe.isPreflightInProgress(t))}static markPreflightInProgress(e){e.forEach(t=>pe.markPreflightInProgress(t.file))}constructor(e,t,i){this.autoUpload=d.isAutoUpload(e),this.view=t,this.onComplete=i,this._entries=Array.from(s.filesAwaitingPreflight(e)||[]).map(n=>new pe(e,n,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(r=>(r.isCancelled()?(this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()):(r.zipPostFlight(e),r.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()})),r));let n=this._entries.reduce((r,o)=>{if(!o.meta)return r;let{name:a,callback:l}=o.uploader(i.uploaders);return r[a]=r[a]||{callback:l,entries:[]},r[a].entries.push(o),r},{});for(let r in n){let{callback:o,entries:a}=n[r];o(a,t,e,i)}}};var qi={anyOf(s,e){return e.some(t=>s instanceof t)},isFocusable(s,e=!1){return s instanceof HTMLAnchorElement&&s.rel!=="ignore"||s instanceof HTMLAreaElement&&s.href!==void 0||!("disabled"in s&&s.disabled)&&this.anyOf(s,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||s instanceof HTMLIFrameElement||s instanceof HTMLElement&&s.tabIndex>=0&&s.getAttribute("aria-hidden")!=="true"||!e&&s.getAttribute("tabindex")!==null&&s.getAttribute("aria-hidden")!=="true"},attemptFocus(s,e=!1){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))return!0;e=e.nextElementSibling}return!1},focusFirst(s){let e=s.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}return!1},focusLast(s){let e=s.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}return!1}},B=qi;var wi=s=>["HTML","BODY"].indexOf(s.nodeName.toUpperCase())>=0?null:["scroll","auto"].indexOf(getComputedStyle(s).overflowY)>=0?s:wi(s.parentElement),ki=s=>s?s.scrollTop:document.documentElement.scrollTop||document.body.scrollTop,Jt=s=>s?s.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight,Wt=s=>s?s.getBoundingClientRect().top:0,Gi=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.top)>=Wt(e)&&Math.floor(t.top)<=Jt(e)},zi=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.bottom)>=Wt(e)&&Math.floor(t.bottom)<=Jt(e)},Ti=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.top)>=Wt(e)&&Math.floor(t.top)<=Jt(e)},Yi={mounted(){this.scrollContainer=wi(this.el);let s=ki(this.scrollContainer),e=!1,t=500,i=null,n=this.throttle(t,(a,l)=>{i=()=>!0,this.liveSocket.js().push(this.el,a,{value:{id:l.id,_overran:!0},callback:()=>{i=null}})}),r=this.throttle(t,(a,l)=>{i=()=>l.scrollIntoView({block:"start"}),this.liveSocket.js().push(this.el,a,{value:{id:l.id},callback:()=>{i=null,window.requestAnimationFrame(()=>{Ti(l,this.scrollContainer)||l.scrollIntoView({block:"start"})})}})}),o=this.throttle(t,(a,l)=>{i=()=>l.scrollIntoView({block:"end"}),this.liveSocket.js().push(this.el,a,{value:{id:l.id},callback:()=>{i=null,window.requestAnimationFrame(()=>{Ti(l,this.scrollContainer)||l.scrollIntoView({block:"end"})})}})});this.onScroll=a=>{let l=ki(this.scrollContainer);if(i)return s=l,i();let c=this.findOverrunTarget(),u=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,h=l<s,v=l>s;h&&u&&!e&&c.top>=0?(e=!0,n(u,g)):v&&e&&c.top<=0&&(e=!1),u&&h&&g&&Gi(g,this.scrollContainer)?r(u,g):p&&v&&m&&zi(m,this.scrollContainer)&&o(p,m),s=l},this.scrollContainer?this.scrollContainer.addEventListener("scroll",this.onScroll):window.addEventListener("scroll",this.onScroll)},updated(){this.scrollContainer&&!this.scrollContainer.isConnected&&(this.destroyed(),this.mounted())},destroyed(){this.scrollContainer?this.scrollContainer.removeEventListener("scroll",this.onScroll):window.removeEventListener("scroll",this.onScroll)},throttle(s,e){let t=0,i;return(...n)=>{let r=Date.now(),o=s-(r-t);o<=0||o>s?(i&&(clearTimeout(i),i=null),t=r,e(...n)):i||(i=setTimeout(()=>{t=Date.now(),i=null,e(...n)},o))}},findOverrunTarget(){let s,e=this.el.getAttribute(this.liveSocket.binding(ni));if(e){let t=document.getElementById(e);if(t)s=t.getBoundingClientRect();else throw new Error("did not find element with id "+e)}else s=this.el.getBoundingClientRect();return s}},Qi={activeRefs(){return this.el.getAttribute(Ge)},preflightedRefs(){return this.el.getAttribute(He)},mounted(){this.js().ignoreAttributes(this.el,["value"]),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=""),this.el.dispatchEvent(new CustomEvent(Ie))}},Zi={mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(G)),this.url=R.getEntryDataURL(this.inputEl,this.ref),this.el.src=this.url},destroyed(){URL.revokeObjectURL(this.url)}},en={LiveFileUpload:Qi,LiveImgPreview:Zi,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;B.attemptFocus(e)||B.focusFirst(e)}else B.focusLast(this.el)}),this.focusEnd.addEventListener("focus",s=>{if(!s.relatedTarget||!this.el.contains(s.relatedTarget)){let e=s.target.previousElementSibling;B.attemptFocus(e)||B.focusLast(e)}else B.focusFirst(this.el)}),this.el.contains(document.activeElement)||(this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&B.focusFirst(this.el))}},InfiniteScroll:Yi},_i=en;var ye=class{static onUnlock(e,t){if(!d.isLocked(e)&&!e.closest(`[${C}]`))return t();let i=e.closest(`[${C}]`),n=i.closest(`[${C}]`).getAttribute(C);i.addEventListener(`phx:undo-lock:${n}`,()=>{t()},{once:!0})}constructor(e){this.el=e,this.loadingRef=e.hasAttribute(ve)?parseInt(e.getAttribute(ve),10):null,this.lockRef=e.hasAttribute(C)?parseInt(e.getAttribute(C),10):null}maybeUndo(e,t,i){if(!this.isWithin(e)){d.updatePrivate(this.el,Ct,[],n=>(n.push(e),n));return}this.undoLocks(e,t,i),this.undoLoading(e,t),d.updatePrivate(this.el,Ct,[],n=>n.filter(r=>{let o={detail:{ref:r,event:t},bubbles:!0,cancelable:!1};return this.loadingRef&&this.loadingRef>r&&this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${r}`,o)),this.lockRef&&this.lockRef>r&&this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${r}`,o)),r>e})),this.isFullyResolvedBy(e)&&this.el.removeAttribute(U)}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 n=d.private(this.el,C);n&&(i(n),d.deletePrivate(this.el,C)),this.el.removeAttribute(C);let r={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${this.lockRef}`,r))}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(ve);let i=this.el.getAttribute(Ee),n=this.el.getAttribute(et);n!==null&&"readOnly"in this.el&&(this.el.readOnly=n==="true",this.el.removeAttribute(et)),i!==null&&"disabled"in this.el&&(this.el.disabled=i==="true",this.el.removeAttribute(Ee));let r=this.el.getAttribute(Me);r!==null&&(this.el.textContent=r,this.el.removeAttribute(Me));let o={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${this.loadingRef}`,o))}ut.forEach(i=>{(i!=="phx-submit-loading"||this.canUndoLoading(e))&&d.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 st=class{constructor(e,t,i){let n=new Set,r=new Set([...t.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(n.add(a.id),r.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...r].filter(a=>!n.has(a))}perform(){let e=d.byId(this.containerId);e&&(this.elementsToModify.forEach(t=>{t.previousElementId?fe(document.getElementById(t.previousElementId),i=>{fe(document.getElementById(t.elementId),n=>{n.previousElementSibling&&n.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",n)})}):fe(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{fe(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))}))}};var Pi=11;function tn(s,e){var t=e.attributes,i,n,r,o,a;if(!(e.nodeType===Pi||s.nodeType===Pi)){for(var l=t.length-1;l>=0;l--)i=t[l],n=i.name,r=i.namespaceURI,o=i.value,r?(n=i.localName||n,a=s.getAttributeNS(r,n),a!==o&&(i.prefix==="xmlns"&&(n=i.name),s.setAttributeNS(r,n,o))):(a=s.getAttribute(n),a!==o&&s.setAttribute(n,o));for(var c=s.attributes,u=c.length-1;u>=0;u--)i=c[u],n=i.name,r=i.namespaceURI,r?(n=i.localName||n,e.hasAttributeNS(r,n)||s.removeAttributeNS(r,n)):e.hasAttribute(n)||s.removeAttribute(n)}}var At,nn="http://www.w3.org/1999/xhtml",j=typeof document=="undefined"?void 0:document,sn=!!j&&"content"in j.createElement("template"),rn=!!j&&j.createRange&&"createContextualFragment"in j.createRange();function on(s){var e=j.createElement("template");return e.innerHTML=s,e.content.childNodes[0]}function an(s){At||(At=j.createRange(),At.selectNode(j.body));var e=At.createContextualFragment(s);return e.childNodes[0]}function ln(s){var e=j.createElement("body");return e.innerHTML=s,e.childNodes[0]}function dn(s){return s=s.trim(),sn?on(s):rn?an(s):ln(s)}function St(s,e){var t=s.nodeName,i=e.nodeName,n,r;return t===i?!0:(n=t.charCodeAt(0),r=i.charCodeAt(0),n<=90&&r>=97?t===i.toUpperCase():r<=90&&n>=97?i===t.toUpperCase():!1)}function cn(s,e){return!e||e===nn?j.createElement(s):j.createElementNS(e,s)}function hn(s,e){for(var t=s.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function Kt(s,e,t){s[t]!==e[t]&&(s[t]=e[t],s[t]?s.setAttribute(t,""):s.removeAttribute(t))}var Ci={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)}Kt(s,e,"selected")},INPUT:function(s,e){Kt(s,e,"checked"),Kt(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 n=i.nodeValue;if(n==t||!t&&n==s.placeholder)return;i.nodeValue=t}},SELECT:function(s,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,n=s.firstChild,r,o;n;)if(o=n.nodeName&&n.nodeName.toUpperCase(),o==="OPTGROUP")r=n,n=r.firstChild,n||(n=r.nextSibling,r=null);else{if(o==="OPTION"){if(n.hasAttribute("selected")){t=i;break}i++}n=n.nextSibling,!n&&r&&(n=r.nextSibling,r=null)}s.selectedIndex=t}}},rt=1,Ri=11,xi=3,Li=8;function Ae(){}function un(s){if(s)return s.getAttribute&&s.getAttribute("id")||s.id}function fn(s){return function(t,i,n){if(n||(n={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"){var r=i;i=j.createElement("html"),i.innerHTML=r}else if(t.nodeName==="BODY"){var o=i;i=j.createElement("html"),i.innerHTML=o;var a=i.querySelector("body");a&&(i=a)}else i=dn(i);else i.nodeType===Ri&&(i=i.firstElementChild);var l=n.getNodeKey||un,c=n.onBeforeNodeAdded||Ae,u=n.onNodeAdded||Ae,p=n.onBeforeElUpdated||Ae,m=n.onElUpdated||Ae,g=n.onBeforeNodeDiscarded||Ae,h=n.onNodeDiscarded||Ae,v=n.onBeforeElChildrenUpdated||Ae,E=n.skipFromChildren||Ae,M=n.addChild||function(y,A){return y.appendChild(A)},X=n.childrenOnly===!0,F=Object.create(null),S=[];function _(y){S.push(y)}function L(y,A){if(y.nodeType===rt)for(var O=y.firstChild;O;){var w=void 0;A&&(w=l(O))?_(w):(h(O),O.firstChild&&L(O,A)),O=O.nextSibling}}function J(y,A,O){g(y)!==!1&&(A&&A.removeChild(y),h(y),L(y,O))}function f(y){if(y.nodeType===rt||y.nodeType===Ri)for(var A=y.firstChild;A;){var O=l(A);O&&(F[O]=A),f(A),A=A.nextSibling}}f(t);function b(y){u(y);for(var A=y.firstChild;A;){var O=A.nextSibling,w=l(A);if(w){var P=F[w];P&&St(A,P)?(A.parentNode.replaceChild(P,A),W(P,A)):b(A)}else b(A);A=O}}function H(y,A,O){for(;A;){var w=A.nextSibling;(O=l(A))?_(O):J(A,y,!0),A=w}}function W(y,A,O){var w=l(A);if(w&&delete F[w],!O){var P=p(y,A);if(P===!1||(P instanceof HTMLElement&&(y=P,f(y)),s(y,A),m(y),v(y,A)===!1))return}y.nodeName!=="TEXTAREA"?N(y,A):Ci.TEXTAREA(y,A)}function N(y,A){var O=E(y,A),w=A.firstChild,P=y.firstChild,xe,ae,Le,lt,me;e:for(;w;){for(lt=w.nextSibling,xe=l(w);!O&&P;){if(Le=P.nextSibling,w.isSameNode&&w.isSameNode(P)){w=lt,P=Le;continue e}ae=l(P);var dt=P.nodeType,ge=void 0;if(dt===w.nodeType&&(dt===rt?(xe?xe!==ae&&((me=F[xe])?Le===me?ge=!1:(y.insertBefore(me,P),ae?_(ae):J(P,y,!0),P=me,ae=l(P)):ge=!1):ae&&(ge=!1),ge=ge!==!1&&St(P,w),ge&&W(P,w)):(dt===xi||dt==Li)&&(ge=!0,P.nodeValue!==w.nodeValue&&(P.nodeValue=w.nodeValue))),ge){w=lt,P=Le;continue e}ae?_(ae):J(P,y,!0),P=Le}if(xe&&(me=F[xe])&&St(me,w))O||M(y,me),W(me,w);else{var _t=c(w);_t!==!1&&(_t&&(w=_t),w.actualize&&(w=w.actualize(y.ownerDocument||j)),M(y,w),b(w))}w=lt,P=Le}H(y,P,ae);var Yt=Ci[y.nodeName];Yt&&Yt(y,A)}var I=t,ie=I.nodeType,zt=i.nodeType;if(!X){if(ie===rt)zt===rt?St(t,i)||(h(t),I=hn(t,cn(i.nodeName,i.namespaceURI))):I=i;else if(ie===xi||ie===Li){if(zt===ie)return I.nodeValue!==i.nodeValue&&(I.nodeValue=i.nodeValue),I;I=i}}if(I===i)h(t);else{if(i.isSameNode&&i.isSameNode(I))return;if(W(I,i,X),S)for(var Tt=0,Fi=S.length;Tt<Fi;Tt++){var wt=F[S[Tt]];wt&&J(wt,wt.parentNode,!1)}}return!X&&I!==t&&t.parentNode&&(I.actualize&&(I=I.actualize(t.ownerDocument||j)),t.parentNode.replaceChild(I,t)),I}}var pn=fn(tn),ot=pn;var Se=class{constructor(e,t,i,n,r,o={}){var a;this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.rootID=e.root.id,this.html=i,this.streams=n,this.streamInserts={},this.streamComponentRestore={},this.targetCID=r,this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.targetContainer=r?d.getComponent(this.view.id,r):t,this.beforeUpdatedCallbacks=[],this.afterAddedCallbacks=[],this.afterUpdatedCallbacks=[],this.afterPhxChildAddedCallbacks=[],this.afterDiscardedCallbacks=[],this.afterTransitionsDiscardedCallbacks=[],this.withChildren=o.withChildren||o.undoRef!==void 0||!1,this.undoRef=(a=o.undoRef)!=null?a:null}beforeUpdated(e){this.beforeUpdatedCallbacks.push(e)}afterAdded(e){this.afterAddedCallbacks.push(e)}afterUpdated(e){this.afterUpdatedCallbacks.push(e)}afterPhxChildAdded(e){this.afterPhxChildAddedCallbacks.push(e)}afterDiscarded(e){this.afterDiscardedCallbacks.push(e)}afterTransitionsDiscarded(e){this.afterTransitionsDiscardedCallbacks.push(e)}markPrunableContentForRemoval(){let e=this.liveSocket.binding(Ne);d.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(Rt,"")})}perform(e){let{view:t,liveSocket:i,html:n,container:r}=this,o=this.targetContainer;if(this.targetCID){let S=o.closest(`[${C}]`);if(S&&!S.isSameNode(o)){let _=d.private(S,C);if(_&&(o=_.querySelector(`[data-phx-component="${this.targetCID}"]`),!o))return}}let a=i.getActiveElement(),{selectionStart:l,selectionEnd:c}=a&&d.hasSelectionRange(a)?a:{},u=i.binding(Ne),p=i.binding(Ye),m=i.binding(Qe),g=i.binding(si),h=[],v=[],E=[],M=[],X=null,F=(S,_,L=this.withChildren)=>{let J={childrenOnly:S.getAttribute(K)===null&&!L,getNodeKey:f=>!(f instanceof Element)||d.isPhxDestroyed(f)?null:e?f.id:d.private(f,"clientsideIdAttribute")?f.getAttribute(ze):f.id||f.getAttribute(ze),skipFromChildren:f=>f.getAttribute(u)===Ue,addChild:(f,b)=>{let{ref:H,streamAt:W}=this.getStreamInsert(b);if(H===void 0)return f.appendChild(b);if(this.setStreamRef(b,H),W===0)f.insertAdjacentElement("afterbegin",b);else if(W===-1){let N=f.lastElementChild;if(N&&!N.hasAttribute(Xe)){let I=Array.from(f.children).find(ie=>!ie.hasAttribute(Xe));f.insertBefore(b,I!=null?I:null)}else f.appendChild(b)}else if(W>0){let N=Array.from(f.children)[W];f.insertBefore(b,N)}},onBeforeNodeAdded:f=>{var H;if(!(f instanceof Element))return f;if((H=this.getStreamInsert(f))!=null&&H.updateOnly&&!this.streamComponentRestore[f.id])return!1;d.maintainPrivateHooks(f,f,p,m);let b=f;return this.streamComponentRestore[f.id]&&(b=this.streamComponentRestore[f.id],delete this.streamComponentRestore[f.id],F(b,f,!0)),b},onNodeAdded:f=>{if(!(f instanceof Element)){h.push(f);return}this.maybeReOrderStream(f,!0),d.isPortalTemplate(f)&&M.push(()=>this.teleport(f,F)),f instanceof HTMLImageElement&&f.srcset?f.srcset=f.srcset:f instanceof HTMLVideoElement&&f.autoplay&&f.play(),d.isNowTriggerFormExternal(f,g)&&(X=f),(d.isPhxChild(f)&&t.ownsElement(f)||d.isPhxSticky(f)&&t.ownsElement(f.parentNode))&&this.trackAfterPhxChildAdded(f),f.nodeName==="SCRIPT"&&f.hasAttribute(Ve)&&this.handleRuntimeHook(f,_),h.push(f)},onNodeDiscarded:f=>this.onNodeDiscarded(f),onBeforeNodeDiscarded:f=>{var b;if(!(f instanceof Element)||f.getAttribute(Rt)!==null)return!0;if(f.parentElement!==null&&f.id&&d.isPhxUpdate(f.parentElement,u,[Ue,"append","prepend"])||f.getAttribute(re)||this.maybePendingRemove(f)||this.skipCIDSibling(f))return!1;if(d.isPortalTemplate(f)){let H=document.getElementById(((b=f.content.firstElementChild)==null?void 0:b.id)||"");H&&(H.remove(),J.onNodeDiscarded(H),this.view.dropPortalElementId(H.id))}return!0},onElUpdated:f=>{d.isNowTriggerFormExternal(f,g)&&(X=f),v.push(f),this.maybeReOrderStream(f,!1)},onBeforeElUpdated:(f,b)=>{if(f.id&&f.isSameNode(S)&&f.id!==b.id)return J.onNodeDiscarded(f),f.replaceWith(b),J.onNodeAdded(b);d.syncPendingAttrs(f,b),d.maintainPrivateHooks(f,b,p,m),d.cleanChildNodes(b,u);let H=a&&f.isSameNode(a)&&d.isEditableInput(f),W=H&&this.isChangedSelect(f,b);if(this.skipCIDSibling(b))return this.maybeCloneLockedElement(f,H),this.copyNestedPrivateLock(f,b),this.maybeReOrderStream(f),!1;if(d.isPhxSticky(f))return[q,se,z].map(N=>[N,f.getAttribute(N),b.getAttribute(N)]).forEach(([N,I,ie])=>{ie&&I!==ie&&f.setAttribute(N,ie)}),!1;if(d.isIgnored(f,u)||f.form&&f.form.isSameNode(X))return this.trackBeforeUpdated(f,b),d.mergeAttrs(f,b,{isIgnored:d.isIgnored(f,u)}),v.push(f),d.applyStickyOperations(f),!1;if(f.type==="number"&&f.validity&&f.validity.badInput)return!1;if(f=this.maybeCloneLockedElement(f,H),d.isPhxChild(b)){let N=f.getAttribute(q);return d.mergeAttrs(f,b,{exclude:[se]}),N!==""&&f.setAttribute(q,N),f.setAttribute(z,this.rootID),d.applyStickyOperations(f),!1}return this.copyNestedPrivateLock(f,b),d.copyPrivates(b,f),d.isPortalTemplate(b)?(M.push(()=>this.teleport(b,F)),f.content.replaceChildren(b.content.cloneNode(!0)),!1):H&&f.type!=="hidden"&&!W?(this.trackBeforeUpdated(f,b),d.mergeFocusedInput(f,b),d.syncAttrsToProps(f),v.push(f),d.applyStickyOperations(f),!1):(W&&f.blur(),d.isPhxUpdate(b,u,["append","prepend"])&&E.push(new st(f,b,b.getAttribute(u))),d.syncAttrsToProps(b),d.applyStickyOperations(b),this.trackBeforeUpdated(f,b),f)}};ot(S,_,J)};if(this.trackBeforeUpdated(r,r),i.time("morphdom",()=>{this.streams.forEach(([_,L,J,f])=>{L.forEach(([b,H,W,N])=>{this.streamInserts[b]={ref:_,streamAt:H,limit:W,reset:f,updateOnly:N}}),f!==void 0&&d.all(document,`[${Xe}="${_}"]`,b=>{this.removeStreamChildElement(b)}),J.forEach(b=>{let H=document.getElementById(b);H&&this.removeStreamChildElement(H)})}),e&&d.all(this.container,`[${u}=${Ue}]`).filter(_=>this.view.ownsElement(_)).forEach(_=>{Array.from(_.children).forEach(L=>{this.removeStreamChildElement(L,!0)})}),F(o,n);let S=0;for(;M.length>0&&S<5;){let _=M.slice();M=[],_.forEach(L=>L()),S++}this.view.portalElementIds.forEach(_=>{let L=document.getElementById(_);if(L){let J=L.getAttribute(Z);J&&(document.getElementById(J)||(L.remove(),this.onNodeDiscarded(L),this.view.dropPortalElementId(_)))}})}),i.isDebugEnabled()&&(vi(),bi(this.streamInserts),Array.from(document.querySelectorAll("input[name=id]")).forEach(S=>{S instanceof HTMLInputElement&&S.form&&console.error(`Detected an input with name="id" inside a form! This will cause problems when patching the DOM.
|
|
9
|
-
`,S)})),E.length>0&&i.time("post-morph append/prepend restoration",()=>{E.forEach(S=>S.perform())}),i.silenceEvents(()=>d.restoreFocus(a,l,c)),d.dispatchEvent(document,"phx:update"),h.forEach(S=>this.trackAfterAdded(S)),v.forEach(S=>this.trackAfterUpdated(S)),this.transitionPendingRemoves(),X){i.unload();let S=d.private(X,"submitter");if(S&&S.name&&o.contains(S)){let _=document.createElement("input");_.type="hidden";let L=S.getAttribute("form");L&&_.setAttribute("form",L),_.name=S.name,_.value=S.value,S.parentElement.insertBefore(_,S)}Object.getPrototypeOf(X).submit.call(X)}return!0}trackBeforeUpdated(e,t){this.beforeUpdatedCallbacks.forEach(i=>i(e,t))}trackAfterAdded(e){this.afterAddedCallbacks.forEach(t=>t(e))}trackAfterUpdated(e){this.afterUpdatedCallbacks.forEach(t=>t(e))}trackAfterPhxChildAdded(e){this.afterPhxChildAddedCallbacks.forEach(t=>t(e))}trackAfterDiscarded(e){this.afterDiscardedCallbacks.forEach(t=>t(e))}trackAfterTransitionsDiscarded(e){this.afterTransitionsDiscardedCallbacks.forEach(t=>t(e))}onNodeDiscarded(e){(d.isPhxChild(e)||d.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfterDiscarded(e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}removeStreamChildElement(e,t=!1){!t&&!this.view.ownsElement(e)||(this.streamInserts[e.id]?(this.streamComponentRestore[e.id]=e,e.remove()):this.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e)))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}setStreamRef(e,t){d.putSticky(e,Xe,i=>i.setAttribute(Xe,t))}maybeReOrderStream(e,t=!1){let{ref:i,streamAt:n,reset:r}=this.getStreamInsert(e);if(n!==void 0&&(this.setStreamRef(e,i),!(!r&&!t)&&e.parentElement)){if(n===0)this.moveOrInsertBefore(e.parentElement,e,e.parentElement.firstElementChild);else if(n>0){let o=Array.from(e.parentElement.children),a=o.indexOf(e);if(n>=o.length-1)this.moveOrInsertBefore(e.parentElement,e,null);else{let l=o[n];a>n?this.moveOrInsertBefore(e.parentElement,e,l):this.moveOrInsertBefore(e.parentElement,e,l.nextElementSibling)}}this.maybeLimitStream(e)}}moveOrInsertBefore(e,t,i){if(typeof e.moveBefore=="function")try{e.moveBefore(t,i);return}catch(n){}e.insertBefore(t,i)}maybeLimitStream(e){let{limit:t}=this.getStreamInsert(e);if(t!==null){let i=Array.from(e.parentElement.children);t<0&&i.length>t*-1?i.slice(0,i.length+t).forEach(n=>this.removeStreamChildElement(n)):t>=0&&i.length>t&&i.slice(t).forEach(n=>this.removeStreamChildElement(n))}}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:t}=this;e.length>0&&t.transitionRemoves(e,()=>{e.forEach(i=>{let n=d.firstPhxChild(i);n&&t.destroyViewByEl(n),i.remove()}),this.trackAfterTransitionsDiscarded(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))}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(gt)}maybeCloneLockedElement(e,t){if(!e.hasAttribute(U))return e;let i=new ye(e);if(!e.hasAttribute(C)||this.undoRef!==null&&i.isLockUndoneBy(this.undoRef))return e;d.applyStickyOperations(e);let n=e.hasAttribute(C)?d.private(e,C)||e.cloneNode(!0):null;return n?(d.putPrivate(e,C,n),t?e:n):e}copyNestedPrivateLock(e,t){this.undoRef===null||!d.private(t,C)||d.putPrivate(e,C,d.private(t,C))}indexOf(e,t){return Array.from(e.children).indexOf(t)}teleport(e,t){let i=e.getAttribute($e),n=document.querySelector(i);if(!n)throw new Error("portal target with selector "+i+" not found");let r=e.content.firstElementChild;if(this.skipCIDSibling(r))return;if(!(r!=null&&r.id))throw new Error("phx-portal template must have a single root element with ID!");let o=document.getElementById(r.id),a;o?(n.contains(o)||n.appendChild(o),a=o):(a=document.createElement(r.tagName),n.appendChild(a)),r.setAttribute(re,this.view.id),r.setAttribute(Z,e.id),t(a,r,!0),r.removeAttribute(re),r.removeAttribute(Z),this.view.pushPortalElementId(r.id)}handleRuntimeHook(e,t){var o,a;let i=e.getAttribute(Ve),n=e.hasAttribute("nonce")?e.getAttribute("nonce"):null;if(e.hasAttribute("nonce")){let l=document.createElement("template");l.innerHTML=t,n=(a=(o=l.content.querySelector(`script[${Ve}="${CSS.escape(i)}"]`))==null?void 0:o.getAttribute("nonce"))!=null?a:null}let r=document.createElement("script");r.textContent=e.textContent,d.mergeAttrs(r,e,{isIgnored:!1}),n&&(r.nonce=n),e.replaceWith(r),e=r}};var mn=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),gn=new Set(["'",'"']),Hi=(s,e,t)=>{let i=0,n=!1,r,o,a,l,c,u,p=s.match(/^(\s*(?:<!--.*?-->\s*)*)<([^\s\/>]+)/);if(p===null)throw new Error(`malformed html ${s}`);for(i=p[0].length,r=p[1],a=p[2],l=i,i;i<s.length&&s.charAt(i)!==">";i++)if(s.charAt(i)==="="){let h=s.slice(i-3,i)===" id";i++;let v=s.charAt(i);if(gn.has(v)){let E=i;for(i++,i;i<s.length&&s.charAt(i)!==v;i++);if(h){c=s.slice(E+1,i);break}}}let m=s.length-1;for(n=!1;m>=r.length+a.length;){let h=s.charAt(m);if(n)h==="-"&&s.slice(m-3,m)==="<!-"?(n=!1,m-=4):m-=1;else if(h===">"&&s.slice(m-2,m)==="--")n=!0,m-=3;else{if(h===">")break;m-=1}}o=s.slice(m+1,s.length);let g=Object.keys(e).map(h=>e[h]===!0?h:`${h}="${e[h]}"`).join(" ");if(t){let h=c?` id="${c}"`:"";mn.has(a)?u=`<${a}${h}${g===""?"":" "}${g}/>`:u=`<${a}${h}${g===""?"":" "}${g}></${a}>`}else{let h=s.slice(l,m+1);u=`<${a}${g===""?"":" "}${g}${h}`}return[u,r,o]},Ke=class{static extract(e){let{[$t]:t,[Xt]:i,[Vt]:n}=e;return delete e[$t],delete e[Xt],delete e[Vt],{diff:e,title:n,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{buffer:t,streams:i}=this.recursiveToString(this.rendered,this.rendered[$],e,!0,{});return{buffer:t,streams:i}}recursiveToString(e,t=e[$],i,n,r){i=i?new Set(i):null;let o={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,o,n,r),{buffer:o.buffer,streams:o.streams}}componentCIDs(e){return Object.keys(e[$]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[$]?Object.keys(e).length===1:!1}getComponent(e,t){return e[$][t]}resetRender(e){this.rendered[$][e]&&(this.rendered[$][e].reset=!0)}mergeDiff(e){let t=e[$],i={};if(delete e[$],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[$]=this.rendered[$]||{},t){let n=this.rendered[$];for(let r in t)t[r]=this.cachedFindComponent(r,t[r],n,t,i);for(let r in t)n[r]=t[r];e[$]=t}}cachedFindComponent(e,t,i,n,r){if(r[e])return r[e];{let o,a,l=t[Y];if(oe(l)){let c;l>0?c=this.cachedFindComponent(l,n[l],i,n,r):c=i[-l],a=c[Y],o=this.cloneMerge(c,t,!0),o[Y]=a}else o=t[Y]!==void 0||i[e]===void 0?t:this.cloneMerge(i[e],t,!1);return r[e]=o,o}}mutableMerge(e,t){return t[Y]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){if(t[x])this.mergeKeyed(e,t);else for(let i in t){let n=t[i],r=e[i];Pe(n)&&n[Y]===void 0&&Pe(r)?this.doMutableMerge(r,n):e[i]=n}e[yt]&&(e.newRender=!0)}clone(e){return"structuredClone"in window?structuredClone(e):JSON.parse(JSON.stringify(e))}mergeKeyed(e,t){let i=this.clone(e);if(Object.entries(t[x]).forEach(([n,r])=>{if(n!==te)if(Array.isArray(r)){let[o,a]=r;e[x][n]=i[x][o],this.doMutableMerge(e[x][n],a)}else if(typeof r=="number"){let o=r;e[x][n]=i[x][o]}else typeof r=="object"&&(e[x][n]||(e[x][n]={}),this.doMutableMerge(e[x][n],r))}),t[x][te]<e[x][te])for(let n=t[x][te];n<e[x][te];n++)delete e[x][n];e[x][te]=t[x][te],t[_e]&&(e[_e]=t[_e]),t[he]&&(e[he]=t[he])}cloneMerge(e,t,i){let n;if(t[x])n=this.clone(e),this.mergeKeyed(n,t);else{n=D(D({},e),t);for(let r in n){let o=t[r],a=e[r];Pe(o)&&o[Y]===void 0&&Pe(a)?n[r]=this.cloneMerge(a,o,i):o===void 0&&Pe(a)&&(n[r]=this.cloneMerge(a,{},i))}}return i?(delete n.magicId,delete n.newRender):e[yt]&&(n.newRender=!0),n}componentToString(e){let{buffer:t,streams:i}=this.recursiveCIDToString(this.rendered[$],e,null),[n,r,o]=Hi(t,{});return{buffer:n,streams:i}}pruneCIDs(e){e.forEach(t=>delete this.rendered[$][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[Y]}templateStatic(e,t){return typeof e=="number"?t[e]:e}nextMagicID(){return this.magicId++,`m${this.magicId}-${this.parentViewId()}`}toOutputBuffer(e,t,i,n,r={}){if(e[x])return this.comprehensionToBuffer(e,t,i,n);e[he]&&(t=e[he],delete e[he]);let{[Y]:o}=e;o=this.templateStatic(o,t),e[Y]=o;let a=e[yt],l=i.buffer;a&&(i.buffer=""),n&&a&&!e.magicId&&(e.newRender=!0,e.magicId=this.nextMagicID()),i.buffer+=o[0];for(let c=1;c<o.length;c++)this.dynamicToBuffer(e[c-1],t,i,n),i.buffer+=o[c];if(a){let c=!1,u;n||e.magicId?(c=n&&!e.newRender,u=D({[ze]:e.magicId},r)):u=r,c&&(u[gt]=!0);let[p,m,g]=Hi(i.buffer,u,c);e.newRender=!1,i.buffer=l+m+p+g}}comprehensionToBuffer(e,t,i,n){let r=t||e[he],o=this.templateStatic(e[Y],t);e[Y]=o,delete e[he];for(let a=0;a<e[x][te];a++){i.buffer+=o[0];for(let l=1;l<o.length;l++)this.dynamicToBuffer(e[x][a][l-1],r,i,n),i.buffer+=o[l]}if(e[_e]){let a=e[_e],[l,c,u,p]=a||[null,{},[],null];a!==void 0&&(e[x][te]>0||u.length>0||p)&&(delete e[_e],e[x]={[te]:0},i.streams.add(a))}}dynamicToBuffer(e,t,i,n){if(typeof e=="number"){let{buffer:r,streams:o}=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=r,i.streams=new Set([...i.streams,...o])}else Pe(e)?this.toOutputBuffer(e,t,i,n,{}):i.buffer+=e}recursiveCIDToString(e,t,i){let n=e[t]||T(`no component for CID ${t}`,e),r={[K]:t,[de]:this.viewId},o=i&&!i.has(t);n.newRender=!o,n.magicId=`c${t}-${this.parentViewId()}`;let a=!n.reset,{buffer:l,streams:c}=this.recursiveToString(n,e,i,a,r);return delete n.reset,{buffer:l,streams:c}}};var Ii=[],Oi=200,vn={exec(s,e,t,i,n,r){let[o,a]=r||[null,{callback:r&&r.callback}];(Array.isArray(t)?t:typeof t=="string"&&t.startsWith("[")?JSON.parse(t):[[o,a]]).forEach(([c,u])=>{c===o&&(u=D(D({},a),u),u.callback=u.callback||a.callback),this.filterToEls(i.liveSocket,n,u).forEach(p=>{this[`exec_${c}`](s,e,t,i,n,p,u)})})},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,n,r,{attr:o,to:a}){let l=r.getAttribute(o);if(!l)throw new Error(`expected ${o} to contain JS command on "${a}"`);i.liveSocket.execJS(r,l,e)},exec_dispatch(s,e,t,i,n,r,{event:o,detail:a,bubbles:l,blocking:c}){if(a=a||{},a.dispatcher=n,c){let u=new Promise((p,m)=>{a.done=p});i.liveSocket.asyncTransition(u)}d.dispatchEvent(r,o,{detail:a,bubbles:l})},exec_push(s,e,t,i,n,r,o){let{event:a,data:l,target:c,page_loading:u,loading:p,value:m,dispatcher:g,callback:h}=o,v={loading:p,value:m,target:c,page_loading:!!u,originalEvent:s},E=e==="change"&&g?g:n,M=c||E.getAttribute(i.binding("target"))||E,X=(F,S)=>{if(F.isConnected())if(e==="change"){let{newCid:_,_target:L}=o;L=L||(d.isFormAssociated(n)?n.name:void 0),L&&(v._target=L),F.pushInput(n,S,_,a||t,v,h)}else if(e==="submit"){let{submitter:_}=o;F.submitForm(n,S,a||t,_,v,h)}else F.pushEvent(e,n,S,a||t,l,v,h)};o.targetView&&o.targetCtx?X(o.targetView,o.targetCtx):i.withinTargets(M,X)},exec_navigate(s,e,t,i,n,r,{href:o,replace:a}){i.liveSocket.historyRedirect(s,o,a?"replace":"push",null,n)},exec_patch(s,e,t,i,n,r,{href:o,replace:a}){i.liveSocket.pushHistoryPatch(s,o,a?"replace":"push",n)},exec_focus(s,e,t,i,n,r){B.attemptFocus(r),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>B.attemptFocus(r))})},exec_focus_first(s,e,t,i,n,r){B.focusFirstInteractive(r)||B.focusFirst(r),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>B.focusFirstInteractive(r)||B.focusFirst(r))})},exec_push_focus(s,e,t,i,n,r){Ii.push(r||n)},exec_pop_focus(s,e,t,i,n,r){let o=Ii.pop();o&&(o.focus(),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o.focus())}))},exec_add_class(s,e,t,i,n,r,{names:o,transition:a,time:l,blocking:c}){this.addOrRemoveClasses(r,o,[],a,l,i,c)},exec_remove_class(s,e,t,i,n,r,{names:o,transition:a,time:l,blocking:c}){this.addOrRemoveClasses(r,[],o,a,l,i,c)},exec_toggle_class(s,e,t,i,n,r,{names:o,transition:a,time:l,blocking:c}){this.toggleClasses(r,o,a,l,i,c)},exec_toggle_attr(s,e,t,i,n,r,{attr:[o,a,l]}){this.toggleAttr(r,o,a,l)},exec_ignore_attrs(s,e,t,i,n,r,{attrs:o}){this.ignoreAttrs(r,o)},exec_transition(s,e,t,i,n,r,{time:o,transition:a,blocking:l}){this.addOrRemoveClasses(r,[],[],a,o,i,l)},exec_toggle(s,e,t,i,n,r,{display:o,ins:a,outs:l,time:c,blocking:u}){this.toggle(e,i,r,o,a,l,c,u)},exec_show(s,e,t,i,n,r,{display:o,transition:a,time:l,blocking:c}){this.show(e,i,r,o,a,l,c)},exec_hide(s,e,t,i,n,r,{display:o,transition:a,time:l,blocking:c}){this.hide(e,i,r,o,a,l,c)},exec_set_attr(s,e,t,i,n,r,{attr:[o,a]}){this.setOrRemoveAttrs(r,[[o,a]],[])},exec_remove_attr(s,e,t,i,n,r,{attr:o}){this.setOrRemoveAttrs(r,[],[o])},ignoreAttrs(s,e){d.putPrivate(s,"JS:ignore_attrs",{apply:(t,i)=>{let n=Array.from(t.attributes),r=n.map(o=>o.name);Array.from(i.attributes).filter(o=>!r.includes(o.name)).forEach(o=>{d.attributeIgnored(o,e)&&i.removeAttribute(o.name)}),n.forEach(o=>{d.attributeIgnored(o,e)&&i.setAttribute(o.name,o.value)})}})},onBeforeElUpdated(s,e){let t=d.private(s,"JS:ignore_attrs");t&&t.apply(s,e)},show(s,e,t,i,n,r,o){this.isVisible(t)||this.toggle(s,e,t,i,n,null,r,o)},hide(s,e,t,i,n,r,o){this.isVisible(t)&&this.toggle(s,e,t,i,null,n,r,o)},toggle(s,e,t,i,n,r,o,a){o=o||Oi;let[l,c,u]=n||[[],[],[]],[p,m,g]=r||[[],[],[]];if(l.length>0||p.length>0)if(this.isVisible(t)){let h=()=>{this.addOrRemoveClasses(t,m,l.concat(c).concat(u)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,p,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,g,m))})},v=()=>{this.addOrRemoveClasses(t,[],p.concat(g)),d.putSticky(t,"toggle",E=>E.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))};t.dispatchEvent(new Event("phx:hide-start")),a===!1?(h(),setTimeout(v,o)):e.transition(o,h,v)}else{if(s==="remove")return;let h=()=>{this.addOrRemoveClasses(t,c,p.concat(m).concat(g));let E=i||this.defaultDisplay(t);window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,l,[]),window.requestAnimationFrame(()=>{d.putSticky(t,"toggle",M=>M.style.display=E),this.addOrRemoveClasses(t,u,c)})})},v=()=>{this.addOrRemoveClasses(t,[],l.concat(u)),t.dispatchEvent(new Event("phx:show-end"))};t.dispatchEvent(new Event("phx:show-start")),a===!1?(h(),setTimeout(v,o)):e.transition(o,h,v)}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),d.putSticky(t,"toggle",h=>h.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start"));let h=i||this.defaultDisplay(t);d.putSticky(t,"toggle",v=>v.style.display=h),t.dispatchEvent(new Event("phx:show-end"))})},toggleClasses(s,e,t,i,n,r){window.requestAnimationFrame(()=>{let[o,a]=d.getSticky(s,"classes",[[],[]]),l=e.filter(u=>o.indexOf(u)<0&&!s.classList.contains(u)),c=e.filter(u=>a.indexOf(u)<0&&s.classList.contains(u));this.addOrRemoveClasses(s,l,c,t,i,n,r)})},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,n,r,o){n=n||Oi;let[a,l,c]=i||[[],[],[]];if(a.length>0){let u=()=>{this.addOrRemoveClasses(s,l,[].concat(a).concat(c)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(s,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(s,c,l))})},p=()=>this.addOrRemoveClasses(s,e.concat(c),t.concat(a).concat(l));o===!1?(u(),setTimeout(p,n)):r.transition(n,u,p);return}window.requestAnimationFrame(()=>{let[u,p]=d.getSticky(s,"classes",[[],[]]),m=e.filter(E=>u.indexOf(E)<0&&!s.classList.contains(E)),g=t.filter(E=>p.indexOf(E)<0&&s.classList.contains(E)),h=u.filter(E=>t.indexOf(E)<0).concat(m),v=p.filter(E=>e.indexOf(E)<0).concat(g);d.putSticky(s,"classes",E=>(E.classList.remove(...v),E.classList.add(...h),[h,v]))})},setOrRemoveAttrs(s,e,t){let[i,n]=d.getSticky(s,"attrs",[[],[]]),r=e.map(([l,c])=>l).concat(t),o=i.filter(([l,c])=>!r.includes(l)).concat(e),a=n.filter(l=>!r.includes(l)).concat(t);e.some(([l,c])=>l==="id")&&d.putPrivate(s,"clientsideIdAttribute",!0),d.putSticky(s,"attrs",l=>(a.forEach(c=>l.removeAttribute(c)),o.forEach(([c,u])=>l.setAttribute(c,u)),[o,a]))},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 n=e.closest(t.closest);return n?[n]:[]}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]}},k=vn;var kt=(s,e)=>({exec(t,i){s.execJS(t,i,e)},show(t,i={}){let n=s.owner(t);k.show(e,n,t,i.display,k.transitionClasses(i.transition),i.time,i.blocking)},hide(t,i={}){let n=s.owner(t);k.hide(e,n,t,null,k.transitionClasses(i.transition),i.time,i.blocking)},toggle(t,i={}){let n=s.owner(t),r=k.transitionClasses(i.in),o=k.transitionClasses(i.out);k.toggle(e,n,t,i.display,r,o,i.time,i.blocking)},addClass(t,i,n={}){let r=Array.isArray(i)?i:i.split(" "),o=s.owner(t);k.addOrRemoveClasses(t,r,[],k.transitionClasses(n.transition),n.time,o,n.blocking)},removeClass(t,i,n={}){let r=Array.isArray(i)?i:i.split(" "),o=s.owner(t);k.addOrRemoveClasses(t,[],r,k.transitionClasses(n.transition),n.time,o,n.blocking)},toggleClass(t,i,n={}){let r=Array.isArray(i)?i:i.split(" "),o=s.owner(t);k.toggleClasses(t,r,k.transitionClasses(n.transition),n.time,o,n.blocking)},transition(t,i,n={}){let r=s.owner(t);k.addOrRemoveClasses(t,[],[],k.transitionClasses(i),n.time,r,n.blocking)},setAttribute(t,i,n){k.setOrRemoveAttrs(t,[[i,n]],[])},removeAttribute(t,i){k.setOrRemoveAttrs(t,[],[i])},toggleAttribute(t,i,n,r){k.toggleAttr(t,i,n,r)},push(t,i,n={}){s.withinOwners(t,r=>{let o=n.value||{};delete n.value;let a=new CustomEvent("phx:exec",{detail:{sourceElement:t}});k.exec(a,e,i,r,t,["push",D({data:o},n)])})},navigate(t,i={}){Bt(t,"navigate");let n=new CustomEvent("phx:exec");s.historyRedirect(n,t,i.replace?"replace":"push",null,null)},patch(t,i={}){Bt(t,"patch");let n=new CustomEvent("phx:exec");s.pushHistoryPatch(n,t,i.replace?"replace":"push",null)},ignoreAttributes(t,i){k.ignoreAttrs(t,Array.isArray(i)?i:[i])}});var qt="hookId",Di="deadHook",bn=1,Q=class s{get liveSocket(){return this.__liveSocket()}static makeID(){return bn++}static elementID(e){return d.private(e,qt)}static deadHook(e){return d.private(e,Di)===!0}constructor(e,t,i){if(this.el=t,this.__attachView(e),this.__listeners=new Set,this.__isDisconnected=!1,d.putPrivate(this.el,qt,s.makeID()),e&&e.isDead&&d.putPrivate(this.el,Di,!0),i){let n=new Set(["el","liveSocket","__view","__listeners","__isDisconnected","constructor","js","pushEvent","pushEventTo","handleEvent","removeHandleEvent","upload","uploadTo","__mounted","__updated","__beforeUpdate","__destroyed","__reconnected","__disconnected","__cleanup__"]);for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&(this[o]=i[o],n.has(o)&&console.warn(`Hook object for element #${t.id} overwrites core property '${o}'!`));["mounted","beforeUpdate","updated","destroyed","disconnected","reconnected"].forEach(o=>{i[o]&&typeof i[o]=="function"&&(this[o]=i[o])})}}__attachView(e){e?(this.__view=()=>e,this.__liveSocket=()=>e.liveSocket):(this.__view=()=>{throw new Error(`hook not yet attached to a live view: ${this.el.outerHTML}`)},this.__liveSocket=()=>{throw new Error(`hook not yet attached to a live view: ${this.el.outerHTML}`)})}mounted(){}beforeUpdate(){}updated(){}destroyed(){}disconnected(){}reconnected(){}__mounted(){this.mounted()}__updated(){this.updated()}__beforeUpdate(){this.beforeUpdate()}__destroyed(){this.destroyed(),d.deletePrivate(this.el,qt)}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected()}js(){return le(D({},kt(this.__view().liveSocket,"hook")),{exec:e=>{this.__view().liveSocket.execJS(this.el,e,"hook")}})}pushEvent(e,t,i){let n=this.__view().pushHookEvent(this.el,null,e,t||{});if(i===void 0)return n.then(({reply:r})=>r);n.then(({reply:r,ref:o})=>i(r,o)).catch(()=>{})}pushEventTo(e,t,i,n){if(n===void 0){let r=[];this.__view().withinTargets(e,(a,l)=>{r.push({view:a,targetCtx:l})});let o=r.map(({view:a,targetCtx:l})=>a.pushHookEvent(this.el,l,t,i||{}));return Promise.allSettled(o)}this.__view().withinTargets(e,(r,o)=>{r.pushHookEvent(this.el,o,t,i||{}).then(({reply:a,ref:l})=>n(a,l)).catch(()=>{})})}handleEvent(e,t){let i={event:e,callback:n=>t(n.detail)};return window.addEventListener(`phx:${e}`,i.callback),this.__listeners.add(i),i}removeHandleEvent(e){window.removeEventListener(`phx:${e.event}`,e.callback),this.__listeners.delete(e)}upload(e,t){return this.__view().dispatchUploads(null,e,t)}uploadTo(e,t,i){return this.__view().withinTargets(e,(n,r)=>{n.dispatchUploads(r,t,i)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var En=(s,e)=>{let t=s.endsWith("[]"),i=t?s.slice(0,-2):s;return i=i.replace(/([^\[\]]+)(\]?$)/,`${e}$1$2`),t&&(i+="[]"),i},Re=class s{static closestView(e){let t=e.closest(ce);return t?d.private(t,"view"):null}constructor(e,t,i,n=null,r=null){this.rendered=null,this.isDead=!1,this.liveSocket=t,this.flash=n,this.parent=i,this.root=i?i.root:this,this.el=e;let o=d.private(this.el,"view");if(o!==void 0&&o.isDead!==!0)throw T(`The DOM element for this view has already been bound to a view.
|
|
8
|
+
`),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(s,e,t){let i=new Set(["id",q,se,De,z]);if(s.tagName.toLowerCase()===e.toLowerCase())return Array.from(s.attributes).filter(n=>!i.has(n.name.toLowerCase())).forEach(n=>s.removeAttribute(n.name)),Object.keys(t).filter(n=>!i.has(n.toLowerCase())).forEach(n=>s.setAttribute(n,t[n])),s;{let n=document.createElement(e);return Object.keys(t).forEach(r=>n.setAttribute(r,t[r])),i.forEach(r=>{let o=s.getAttribute(r);o!==null&&n.setAttribute(r,o)}),n.innerHTML=s.innerHTML,s.replaceWith(n),n}},getSticky(s,e,t){let i=(Ce.private(s,"sticky")||[]).find(([n])=>e===n);if(i){let[n,r,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(s,e){this.updatePrivate(s,"sticky",[],t=>t.filter(([i,n])=>i!==e))},putSticky(s,e,t){let i=t(s);this.updatePrivate(s,"sticky",[],n=>{let r=n.findIndex(([o])=>e===o);return r>=0?n[r]=[e,t,i]:n.push([e,t,i]),n})},applyStickyOperations(s){let e=Ce.private(s,"sticky");e&&e.forEach(([t,i,n])=>this.putSticky(s,t,i))},isLocked(s){return s.hasAttribute&&s.hasAttribute(C)},attributeIgnored(s,e){return e.some(t=>s.name==t||t==="*"||t.includes("*")&&s.name.match(t)!=null)}},d=Ce;var pe=class{static isActive(e,t){let i=t._phxRef===void 0,r=e.getAttribute(Ge).split(",").indexOf(R.genFileRef(t))>=0;return t.size>0&&(i||r)}static isPreflighted(e,t){return e.getAttribute(He).split(",").indexOf(R.genFileRef(t))>=0&&this.isActive(e,t)}static isPreflightInProgress(e){return e._preflightInProgress===!0}static markPreflightInProgress(e){e._preflightInProgress=!0}constructor(e,t,i,n){this.ref=R.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(Ie,this._onElUpdated),this.autoUpload=n}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,()=>{R.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(Ie,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),this.isAutoUpload()||R.clearFiles(this.fileEl)}isAutoUpload(){return this.autoUpload}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(Ie,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(Ge).split(",").indexOf(this.ref)===-1&&(R.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]||w(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:Ai}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||w(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var Ki=0,R=class s{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(Ki++).toString(),e._phxRef)}static getEntryDataURL(e,t){let i=this.activeFiles(e).find(n=>this.genFileRef(n)===t);return i?URL.createObjectURL(i):null}static hasUploadsInProgress(e){let t=0;return d.findUploadInputs(e).forEach(i=>{i.getAttribute(He)!==i.getAttribute(ii)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(n=>{let r={path:e.name},o=e.getAttribute(G);i[o]=i[o]||[],r.ref=this.genFileRef(n),r.last_modified=n.lastModified,r.name=n.name||r.ref,r.relative_path=n.webkitRelativePath,r.type=n.type,r.size=n.size,typeof n.meta=="function"&&(r.meta=n.meta()),i[o].push(r)}),i}static clearFiles(e){e.value=null,e.removeAttribute(G),d.putPrivate(e,"files",[])}static untrackFile(e,t){d.putPrivate(e,"files",d.private(e,"files").filter(i=>!Object.is(i,t)))}static trackFiles(e,t,i){if(e.getAttribute("multiple")!==null){let n=t.filter(r=>!this.activeFiles(e).find(o=>Object.is(o,r)));d.updatePrivate(e,"files",[],r=>r.concat(n)),e.value=""}else i&&i.files.length>0&&(e.files=i.files),d.putPrivate(e,"files",t)}static activeFileInputs(e){let t=d.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(d.private(e,"files")||[]).filter(t=>pe.isActive(e,t))}static inputsAwaitingPreflight(e){let t=d.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!pe.isPreflighted(e,t)&&!pe.isPreflightInProgress(t))}static markPreflightInProgress(e){e.forEach(t=>pe.markPreflightInProgress(t.file))}constructor(e,t,i){this.autoUpload=d.isAutoUpload(e),this.view=t,this.onComplete=i,this._entries=Array.from(s.filesAwaitingPreflight(e)||[]).map(n=>new pe(e,n,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(r=>(r.isCancelled()?(this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()):(r.zipPostFlight(e),r.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()})),r));let n=this._entries.reduce((r,o)=>{if(!o.meta)return r;let{name:a,callback:l}=o.uploader(i.uploaders);return r[a]=r[a]||{callback:l,entries:[]},r[a].entries.push(o),r},{});for(let r in n){let{callback:o,entries:a}=n[r];o(a,t,e,i)}}};var qi={anyOf(s,e){return e.some(t=>s instanceof t)},isFocusable(s,e=!1){return s instanceof HTMLAnchorElement&&s.rel!=="ignore"||s instanceof HTMLAreaElement&&s.href!==void 0||!("disabled"in s&&s.disabled)&&this.anyOf(s,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||s instanceof HTMLIFrameElement||s instanceof HTMLElement&&s.tabIndex>=0&&s.getAttribute("aria-hidden")!=="true"||!e&&s.getAttribute("tabindex")!==null&&s.getAttribute("aria-hidden")!=="true"},attemptFocus(s,e=!1){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))return!0;e=e.nextElementSibling}return!1},focusFirst(s){let e=s.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}return!1},focusLast(s){let e=s.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}return!1}},B=qi;var Ti=s=>["HTML","BODY"].indexOf(s.nodeName.toUpperCase())>=0?null:["scroll","auto"].indexOf(getComputedStyle(s).overflowY)>=0?s:Ti(s.parentElement),ki=s=>s?s.scrollTop:document.documentElement.scrollTop||document.body.scrollTop,jt=s=>s?s.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight,Wt=s=>s?s.getBoundingClientRect().top:0,Gi=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.top)>=Wt(e)&&Math.floor(t.top)<=jt(e)},zi=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.bottom)>=Wt(e)&&Math.floor(t.bottom)<=jt(e)},wi=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.top)>=Wt(e)&&Math.floor(t.top)<=jt(e)},Yi={mounted(){this.scrollContainer=Ti(this.el);let s=ki(this.scrollContainer),e=!1,t=500,i=null,n=this.throttle(t,(a,l)=>{i=()=>!0,this.liveSocket.js().push(this.el,a,{value:{id:l.id,_overran:!0},callback:()=>{i=null}})}),r=this.throttle(t,(a,l)=>{i=()=>l.scrollIntoView({block:"start"}),this.liveSocket.js().push(this.el,a,{value:{id:l.id},callback:()=>{i=null,window.requestAnimationFrame(()=>{wi(l,this.scrollContainer)||l.scrollIntoView({block:"start"})})}})}),o=this.throttle(t,(a,l)=>{i=()=>l.scrollIntoView({block:"end"}),this.liveSocket.js().push(this.el,a,{value:{id:l.id},callback:()=>{i=null,window.requestAnimationFrame(()=>{wi(l,this.scrollContainer)||l.scrollIntoView({block:"end"})})}})});this.onScroll=a=>{let l=ki(this.scrollContainer);if(i)return s=l,i();let c=this.findOverrunTarget(),u=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,h=l<s,v=l>s;h&&u&&!e&&c.top>=0?(e=!0,n(u,g)):v&&e&&c.top<=0&&(e=!1),u&&h&&g&&Gi(g,this.scrollContainer)?r(u,g):p&&v&&m&&zi(m,this.scrollContainer)&&o(p,m),s=l},this.scrollContainer?this.scrollContainer.addEventListener("scroll",this.onScroll):window.addEventListener("scroll",this.onScroll)},updated(){this.scrollContainer&&!this.scrollContainer.isConnected&&(this.destroyed(),this.mounted())},destroyed(){this.scrollContainer?this.scrollContainer.removeEventListener("scroll",this.onScroll):window.removeEventListener("scroll",this.onScroll)},throttle(s,e){let t=0,i;return(...n)=>{let r=Date.now(),o=s-(r-t);o<=0||o>s?(i&&(clearTimeout(i),i=null),t=r,e(...n)):i||(i=setTimeout(()=>{t=Date.now(),i=null,e(...n)},o))}},findOverrunTarget(){let s,e=this.el.getAttribute(this.liveSocket.binding(ni));if(e){let t=document.getElementById(e);if(t)s=t.getBoundingClientRect();else throw new Error("did not find element with id "+e)}else s=this.el.getBoundingClientRect();return s}},Qi={activeRefs(){return this.el.getAttribute(Ge)},preflightedRefs(){return this.el.getAttribute(He)},mounted(){this.js().ignoreAttributes(this.el,["value"]),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=""),this.el.dispatchEvent(new CustomEvent(Ie))}},Zi={mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(G)),this.url=R.getEntryDataURL(this.inputEl,this.ref),this.el.src=this.url},destroyed(){URL.revokeObjectURL(this.url)}},en={LiveFileUpload:Qi,LiveImgPreview:Zi,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;B.attemptFocus(e)||B.focusFirst(e)}else B.focusLast(this.el)}),this.focusEnd.addEventListener("focus",s=>{if(!s.relatedTarget||!this.el.contains(s.relatedTarget)){let e=s.target.previousElementSibling;B.attemptFocus(e)||B.focusLast(e)}else B.focusFirst(this.el)}),this.el.contains(document.activeElement)||(this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&B.focusFirst(this.el))}},InfiniteScroll:Yi},_i=en;var ye=class{static onUnlock(e,t){if(!d.isLocked(e)&&!e.closest(`[${C}]`))return t();let i=e.closest(`[${C}]`),n=i.closest(`[${C}]`).getAttribute(C);i.addEventListener(`phx:undo-lock:${n}`,()=>{t()},{once:!0})}constructor(e){this.el=e,this.loadingRef=e.hasAttribute(ve)?parseInt(e.getAttribute(ve),10):null,this.lockRef=e.hasAttribute(C)?parseInt(e.getAttribute(C),10):null}maybeUndo(e,t,i){if(!this.isWithin(e)){d.updatePrivate(this.el,Ct,[],n=>(n.push(e),n));return}this.undoLocks(e,t,i),this.undoLoading(e,t),d.updatePrivate(this.el,Ct,[],n=>n.filter(r=>{let o={detail:{ref:r,event:t},bubbles:!0,cancelable:!1};return this.loadingRef&&this.loadingRef>r&&this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${r}`,o)),this.lockRef&&this.lockRef>r&&this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${r}`,o)),r>e})),this.isFullyResolvedBy(e)&&this.el.removeAttribute(U)}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 n=d.private(this.el,C);n&&(i(n),d.deletePrivate(this.el,C)),this.el.removeAttribute(C);let r={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${this.lockRef}`,r))}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(ve);let i=this.el.getAttribute(be),n=this.el.getAttribute(et);n!==null&&"readOnly"in this.el&&(this.el.readOnly=n==="true",this.el.removeAttribute(et)),i!==null&&"disabled"in this.el&&(this.el.disabled=i==="true",this.el.removeAttribute(be));let r=this.el.getAttribute(Me);r!==null&&(this.el.textContent=r,this.el.removeAttribute(Me));let o={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${this.loadingRef}`,o))}ut.forEach(i=>{(i!=="phx-submit-loading"||this.canUndoLoading(e))&&d.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 st=class{constructor(e,t,i){let n=new Set,r=new Set([...t.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(n.add(a.id),r.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...r].filter(a=>!n.has(a))}perform(){let e=d.byId(this.containerId);e&&(this.elementsToModify.forEach(t=>{t.previousElementId?fe(document.getElementById(t.previousElementId),i=>{fe(document.getElementById(t.elementId),n=>{n.previousElementSibling&&n.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",n)})}):fe(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{fe(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))}))}};var Pi=11;function tn(s,e){var t=e.attributes,i,n,r,o,a;if(!(e.nodeType===Pi||s.nodeType===Pi)){for(var l=t.length-1;l>=0;l--)i=t[l],n=i.name,r=i.namespaceURI,o=i.value,r?(n=i.localName||n,a=s.getAttributeNS(r,n),a!==o&&(i.prefix==="xmlns"&&(n=i.name),s.setAttributeNS(r,n,o))):(a=s.getAttribute(n),a!==o&&s.setAttribute(n,o));for(var c=s.attributes,u=c.length-1;u>=0;u--)i=c[u],n=i.name,r=i.namespaceURI,r?(n=i.localName||n,e.hasAttributeNS(r,n)||s.removeAttributeNS(r,n)):e.hasAttribute(n)||s.removeAttribute(n)}}var At,nn="http://www.w3.org/1999/xhtml",J=typeof document=="undefined"?void 0:document,sn=!!J&&"content"in J.createElement("template"),rn=!!J&&J.createRange&&"createContextualFragment"in J.createRange();function on(s){var e=J.createElement("template");return e.innerHTML=s,e.content.childNodes[0]}function an(s){At||(At=J.createRange(),At.selectNode(J.body));var e=At.createContextualFragment(s);return e.childNodes[0]}function ln(s){var e=J.createElement("body");return e.innerHTML=s,e.childNodes[0]}function dn(s){return s=s.trim(),sn?on(s):rn?an(s):ln(s)}function St(s,e){var t=s.nodeName,i=e.nodeName,n,r;return t===i?!0:(n=t.charCodeAt(0),r=i.charCodeAt(0),n<=90&&r>=97?t===i.toUpperCase():r<=90&&n>=97?i===t.toUpperCase():!1)}function cn(s,e){return!e||e===nn?J.createElement(s):J.createElementNS(e,s)}function hn(s,e){for(var t=s.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function Kt(s,e,t){s[t]!==e[t]&&(s[t]=e[t],s[t]?s.setAttribute(t,""):s.removeAttribute(t))}var Ci={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)}Kt(s,e,"selected")},INPUT:function(s,e){Kt(s,e,"checked"),Kt(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 n=i.nodeValue;if(n==t||!t&&n==s.placeholder)return;i.nodeValue=t}},SELECT:function(s,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,n=s.firstChild,r,o;n;)if(o=n.nodeName&&n.nodeName.toUpperCase(),o==="OPTGROUP")r=n,n=r.firstChild,n||(n=r.nextSibling,r=null);else{if(o==="OPTION"){if(n.hasAttribute("selected")){t=i;break}i++}n=n.nextSibling,!n&&r&&(n=r.nextSibling,r=null)}s.selectedIndex=t}}},rt=1,Ri=11,xi=3,Li=8;function Ae(){}function un(s){if(s)return s.getAttribute&&s.getAttribute("id")||s.id}function fn(s){return function(t,i,n){if(n||(n={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"){var r=i;i=J.createElement("html"),i.innerHTML=r}else if(t.nodeName==="BODY"){var o=i;i=J.createElement("html"),i.innerHTML=o;var a=i.querySelector("body");a&&(i=a)}else i=dn(i);else i.nodeType===Ri&&(i=i.firstElementChild);var l=n.getNodeKey||un,c=n.onBeforeNodeAdded||Ae,u=n.onNodeAdded||Ae,p=n.onBeforeElUpdated||Ae,m=n.onElUpdated||Ae,g=n.onBeforeNodeDiscarded||Ae,h=n.onNodeDiscarded||Ae,v=n.onBeforeElChildrenUpdated||Ae,b=n.skipFromChildren||Ae,M=n.addChild||function(y,A){return y.appendChild(A)},X=n.childrenOnly===!0,F=Object.create(null),S=[];function _(y){S.push(y)}function L(y,A){if(y.nodeType===rt)for(var O=y.firstChild;O;){var T=void 0;A&&(T=l(O))?_(T):(h(O),O.firstChild&&L(O,A)),O=O.nextSibling}}function j(y,A,O){g(y)!==!1&&(A&&A.removeChild(y),h(y),L(y,O))}function f(y){if(y.nodeType===rt||y.nodeType===Ri)for(var A=y.firstChild;A;){var O=l(A);O&&(F[O]=A),f(A),A=A.nextSibling}}f(t);function E(y){u(y);for(var A=y.firstChild;A;){var O=A.nextSibling,T=l(A);if(T){var P=F[T];P&&St(A,P)?(A.parentNode.replaceChild(P,A),W(P,A)):E(A)}else E(A);A=O}}function H(y,A,O){for(;A;){var T=A.nextSibling;(O=l(A))?_(O):j(A,y,!0),A=T}}function W(y,A,O){var T=l(A);if(T&&delete F[T],!O){var P=p(y,A);if(P===!1||(P instanceof HTMLElement&&(y=P,f(y)),s(y,A),m(y),v(y,A)===!1))return}y.nodeName!=="TEXTAREA"?N(y,A):Ci.TEXTAREA(y,A)}function N(y,A){var O=b(y,A),T=A.firstChild,P=y.firstChild,xe,ae,Le,lt,me;e:for(;T;){for(lt=T.nextSibling,xe=l(T);!O&&P;){if(Le=P.nextSibling,T.isSameNode&&T.isSameNode(P)){T=lt,P=Le;continue e}ae=l(P);var dt=P.nodeType,ge=void 0;if(dt===T.nodeType&&(dt===rt?(xe?xe!==ae&&((me=F[xe])?Le===me?ge=!1:(y.insertBefore(me,P),ae?_(ae):j(P,y,!0),P=me,ae=l(P)):ge=!1):ae&&(ge=!1),ge=ge!==!1&&St(P,T),ge&&W(P,T)):(dt===xi||dt==Li)&&(ge=!0,P.nodeValue!==T.nodeValue&&(P.nodeValue=T.nodeValue))),ge){T=lt,P=Le;continue e}ae?_(ae):j(P,y,!0),P=Le}if(xe&&(me=F[xe])&&St(me,T))O||M(y,me),W(me,T);else{var _t=c(T);_t!==!1&&(_t&&(T=_t),T.actualize&&(T=T.actualize(y.ownerDocument||J)),M(y,T),E(T))}T=lt,P=Le}H(y,P,ae);var Yt=Ci[y.nodeName];Yt&&Yt(y,A)}var I=t,ie=I.nodeType,zt=i.nodeType;if(!X){if(ie===rt)zt===rt?St(t,i)||(h(t),I=hn(t,cn(i.nodeName,i.namespaceURI))):I=i;else if(ie===xi||ie===Li){if(zt===ie)return I.nodeValue!==i.nodeValue&&(I.nodeValue=i.nodeValue),I;I=i}}if(I===i)h(t);else{if(i.isSameNode&&i.isSameNode(I))return;if(W(I,i,X),S)for(var wt=0,Fi=S.length;wt<Fi;wt++){var Tt=F[S[wt]];Tt&&j(Tt,Tt.parentNode,!1)}}return!X&&I!==t&&t.parentNode&&(I.actualize&&(I=I.actualize(t.ownerDocument||J)),t.parentNode.replaceChild(I,t)),I}}var pn=fn(tn),ot=pn;var Se=class{constructor(e,t,i,n,r,o={}){var a;this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.rootID=e.root.id,this.html=i,this.streams=n,this.streamInserts={},this.streamComponentRestore={},this.targetCID=r,this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.targetContainer=r?d.getComponent(this.view.id,r):t,this.beforeUpdatedCallbacks=[],this.afterAddedCallbacks=[],this.afterUpdatedCallbacks=[],this.afterPhxChildAddedCallbacks=[],this.afterDiscardedCallbacks=[],this.afterTransitionsDiscardedCallbacks=[],this.withChildren=o.withChildren||o.undoRef!==void 0||!1,this.undoRef=(a=o.undoRef)!=null?a:null}beforeUpdated(e){this.beforeUpdatedCallbacks.push(e)}afterAdded(e){this.afterAddedCallbacks.push(e)}afterUpdated(e){this.afterUpdatedCallbacks.push(e)}afterPhxChildAdded(e){this.afterPhxChildAddedCallbacks.push(e)}afterDiscarded(e){this.afterDiscardedCallbacks.push(e)}afterTransitionsDiscarded(e){this.afterTransitionsDiscardedCallbacks.push(e)}markPrunableContentForRemoval(){let e=this.liveSocket.binding(Ne);d.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(Rt,"")})}perform(e){let{view:t,liveSocket:i,html:n,container:r}=this,o=this.targetContainer;if(this.targetCID){let S=o.closest(`[${C}]`);if(S&&!S.isSameNode(o)){let _=d.private(S,C);if(_&&(o=_.querySelector(`[data-phx-component="${this.targetCID}"]`),!o))return}}let a=i.getActiveElement(),{selectionStart:l,selectionEnd:c}=a&&d.hasSelectionRange(a)?a:{},u=i.binding(Ne),p=i.binding(Ye),m=i.binding(Qe),g=i.binding(si),h=[],v=[],b=[],M=[],X=null,F=(S,_,L=this.withChildren)=>{let j={childrenOnly:S.getAttribute(K)===null&&!L,getNodeKey:f=>!(f instanceof Element)||d.isPhxDestroyed(f)?null:e?f.id:d.private(f,"clientsideIdAttribute")?f.getAttribute(ze):f.id||f.getAttribute(ze),skipFromChildren:f=>f.getAttribute(u)===Ue,addChild:(f,E)=>{let{ref:H,streamAt:W}=this.getStreamInsert(E);if(H===void 0)return f.appendChild(E);if(this.setStreamRef(E,H),W===0)f.insertAdjacentElement("afterbegin",E);else if(W===-1){let N=f.lastElementChild;if(N&&!N.hasAttribute(Xe)){let I=Array.from(f.children).find(ie=>!ie.hasAttribute(Xe));f.insertBefore(E,I!=null?I:null)}else f.appendChild(E)}else if(W>0){let N=Array.from(f.children)[W];f.insertBefore(E,N)}},onBeforeNodeAdded:f=>{var H;if(!(f instanceof Element))return f;if((H=this.getStreamInsert(f))!=null&&H.updateOnly&&!this.streamComponentRestore[f.id])return!1;d.maintainPrivateHooks(f,f,p,m);let E=f;return this.streamComponentRestore[f.id]&&(E=this.streamComponentRestore[f.id],delete this.streamComponentRestore[f.id],F(E,f,!0)),E},onNodeAdded:f=>{if(!(f instanceof Element)){h.push(f);return}this.maybeReOrderStream(f,!0),d.isPortalTemplate(f)&&M.push(()=>this.teleport(f,F)),f instanceof HTMLImageElement&&f.srcset?f.srcset=f.srcset:f instanceof HTMLVideoElement&&f.autoplay&&f.play(),d.isNowTriggerFormExternal(f,g)&&(X=f),(d.isPhxChild(f)&&t.ownsElement(f)||d.isPhxSticky(f)&&t.ownsElement(f.parentNode))&&this.trackAfterPhxChildAdded(f),f.nodeName==="SCRIPT"&&f.hasAttribute(Ve)&&this.handleRuntimeHook(f,_),h.push(f)},onNodeDiscarded:f=>this.onNodeDiscarded(f),onBeforeNodeDiscarded:f=>{var E;if(!(f instanceof Element)||f.getAttribute(Rt)!==null)return!0;if(f.parentElement!==null&&f.id&&d.isPhxUpdate(f.parentElement,u,[Ue,"append","prepend"])||f.getAttribute(re)||this.maybePendingRemove(f)||this.skipCIDSibling(f))return!1;if(d.isPortalTemplate(f)){let H=document.getElementById(((E=f.content.firstElementChild)==null?void 0:E.id)||"");H&&(H.remove(),j.onNodeDiscarded(H),this.view.dropPortalElementId(H.id))}return!0},onElUpdated:f=>{d.isNowTriggerFormExternal(f,g)&&(X=f),v.push(f),this.maybeReOrderStream(f,!1)},onBeforeElUpdated:(f,E)=>{if(f.id&&f.isSameNode(S)&&f.id!==E.id)return j.onNodeDiscarded(f),f.replaceWith(E),j.onNodeAdded(E);d.syncPendingAttrs(f,E),d.maintainPrivateHooks(f,E,p,m),d.cleanChildNodes(E,u);let H=a&&f.isSameNode(a)&&d.isEditableInput(f),W=H&&this.isChangedSelect(f,E);if(this.skipCIDSibling(E))return this.maybeCloneLockedElement(f,H),this.copyNestedPrivateLock(f,E),this.maybeReOrderStream(f),!1;if(d.isPhxSticky(f))return[q,se,z].map(N=>[N,f.getAttribute(N),E.getAttribute(N)]).forEach(([N,I,ie])=>{ie&&I!==ie&&f.setAttribute(N,ie)}),!1;if(d.isIgnored(f,u)||f.form&&f.form.isSameNode(X))return this.trackBeforeUpdated(f,E),d.mergeAttrs(f,E,{isIgnored:d.isIgnored(f,u)}),v.push(f),d.applyStickyOperations(f),!1;if(f.type==="number"&&f.validity&&f.validity.badInput)return!1;if(f=this.maybeCloneLockedElement(f,H),d.isPhxChild(E)){let N=f.getAttribute(q);return d.mergeAttrs(f,E,{exclude:[se]}),N!==""&&f.setAttribute(q,N),f.setAttribute(z,this.rootID),d.applyStickyOperations(f),!1}return this.copyNestedPrivateLock(f,E),d.copyPrivates(E,f),d.isPortalTemplate(E)?(M.push(()=>this.teleport(E,F)),f.content.replaceChildren(E.content.cloneNode(!0)),!1):H&&f.type!=="hidden"&&!W?(this.trackBeforeUpdated(f,E),d.mergeFocusedInput(f,E),d.syncAttrsToProps(f),v.push(f),d.applyStickyOperations(f),!1):(W&&f.blur(),d.isPhxUpdate(E,u,["append","prepend"])&&b.push(new st(f,E,E.getAttribute(u))),d.syncAttrsToProps(E),d.applyStickyOperations(E),this.trackBeforeUpdated(f,E),f)}};ot(S,_,j)};if(this.trackBeforeUpdated(r,r),i.time("morphdom",()=>{this.streams.forEach(([_,L,j,f])=>{L.forEach(([E,H,W,N])=>{this.streamInserts[E]={ref:_,streamAt:H,limit:W,reset:f,updateOnly:N}}),f!==void 0&&d.all(document,`[${Xe}="${_}"]`,E=>{this.removeStreamChildElement(E)}),j.forEach(E=>{let H=document.getElementById(E);H&&this.removeStreamChildElement(H)})}),e&&d.all(this.container,`[${u}=${Ue}]`).filter(_=>this.view.ownsElement(_)).forEach(_=>{Array.from(_.children).forEach(L=>{this.removeStreamChildElement(L,!0)})}),F(o,n);let S=0;for(;M.length>0&&S<5;){let _=M.slice();M=[],_.forEach(L=>L()),S++}this.view.portalElementIds.forEach(_=>{let L=document.getElementById(_);if(L){let j=L.getAttribute(Z);j&&(document.getElementById(j)||(L.remove(),this.onNodeDiscarded(L),this.view.dropPortalElementId(_)))}})}),i.isDebugEnabled()&&(vi(),Ei(this.streamInserts),Array.from(document.querySelectorAll("input[name=id]")).forEach(S=>{S instanceof HTMLInputElement&&S.form&&console.error(`Detected an input with name="id" inside a form! This will cause problems when patching the DOM.
|
|
9
|
+
`,S)})),b.length>0&&i.time("post-morph append/prepend restoration",()=>{b.forEach(S=>S.perform())}),i.silenceEvents(()=>d.restoreFocus(a,l,c)),d.dispatchEvent(document,"phx:update"),h.forEach(S=>this.trackAfterAdded(S)),v.forEach(S=>this.trackAfterUpdated(S)),this.transitionPendingRemoves(),X){i.unload();let S=d.private(X,"submitter");if(S&&S.name&&o.contains(S)){let _=document.createElement("input");_.type="hidden";let L=S.getAttribute("form");L&&_.setAttribute("form",L),_.name=S.name,_.value=S.value,S.parentElement.insertBefore(_,S)}Object.getPrototypeOf(X).submit.call(X)}return!0}trackBeforeUpdated(e,t){this.beforeUpdatedCallbacks.forEach(i=>i(e,t))}trackAfterAdded(e){this.afterAddedCallbacks.forEach(t=>t(e))}trackAfterUpdated(e){this.afterUpdatedCallbacks.forEach(t=>t(e))}trackAfterPhxChildAdded(e){this.afterPhxChildAddedCallbacks.forEach(t=>t(e))}trackAfterDiscarded(e){this.afterDiscardedCallbacks.forEach(t=>t(e))}trackAfterTransitionsDiscarded(e){this.afterTransitionsDiscardedCallbacks.forEach(t=>t(e))}onNodeDiscarded(e){(d.isPhxChild(e)||d.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfterDiscarded(e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}removeStreamChildElement(e,t=!1){!t&&!this.view.ownsElement(e)||(this.streamInserts[e.id]?(this.streamComponentRestore[e.id]=e,e.remove()):this.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e)))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}setStreamRef(e,t){d.putSticky(e,Xe,i=>i.setAttribute(Xe,t))}maybeReOrderStream(e,t=!1){let{ref:i,streamAt:n,reset:r}=this.getStreamInsert(e);if(n!==void 0&&(this.setStreamRef(e,i),!(!r&&!t)&&e.parentElement)){if(n===0)this.moveOrInsertBefore(e.parentElement,e,e.parentElement.firstElementChild);else if(n>0){let o=Array.from(e.parentElement.children),a=o.indexOf(e);if(n>=o.length-1)this.moveOrInsertBefore(e.parentElement,e,null);else{let l=o[n];a>n?this.moveOrInsertBefore(e.parentElement,e,l):this.moveOrInsertBefore(e.parentElement,e,l.nextElementSibling)}}this.maybeLimitStream(e)}}moveOrInsertBefore(e,t,i){if(typeof e.moveBefore=="function")try{e.moveBefore(t,i);return}catch(n){}e.insertBefore(t,i)}maybeLimitStream(e){let{limit:t}=this.getStreamInsert(e);if(t!==null){let i=Array.from(e.parentElement.children);t<0&&i.length>t*-1?i.slice(0,i.length+t).forEach(n=>this.removeStreamChildElement(n)):t>=0&&i.length>t&&i.slice(t).forEach(n=>this.removeStreamChildElement(n))}}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:t}=this;e.length>0&&t.transitionRemoves(e,()=>{e.forEach(i=>{let n=d.firstPhxChild(i);n&&t.destroyViewByEl(n),i.remove()}),this.trackAfterTransitionsDiscarded(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))}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(gt)}maybeCloneLockedElement(e,t){if(!e.hasAttribute(U))return e;let i=new ye(e);if(!e.hasAttribute(C)||this.undoRef!==null&&i.isLockUndoneBy(this.undoRef))return e;d.applyStickyOperations(e);let n=e.hasAttribute(C)?d.private(e,C)||e.cloneNode(!0):null;return n?(d.putPrivate(e,C,n),t?e:n):e}copyNestedPrivateLock(e,t){this.undoRef===null||!d.private(t,C)||d.putPrivate(e,C,d.private(t,C))}indexOf(e,t){return Array.from(e.children).indexOf(t)}teleport(e,t){let i=e.getAttribute($e),n=document.querySelector(i);if(!n)throw new Error("portal target with selector "+i+" not found");let r=e.content.firstElementChild;if(this.skipCIDSibling(r))return;if(!(r!=null&&r.id))throw new Error("phx-portal template must have a single root element with ID!");let o=document.getElementById(r.id),a;o?(n.contains(o)||n.appendChild(o),a=o):(a=document.createElement(r.tagName),n.appendChild(a)),r.setAttribute(re,this.view.id),r.setAttribute(Z,e.id),t(a,r,!0),r.removeAttribute(re),r.removeAttribute(Z),this.view.pushPortalElementId(r.id)}handleRuntimeHook(e,t){var o,a;let i=e.getAttribute(Ve),n=e.hasAttribute("nonce")?e.getAttribute("nonce"):null;if(e.hasAttribute("nonce")){let l=document.createElement("template");l.innerHTML=t,n=(a=(o=l.content.querySelector(`script[${Ve}="${CSS.escape(i)}"]`))==null?void 0:o.getAttribute("nonce"))!=null?a:null}let r=document.createElement("script");r.textContent=e.textContent,d.mergeAttrs(r,e,{isIgnored:!1}),n&&(r.nonce=n),e.replaceWith(r),e=r}};var mn=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),gn=new Set(["'",'"']),Hi=(s,e,t)=>{let i=0,n=!1,r,o,a,l,c,u,p=s.match(/^(\s*(?:<!--.*?-->\s*)*)<([^\s\/>]+)/);if(p===null)throw new Error(`malformed html ${s}`);for(i=p[0].length,r=p[1],a=p[2],l=i,i;i<s.length&&s.charAt(i)!==">";i++)if(s.charAt(i)==="="){let h=s.slice(i-3,i)===" id";i++;let v=s.charAt(i);if(gn.has(v)){let b=i;for(i++,i;i<s.length&&s.charAt(i)!==v;i++);if(h){c=s.slice(b+1,i);break}}}let m=s.length-1;for(n=!1;m>=r.length+a.length;){let h=s.charAt(m);if(n)h==="-"&&s.slice(m-3,m)==="<!-"?(n=!1,m-=4):m-=1;else if(h===">"&&s.slice(m-2,m)==="--")n=!0,m-=3;else{if(h===">")break;m-=1}}o=s.slice(m+1,s.length);let g=Object.keys(e).map(h=>e[h]===!0?h:`${h}="${e[h]}"`).join(" ");if(t){let h=c?` id="${c}"`:"";mn.has(a)?u=`<${a}${h}${g===""?"":" "}${g}/>`:u=`<${a}${h}${g===""?"":" "}${g}></${a}>`}else{let h=s.slice(l,m+1);u=`<${a}${g===""?"":" "}${g}${h}`}return[u,r,o]},Ke=class{static extract(e){let{[$t]:t,[Xt]:i,[Vt]:n}=e;return delete e[$t],delete e[Xt],delete e[Vt],{diff:e,title:n,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{buffer:t,streams:i}=this.recursiveToString(this.rendered,this.rendered[$],e,!0,{});return{buffer:t,streams:i}}recursiveToString(e,t=e[$],i,n,r){i=i?new Set(i):null;let o={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,o,n,r),{buffer:o.buffer,streams:o.streams}}componentCIDs(e){return Object.keys(e[$]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[$]?Object.keys(e).length===1:!1}getComponent(e,t){return e[$][t]}resetRender(e){this.rendered[$][e]&&(this.rendered[$][e].reset=!0)}mergeDiff(e){let t=e[$],i={};if(delete e[$],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[$]=this.rendered[$]||{},t){let n=this.rendered[$];for(let r in t)t[r]=this.cachedFindComponent(r,t[r],n,t,i);for(let r in t)n[r]=t[r];e[$]=t}}cachedFindComponent(e,t,i,n,r){if(r[e])return r[e];{let o,a,l=t[Y];if(oe(l)){let c;l>0?c=this.cachedFindComponent(l,n[l],i,n,r):c=i[-l],a=c[Y],o=this.cloneMerge(c,t,!0),o[Y]=a}else o=t[Y]!==void 0||i[e]===void 0?t:this.cloneMerge(i[e],t,!1);return r[e]=o,o}}mutableMerge(e,t){return t[Y]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){if(t[x])this.mergeKeyed(e,t);else for(let i in t){let n=t[i],r=e[i];Pe(n)&&n[Y]===void 0&&Pe(r)?this.doMutableMerge(r,n):e[i]=n}e[yt]&&(e.newRender=!0)}clone(e){return"structuredClone"in window?structuredClone(e):JSON.parse(JSON.stringify(e))}mergeKeyed(e,t){let i=this.clone(e);if(Object.entries(t[x]).forEach(([n,r])=>{if(n!==te)if(Array.isArray(r)){let[o,a]=r;e[x][n]=i[x][o],this.doMutableMerge(e[x][n],a)}else if(typeof r=="number"){let o=r;e[x][n]=i[x][o]}else typeof r=="object"&&(e[x][n]||(e[x][n]={}),this.doMutableMerge(e[x][n],r))}),t[x][te]<e[x][te])for(let n=t[x][te];n<e[x][te];n++)delete e[x][n];e[x][te]=t[x][te],t[_e]&&(e[_e]=t[_e]),t[he]&&(e[he]=t[he])}cloneMerge(e,t,i){let n;if(t[x])n=this.clone(e),this.mergeKeyed(n,t);else{n=D(D({},e),t);for(let r in n){let o=t[r],a=e[r];Pe(o)&&o[Y]===void 0&&Pe(a)?n[r]=this.cloneMerge(a,o,i):o===void 0&&Pe(a)&&(n[r]=this.cloneMerge(a,{},i))}}return i?(delete n.magicId,delete n.newRender):e[yt]&&(n.newRender=!0),n}componentToString(e){let{buffer:t,streams:i}=this.recursiveCIDToString(this.rendered[$],e,null),[n,r,o]=Hi(t,{});return{buffer:n,streams:i}}pruneCIDs(e){e.forEach(t=>delete this.rendered[$][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[Y]}templateStatic(e,t){return typeof e=="number"?t[e]:e}nextMagicID(){return this.magicId++,`m${this.magicId}-${this.parentViewId()}`}toOutputBuffer(e,t,i,n,r={}){if(e[x])return this.comprehensionToBuffer(e,t,i,n);e[he]&&(t=e[he],delete e[he]);let{[Y]:o}=e;o=this.templateStatic(o,t),e[Y]=o;let a=e[yt],l=i.buffer;a&&(i.buffer=""),n&&a&&!e.magicId&&(e.newRender=!0,e.magicId=this.nextMagicID()),i.buffer+=o[0];for(let c=1;c<o.length;c++)this.dynamicToBuffer(e[c-1],t,i,n),i.buffer+=o[c];if(a){let c=!1,u;n||e.magicId?(c=n&&!e.newRender,u=D({[ze]:e.magicId},r)):u=r,c&&(u[gt]=!0);let[p,m,g]=Hi(i.buffer,u,c);e.newRender=!1,i.buffer=l+m+p+g}}comprehensionToBuffer(e,t,i,n){let r=t||e[he],o=this.templateStatic(e[Y],t);e[Y]=o,delete e[he];for(let a=0;a<e[x][te];a++){i.buffer+=o[0];for(let l=1;l<o.length;l++)this.dynamicToBuffer(e[x][a][l-1],r,i,n),i.buffer+=o[l]}if(e[_e]){let a=e[_e],[l,c,u,p]=a||[null,{},[],null];a!==void 0&&(e[x][te]>0||u.length>0||p)&&(delete e[_e],e[x]={[te]:0},i.streams.add(a))}}dynamicToBuffer(e,t,i,n){if(typeof e=="number"){let{buffer:r,streams:o}=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=r,i.streams=new Set([...i.streams,...o])}else Pe(e)?this.toOutputBuffer(e,t,i,n,{}):i.buffer+=e}recursiveCIDToString(e,t,i){let n=e[t]||w(`no component for CID ${t}`,e),r={[K]:t,[de]:this.viewId},o=i&&!i.has(t);n.newRender=!o,n.magicId=`c${t}-${this.parentViewId()}`;let a=!n.reset,{buffer:l,streams:c}=this.recursiveToString(n,e,i,a,r);return delete n.reset,{buffer:l,streams:c}}};var Ii=[],Oi=200,vn={exec(s,e,t,i,n,r){let[o,a]=r||[null,{callback:r&&r.callback}];(Array.isArray(t)?t:typeof t=="string"&&t.startsWith("[")?JSON.parse(t):[[o,a]]).forEach(([c,u])=>{c===o&&(u=D(D({},a),u),u.callback=u.callback||a.callback),this.filterToEls(i.liveSocket,n,u).forEach(p=>{this[`exec_${c}`](s,e,t,i,n,p,u)})})},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,n,r,{attr:o,to:a}){let l=r.getAttribute(o);if(!l)throw new Error(`expected ${o} to contain JS command on "${a}"`);i.liveSocket.execJS(r,l,e)},exec_dispatch(s,e,t,i,n,r,{event:o,detail:a,bubbles:l,blocking:c}){if(a=a||{},a.dispatcher=n,c){let u=new Promise((p,m)=>{a.done=p});i.liveSocket.asyncTransition(u)}d.dispatchEvent(r,o,{detail:a,bubbles:l})},exec_push(s,e,t,i,n,r,o){let{event:a,data:l,target:c,page_loading:u,loading:p,value:m,dispatcher:g,callback:h}=o,v={loading:p,value:m,target:c,page_loading:!!u,originalEvent:s},b=e==="change"&&g?g:n,M=c||b.getAttribute(i.binding("target"))||b,X=(F,S)=>{if(F.isConnected())if(e==="change"){let{newCid:_,_target:L}=o;L=L||(d.isFormAssociated(n)?n.name:void 0),L&&(v._target=L),F.pushInput(n,S,_,a||t,v,h)}else if(e==="submit"){let{submitter:_}=o;F.submitForm(n,S,a||t,_,v,h)}else F.pushEvent(e,n,S,a||t,l,v,h)};o.targetView&&o.targetCtx?X(o.targetView,o.targetCtx):i.withinTargets(M,X)},exec_navigate(s,e,t,i,n,r,{href:o,replace:a}){i.liveSocket.historyRedirect(s,o,a?"replace":"push",null,n)},exec_patch(s,e,t,i,n,r,{href:o,replace:a}){i.liveSocket.pushHistoryPatch(s,o,a?"replace":"push",n)},exec_focus(s,e,t,i,n,r){B.attemptFocus(r),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>B.attemptFocus(r))})},exec_focus_first(s,e,t,i,n,r){B.focusFirstInteractive(r)||B.focusFirst(r),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>B.focusFirstInteractive(r)||B.focusFirst(r))})},exec_push_focus(s,e,t,i,n,r){Ii.push(r||n)},exec_pop_focus(s,e,t,i,n,r){let o=Ii.pop();o&&(o.focus(),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o.focus())}))},exec_add_class(s,e,t,i,n,r,{names:o,transition:a,time:l,blocking:c}){this.addOrRemoveClasses(r,o,[],a,l,i,c)},exec_remove_class(s,e,t,i,n,r,{names:o,transition:a,time:l,blocking:c}){this.addOrRemoveClasses(r,[],o,a,l,i,c)},exec_toggle_class(s,e,t,i,n,r,{names:o,transition:a,time:l,blocking:c}){this.toggleClasses(r,o,a,l,i,c)},exec_toggle_attr(s,e,t,i,n,r,{attr:[o,a,l]}){this.toggleAttr(r,o,a,l)},exec_ignore_attrs(s,e,t,i,n,r,{attrs:o}){this.ignoreAttrs(r,o)},exec_transition(s,e,t,i,n,r,{time:o,transition:a,blocking:l}){this.addOrRemoveClasses(r,[],[],a,o,i,l)},exec_toggle(s,e,t,i,n,r,{display:o,ins:a,outs:l,time:c,blocking:u}){this.toggle(e,i,r,o,a,l,c,u)},exec_show(s,e,t,i,n,r,{display:o,transition:a,time:l,blocking:c}){this.show(e,i,r,o,a,l,c)},exec_hide(s,e,t,i,n,r,{display:o,transition:a,time:l,blocking:c}){this.hide(e,i,r,o,a,l,c)},exec_set_attr(s,e,t,i,n,r,{attr:[o,a]}){this.setOrRemoveAttrs(r,[[o,a]],[])},exec_remove_attr(s,e,t,i,n,r,{attr:o}){this.setOrRemoveAttrs(r,[],[o])},ignoreAttrs(s,e){d.putPrivate(s,"JS:ignore_attrs",{apply:(t,i)=>{let n=Array.from(t.attributes),r=n.map(o=>o.name);Array.from(i.attributes).filter(o=>!r.includes(o.name)).forEach(o=>{d.attributeIgnored(o,e)&&i.removeAttribute(o.name)}),n.forEach(o=>{d.attributeIgnored(o,e)&&i.setAttribute(o.name,o.value)})}})},onBeforeElUpdated(s,e){let t=d.private(s,"JS:ignore_attrs");t&&t.apply(s,e)},show(s,e,t,i,n,r,o){this.isVisible(t)||this.toggle(s,e,t,i,n,null,r,o)},hide(s,e,t,i,n,r,o){this.isVisible(t)&&this.toggle(s,e,t,i,null,n,r,o)},toggle(s,e,t,i,n,r,o,a){o=o||Oi;let[l,c,u]=n||[[],[],[]],[p,m,g]=r||[[],[],[]];if(l.length>0||p.length>0)if(this.isVisible(t)){let h=()=>{this.addOrRemoveClasses(t,m,l.concat(c).concat(u)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,p,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,g,m))})},v=()=>{this.addOrRemoveClasses(t,[],p.concat(g)),d.putSticky(t,"toggle",b=>b.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))};t.dispatchEvent(new Event("phx:hide-start")),a===!1?(h(),setTimeout(v,o)):e.transition(o,h,v)}else{if(s==="remove")return;let h=()=>{this.addOrRemoveClasses(t,c,p.concat(m).concat(g));let b=i||this.defaultDisplay(t);window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,l,[]),window.requestAnimationFrame(()=>{d.putSticky(t,"toggle",M=>M.style.display=b),this.addOrRemoveClasses(t,u,c)})})},v=()=>{this.addOrRemoveClasses(t,[],l.concat(u)),t.dispatchEvent(new Event("phx:show-end"))};t.dispatchEvent(new Event("phx:show-start")),a===!1?(h(),setTimeout(v,o)):e.transition(o,h,v)}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),d.putSticky(t,"toggle",h=>h.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start"));let h=i||this.defaultDisplay(t);d.putSticky(t,"toggle",v=>v.style.display=h),t.dispatchEvent(new Event("phx:show-end"))})},toggleClasses(s,e,t,i,n,r){window.requestAnimationFrame(()=>{let[o,a]=d.getSticky(s,"classes",[[],[]]),l=e.filter(u=>o.indexOf(u)<0&&!s.classList.contains(u)),c=e.filter(u=>a.indexOf(u)<0&&s.classList.contains(u));this.addOrRemoveClasses(s,l,c,t,i,n,r)})},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,n,r,o){n=n||Oi;let[a,l,c]=i||[[],[],[]];if(a.length>0){let u=()=>{this.addOrRemoveClasses(s,l,[].concat(a).concat(c)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(s,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(s,c,l))})},p=()=>this.addOrRemoveClasses(s,e.concat(c),t.concat(a).concat(l));o===!1?(u(),setTimeout(p,n)):r.transition(n,u,p);return}window.requestAnimationFrame(()=>{let[u,p]=d.getSticky(s,"classes",[[],[]]),m=e.filter(b=>u.indexOf(b)<0&&!s.classList.contains(b)),g=t.filter(b=>p.indexOf(b)<0&&s.classList.contains(b)),h=u.filter(b=>t.indexOf(b)<0).concat(m),v=p.filter(b=>e.indexOf(b)<0).concat(g);d.putSticky(s,"classes",b=>(b.classList.remove(...v),b.classList.add(...h),[h,v]))})},setOrRemoveAttrs(s,e,t){let[i,n]=d.getSticky(s,"attrs",[[],[]]),r=e.map(([l,c])=>l).concat(t),o=i.filter(([l,c])=>!r.includes(l)).concat(e),a=n.filter(l=>!r.includes(l)).concat(t);e.some(([l,c])=>l==="id")&&d.putPrivate(s,"clientsideIdAttribute",!0),d.putSticky(s,"attrs",l=>(a.forEach(c=>l.removeAttribute(c)),o.forEach(([c,u])=>l.setAttribute(c,u)),[o,a]))},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 n=e.closest(t.closest);return n?[n]:[]}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]}},k=vn;var kt=(s,e)=>({exec(t,i){s.execJS(t,i,e)},show(t,i={}){let n=s.owner(t);k.show(e,n,t,i.display,k.transitionClasses(i.transition),i.time,i.blocking)},hide(t,i={}){let n=s.owner(t);k.hide(e,n,t,null,k.transitionClasses(i.transition),i.time,i.blocking)},toggle(t,i={}){let n=s.owner(t),r=k.transitionClasses(i.in),o=k.transitionClasses(i.out);k.toggle(e,n,t,i.display,r,o,i.time,i.blocking)},addClass(t,i,n={}){let r=Array.isArray(i)?i:i.split(" "),o=s.owner(t);k.addOrRemoveClasses(t,r,[],k.transitionClasses(n.transition),n.time,o,n.blocking)},removeClass(t,i,n={}){let r=Array.isArray(i)?i:i.split(" "),o=s.owner(t);k.addOrRemoveClasses(t,[],r,k.transitionClasses(n.transition),n.time,o,n.blocking)},toggleClass(t,i,n={}){let r=Array.isArray(i)?i:i.split(" "),o=s.owner(t);k.toggleClasses(t,r,k.transitionClasses(n.transition),n.time,o,n.blocking)},transition(t,i,n={}){let r=s.owner(t);k.addOrRemoveClasses(t,[],[],k.transitionClasses(i),n.time,r,n.blocking)},setAttribute(t,i,n){k.setOrRemoveAttrs(t,[[i,n]],[])},removeAttribute(t,i){k.setOrRemoveAttrs(t,[],[i])},toggleAttribute(t,i,n,r){k.toggleAttr(t,i,n,r)},push(t,i,n={}){s.withinOwners(t,r=>{let o=n.value||{};delete n.value;let a=new CustomEvent("phx:exec",{detail:{sourceElement:t}});k.exec(a,e,i,r,t,["push",D({data:o},n)])})},navigate(t,i={}){Bt(t,"navigate");let n=new CustomEvent("phx:exec");s.historyRedirect(n,t,i.replace?"replace":"push",null,null)},patch(t,i={}){Bt(t,"patch");let n=new CustomEvent("phx:exec");s.pushHistoryPatch(n,t,i.replace?"replace":"push",null)},ignoreAttributes(t,i){k.ignoreAttrs(t,Array.isArray(i)?i:[i])}});var qt="hookId",Di="deadHook",En=1,Q=class s{get liveSocket(){return this.__liveSocket()}static makeID(){return En++}static elementID(e){return d.private(e,qt)}static deadHook(e){return d.private(e,Di)===!0}constructor(e,t,i){if(this.el=t,this.__attachView(e),this.__listeners=new Set,this.__isDisconnected=!1,d.putPrivate(this.el,qt,s.makeID()),e&&e.isDead&&d.putPrivate(this.el,Di,!0),i){let n=new Set(["el","liveSocket","__view","__listeners","__isDisconnected","constructor","js","pushEvent","pushEventTo","handleEvent","removeHandleEvent","upload","uploadTo","__mounted","__updated","__beforeUpdate","__destroyed","__reconnected","__disconnected","__cleanup__"]);for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&(this[o]=i[o],n.has(o)&&console.warn(`Hook object for element #${t.id} overwrites core property '${o}'!`));["mounted","beforeUpdate","updated","destroyed","disconnected","reconnected"].forEach(o=>{i[o]&&typeof i[o]=="function"&&(this[o]=i[o])})}}__attachView(e){e?(this.__view=()=>e,this.__liveSocket=()=>e.liveSocket):(this.__view=()=>{throw new Error(`hook not yet attached to a live view: ${this.el.outerHTML}`)},this.__liveSocket=()=>{throw new Error(`hook not yet attached to a live view: ${this.el.outerHTML}`)})}mounted(){}beforeUpdate(){}updated(){}destroyed(){}disconnected(){}reconnected(){}__mounted(){this.mounted()}__updated(){this.updated()}__beforeUpdate(){this.beforeUpdate()}__destroyed(){this.destroyed(),d.deletePrivate(this.el,qt)}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected()}js(){return le(D({},kt(this.__view().liveSocket,"hook")),{exec:e=>{this.__view().liveSocket.execJS(this.el,e,"hook")}})}pushEvent(e,t,i){let n=this.__view().pushHookEvent(this.el,null,e,t||{});if(i===void 0)return n.then(({reply:r})=>r);n.then(({reply:r,ref:o})=>i(r,o)).catch(()=>{})}pushEventTo(e,t,i,n){if(n===void 0){let r=[];this.__view().withinTargets(e,(a,l)=>{r.push({view:a,targetCtx:l})});let o=r.map(({view:a,targetCtx:l})=>a.pushHookEvent(this.el,l,t,i||{}));return Promise.allSettled(o)}this.__view().withinTargets(e,(r,o)=>{r.pushHookEvent(this.el,o,t,i||{}).then(({reply:a,ref:l})=>n(a,l)).catch(()=>{})})}handleEvent(e,t){let i={event:e,callback:n=>t(n.detail)};return window.addEventListener(`phx:${e}`,i.callback),this.__listeners.add(i),i}removeHandleEvent(e){window.removeEventListener(`phx:${e.event}`,e.callback),this.__listeners.delete(e)}upload(e,t){return this.__view().dispatchUploads(null,e,t)}uploadTo(e,t,i){return this.__view().withinTargets(e,(n,r)=>{n.dispatchUploads(r,t,i)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var bn=(s,e)=>{let t=s.endsWith("[]"),i=t?s.slice(0,-2):s;return i=i.replace(/([^\[\]]+)(\]?$)/,`${e}$1$2`),t&&(i+="[]"),i},Re=class s{static closestView(e){let t=e.closest(ce);return t?d.private(t,"view"):null}constructor(e,t,i,n=null,r=null){this.rendered=null,this.isDead=!1,this.liveSocket=t,this.flash=n,this.parent=i,this.root=i?i.root:this,this.el=e;let o=d.private(this.el,"view");if(o!==void 0&&o.isDead!==!0)throw w(`The DOM element for this view has already been bound to a view.
|
|
10
10
|
|
|
11
11
|
An element can only ever be associated with a single view!
|
|
12
12
|
Please ensure that you are not trying to initialize multiple LiveSockets on the same page.
|
|
13
13
|
This could happen if you're accidentally trying to render your root layout more than once.
|
|
14
14
|
Ensure that the template set on the LiveView is different than the root layout.
|
|
15
|
-
`,{view:o}),new Error("Cannot bind multiple views to the same DOM element.");d.putPrivate(this.el,"view",this),this.id=this.el.id,this.el.setAttribute(z,this.root.id),this.ref=0,this.lastAckRef=null,this.childJoins=0,this.loaderTimer=null,this.disconnectedTimer=null,this.pendingDiffs=[],this.pendingForms=new Set,this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinAttempts=0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(a){a&&a()},this.stopCallback=function(){},this.pendingJoinOps=[],this.viewHooks={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.formsForRecovery={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{var l;let a=this.href&&this.expandURL(this.href);return{redirect:this.redirect?a:void 0,url:this.redirect?void 0:a||void 0,params:this.connectParams(r),session:this.getSession(),static:this.getStatic(),flash:(l=this.flash)!=null?l:void 0,sticky:this.el.hasAttribute(Ze)}}),this.portalElementIds=new Set}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(De)}connectParams(e){let t=this.liveSocket.params(this.el),i=d.all(document,`[${this.binding(ti)}]`).map(n=>"src"in n&&n.src||"href"in n&&n.href).filter(n=>typeof n=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._mount_attempts=this.joinAttempts,t._live_referer=e!=null?e:void 0,this.joinAttempts++,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(q)}getStatic(){let e=this.el.getAttribute(se);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyPortalElements(),this.destroyed=!0,d.deletePrivate(this.el,"view"),delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],this.loaderTimer!=null&&clearTimeout(this.loaderTimer);let t=()=>{e();for(let i in this.viewHooks)this.destroyHook(this.viewHooks[i])};d.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",t).receive("error",t).receive("timeout",t)}setContainerClasses(...e){this.el.classList.remove(xt,be,ke,Lt,Oe),this.el.classList.add(...e)}showLoader(e){if(this.loaderTimer!=null&&clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let t in this.viewHooks)this.viewHooks[t].__disconnected();this.setContainerClasses(be)}}execAll(e){d.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){this.loaderTimer!=null&&clearTimeout(this.loaderTimer),this.disconnectedTimer!=null&&clearTimeout(this.disconnectedTimer),this.setContainerClasses(xt),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){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,n=>t(n,e));if(oe(e))d.findComponent(this.id,e,i)?t(this,typeof e=="number"?e:parseInt(e)):T(`no component found matching phx-target of ${e}`);else{let n=Array.from(i.querySelectorAll(e));n.length===0&&T(`nothing found matching the phx-target selector "${e}"`),n.forEach(r=>this.liveSocket.owner(r,o=>t(o,r)))}}applyDiff(e,t,i){this.log(e,()=>["",We(t)]);let{diff:n,reply:r,events:o,title:a}=Ke.extract(t),l=o.reduce((u,p)=>(p.length===3&&p[2]==!0?u.pre.push(p.slice(0,-1)):u.post.push(p),u),{pre:[],post:[]});this.liveSocket.dispatchEvents(l.pre);let c=()=>{i({diff:n,reply:r,events:l.post}),(typeof a=="string"||e=="mount"&&this.isMain())&&window.requestAnimationFrame(()=>d.putTitle(a))};"onDocumentPatch"in this.liveSocket.domCallbacks?this.liveSocket.triggerDOM("onDocumentPatch",[c]):c()}onJoin(e){let{rendered:t,container:i,liveview_version:n,pid:r}=e;if(i){let[o,a]=i;this.el=d.replaceRootContainer(this.el,o,a)}this.childJoins=0,this.joinPending=!0,this.flash=null,this.root===this&&(this.formsForRecovery=this.getFormsForRecovery()),this.isMain()&&window.history.state===null&&V.pushState("replace",{type:"patch",id:this.id,position:this.liveSocket.currentHistoryPosition}),n!==this.liveSocket.version()&&console.warn(`LiveView asset version mismatch. JavaScript version ${this.liveSocket.version()} vs. server ${n}. To avoid issues, please ensure that your assets use the same version as the server.`),r&&this.el.setAttribute(li,r),V.dropLocal(this.liveSocket.localStorage,window.location.pathname,ht),this.applyDiff("mount",t,({diff:o,events:a})=>{this.rendered=new Ke(this.id,o);let[l,c]=this.renderContainer(null,"join");this.dropPendingRefs(),this.joinCount++,this.joinAttempts=0,this.maybeRecoverForms(l,()=>{this.onJoinComplete(e,l,c,a)})})}dropPendingRefs(){d.all(document,`[${U}="${this.refSrc()}"]`,e=>{e.removeAttribute(ve),e.removeAttribute(U),e.removeAttribute(C)})}onJoinComplete({live_patch:e},t,i,n){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i,n);d.findPhxChildrenInFragment(t,this.id).filter(o=>{let a=o.id&&this.el.querySelector(`[id="${o.id}"]`),l=a&&a.getAttribute(se);return l&&o.setAttribute(se,l),a&&a.setAttribute(z,this.root.id),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,n)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i,n)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,n)])}attachTrueDocEl(){let e=d.byId(this.id);if(!e)throw new Error("unable to find root element for view");this.el=e,this.el.setAttribute(z,this.root.id)}execNewMounted(e=document){let t=this.binding(Ye),i=this.binding(Qe);this.all(e,`[${t}], [${i}]`,n=>{d.maintainPrivateHooks(n,n,t,i),this.maybeAddNewHook(n)}),this.all(e,`[${this.binding(Fe)}], [data-phx-${Fe}]`,n=>{this.maybeAddNewHook(n)}),this.all(e,`[${this.binding(Dt)}]`,n=>{this.maybeMounted(n)})}all(e,t,i){d.all(e,t,n=>{this.ownsElement(n)&&i(n)})}applyJoinPatch(e,t,i,n){this.joinCount>1&&this.pendingJoinOps.length&&(this.pendingJoinOps.forEach(o=>typeof o=="function"&&o()),this.pendingJoinOps=[]),this.attachTrueDocEl();let r=new Se(this,this.el,t,i,null);if(r.markPrunableContentForRemoval(),this.performPatch(r,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(n),this.applyPendingUpdates(),e){let{kind:o,to:a}=e;this.liveSocket.historyPatch(a,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),n=i&&d.isIgnored(e,this.binding(Ne));if(i&&!e.isEqualNode(t)&&!(n&&yi(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(Dt)),i=t&&d.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),d.putPrivate(e,"mounted",!0))}maybeAddNewHook(e){let t=this.addHook(e);t&&t.__mounted()}performPatch(e,t,i=!1){let n=[],r=!1,o=new Set;return this.liveSocket.triggerDOM("onPatchStart",[e.targetContainer]),e.afterAdded(a=>{this.liveSocket.triggerDOM("onNodeAdded",[a]);let l=this.binding(Ye),c=this.binding(Qe);d.maintainPrivateHooks(a,a,l,c),this.maybeAddNewHook(a),a.getAttribute&&this.maybeMounted(a)}),e.afterPhxChildAdded(a=>{d.isPhxSticky(a)?this.liveSocket.joinRootViews():r=!0}),e.beforeUpdated((a,l)=>{this.triggerBeforeUpdateHook(a,l)&&o.add(a.id),k.onBeforeElUpdated(a,l)}),e.afterUpdated(a=>{if(o.has(a.id)){let l=this.getHook(a);l&&l.__updated()}}),e.afterDiscarded(a=>{a.nodeType===Node.ELEMENT_NODE&&n.push(a)}),e.afterTransitionsDiscarded(a=>this.afterElementsRemoved(a,t)),e.perform(i),this.afterElementsRemoved(n,t),this.liveSocket.triggerDOM("onPatchEnd",[e.targetContainer]),r}afterElementsRemoved(e,t){let i=[];e.forEach(n=>{let r=d.all(n,`[${de}="${this.id}"][${K}]`),o=d.all(n,`[${this.binding(Fe)}], [data-phx-hook]`);r.concat(n).forEach(a=>{let l=this.componentID(a);oe(l)&&i.indexOf(l)===-1&&a.getAttribute(de)===this.id&&i.push(l)}),o.concat(n).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){d.findPhxChildren(document,this.id).forEach(e=>this.joinChild(e))}maybeRecoverForms(e,t){var l;let i=this.binding("change"),n=this.root.formsForRecovery,r=document.createElement("template");if(r.innerHTML=e,!r.content.firstElementChild)return;d.all(r.content,`[${$e}]`).forEach(c=>{var u;c instanceof HTMLTemplateElement&&((u=r.content.firstElementChild)==null||u.appendChild(c.content.firstElementChild))});let o=r.content.firstElementChild;o.id=this.id,o.setAttribute(z,this.root.id),o.setAttribute(q,this.getSession()),o.setAttribute(se,(l=this.getStatic())!=null?l:""),this.parent&&o.setAttribute(ne,this.parent.id);let a=d.all(r.content,"form").filter(c=>c.id&&n[c.id]).filter(c=>!this.pendingForms.has(c.id)).filter(c=>n[c.id].getAttribute(i)===c.getAttribute(i)).map(c=>[n[c.id],c]);if(a.length===0)return t();a.forEach(([c,u],p)=>{this.pendingForms.add(u.id),this.pushFormRecovery(c,u,r.content.firstElementChild,()=>{this.pendingForms.delete(u.id),p===a.length-1&&t()})})}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){var t;return e.id===this.id?this:this.children&&((t=this.children[e.getAttribute(ne)])==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,i=!1){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return i||this.pendingDiffs.push({diff:e,events:t}),!1;this.rendered.mergeDiff(e);let n=!1;return this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{d.findExistingParentCIDs(this.id,this.rendered.componentCIDs(e)).forEach(o=>{this.componentPatch(this.rendered.getComponent(e,o),o)&&(n=!0)})}):jt(e)||this.liveSocket.time("full patch complete",()=>{let[r,o]=this.renderContainer(e,"update"),a=new Se(this,this.el,r,o,null);n=this.performPatch(a,!0)}),this.liveSocket.dispatchEvents(t),n&&this.joinNewChildren(),!0}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,n=e?this.rendered.componentCIDs(e):null,{buffer:r,streams:o}=this.rendered.toString(n);return[`<${i}>${r}</${i}>`,o]})}componentPatch(e,t){if(jt(e))return!1;let{buffer:i,streams:n}=this.rendered.componentToString(t),r=new Se(this,this.el,i,n,t);return this.performPatch(r,!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]){if(Q.deadHook(e))return;let i=d.getCustomElHook(e)||T(`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-${Fe}`)||e.getAttribute(this.binding(Fe));if(!i)return;let n=this.liveSocket.getHookDefinition(i);if(n){if(!e.id){T(`no DOM ID for hook "${i}". Hooks require a unique ID on each element.`,e);return}let r;try{if(typeof n=="function"&&n.prototype instanceof Q)r=new n(this,e);else if(typeof n=="object"&&n!==null)r=new Q(this,e,n);else{T(`Invalid hook definition for "${i}". Expected a class extending ViewHook or an object definition.`,e);return}}catch(o){let a=o instanceof Error?o.message:String(o);T(`Failed to create hook "${i}": ${a}`,e);return}return this.viewHooks[Q.elementID(r.el)]=r,r}else i!==null&&T(`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=this.pendingDiffs.filter(({diff:e,events:t})=>!this.update(e,t,!0)),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.joinCount>1?this.pendingJoinOps.push(()=>t(i)):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:n}=e,r=this.expandURL(t),o=new CustomEvent("phx:server-navigate",{detail:{to:t,kind:i,flash:n}});this.liveSocket.historyRedirect(o,r,i,n)}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!=null?t:null,i!=null?i:null)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.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.liveSocket.main.href,reloadToken:e.token});return}else if(e.reason==="unauthorized"||e.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.onRedirect({to:this.liveSocket.main.href,flash:this.flash});return}if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);if(this.log("error",()=>["unable to join",e]),this.isMain())this.displayError([be,ke,Oe],{unstructuredError:e,errorKind:"server"}),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this);else{this.joinAttempts>=Ft&&(this.root.displayError([be,ke,Oe],{unstructuredError:e,errorKind:"server"}),this.log("error",()=>[`giving up trying to mount after ${Ft} tries`,e]),this.destroy());let t=d.byId(this.el.id);t?(d.mergeAttrs(t,this.el),this.displayError([be,ke,Oe],{unstructuredError:e,errorKind:"server"}),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),this.liveSocket.isUnloaded()&&this.showLoader(ui)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([be,ke,Oe],{unstructuredError:e,errorKind:"server"}):this.displayError([be,ke,Lt],{unstructuredError:e,errorKind:"client"}))}displayError(e,t={}){this.isMain()&&d.dispatchEvent(window,"phx:page-loading-start",{detail:D({to:this.href,kind:"error"},t)}),this.showLoader(),this.setContainerClasses(...e),this.delayedDisconnected()}delayedDisconnected(){this.disconnectedTimer=setTimeout(()=>{this.execAll(this.binding("disconnected"))},this.liveSocket.disconnectedTimeout)}wrapPush(e,t){let i=this.liveSocket.getLatencySim(),n=i?r=>setTimeout(()=>!this.isDestroyed()&&r(),i):r=>!this.isDestroyed()&&r();n(()=>{e().receive("ok",r=>n(()=>t.ok&&t.ok(r))).receive("error",r=>n(()=>t.error&&t.error(r))).receive("timeout",()=>n(()=>t.timeout&&t.timeout()))})}pushWithReply(e,t,i){if(!this.isConnected())return Promise.reject(new Error("no connection"));let[n,[r],o]=e?e({payload:i}):[null,[],{}],a=this.joinCount,l=function(){};return o.page_loading&&(l=this.liveSocket.withPageLoading({kind:"element",target:r})),typeof i.cid!="number"&&delete i.cid,new Promise((c,u)=>{this.wrapPush(()=>this.channel.push(t,i,mi),{ok:p=>{n!==null&&(this.lastAckRef=n);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),l(),c({resp:p,reply:g,ref:n})};p.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",p.diff,({diff:g,reply:h,events:v})=>{n!==null&&this.undoRefs(n,i.event),this.update(g,v),m(h)})}):(n!==null&&this.undoRefs(n,i.event),m(null))},error:p=>u(new Error(`failed with reason: ${JSON.stringify(p)}`)),timeout:()=>{u(new Error("timeout")),this.joinCount===a&&this.liveSocket.reloadWithJitter(this,()=>{this.log("timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}})})}undoRefs(e,t,i){if(!this.isConnected())return;let n=`[${U}="${this.refSrc()}"]`;i?(i=new Set(i),d.all(document,n,r=>{i&&!i.has(r)||(d.all(r,n,o=>this.undoElRef(o,e,t)),this.undoElRef(r,e,t))})):d.all(document,n,r=>this.undoElRef(r,e,t))}undoElRef(e,t,i){new ye(e).maybeUndo(t,i,r=>{let o=new Se(this,e,r,new Set,null,{undoRef:t}),a=this.performPatch(o,!0);d.all(e,`[${U}="${this.refSrc()}"]`,l=>this.undoElRef(l,t,i)),a&&this.joinNewChildren()})}refSrc(){return this.el.id}putRef(e,t,i,n={}){let r=this.ref++,o=this.binding(Ht);if(n.loading){let a=d.all(document,n.loading).map(l=>({el:l,lock:!0,loading:!0}));e=e.concat(a)}for(let{el:a,lock:l,loading:c}of e){if(!l&&!c)throw new Error("putRef requires lock or loading");if(a.setAttribute(U,this.refSrc()),c&&a.setAttribute(ve,r.toString()),l&&a.setAttribute(C,r.toString()),!c||n.submitter&&!(a===n.submitter||a===n.form))continue;let u=new Promise(h=>{a.addEventListener(`phx:undo-lock:${r}`,()=>h(g),{once:!0})}),p=new Promise(h=>{a.addEventListener(`phx:undo-loading:${r}`,()=>h(g),{once:!0})});a.classList.add(`phx-${i}-loading`);let m=a.getAttribute(o);m!==null&&(a.getAttribute(Me)||a.setAttribute(Me,a.textContent||""),m!==""&&(a.textContent=m),a.setAttribute(Ee,a.getAttribute(Ee)||("disabled"in a?String(a.disabled):"")),a.setAttribute("disabled",""));let g={event:t,eventType:i,ref:r,isLoading:c,isLocked:l,lockElements:e.filter(({lock:h})=>h).map(({el:h})=>h),loadingElements:e.filter(({loading:h})=>h).map(({el:h})=>h),unlock:h=>{h=Array.isArray(h)?h:[h],this.undoRefs(r,t,h)},lockComplete:u,loadingComplete:p,lock:h=>new Promise(v=>{if(this.isAcked(r))return v(g);h.setAttribute(C,r),h.setAttribute(U,this.refSrc()),h.addEventListener(`phx:lock-stop:${r}`,()=>v(g),{once:!0})})};n.payload&&(g.payload=n.payload),n.target&&(g.target=n.target),n.originalEvent&&(g.originalEvent=n.originalEvent),a.dispatchEvent(new CustomEvent("phx:push",{detail:g,bubbles:!0,cancelable:!1})),t&&a.dispatchEvent(new CustomEvent(`phx:push:${t}`,{detail:g,bubbles:!0,cancelable:!1}))}return[r,e.map(({el:a})=>a),n]}isAcked(e){return this.lastAckRef!==null&&this.lastAckRef>=e}componentID(e){let t=e.getAttribute&&e.getAttribute(K);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(oe(t))return t;let n=i.target||e.getAttribute(this.binding("target"));return oe(n)?typeof n=="number"?n:parseInt(n):t&&(n!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return oe(e)?e:e?fe(e.closest(`[${K}],[${Z}]`),t=>{if(t.hasAttribute(K))return this.ownsElement(t)&&this.componentID(t);if(t.hasAttribute(Z)){let i=d.byId(t.getAttribute(Z));return this.closestComponentID(i)}}):null}pushHookEvent(e,t,i,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",i,n]),Promise.reject(new Error("unable to push hook event. LiveView not connected"));let r=()=>this.putRef([{el:e,loading:!0,lock:!0}],i,"hook",{payload:n,target:t});return this.pushWithReply(r,"event",{type:"hook",event:i,value:n,cid:this.closestComponentID(t)}).then(({resp:o,reply:a,ref:l})=>({reply:a,ref:l}))}extractMeta(e,t,i){let n=this.binding("value-");for(let r=0;r<e.attributes.length;r++){t||(t={});let o=e.attributes[r].name;o.startsWith(n)&&(t[o.replace(n,"")]=e.getAttribute(o))}if(e.value!==void 0&&!(e instanceof HTMLFormElement)&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&vt.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let r in i)t[r]=i[r]}return t}serializeForm(e,t={},i=[]){let{submitter:n}=t,r;if(n&&n.name){let m=document.createElement("input");m.type="hidden";let g=n.getAttribute("form");g&&m.setAttribute("form",g),m.name=n.name,m.value=n.value,n.parentElement.insertBefore(m,n),r=m}let o=new FormData(e),a=[];o.forEach((m,g,h)=>{m instanceof File&&a.push(g)}),a.forEach(m=>o.delete(m));let l=new URLSearchParams,{inputsUnused:c,onlyHiddenInputs:u}=Array.from(e.elements).reduce((m,g)=>{if(!d.isFormAssociated(g))return m;let{inputsUnused:h,onlyHiddenInputs:v}=m,E=g.name;if(!E)return m;h[E]===void 0&&(h[E]=!0),v[E]===void 0&&(v[E]=!0);let M=g.hasAttribute(this.binding(Ot)),X=d.private(g,Te)||d.private(g,we)||M,F=g.type==="hidden";return h[E]=h[E]&&!X,v[E]=v[E]&&F,m},{inputsUnused:{},onlyHiddenInputs:{}}),p=e.hasAttribute(this.binding(Ot));for(let[m,g]of o.entries())if(i.length===0||i.indexOf(m)>=0){let h=c[m],v=u[m];!p&&h&&!(n&&n.name==m)&&!v&&l.append(En(m,"_unused_"),""),typeof g=="string"&&l.append(m,g)}return n&&r&&n.parentElement.removeChild(r),l.toString()}pushEvent(e,t,i,n,r,o={},a){this.pushWithReply(l=>this.putRef([{el:t,loading:!0,lock:!0}],n,e,le(D({},o),{payload:l==null?void 0:l.payload})),"event",{type:e,event:n,value:this.extractMeta(t,r,o.value),cid:this.targetComponentID(t,i,o)}).then(({reply:l})=>a&&a(l)).catch(l=>T("Failed to push event",l))}pushFileProgress(e,t,i,n=function(){}){this.liveSocket.withinOwners(e.form,(r,o)=>{r.pushWithReply(null,"progress",{event:e.getAttribute(r.binding(ci)),ref:e.getAttribute(G),entry_ref:t,progress:i,cid:r.targetComponentID(e.form,o)}).then(()=>n()).catch(a=>T("Failed to push file progress",a))})}pushInput(e,t,i,n,r,o){if(!e.form)throw new Error("form events require the input to be inside a form");let a,l=oe(i)?i:this.targetComponentID(e.form,t,r),c=h=>this.putRef([{el:e,loading:!0,lock:!0},{el:e.form,loading:!0,lock:!0}],n,"change",le(D({},r),{payload:h==null?void 0:h.payload})),u,p=this.extractMeta(e.form,{},r.value),m={};e instanceof HTMLButtonElement&&(m.submitter=e),e.getAttribute(this.binding("change"))?u=this.serializeForm(e.form,m,[e.name]):u=this.serializeForm(e.form,m),d.isUploadInput(e)&&e.files&&e.files.length>0&&R.trackFiles(e,Array.from(e.files)),a=R.serializeUploads(e);let g={type:"form",event:n,value:u,meta:D({_target:r._target||"undefined"},p),uploads:a,cid:l};this.pushWithReply(c,"event",g).then(({resp:h})=>{d.isUploadInput(e)&&d.isAutoUpload(e)?ye.onUnlock(e,()=>{if(R.filesAwaitingPreflight(e).length>0){let[v,E]=c();this.undoRefs(v,n,[e.form]),this.uploadFiles(e.form,n,t,v,l,M=>{o&&o(h),this.triggerAwaitingSubmit(e.form,n),this.undoRefs(v,n)})}}):o&&o(h)}).catch(h=>T("Failed to push input event",h))}triggerAwaitingSubmit(e,t){let i=this.getScheduledSubmit(e);if(i){let[n,r,o,a]=i;this.cancelSubmit(e,t),a()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,n,r])=>t.isSameNode(e))}scheduleSubmit(e,t,i,n){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,n])}cancelSubmit(e,t){this.formSubmits=this.formSubmits.filter(([i,n,r,o])=>i.isSameNode(e)?(this.undoRefs(n,t),!1):!0)}disableForm(e,t,i={}){let n=h=>!(ue(h,`${this.binding(Ne)}=ignore`,h.form)||ue(h,"data-phx-update=ignore",h.form)),r=h=>h.hasAttribute(this.binding(Ht)),o=h=>h.tagName=="BUTTON",a=h=>["INPUT","TEXTAREA"].includes(h.tagName),l=Array.from(e.elements),c=l.filter(r),u=l.filter(o).filter(n),p=l.filter(a).filter(n);u.forEach(h=>{h.setAttribute(Ee,h.disabled.toString()),h.disabled=!0}),p.forEach(h=>{h.setAttribute(et,h.readOnly.toString()),h.readOnly=!0,h instanceof HTMLInputElement&&h.files&&(h.setAttribute(Ee,h.disabled.toString()),h.disabled=!0)});let m=c.concat(u).concat(p).map(h=>({el:h,loading:!0,lock:!0})),g=[{el:e,loading:!0,lock:!1},...m].reverse();return this.putRef(g,t,"submit",i)}pushFormSubmit(e,t,i,n,r,o){let a=c=>this.disableForm(e,i,le(D({},r),{form:e,payload:c==null?void 0:c.payload,submitter:n}));d.putPrivate(e,"submitter",n);let l=this.targetComponentID(e,t);if(R.hasUploadsInProgress(e)){let[c,u]=a(),p=()=>this.pushFormSubmit(e,t,i,n,r,o);return this.scheduleSubmit(e,c,r,p)}else if(R.inputsAwaitingPreflight(e).length>0){let[c,u]=a(),p=()=>[c,u,r];this.uploadFiles(e,i,t,c,l,m=>{if(R.inputsAwaitingPreflight(e).length>0)return this.undoRefs(c,i);let g=this.extractMeta(e,{},r.value),h=this.serializeForm(e,{submitter:n});this.pushWithReply(p,"event",{type:"form",event:i,value:h,meta:g,cid:l}).then(({resp:v})=>o(v)).catch(v=>T("Failed to push form submit",v))})}else if(!(e.hasAttribute(U)&&e.classList.contains("phx-submit-loading"))){let c=this.extractMeta(e,{},r.value),u=this.serializeForm(e,{submitter:n});this.pushWithReply(a,"event",{type:"form",event:i,value:u,meta:c,cid:l}).then(({resp:p})=>o(p)).catch(p=>T("Failed to push form submit",p))}}uploadFiles(e,t,i,n,r,o){let a=this.joinCount,l=R.activeFileInputs(e),c=l.length;l.forEach(u=>{let p=new R(u,this,()=>{c--,c===0&&o()}),m=p.entries().map(h=>h.toPreflightPayload());if(m.length===0){c--;return}let g={ref:u.getAttribute(G),entries:m,cid:this.targetComponentID(u.form,i)};this.log("upload",()=>["sending preflight request",g]),this.pushWithReply(null,"allow_upload",g).then(({resp:h})=>{if(this.log("upload",()=>["got preflight response",h]),p.entries().forEach(v=>{h.entries&&!h.entries[v.ref]&&this.handleFailedEntryPreflight(v.ref,"failed preflight",p)}),h.error||Object.keys(h.entries).length===0)this.undoRefs(n,t),(h.error||[]).map(([E,M])=>{this.handleFailedEntryPreflight(E,M,p)});else{let v=E=>{this.channel.onError(()=>{this.joinCount===a&&E()})};p.initAdapterUpload(h,v,this.liveSocket)}}).catch(h=>T("Failed to push upload",h))})}handleFailedEntryPreflight(e,t,i){if(i.isAutoUpload()){let n=i.entries().find(r=>r.ref===e.toString());n&&n.cancel()}else i.entries().map(n=>n.cancel());this.log("upload",()=>[`error for entry ${e}`,t])}dispatchUploads(e,t,i){let n=this.targetCtxElement(e)||this.el,r=d.findUploadInputs(n).filter(o=>o.name===t);r.length===0?T(`no live file inputs found matching the name "${t}"`):r.length>1?T(`duplicate live file inputs found matching the name "${t}"`):d.dispatchEvent(r[0],mt,{detail:{files:i}})}targetCtxElement(e){return oe(e)?d.findComponent(this.id,e):e||null}pushFormRecovery(e,t,i,n){let r=this.binding("change"),o=t.getAttribute(this.binding("target"))||t,a=t.getAttribute(this.binding(It))||t.getAttribute(this.binding("change")),l=Array.from(e.elements).filter(p=>d.isFormAssociated(p)&&p.name&&!p.hasAttribute(r));if(l.length===0){n();return}l.forEach(p=>p.hasAttribute(G)&&R.clearFiles(p));let c=l.find(p=>p.type!=="hidden")||l[0],u=0;this.withinTargets(o,(p,m)=>{let g=this.targetComponentID(t,m);u++;let h=new CustomEvent("phx:form-recovery",{detail:{sourceElement:e}});k.exec(h,"change",a,this,c,["push",{_target:c.name,targetView:p,targetCtx:m,newCid:g,callback:()=>{u--,u===0&&n()}}])},i)}pushLinkPatch(e,t,i,n){let r=this.liveSocket.setPendingLink(t),o=e.isTrusted&&e.type!=="popstate",a=i?()=>this.putRef([{el:i,loading:o,lock:!0}],null,"click"):null,l=()=>this.liveSocket.redirect(window.location.href,null,null),c=t.startsWith("/")?`${location.protocol}//${location.host}${t}`:t;this.pushWithReply(a,"live_patch",{url:c}).then(({resp:u})=>{this.liveSocket.requestDOMUpdate(()=>{if(u.link_redirect)this.liveSocket.replaceMain(t,null,n,r);else{if(u.redirect)return;this.liveSocket.commitPendingLink(r)&&(this.href=t),this.applyPendingUpdates(),n&&n(r)}})},({error:u,timeout:p})=>l())}getFormsForRecovery(){if(this.joinCount===0)return{};let e=this.binding("change");return d.all(document,`#${CSS.escape(this.id)} form[${e}], [${re}="${CSS.escape(this.id)}"] form[${e}]`).filter(t=>t instanceof HTMLFormElement).filter(t=>t.id).filter(t=>t.elements.length>0).filter(t=>t.getAttribute(this.binding(It))!=="ignore").map(t=>{let i=t.cloneNode(!0);ot(i,t,{onBeforeElUpdated:(r,o)=>(d.copyPrivates(r,o),r.getAttribute("form")===t.id&&r.parentNode?(r.parentNode.removeChild(r),!1):!0)});let n=document.querySelectorAll(`[form="${CSS.escape(t.id)}"]`);return Array.from(n).forEach(r=>{let o=r.cloneNode(!0);ot(o,r),d.copyPrivates(o,r),o.removeAttribute("form"),i.appendChild(o)}),i}).reduce((t,i)=>(t[i.id]=i,t),{})}maybePushComponentsDestroyed(e){let t=e.filter(n=>d.findComponent(this.id,n)===null),i=n=>{this.isDestroyed()||T("Failed to push components destroyed",n)};t.length>0&&(t.forEach(n=>this.rendered.resetRender(n)),this.pushWithReply(null,"cids_will_destroy",{cids:t}).then(()=>{this.liveSocket.requestDOMUpdate(()=>{let n=t.filter(r=>d.findComponent(this.id,r)===null);n.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:n}).then(({resp:r})=>{this.rendered.pruneCIDs(r.cids)}).catch(i)})}).catch(i))}ownsElement(e){let t=d.closestViewEl(e);return e.getAttribute(ne)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,n,r={}){d.putPrivate(e,we,!0),Array.from(e.elements).forEach(a=>d.putPrivate(a,we,!0)),this.liveSocket.blurActiveElement(),this.pushFormSubmit(e,t,i,n,r,()=>{this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}pushPortalElementId(e){this.portalElementIds.add(e)}dropPortalElementId(e){this.portalElementIds.delete(e)}destroyPortalElements(){this.liveSocket.unloaded||this.portalElementIds.forEach(e=>{let t=document.getElementById(e);t&&t.remove()})}};var Mi=s=>d.isUsedInput(s),at=class{constructor(e,t,i={}){this.unloaded=!1;if(!t||t.constructor.name==="Object")throw new Error(`
|
|
15
|
+
`,{view:o}),new Error("Cannot bind multiple views to the same DOM element.");d.putPrivate(this.el,"view",this),this.id=this.el.id,this.el.setAttribute(z,this.root.id),this.ref=0,this.lastAckRef=null,this.childJoins=0,this.loaderTimer=null,this.disconnectedTimer=null,this.pendingDiffs=[],this.pendingForms=new Set,this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinAttempts=0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(a){a&&a()},this.stopCallback=function(){},this.pendingJoinOps=[],this.viewHooks={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.formsForRecovery={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{var l;let a=this.href&&this.expandURL(this.href);return{redirect:this.redirect?a:void 0,url:this.redirect?void 0:a||void 0,params:this.connectParams(r),session:this.getSession(),static:this.getStatic(),flash:(l=this.flash)!=null?l:void 0,sticky:this.el.hasAttribute(Ze)}}),this.portalElementIds=new Set}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(De)}connectParams(e){let t=this.liveSocket.params(this.el),i=d.all(document,`[${this.binding(ti)}]`).map(n=>"src"in n&&n.src||"href"in n&&n.href).filter(n=>typeof n=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._mount_attempts=this.joinAttempts,t._live_referer=e!=null?e:void 0,this.joinAttempts++,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(q)}getStatic(){let e=this.el.getAttribute(se);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyPortalElements(),this.destroyed=!0,d.deletePrivate(this.el,"view"),delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],this.loaderTimer!=null&&clearTimeout(this.loaderTimer);let t=()=>{e();for(let i in this.viewHooks)this.destroyHook(this.viewHooks[i])};d.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",t).receive("error",t).receive("timeout",t)}setContainerClasses(...e){this.el.classList.remove(xt,Ee,ke,Lt,Oe),this.el.classList.add(...e)}showLoader(e){if(this.loaderTimer!=null&&clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let t in this.viewHooks)this.viewHooks[t].__disconnected();this.setContainerClasses(Ee)}}execAll(e){d.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){this.loaderTimer!=null&&clearTimeout(this.loaderTimer),this.disconnectedTimer!=null&&clearTimeout(this.disconnectedTimer),this.setContainerClasses(xt),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){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,n=>t(n,e));if(oe(e))d.findComponent(this.id,e,i)?t(this,typeof e=="number"?e:parseInt(e)):w(`no component found matching phx-target of ${e}`);else{let n=Array.from(i.querySelectorAll(e));n.length===0&&w(`nothing found matching the phx-target selector "${e}"`),n.forEach(r=>this.liveSocket.owner(r,o=>t(o,r)))}}applyDiff(e,t,i){this.log(e,()=>["",We(t)]);let{diff:n,reply:r,events:o,title:a}=Ke.extract(t),l=o.reduce((u,p)=>(p.length===3&&p[2]==!0?u.pre.push(p.slice(0,-1)):u.post.push(p),u),{pre:[],post:[]});this.liveSocket.dispatchEvents(l.pre);let c=()=>{i({diff:n,reply:r,events:l.post}),(typeof a=="string"||e=="mount"&&this.isMain())&&window.requestAnimationFrame(()=>d.putTitle(a))};"onDocumentPatch"in this.liveSocket.domCallbacks?this.liveSocket.triggerDOM("onDocumentPatch",[c]):c()}onJoin(e){let{rendered:t,container:i,liveview_version:n,pid:r}=e;if(i){let[o,a]=i;this.el=d.replaceRootContainer(this.el,o,a)}this.childJoins=0,this.joinPending=!0,this.flash=null,this.root===this&&(this.formsForRecovery=this.getFormsForRecovery()),this.isMain()&&window.history.state===null&&V.pushState("replace",{type:"patch",id:this.id,position:this.liveSocket.currentHistoryPosition}),n!==this.liveSocket.version()&&console.warn(`LiveView asset version mismatch. JavaScript version ${this.liveSocket.version()} vs. server ${n}. To avoid issues, please ensure that your assets use the same version as the server.`),r&&this.el.setAttribute(li,r),V.dropLocal(this.liveSocket.localStorage,window.location.pathname,ht),this.applyDiff("mount",t,({diff:o,events:a})=>{this.rendered=new Ke(this.id,o);let[l,c]=this.renderContainer(null,"join");this.dropPendingRefs(),this.joinCount++,this.joinAttempts=0,this.maybeRecoverForms(l,()=>{this.onJoinComplete(e,l,c,a)})})}dropPendingRefs(){d.all(document,`[${U}="${this.refSrc()}"]`,e=>{e.removeAttribute(ve),e.removeAttribute(U),e.removeAttribute(C)})}onJoinComplete({live_patch:e},t,i,n){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i,n);d.findPhxChildrenInFragment(t,this.id).filter(o=>{let a=o.id&&this.el.querySelector(`[id="${o.id}"]`),l=a&&a.getAttribute(se);return l&&o.setAttribute(se,l),a&&a.setAttribute(z,this.root.id),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,n)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i,n)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,n)])}attachTrueDocEl(){let e=d.byId(this.id);if(!e)throw new Error("unable to find root element for view");this.el=e,this.el.setAttribute(z,this.root.id)}execNewMounted(e=document){let t=this.binding(Ye),i=this.binding(Qe);this.all(e,`[${t}], [${i}]`,n=>{d.maintainPrivateHooks(n,n,t,i),this.maybeAddNewHook(n)}),this.all(e,`[${this.binding(Fe)}], [data-phx-${Fe}]`,n=>{this.maybeAddNewHook(n)}),this.all(e,`[${this.binding(Dt)}]`,n=>{this.maybeMounted(n)})}all(e,t,i){d.all(e,t,n=>{this.ownsElement(n)&&i(n)})}applyJoinPatch(e,t,i,n){this.joinCount>1&&this.pendingJoinOps.length&&(this.pendingJoinOps.forEach(o=>typeof o=="function"&&o()),this.pendingJoinOps=[]),this.attachTrueDocEl();let r=new Se(this,this.el,t,i,null);if(r.markPrunableContentForRemoval(),this.performPatch(r,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(n),this.applyPendingUpdates(),e){let{kind:o,to:a}=e;this.liveSocket.historyPatch(a,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),n=i&&d.isIgnored(e,this.binding(Ne));if(i&&!e.isEqualNode(t)&&!(n&&yi(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(Dt)),i=t&&d.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),d.putPrivate(e,"mounted",!0))}maybeAddNewHook(e){let t=this.addHook(e);t&&t.__mounted()}performPatch(e,t,i=!1){let n=[],r=!1,o=new Set;return this.liveSocket.triggerDOM("onPatchStart",[e.targetContainer]),e.afterAdded(a=>{this.liveSocket.triggerDOM("onNodeAdded",[a]);let l=this.binding(Ye),c=this.binding(Qe);d.maintainPrivateHooks(a,a,l,c),this.maybeAddNewHook(a),a.getAttribute&&this.maybeMounted(a)}),e.afterPhxChildAdded(a=>{d.isPhxSticky(a)?this.liveSocket.joinRootViews():r=!0}),e.beforeUpdated((a,l)=>{this.triggerBeforeUpdateHook(a,l)&&o.add(a.id),k.onBeforeElUpdated(a,l)}),e.afterUpdated(a=>{if(o.has(a.id)){let l=this.getHook(a);l&&l.__updated()}}),e.afterDiscarded(a=>{a.nodeType===Node.ELEMENT_NODE&&n.push(a)}),e.afterTransitionsDiscarded(a=>this.afterElementsRemoved(a,t)),e.perform(i),this.afterElementsRemoved(n,t),this.liveSocket.triggerDOM("onPatchEnd",[e.targetContainer]),r}afterElementsRemoved(e,t){let i=[];e.forEach(n=>{let r=d.all(n,`[${de}="${this.id}"][${K}]`),o=d.all(n,`[${this.binding(Fe)}], [data-phx-hook]`);r.concat(n).forEach(a=>{let l=this.componentID(a);oe(l)&&i.indexOf(l)===-1&&a.getAttribute(de)===this.id&&i.push(l)}),o.concat(n).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){d.findPhxChildren(document,this.id).forEach(e=>this.joinChild(e))}maybeRecoverForms(e,t){var l;let i=this.binding("change"),n=this.root.formsForRecovery,r=document.createElement("template");if(r.innerHTML=e,!r.content.firstElementChild)return;d.all(r.content,`[${$e}]`).forEach(c=>{var u;c instanceof HTMLTemplateElement&&((u=r.content.firstElementChild)==null||u.appendChild(c.content.firstElementChild))});let o=r.content.firstElementChild;o.id=this.id,o.setAttribute(z,this.root.id),o.setAttribute(q,this.getSession()),o.setAttribute(se,(l=this.getStatic())!=null?l:""),this.parent&&o.setAttribute(ne,this.parent.id);let a=d.all(r.content,"form").filter(c=>c.id&&n[c.id]).filter(c=>!this.pendingForms.has(c.id)).filter(c=>n[c.id].getAttribute(i)===c.getAttribute(i)).map(c=>[n[c.id],c]);if(a.length===0)return t();a.forEach(([c,u],p)=>{this.pendingForms.add(u.id),this.pushFormRecovery(c,u,r.content.firstElementChild,()=>{this.pendingForms.delete(u.id),p===a.length-1&&t()})})}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){var t;return e.id===this.id?this:this.children&&((t=this.children[e.getAttribute(ne)])==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,i=!1){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return i||this.pendingDiffs.push({diff:e,events:t}),!1;this.rendered.mergeDiff(e);let n=!1;return this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{d.findExistingParentCIDs(this.id,this.rendered.componentCIDs(e)).forEach(o=>{this.componentPatch(this.rendered.getComponent(e,o),o)&&(n=!0)})}):Jt(e)||this.liveSocket.time("full patch complete",()=>{let[r,o]=this.renderContainer(e,"update"),a=new Se(this,this.el,r,o,null);n=this.performPatch(a,!0)}),this.liveSocket.dispatchEvents(t),n&&this.joinNewChildren(),!0}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,n=e?this.rendered.componentCIDs(e):null,{buffer:r,streams:o}=this.rendered.toString(n);return[`<${i}>${r}</${i}>`,o]})}componentPatch(e,t){if(Jt(e))return!1;let{buffer:i,streams:n}=this.rendered.componentToString(t),r=new Se(this,this.el,i,n,t);return this.performPatch(r,!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]){if(Q.deadHook(e))return;let i=d.getCustomElHook(e)||w(`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-${Fe}`)||e.getAttribute(this.binding(Fe));if(!i)return;let n=this.liveSocket.getHookDefinition(i);if(n){if(!e.id){w(`no DOM ID for hook "${i}". Hooks require a unique ID on each element.`,e);return}let r;try{if(typeof n=="function"&&n.prototype instanceof Q)r=new n(this,e);else if(typeof n=="object"&&n!==null)r=new Q(this,e,n);else{w(`Invalid hook definition for "${i}". Expected a class extending ViewHook or an object definition.`,e);return}}catch(o){let a=o instanceof Error?o.message:String(o);w(`Failed to create hook "${i}": ${a}`,e);return}return this.viewHooks[Q.elementID(r.el)]=r,r}else i!==null&&w(`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=this.pendingDiffs.filter(({diff:e,events:t})=>!this.update(e,t,!0)),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.joinCount>1?this.pendingJoinOps.push(()=>t(i)):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:n}=e,r=this.expandURL(t),o=new CustomEvent("phx:server-navigate",{detail:{to:t,kind:i,flash:n}});this.liveSocket.historyRedirect(o,r,i,n)}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!=null?t:null,i!=null?i:null)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.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.events&&this.liveSocket.dispatchEvents(e.events),e.reason==="reload"){this.log("error",()=>[`failed mount with ${e.status}. Falling back to page reload`,e]),this.onRedirect({to:this.liveSocket.main.href,reloadToken:e.token});return}else if(e.reason==="unauthorized"||e.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.onRedirect({to:this.liveSocket.main.href,flash:this.flash});return}if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);if(this.log("error",()=>["unable to join",e]),this.isMain())this.displayError([Ee,ke,Oe],{unstructuredError:e,errorKind:"server"}),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this);else{this.joinAttempts>=Ft&&(this.root.displayError([Ee,ke,Oe],{unstructuredError:e,errorKind:"server"}),this.log("error",()=>[`giving up trying to mount after ${Ft} tries`,e]),this.destroy());let t=d.byId(this.el.id);t?(d.mergeAttrs(t,this.el),this.displayError([Ee,ke,Oe],{unstructuredError:e,errorKind:"server"}),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),this.liveSocket.isUnloaded()&&this.showLoader(ui)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([Ee,ke,Oe],{unstructuredError:e,errorKind:"server"}):this.displayError([Ee,ke,Lt],{unstructuredError:e,errorKind:"client"}))}displayError(e,t={}){this.isMain()&&d.dispatchEvent(window,"phx:page-loading-start",{detail:D({to:this.href,kind:"error"},t)}),this.showLoader(),this.setContainerClasses(...e),this.delayedDisconnected()}delayedDisconnected(){this.disconnectedTimer=setTimeout(()=>{this.execAll(this.binding("disconnected"))},this.liveSocket.disconnectedTimeout)}wrapPush(e,t){let i=this.liveSocket.getLatencySim(),n=i?r=>setTimeout(()=>!this.isDestroyed()&&r(),i):r=>!this.isDestroyed()&&r();n(()=>{e().receive("ok",r=>n(()=>t.ok&&t.ok(r))).receive("error",r=>n(()=>t.error&&t.error(r))).receive("timeout",()=>n(()=>t.timeout&&t.timeout()))})}pushWithReply(e,t,i){if(!this.isConnected())return Promise.reject(new Error("no connection"));let[n,[r],o]=e?e({payload:i}):[null,[],{}],a=this.joinCount,l=function(){};return o.page_loading&&(l=this.liveSocket.withPageLoading({kind:"element",target:r})),typeof i.cid!="number"&&delete i.cid,new Promise((c,u)=>{this.wrapPush(()=>this.channel.push(t,i,mi),{ok:p=>{n!==null&&(this.lastAckRef=n);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),l(),c({resp:p,reply:g,ref:n})};p.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",p.diff,({diff:g,reply:h,events:v})=>{n!==null&&this.undoRefs(n,i.event),this.update(g,v),m(h)})}):(n!==null&&this.undoRefs(n,i.event),m(null))},error:p=>u(new Error(`failed with reason: ${JSON.stringify(p)}`)),timeout:()=>{u(new Error("timeout")),this.joinCount===a&&this.liveSocket.reloadWithJitter(this,()=>{this.log("timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}})})}undoRefs(e,t,i){if(!this.isConnected())return;let n=`[${U}="${this.refSrc()}"]`;i?(i=new Set(i),d.all(document,n,r=>{i&&!i.has(r)||(d.all(r,n,o=>this.undoElRef(o,e,t)),this.undoElRef(r,e,t))})):d.all(document,n,r=>this.undoElRef(r,e,t))}undoElRef(e,t,i){new ye(e).maybeUndo(t,i,r=>{let o=new Se(this,e,r,new Set,null,{undoRef:t}),a=this.performPatch(o,!0);d.all(e,`[${U}="${this.refSrc()}"]`,l=>this.undoElRef(l,t,i)),a&&this.joinNewChildren()})}refSrc(){return this.el.id}putRef(e,t,i,n={}){let r=this.ref++,o=this.binding(Ht);if(n.loading){let a=d.all(document,n.loading).map(l=>({el:l,lock:!0,loading:!0}));e=e.concat(a)}for(let{el:a,lock:l,loading:c}of e){if(!l&&!c)throw new Error("putRef requires lock or loading");if(a.setAttribute(U,this.refSrc()),c&&a.setAttribute(ve,r.toString()),l&&a.setAttribute(C,r.toString()),!c||n.submitter&&!(a===n.submitter||a===n.form))continue;let u=new Promise(h=>{a.addEventListener(`phx:undo-lock:${r}`,()=>h(g),{once:!0})}),p=new Promise(h=>{a.addEventListener(`phx:undo-loading:${r}`,()=>h(g),{once:!0})});a.classList.add(`phx-${i}-loading`);let m=a.getAttribute(o);m!==null&&(a.getAttribute(Me)||a.setAttribute(Me,a.textContent||""),m!==""&&(a.textContent=m),a.setAttribute(be,a.getAttribute(be)||("disabled"in a?String(a.disabled):"")),a.setAttribute("disabled",""));let g={event:t,eventType:i,ref:r,isLoading:c,isLocked:l,lockElements:e.filter(({lock:h})=>h).map(({el:h})=>h),loadingElements:e.filter(({loading:h})=>h).map(({el:h})=>h),unlock:h=>{h=Array.isArray(h)?h:[h],this.undoRefs(r,t,h)},lockComplete:u,loadingComplete:p,lock:h=>new Promise(v=>{if(this.isAcked(r))return v(g);h.setAttribute(C,r),h.setAttribute(U,this.refSrc()),h.addEventListener(`phx:lock-stop:${r}`,()=>v(g),{once:!0})})};n.payload&&(g.payload=n.payload),n.target&&(g.target=n.target),n.originalEvent&&(g.originalEvent=n.originalEvent),a.dispatchEvent(new CustomEvent("phx:push",{detail:g,bubbles:!0,cancelable:!1})),t&&a.dispatchEvent(new CustomEvent(`phx:push:${t}`,{detail:g,bubbles:!0,cancelable:!1}))}return[r,e.map(({el:a})=>a),n]}isAcked(e){return this.lastAckRef!==null&&this.lastAckRef>=e}componentID(e){let t=e.getAttribute&&e.getAttribute(K);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(oe(t))return t;let n=i.target||e.getAttribute(this.binding("target"));return oe(n)?typeof n=="number"?n:parseInt(n):t&&(n!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return oe(e)?e:e?fe(e.closest(`[${K}],[${Z}]`),t=>{if(t.hasAttribute(K))return this.ownsElement(t)&&this.componentID(t);if(t.hasAttribute(Z)){let i=d.byId(t.getAttribute(Z));return this.closestComponentID(i)}}):null}pushHookEvent(e,t,i,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",i,n]),Promise.reject(new Error("unable to push hook event. LiveView not connected"));let r=()=>this.putRef([{el:e,loading:!0,lock:!0}],i,"hook",{payload:n,target:t});return this.pushWithReply(r,"event",{type:"hook",event:i,value:n,cid:this.closestComponentID(t)}).then(({resp:o,reply:a,ref:l})=>({reply:a,ref:l}))}extractMeta(e,t,i){let n=this.binding("value-");for(let r=0;r<e.attributes.length;r++){t||(t={});let o=e.attributes[r].name;o.startsWith(n)&&(t[o.replace(n,"")]=e.getAttribute(o))}if(e.value!==void 0&&!(e instanceof HTMLFormElement)&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&vt.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let r in i)t[r]=i[r]}return t}serializeForm(e,t={},i=[]){let{submitter:n}=t,r;if(n&&n.name){let m=document.createElement("input");m.type="hidden";let g=n.getAttribute("form");g&&m.setAttribute("form",g),m.name=n.name,m.value=n.value,n.parentElement.insertBefore(m,n),r=m}let o=new FormData(e),a=[];o.forEach((m,g,h)=>{m instanceof File&&a.push(g)}),a.forEach(m=>o.delete(m));let l=new URLSearchParams,{inputsUnused:c,onlyHiddenInputs:u}=Array.from(e.elements).reduce((m,g)=>{if(!d.isFormAssociated(g))return m;let{inputsUnused:h,onlyHiddenInputs:v}=m,b=g.name;if(!b)return m;h[b]===void 0&&(h[b]=!0),v[b]===void 0&&(v[b]=!0);let M=g.hasAttribute(this.binding(Ot)),X=d.private(g,we)||d.private(g,Te)||M,F=g.type==="hidden";return h[b]=h[b]&&!X,v[b]=v[b]&&F,m},{inputsUnused:{},onlyHiddenInputs:{}}),p=e.hasAttribute(this.binding(Ot));for(let[m,g]of o.entries())if(i.length===0||i.indexOf(m)>=0){let h=c[m],v=u[m];!p&&h&&!(n&&n.name==m)&&!v&&l.append(bn(m,"_unused_"),""),typeof g=="string"&&l.append(m,g)}return n&&r&&n.parentElement.removeChild(r),l.toString()}pushEvent(e,t,i,n,r,o={},a){this.pushWithReply(l=>this.putRef([{el:t,loading:!0,lock:!0}],n,e,le(D({},o),{payload:l==null?void 0:l.payload})),"event",{type:e,event:n,value:this.extractMeta(t,r,o.value),cid:this.targetComponentID(t,i,o)}).then(({reply:l})=>a&&a(l)).catch(l=>w("Failed to push event",l))}pushFileProgress(e,t,i,n=function(){}){this.liveSocket.withinOwners(e.form,(r,o)=>{r.pushWithReply(null,"progress",{event:e.getAttribute(r.binding(ci)),ref:e.getAttribute(G),entry_ref:t,progress:i,cid:r.targetComponentID(e.form,o)}).then(()=>n()).catch(a=>w("Failed to push file progress",a))})}pushInput(e,t,i,n,r,o){if(!e.form)throw new Error("form events require the input to be inside a form");let a,l=oe(i)?i:this.targetComponentID(e.form,t,r),c=h=>this.putRef([{el:e,loading:!0,lock:!0},{el:e.form,loading:!0,lock:!0}],n,"change",le(D({},r),{payload:h==null?void 0:h.payload})),u,p=this.extractMeta(e.form,{},r.value),m={};e instanceof HTMLButtonElement&&(m.submitter=e),e.getAttribute(this.binding("change"))?u=this.serializeForm(e.form,m,[e.name]):u=this.serializeForm(e.form,m),d.isUploadInput(e)&&e.files&&e.files.length>0&&R.trackFiles(e,Array.from(e.files)),a=R.serializeUploads(e);let g={type:"form",event:n,value:u,meta:D({_target:r._target||"undefined"},p),uploads:a,cid:l};this.pushWithReply(c,"event",g).then(({resp:h})=>{d.isUploadInput(e)&&d.isAutoUpload(e)?ye.onUnlock(e,()=>{if(R.filesAwaitingPreflight(e).length>0){let[v,b]=c();this.undoRefs(v,n,[e.form]),this.uploadFiles(e.form,n,t,v,l,M=>{o&&o(h),this.triggerAwaitingSubmit(e.form,n),this.undoRefs(v,n)})}}):o&&o(h)}).catch(h=>w("Failed to push input event",h))}triggerAwaitingSubmit(e,t){let i=this.getScheduledSubmit(e);if(i){let[n,r,o,a]=i;this.cancelSubmit(e,t),a()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,n,r])=>t.isSameNode(e))}scheduleSubmit(e,t,i,n){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,n])}cancelSubmit(e,t){this.formSubmits=this.formSubmits.filter(([i,n,r,o])=>i.isSameNode(e)?(this.undoRefs(n,t),!1):!0)}disableForm(e,t,i={}){let n=h=>!(ue(h,`${this.binding(Ne)}=ignore`,h.form)||ue(h,"data-phx-update=ignore",h.form)),r=h=>h.hasAttribute(this.binding(Ht)),o=h=>h.tagName=="BUTTON",a=h=>["INPUT","TEXTAREA"].includes(h.tagName),l=Array.from(e.elements),c=l.filter(r),u=l.filter(o).filter(n),p=l.filter(a).filter(n);u.forEach(h=>{h.setAttribute(be,h.disabled.toString()),h.disabled=!0}),p.forEach(h=>{h.setAttribute(et,h.readOnly.toString()),h.readOnly=!0,h instanceof HTMLInputElement&&h.files&&(h.setAttribute(be,h.disabled.toString()),h.disabled=!0)});let m=c.concat(u).concat(p).map(h=>({el:h,loading:!0,lock:!0})),g=[{el:e,loading:!0,lock:!1},...m].reverse();return this.putRef(g,t,"submit",i)}pushFormSubmit(e,t,i,n,r,o){let a=c=>this.disableForm(e,i,le(D({},r),{form:e,payload:c==null?void 0:c.payload,submitter:n}));d.putPrivate(e,"submitter",n);let l=this.targetComponentID(e,t);if(R.hasUploadsInProgress(e)){let[c,u]=a(),p=()=>this.pushFormSubmit(e,t,i,n,r,o);return this.scheduleSubmit(e,c,r,p)}else if(R.inputsAwaitingPreflight(e).length>0){let[c,u]=a(),p=()=>[c,u,r];this.uploadFiles(e,i,t,c,l,m=>{if(R.inputsAwaitingPreflight(e).length>0)return this.undoRefs(c,i);let g=this.extractMeta(e,{},r.value),h=this.serializeForm(e,{submitter:n});this.pushWithReply(p,"event",{type:"form",event:i,value:h,meta:g,cid:l}).then(({resp:v})=>o(v)).catch(v=>w("Failed to push form submit",v))})}else if(!(e.hasAttribute(U)&&e.classList.contains("phx-submit-loading"))){let c=this.extractMeta(e,{},r.value),u=this.serializeForm(e,{submitter:n});this.pushWithReply(a,"event",{type:"form",event:i,value:u,meta:c,cid:l}).then(({resp:p})=>o(p)).catch(p=>w("Failed to push form submit",p))}}uploadFiles(e,t,i,n,r,o){let a=this.joinCount,l=R.activeFileInputs(e),c=l.length;l.forEach(u=>{let p=new R(u,this,()=>{c--,c===0&&o()}),m=p.entries().map(h=>h.toPreflightPayload());if(m.length===0){c--;return}let g={ref:u.getAttribute(G),entries:m,cid:this.targetComponentID(u.form,i)};this.log("upload",()=>["sending preflight request",g]),this.pushWithReply(null,"allow_upload",g).then(({resp:h})=>{if(this.log("upload",()=>["got preflight response",h]),p.entries().forEach(v=>{h.entries&&!h.entries[v.ref]&&this.handleFailedEntryPreflight(v.ref,"failed preflight",p)}),h.error||Object.keys(h.entries).length===0)this.undoRefs(n,t),(h.error||[]).map(([b,M])=>{this.handleFailedEntryPreflight(b,M,p)});else{let v=b=>{this.channel.onError(()=>{this.joinCount===a&&b()})};p.initAdapterUpload(h,v,this.liveSocket)}}).catch(h=>w("Failed to push upload",h))})}handleFailedEntryPreflight(e,t,i){if(i.isAutoUpload()){let n=i.entries().find(r=>r.ref===e.toString());n&&n.cancel()}else i.entries().map(n=>n.cancel());this.log("upload",()=>[`error for entry ${e}`,t])}dispatchUploads(e,t,i){let n=this.targetCtxElement(e)||this.el,r=d.findUploadInputs(n).filter(o=>o.name===t);r.length===0?w(`no live file inputs found matching the name "${t}"`):r.length>1?w(`duplicate live file inputs found matching the name "${t}"`):d.dispatchEvent(r[0],mt,{detail:{files:i}})}targetCtxElement(e){return oe(e)?d.findComponent(this.id,e):e||null}pushFormRecovery(e,t,i,n){let r=this.binding("change"),o=t.getAttribute(this.binding("target"))||t,a=t.getAttribute(this.binding(It))||t.getAttribute(this.binding("change")),l=Array.from(e.elements).filter(p=>d.isFormAssociated(p)&&p.name&&!p.hasAttribute(r));if(l.length===0){n();return}l.forEach(p=>p.hasAttribute(G)&&R.clearFiles(p));let c=l.find(p=>p.type!=="hidden")||l[0],u=0;this.withinTargets(o,(p,m)=>{let g=this.targetComponentID(t,m);u++;let h=new CustomEvent("phx:form-recovery",{detail:{sourceElement:e}});k.exec(h,"change",a,this,c,["push",{_target:c.name,targetView:p,targetCtx:m,newCid:g,callback:()=>{u--,u===0&&n()}}])},i)}pushLinkPatch(e,t,i,n){let r=this.liveSocket.setPendingLink(t),o=e.isTrusted&&e.type!=="popstate",a=i?()=>this.putRef([{el:i,loading:o,lock:!0}],null,"click"):null,l=()=>this.liveSocket.redirect(window.location.href,null,null),c=t.startsWith("/")?`${location.protocol}//${location.host}${t}`:t;this.pushWithReply(a,"live_patch",{url:c}).then(({resp:u})=>{this.liveSocket.requestDOMUpdate(()=>{if(u.link_redirect)this.liveSocket.replaceMain(t,null,n,r);else{if(u.redirect)return;this.liveSocket.commitPendingLink(r)&&(this.href=t),this.applyPendingUpdates(),n&&n(r)}})},({error:u,timeout:p})=>l())}getFormsForRecovery(){if(this.joinCount===0)return{};let e=this.binding("change");return d.all(document,`#${CSS.escape(this.id)} form[${e}], [${re}="${CSS.escape(this.id)}"] form[${e}]`).filter(t=>t instanceof HTMLFormElement).filter(t=>t.id).filter(t=>t.elements.length>0).filter(t=>t.getAttribute(this.binding(It))!=="ignore").map(t=>{let i=t.cloneNode(!0);ot(i,t,{onBeforeElUpdated:(r,o)=>(d.copyPrivates(r,o),r.getAttribute("form")===t.id&&r.parentNode?(r.parentNode.removeChild(r),!1):!0)});let n=document.querySelectorAll(`[form="${CSS.escape(t.id)}"]`);return Array.from(n).forEach(r=>{let o=r.cloneNode(!0);ot(o,r),d.copyPrivates(o,r),o.removeAttribute("form"),i.appendChild(o)}),i}).reduce((t,i)=>(t[i.id]=i,t),{})}maybePushComponentsDestroyed(e){let t=e.filter(n=>d.findComponent(this.id,n)===null),i=n=>{this.isDestroyed()||w("Failed to push components destroyed",n)};t.length>0&&(t.forEach(n=>this.rendered.resetRender(n)),this.pushWithReply(null,"cids_will_destroy",{cids:t}).then(()=>{this.liveSocket.requestDOMUpdate(()=>{let n=t.filter(r=>d.findComponent(this.id,r)===null);n.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:n}).then(({resp:r})=>{this.rendered.pruneCIDs(r.cids)}).catch(i)})}).catch(i))}ownsElement(e){let t=d.closestViewEl(e);return e.getAttribute(ne)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,n,r={}){d.putPrivate(e,Te,!0),Array.from(e.elements).forEach(a=>d.putPrivate(a,Te,!0)),this.liveSocket.blurActiveElement(),this.pushFormSubmit(e,t,i,n,r,()=>{this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}pushPortalElementId(e){this.portalElementIds.add(e)}dropPortalElementId(e){this.portalElementIds.delete(e)}destroyPortalElements(){this.liveSocket.unloaded||this.portalElementIds.forEach(e=>{let t=document.getElementById(e);t&&t.remove()})}};var Mi=s=>d.isUsedInput(s),at=class{constructor(e,t,i={}){this.unloaded=!1;if(!t||t.constructor.name==="Object")throw new Error(`
|
|
16
16
|
a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example:
|
|
17
17
|
|
|
18
18
|
import {Socket} from "phoenix"
|
|
19
19
|
import {LiveSocket} from "phoenix_live_view"
|
|
20
20
|
let liveSocket = new LiveSocket("/live", Socket, {...})
|
|
21
|
-
`);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||pi,this.params=Je(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(We(gi),i.defaults||{}),this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=We(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||hi,this.disconnectedTimeout=i.disconnectedTimeout||fi,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.blockPhxChangeWhileComposing=i.blockPhxChangeWhileComposing||!1,this.serverCloseRef=null,this.domCallbacks=Object.assign({jsQuerySelectorAll:null,onPatchStart:Je(),onPatchEnd:Je(),onNodeAdded:Je(),onBeforeElUpdated:Je()},i.dom||{}),this.transitions=new Gt,this.currentHistoryPosition=parseInt(this.sessionStorage.getItem(it)||"0")||0,window.addEventListener("pagehide",n=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}version(){return"1.2.0-rc.3"}isProfileEnabled(){return this.sessionStorage.getItem(bt)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(tt)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(tt)==="false"}enableDebug(){this.sessionStorage.setItem(tt,"true")}enableProfiling(){this.sessionStorage.setItem(bt,"true")}disableDebug(){this.sessionStorage.setItem(tt,"false")}disableProfiling(){this.sessionStorage.removeItem(bt)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(Et,e.toString())}disableLatencySim(){this.sessionStorage.removeItem(Et)}getLatencySim(){let e=this.sessionStorage.getItem(Et);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){this.reloadWithJitterTimer!=null&&clearTimeout(this.reloadWithJitterTimer),this.serverCloseRef&&(this.socket.off([this.serverCloseRef]),this.serverCloseRef=null),this.socket.disconnect(e)}replaceTransport(e){this.reloadWithJitterTimer!=null&&clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){let n=new CustomEvent("phx:exec",{detail:{sourceElement:e}});this.owner(e,r=>k.exec(n,i,t,r,e))}js(){return kt(this,"js")}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(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[n,r]=i();this.viewLogger(e,t,n,r)}else if(this.isDebugEnabled()){let[n,r]=i();Ei(e,t,n,r)}}requestDOMUpdate(e){this.transitions.after(e)}asyncTransition(e){this.transitions.addAsyncTransition(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,n=>{let r=this.getLatencySim();r?setTimeout(()=>i(n),r):i(n)})}reloadWithJitter(e,t){this.reloadWithJitterTimer!=null&&clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,n=this.reloadJitterMax,r=Math.floor(Math.random()*(n-i+1))+i,o=V.updateLocal(this.localStorage,window.location.pathname,ht,0,a=>a+1);o>=this.maxReloads&&(r=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.pendingLink!==null?window.location.href=this.pendingLink:window.location.reload())},r)}getHookDefinition(e){if(e)return this.maybeInternalHook(e)||this.hooks[e]||this.maybeRuntimeHook(e)}maybeInternalHook(e){return e&&e.startsWith("Phoenix.")&&_i[e.split(".")[1]]}maybeRuntimeHook(e){let t=document.querySelector(`script[${Ve}="${CSS.escape(e)}"]`);if(!t)return;let i=window[`phx_hook_${e}`];if(!i||typeof i!="function"){T("a runtime hook must be a function",t);return}let n=i();if(n&&(typeof n=="object"||typeof n=="function"))return n;T("runtime hook must return an object with hook callbacks or an instance of ViewHook",t)}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 d.all(document,`${ce}:not([${ne}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);d.isPhxSticky(t)||i.setHref(this.getHref()),i.join(),t.hasAttribute(De)&&(this.main=i)}e=!0}),e}redirect(e,t,i){i&&V.setCookie(Mt,i,60),this.unload(),V.redirect(e,t)}replaceMain(e,t,i=null,n=this.setPendingLink(e)){if(!this.main)return;let r=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=d.findPhxSticky(document)||[],a=d.all(this.outgoingMainEl,`[${this.binding("remove")}]`).filter(c=>!d.isChildOfAny(c,o)),l=d.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(l,t,r),this.main.setRedirect(e),this.transitionRemoves(a),this.main.join((c,u)=>{c===1&&this.commitPendingLink(n)&&this.requestDOMUpdate(()=>{a.forEach(p=>p.remove()),o.forEach(p=>l.appendChild(p)),this.outgoingMainEl.replaceWith(l),this.outgoingMainEl=null,i&&i(n),u()})})}transitionRemoves(e,t){let i=this.binding("remove"),n=r=>{r.preventDefault(),r.stopImmediatePropagation()};e.forEach(r=>{for(let o of this.boundEventNames)r.addEventListener(o,n,!0);this.execJS(r,r.getAttribute(i),"remove")}),this.requestDOMUpdate(()=>{e.forEach(r=>{for(let o of this.boundEventNames)r.removeEventListener(o,n,!0)}),t&&t()})}isPhxView(e){return e.getAttribute&&e.getAttribute(q)!==null}newRootView(e,t,i){let n=new Re(e,this,null,t,i);return this.roots[n.id]=n,n}owner(e,t){let i,n=d.closestViewEl(e);if(n)i=this.getViewByEl(n);else{if(!e.isConnected)return null;i=this.main}return i&&t?t(i):i}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(z);return fe(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(z));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 instanceof HTMLElement&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive instanceof HTMLElement&&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,n,r,o,a)=>{let l=r.getAttribute(this.binding(di)),c=t.key&&t.key.toLowerCase();if(l&&l.toLowerCase()!==c)return;let u=D({key:t.key},this.eventMeta(i,t,r));k.exec(t,i,o,n,r,["push",{data:u}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,n,r,o,a)=>{if(!a){let l=D({},this.eventMeta(i,t,r));k.exec(t,i,o,n,r,["push",{data:l}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,n,r,o,a)=>{if(a==="window"){let l=this.eventMeta(i,t,r);k.exec(t,i,o,n,r,["push",{data:l}])}}),this.on("dragover",t=>t.preventDefault()),this.on("dragenter",t=>{let i=t.target&&d.elementFromTarget(t.target);if(!i)return;let n=ue(i,this.binding(qe));!n||!(n instanceof HTMLElement)||Si(t)&&this.js().addClass(n,ft)}),this.on("dragleave",t=>{let i=t.target&&d.elementFromTarget(t.target);if(!i)return;let n=ue(i,this.binding(qe));if(!n||!(n instanceof HTMLElement))return;let r=n.getBoundingClientRect();(t.clientX<=r.left||t.clientX>=r.right||t.clientY<=r.top||t.clientY>=r.bottom)&&this.js().removeClass(n,ft)}),this.on("drop",t=>{let i=t.target&&d.elementFromTarget(t.target);if(!i)return;t.preventDefault();let n=ue(i,this.binding(qe));if(!n||!(n instanceof HTMLElement)||(this.js().removeClass(n,ft),!t.dataTransfer))return;let r=n.getAttribute(this.binding(qe)),o=r&&document.getElementById(r),a=Array.from(t.dataTransfer.files||[]);!o||!(o instanceof HTMLInputElement)||o.disabled||a.length===0||!(o.files instanceof FileList)||(R.trackFiles(o,a,t.dataTransfer),o.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(mt,t=>{let i=t.target&&d.elementFromTarget(t.target);if(!d.isUploadInput(i))return;let n=Array.from(t.detail.files||[]).filter(r=>r instanceof File||r instanceof Blob);R.trackFiles(i,n),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let n=this.metadataCallbacks[e];return n?n(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.resetReloadStatus(),this.linkRef}resetReloadStatus(){V.deleteCookie(Mt)}commitPendingLink(e){return this.linkRef!==e?!1:(this.pendingLink!==null&&(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 n=e[i];this.on(n,r=>{let o=this.binding(i),a=this.binding(`window-${i}`),l=r.target instanceof Element&&r.target.getAttribute(o);r.target instanceof Element&&(l?this.debounce(r.target,r,n,()=>{this.withinOwners(r.target,c=>{t(r,i,c,r.target,l,null)})}):d.all(document,`[${a}]`,c=>{let u=c.getAttribute(a);this.debounce(c,r,n,()=>{this.withinOwners(c,p=>{t(r,i,p,c,u,"window")})})}))})}}bindClicks(){this.on("mousedown",e=>this.clickStartedAtTarget=e.target),this.bindClick()}bindClick(){let e=this.binding("click");window.addEventListener("click",t=>{let i=t.target&&d.elementFromTarget(t.target);if(!i)return;t.detail===0&&(this.clickStartedAtTarget=i);let n=this.clickStartedAtTarget||i;if(i=ue(i,e),this.dispatchClickAway(t,n),this.clickStartedAtTarget=null,!i)return;let r=i.getAttribute(e);if(!r){d.isNewPageClick(t,window.location)&&this.unload();return}i.getAttribute("href")==="#"&&t.preventDefault(),!i.hasAttribute(U)&&this.debounce(i,t,"click",()=>{this.withinOwners(i,o=>{k.exec(t,"click",r,o,i,["push",{data:this.eventMeta("click",t,i)}])})})},!1)}dispatchClickAway(e,t){let i=this.binding("click-away"),n=t.closest(`[${Z}]`),r=n&&d.byId(n.getAttribute(Z));d.all(document,`[${i}]`,o=>{let a=t;n&&!n.contains(o)&&(a=r),o.isSameNode(a)||o.contains(a)||!k.isVisible(t)||this.withinOwners(o,l=>{let c=o.getAttribute(i);k.isVisible(o)&&k.isInViewport(o)&&k.exec(e,"click",c,l,o,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!V.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{e!=null&&clearTimeout(e),e=setTimeout(()=>{V.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,backType:n,id:r,scroll:o,position:a}=t.state||{},l=window.location.href,c=a>this.currentHistoryPosition,u=c?i:n||i;this.currentHistoryPosition=a||0,this.sessionStorage.setItem(it,this.currentHistoryPosition.toString()),d.dispatchEvent(window,"phx:navigate",{detail:{href:l,patch:u==="patch",pop:!0,direction:c?"forward":"backward"}}),this.requestDOMUpdate(()=>{let p=()=>{this.maybeScroll(o)};this.main&&this.main.isConnected()&&u==="patch"&&r===this.main.id?this.main.pushLinkPatch(t,l,null,p):this.replaceMain(l,null,p)})},!1),window.addEventListener("click",t=>{let i=t.target&&d.elementFromTarget(t.target);if(!i)return;let n=ue(i,pt),r=n&&n.getAttribute(pt);if(!r||!this.isConnected()||!this.main||d.wantsNewTab(t))return;let o=n.href instanceof SVGAnimatedString?n.href.baseVal:n.href,a=n.getAttribute(Pt);if(a!=="replace"&&a!=="push")throw new Error(`expected ${Pt} to be "replace" or "push", got: ${a}`);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==o&&this.requestDOMUpdate(()=>{if(r==="patch")this.pushHistoryPatch(t,o,a,n);else if(r==="redirect")this.historyRedirect(t,o,a,null,n);else throw new Error(`expected ${pt} to be "patch" or "redirect", got: ${r}`);let l=n.getAttribute(this.binding("click"));l&&this.requestDOMUpdate(()=>this.execJS(n,l,"click"))})},!1)}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}dispatchEvent(e,t={}){d.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){d.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>d.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i,n){if(!this.isConnected()||!(this.main&&this.main.isMain()))return V.redirect(t);this.withPageLoading({to:t,kind:"patch"},r=>{this.main.pushLinkPatch(e,t,n,o=>{this.historyPatch(t,i,o),r()})})}historyPatch(e,t,i=this.setPendingLink(e)){this.commitPendingLink(i)&&(this.currentHistoryPosition++,this.sessionStorage.setItem(it,this.currentHistoryPosition.toString()),V.updateCurrentState(n=>le(D({},n),{backType:"patch"})),V.pushState(t,{type:"patch",id:this.main.id,position:this.currentHistoryPosition},e),d.dispatchEvent(window,"phx:navigate",{detail:{patch:!0,href:e,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location))}historyRedirect(e,t,i,n,r){let o=r&&e.isTrusted&&e.type!=="popstate";if(o&&r.classList.add("phx-click-loading"),!this.isConnected()||!(this.main&&this.main.isMain()))return V.redirect(t,n);if(/^\/$|^\/[^\/]+.*$/.test(t)){let{protocol:l,host:c}=window.location;t=`${l}//${c}${t}`}let a=window.scrollY;this.withPageLoading({to:t,kind:"redirect"},l=>{this.replaceMain(t,n,c=>{c===this.linkRef&&(this.currentHistoryPosition++,this.sessionStorage.setItem(it,this.currentHistoryPosition.toString()),V.updateCurrentState(u=>le(D({},u),{backType:"redirect"})),V.pushState(i,{type:"redirect",id:this.main.id,scroll:a,position:this.currentHistoryPosition},t),d.dispatchEvent(window,"phx:navigate",{detail:{href:t,patch:!1,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location)),o&&r.classList.remove("phx-click-loading"),l()})})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=We(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{if(!(i.target instanceof HTMLFormElement))return;let n=i.target.getAttribute(this.binding("submit")),r=i.target.getAttribute(this.binding("change"));!t&&r&&!n&&(t=!0,i.preventDefault(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>{d.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))}),this.on("submit",i=>{if(!(i.target instanceof HTMLFormElement))return;let n=i.target.getAttribute(this.binding("submit"));if(!n){d.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,r=>{k.exec(i,"submit",n,r,i.target,["push",{submitter:i.submitter}])})});for(let i of["change","input"])this.on(i,n=>{if(!d.isFormAssociated(n.target))return;if(n instanceof CustomEvent&&n.target.form===void 0){if(n.detail&&n.detail.dispatcher)throw new Error(`dispatching a custom ${i} event is only supported on input elements inside a form`);return}let r=n.target,o=this.binding("change");if(this.blockPhxChangeWhileComposing&&n instanceof InputEvent&&n.isComposing){let h=`composition-listener-${i}`;d.private(r,h)||(d.putPrivate(r,h,!0),r.addEventListener("compositionend",()=>{r.dispatchEvent(new Event(i,{bubbles:!0})),d.deletePrivate(r,h)},{once:!0}));return}let a=r.getAttribute(o),l=r.form&&r.form.getAttribute(o),c=a||l;if(!c||r.type==="number"&&r.validity&&r.validity.badInput)return;let u=a?r:r.form,p=e;e++;let{at:m,type:g}=d.private(r,"prev-iteration")||{};m===p-1&&i==="change"&&g==="input"||(d.putPrivate(r,"prev-iteration",{at:p,type:i}),this.debounce(r,n,i,()=>{this.withinOwners(u,h=>{d.putPrivate(r,Te,!0),k.exec(n,"change",c,h,r,["push",{_target:r.name,dispatcher:u}])})}))});this.on("reset",i=>{let n=i.target;d.resetForm(n);let r=Array.from(n.elements).find(o=>"type"in o&&o.type==="reset");r&&window.requestAnimationFrame(()=>{r.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,t,i,n){if(i==="blur"||i==="focusout")return n();let r=this.binding(oi),o=this.binding(ai),a=this.defaults.debounce.toString(),l=this.defaults.throttle.toString();this.withinOwners(e,c=>{let u=()=>!c.isDestroyed()&&document.body.contains(e);d.debounce(e,t,r,a,o,l,u,()=>{n()})})}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 n=this.domCallbacks.jsQuerySelectorAll;return n?n(e,t,i):i()}},Gt=class{constructor(){this.transitions=new Set,this.promises=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.promises.clear(),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let n=setTimeout(()=>{this.transitions.delete(n),i(),this.flushPendingOps()},e);this.transitions.add(n)}addAsyncTransition(e){this.promises.add(e),e.then(()=>{this.promises.delete(e),this.flushPendingOps()})}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size+this.promises.size}flushPendingOps(){if(this.size()>0)return;let e=this.pendingOps.shift();e&&(e(),this.flushPendingOps())}};function Tn(s,e){let t=d.getCustomElHook(s);if(t)return t;s.hasAttribute("id")||T("Elements passed to createHook need to have a unique id attribute",s);let i=new Q(Re.closestView(s),s,e);return d.putCustomElHook(s,i),i}function wn(s,e){return R.getEntryDataURL(s,e)}return Ji(_n);})();
|
|
21
|
+
`);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||pi,this.params=je(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(We(gi),i.defaults||{}),this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=We(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||hi,this.disconnectedTimeout=i.disconnectedTimeout||fi,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.blockPhxChangeWhileComposing=i.blockPhxChangeWhileComposing||!1,this.serverCloseRef=null,this.domCallbacks=Object.assign({jsQuerySelectorAll:null,onPatchStart:je(),onPatchEnd:je(),onNodeAdded:je(),onBeforeElUpdated:je()},i.dom||{}),this.transitions=new Gt,this.currentHistoryPosition=parseInt(this.sessionStorage.getItem(it)||"0")||0,window.addEventListener("pagehide",n=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}version(){return"1.2.0"}isProfileEnabled(){return this.sessionStorage.getItem(Et)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(tt)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(tt)==="false"}enableDebug(){this.sessionStorage.setItem(tt,"true")}enableProfiling(){this.sessionStorage.setItem(Et,"true")}disableDebug(){this.sessionStorage.setItem(tt,"false")}disableProfiling(){this.sessionStorage.removeItem(Et)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(bt,e.toString())}disableLatencySim(){this.sessionStorage.removeItem(bt)}getLatencySim(){let e=this.sessionStorage.getItem(bt);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){this.reloadWithJitterTimer!=null&&clearTimeout(this.reloadWithJitterTimer),this.serverCloseRef&&(this.socket.off([this.serverCloseRef]),this.serverCloseRef=null),this.socket.disconnect(e)}replaceTransport(e){this.reloadWithJitterTimer!=null&&clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){let n=new CustomEvent("phx:exec",{detail:{sourceElement:e}});this.owner(e,r=>k.exec(n,i,t,r,e))}js(){return kt(this,"js")}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(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[n,r]=i();this.viewLogger(e,t,n,r)}else if(this.isDebugEnabled()){let[n,r]=i();bi(e,t,n,r)}}requestDOMUpdate(e){this.transitions.after(e)}asyncTransition(e){this.transitions.addAsyncTransition(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,n=>{let r=this.getLatencySim();r?setTimeout(()=>i(n),r):i(n)})}reloadWithJitter(e,t){this.reloadWithJitterTimer!=null&&clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,n=this.reloadJitterMax,r=Math.floor(Math.random()*(n-i+1))+i,o=V.updateLocal(this.localStorage,window.location.pathname,ht,0,a=>a+1);o>=this.maxReloads&&(r=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.pendingLink!==null?window.location.href=this.pendingLink:window.location.reload())},r)}getHookDefinition(e){if(e)return this.maybeInternalHook(e)||this.hooks[e]||this.maybeRuntimeHook(e)}maybeInternalHook(e){return e&&e.startsWith("Phoenix.")&&_i[e.split(".")[1]]}maybeRuntimeHook(e){let t=document.querySelector(`script[${Ve}="${CSS.escape(e)}"]`);if(!t)return;let i=window[`phx_hook_${e}`];if(!i||typeof i!="function"){w("a runtime hook must be a function",t);return}let n=i();if(n&&(typeof n=="object"||typeof n=="function"))return n;w("runtime hook must return an object with hook callbacks or an instance of ViewHook",t)}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 d.all(document,`${ce}:not([${ne}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);d.isPhxSticky(t)||i.setHref(this.getHref()),i.join(),t.hasAttribute(De)&&(this.main=i)}e=!0}),e}redirect(e,t,i){i&&V.setCookie(Mt,i,60),this.unload(),V.redirect(e,t)}replaceMain(e,t,i=null,n=this.setPendingLink(e)){if(!this.main)return;let r=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=d.findPhxSticky(document)||[],a=d.all(this.outgoingMainEl,`[${this.binding("remove")}]`).filter(c=>!d.isChildOfAny(c,o)),l=d.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(l,t,r),this.main.setRedirect(e),this.transitionRemoves(a),this.main.join((c,u)=>{c===1&&this.commitPendingLink(n)&&this.requestDOMUpdate(()=>{a.forEach(p=>p.remove()),o.forEach(p=>l.appendChild(p)),this.outgoingMainEl.replaceWith(l),this.outgoingMainEl=null,i&&i(n),u()})})}transitionRemoves(e,t){let i=this.binding("remove"),n=r=>{r.preventDefault(),r.stopImmediatePropagation()};e.forEach(r=>{for(let o of this.boundEventNames)r.addEventListener(o,n,!0);this.execJS(r,r.getAttribute(i),"remove")}),this.requestDOMUpdate(()=>{e.forEach(r=>{for(let o of this.boundEventNames)r.removeEventListener(o,n,!0)}),t&&t()})}isPhxView(e){return e.getAttribute&&e.getAttribute(q)!==null}newRootView(e,t,i){let n=new Re(e,this,null,t,i);return this.roots[n.id]=n,n}owner(e,t){let i,n=d.closestViewEl(e);if(n)i=this.getViewByEl(n);else{if(!e.isConnected)return null;i=this.main}return i&&t?t(i):i}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(z);return fe(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(z));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 instanceof HTMLElement&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive instanceof HTMLElement&&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,n,r,o,a)=>{let l=r.getAttribute(this.binding(di)),c=t.key&&t.key.toLowerCase();if(l&&l.toLowerCase()!==c)return;let u=D({key:t.key},this.eventMeta(i,t,r));k.exec(t,i,o,n,r,["push",{data:u}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,n,r,o,a)=>{if(!a){let l=D({},this.eventMeta(i,t,r));k.exec(t,i,o,n,r,["push",{data:l}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,n,r,o,a)=>{if(a==="window"){let l=this.eventMeta(i,t,r);k.exec(t,i,o,n,r,["push",{data:l}])}}),this.on("dragover",t=>t.preventDefault()),this.on("dragenter",t=>{let i=t.target&&d.elementFromTarget(t.target);if(!i)return;let n=ue(i,this.binding(qe));!n||!(n instanceof HTMLElement)||Si(t)&&this.js().addClass(n,ft)}),this.on("dragleave",t=>{let i=t.target&&d.elementFromTarget(t.target);if(!i)return;let n=ue(i,this.binding(qe));if(!n||!(n instanceof HTMLElement))return;let r=n.getBoundingClientRect();(t.clientX<=r.left||t.clientX>=r.right||t.clientY<=r.top||t.clientY>=r.bottom)&&this.js().removeClass(n,ft)}),this.on("drop",t=>{let i=t.target&&d.elementFromTarget(t.target);if(!i)return;t.preventDefault();let n=ue(i,this.binding(qe));if(!n||!(n instanceof HTMLElement)||(this.js().removeClass(n,ft),!t.dataTransfer))return;let r=n.getAttribute(this.binding(qe)),o=r&&document.getElementById(r),a=Array.from(t.dataTransfer.files||[]);!o||!(o instanceof HTMLInputElement)||o.disabled||a.length===0||!(o.files instanceof FileList)||(R.trackFiles(o,a,t.dataTransfer),o.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(mt,t=>{let i=t.target&&d.elementFromTarget(t.target);if(!d.isUploadInput(i))return;let n=Array.from(t.detail.files||[]).filter(r=>r instanceof File||r instanceof Blob);R.trackFiles(i,n),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let n=this.metadataCallbacks[e];return n?n(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.resetReloadStatus(),this.linkRef}resetReloadStatus(){V.deleteCookie(Mt)}commitPendingLink(e){return this.linkRef!==e?!1:(this.pendingLink!==null&&(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 n=e[i];this.on(n,r=>{let o=this.binding(i),a=this.binding(`window-${i}`),l=r.target instanceof Element&&r.target.getAttribute(o);r.target instanceof Element&&(l?this.debounce(r.target,r,n,()=>{this.withinOwners(r.target,c=>{t(r,i,c,r.target,l,null)})}):d.all(document,`[${a}]`,c=>{let u=c.getAttribute(a);this.debounce(c,r,n,()=>{this.withinOwners(c,p=>{t(r,i,p,c,u,"window")})})}))})}}bindClicks(){this.on("mousedown",e=>this.clickStartedAtTarget=e.target),this.bindClick()}bindClick(){let e=this.binding("click");window.addEventListener("click",t=>{let i=t.target&&d.elementFromTarget(t.target);if(!i)return;t.detail===0&&(this.clickStartedAtTarget=i);let n=this.clickStartedAtTarget||i;if(i=ue(i,e),this.dispatchClickAway(t,n),this.clickStartedAtTarget=null,!i)return;let r=i.getAttribute(e);if(!r){d.isNewPageClick(t,window.location)&&this.unload();return}i.getAttribute("href")==="#"&&t.preventDefault(),!i.hasAttribute(U)&&this.debounce(i,t,"click",()=>{this.withinOwners(i,o=>{k.exec(t,"click",r,o,i,["push",{data:this.eventMeta("click",t,i)}])})})},!1)}dispatchClickAway(e,t){let i=this.binding("click-away"),n=t.closest(`[${Z}]`),r=n&&d.byId(n.getAttribute(Z));d.all(document,`[${i}]`,o=>{let a=t;n&&!n.contains(o)&&(a=r),o.isSameNode(a)||o.contains(a)||!k.isVisible(t)||this.withinOwners(o,l=>{let c=o.getAttribute(i);k.isVisible(o)&&k.isInViewport(o)&&k.exec(e,"click",c,l,o,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!V.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{e!=null&&clearTimeout(e),e=setTimeout(()=>{V.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,backType:n,id:r,scroll:o,position:a}=t.state||{},l=window.location.href,c=a>this.currentHistoryPosition,u=c?i:n||i;this.currentHistoryPosition=a||0,this.sessionStorage.setItem(it,this.currentHistoryPosition.toString()),d.dispatchEvent(window,"phx:navigate",{detail:{href:l,patch:u==="patch",pop:!0,direction:c?"forward":"backward"}}),this.requestDOMUpdate(()=>{let p=()=>{this.maybeScroll(o)};this.main&&this.main.isConnected()&&u==="patch"&&r===this.main.id?this.main.pushLinkPatch(t,l,null,p):this.replaceMain(l,null,p)})},!1),window.addEventListener("click",t=>{let i=t.target&&d.elementFromTarget(t.target);if(!i)return;let n=ue(i,pt),r=n&&n.getAttribute(pt);if(!r||!this.isConnected()||!this.main||d.wantsNewTab(t))return;let o=n.href instanceof SVGAnimatedString?n.href.baseVal:n.href,a=n.getAttribute(Pt);if(a!=="replace"&&a!=="push")throw new Error(`expected ${Pt} to be "replace" or "push", got: ${a}`);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==o&&this.requestDOMUpdate(()=>{if(r==="patch")this.pushHistoryPatch(t,o,a,n);else if(r==="redirect")this.historyRedirect(t,o,a,null,n);else throw new Error(`expected ${pt} to be "patch" or "redirect", got: ${r}`);let l=n.getAttribute(this.binding("click"));l&&this.requestDOMUpdate(()=>this.execJS(n,l,"click"))})},!1)}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}dispatchEvent(e,t={}){d.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){d.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>d.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i,n){if(!this.isConnected()||!(this.main&&this.main.isMain()))return V.redirect(t);this.withPageLoading({to:t,kind:"patch"},r=>{this.main.pushLinkPatch(e,t,n,o=>{this.historyPatch(t,i,o),r()})})}historyPatch(e,t,i=this.setPendingLink(e)){this.commitPendingLink(i)&&(this.currentHistoryPosition++,this.sessionStorage.setItem(it,this.currentHistoryPosition.toString()),V.updateCurrentState(n=>le(D({},n),{backType:"patch"})),V.pushState(t,{type:"patch",id:this.main.id,position:this.currentHistoryPosition},e),d.dispatchEvent(window,"phx:navigate",{detail:{patch:!0,href:e,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location))}historyRedirect(e,t,i,n,r){let o=r&&e.isTrusted&&e.type!=="popstate";if(o&&r.classList.add("phx-click-loading"),!this.isConnected()||!(this.main&&this.main.isMain()))return V.redirect(t,n);if(/^\/$|^\/[^\/]+.*$/.test(t)){let{protocol:l,host:c}=window.location;t=`${l}//${c}${t}`}let a=window.scrollY;this.withPageLoading({to:t,kind:"redirect"},l=>{this.replaceMain(t,n,c=>{c===this.linkRef&&(this.currentHistoryPosition++,this.sessionStorage.setItem(it,this.currentHistoryPosition.toString()),V.updateCurrentState(u=>le(D({},u),{backType:"redirect"})),V.pushState(i,{type:"redirect",id:this.main.id,scroll:a,position:this.currentHistoryPosition},t),d.dispatchEvent(window,"phx:navigate",{detail:{href:t,patch:!1,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location)),o&&r.classList.remove("phx-click-loading"),l()})})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=We(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{if(!(i.target instanceof HTMLFormElement))return;let n=i.target.getAttribute(this.binding("submit")),r=i.target.getAttribute(this.binding("change"));!t&&r&&!n&&(t=!0,i.preventDefault(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>{d.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))}),this.on("submit",i=>{if(!(i.target instanceof HTMLFormElement))return;let n=i.target.getAttribute(this.binding("submit"));if(!n){d.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,r=>{k.exec(i,"submit",n,r,i.target,["push",{submitter:i.submitter}])})});for(let i of["change","input"])this.on(i,n=>{if(!d.isFormAssociated(n.target))return;if(n instanceof CustomEvent&&n.target.form===void 0){if(n.detail&&n.detail.dispatcher)throw new Error(`dispatching a custom ${i} event is only supported on input elements inside a form`);return}let r=n.target,o=this.binding("change");if(this.blockPhxChangeWhileComposing&&n instanceof InputEvent&&n.isComposing){let h=`composition-listener-${i}`;d.private(r,h)||(d.putPrivate(r,h,!0),r.addEventListener("compositionend",()=>{r.dispatchEvent(new Event(i,{bubbles:!0})),d.deletePrivate(r,h)},{once:!0}));return}let a=r.getAttribute(o),l=r.form&&r.form.getAttribute(o),c=a||l;if(!c||r.type==="number"&&r.validity&&r.validity.badInput)return;let u=a?r:r.form,p=e;e++;let{at:m,type:g}=d.private(r,"prev-iteration")||{};m===p-1&&i==="change"&&g==="input"||(d.putPrivate(r,"prev-iteration",{at:p,type:i}),this.debounce(r,n,i,()=>{this.withinOwners(u,h=>{d.putPrivate(r,we,!0),k.exec(n,"change",c,h,r,["push",{_target:r.name,dispatcher:u}])})}))});this.on("reset",i=>{let n=i.target;d.resetForm(n);let r=Array.from(n.elements).find(o=>"type"in o&&o.type==="reset");r&&window.requestAnimationFrame(()=>{r.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,t,i,n){if(i==="blur"||i==="focusout")return n();let r=this.binding(oi),o=this.binding(ai),a=this.defaults.debounce.toString(),l=this.defaults.throttle.toString();this.withinOwners(e,c=>{let u=()=>!c.isDestroyed()&&document.body.contains(e);d.debounce(e,t,r,a,o,l,u,()=>{n()})})}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 n=this.domCallbacks.jsQuerySelectorAll;return n?n(e,t,i):i()}},Gt=class{constructor(){this.transitions=new Set,this.promises=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.promises.clear(),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let n=setTimeout(()=>{this.transitions.delete(n),i(),this.flushPendingOps()},e);this.transitions.add(n)}addAsyncTransition(e){this.promises.add(e),e.then(()=>{this.promises.delete(e),this.flushPendingOps()})}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size+this.promises.size}flushPendingOps(){if(this.size()>0)return;let e=this.pendingOps.shift();e&&(e(),this.flushPendingOps())}};function wn(s,e){let t=d.getCustomElHook(s);if(t)return t;s.hasAttribute("id")||w("Elements passed to createHook need to have a unique id attribute",s);let i=new Q(Re.closestView(s),s,e);return d.putCustomElHook(s,i),i}function Tn(s,e){return R.getEntryDataURL(s,e)}return ji(_n);})();
|