var OmniFaces=(()=>{var B=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var Q=(d,l)=>{for(var E in l)B(d,E,{get:l[E],enumerable:!0})},K=(d,l,E,a)=>{if(l&&typeof l=="object"||typeof l=="function")for(let t of z(l))!G.call(d,t)&&t!==E&&B(d,t,{get:()=>l[t],enumerable:!(a=X(l,t))||a.enumerable});return d};var J=d=>K(B({},"__esModule",{value:!0}),d);var Y={};Q(Y,{CLIENT_WINDOW_PARAM:()=>D,DeferredScript:()=>I,EVENT:()=>R,Form:()=>C,GraphicImage:()=>V,HashParam:()=>H,Highlight:()=>M,InputFile:()=>k,LazyPanel:()=>P,Notification:()=>j,Push:()=>O,ScriptErrorHandler:()=>q,ScriptParam:()=>U,ServiceWorker:()=>W,Unload:()=>_,Util:()=>u,VIEW_STATE_PARAM:()=>T});var u;(o=>{let d="OmniFaces: Cannot find a Faces form in the document. Please add one.";function l(e,m,p){s(e,"addEventListener",m,p)}o.addEventListener=l;function E(e,m,p){s(e,"removeEventListener",m,p)}o.removeEventListener=E;function a(e){window.jQuery?window.jQuery(e):document.readyState==="complete"?setTimeout(e):l(window,"load",e)}o.addOnloadListener=a;function t(e){l(document,"submit",e),window.mojarra&&w(window.mojarra,"cljs",e),window.myfaces&&w(window.myfaces.oam,"submitForm",e),window.PrimeFaces&&w(window.PrimeFaces,"addSubmitParam",e)}o.addSubmitListener=t;function r(e){return typeof e=="function"?e:window[e]??(()=>{})}o.resolveFunction=r;function n(){let e=Array.from(document.forms).find(p=>p[T]);if(e)return e;let m=window.faces;return(!m||m.getProjectStage()==="Development")&&console.error?.(d),null}o.getFacesForm=n;function g(e,m,p){let y=new URLSearchParams(e);return p?y.set(m,p):y.delete(m),y.toString()}o.updateParameter=g;function h(e,m,p){let y=p?.once===!0;if(window.IntersectionObserver){let v=new IntersectionObserver((f,S)=>{f.forEach(c=>{c.isIntersecting&&(m(c.target),y?S.disconnect():S.unobserve(c.target))})});Array.from(e()).forEach(f=>v.observe(f))}else{let v,f=function(){v&&clearTimeout(v),v=setTimeout(function(){let S=window.innerHeight+window.pageYOffset,c=Array.from(e()),x=!1;for(let F of c)if(F.offsetTop<S&&(m(F),x=!0,y))break;(y&&x||e().length===0)&&(E(window,"resize orientationChange",f),E(document,"scroll",f))},50)};l(window,"resize orientationChange",f),l(document,"scroll",f)}}o.addIntersectionListener=h;function i(e,m,p,y,v,f,S){let c=r(y),x=r(v),F=r(f),b=r(S),L=document.createElement("script"),N=document.head??document.documentElement;L.async=!0,L.src=e,m&&L.setAttribute("crossorigin",m),p&&L.setAttribute("integrity",p),L.onerror=()=>{F(),b()},L.onload=()=>{x(),b()},a(()=>{c(),N.appendChild(L)})}o.loadScript=i;function s(e,m,p,y){p.trim().split(/\s+/).forEach(v=>e[m]?.(v,y))}function w(e,m,p){let y=e[m];y&&(e[m]=function(...v){return p(),y.apply(this,v)})}})(u||(u={}));var M;(g=>{g.DATA_HIGHLIGHT_CLASS="data-omnifaces-highlight-class",g.DATA_HIGHLIGHT_LABEL="data-omnifaces-highlight-label";let E;function a(h,i,s){E=t();for(let w of h){let o=r(w);if(o){o.classList.add(i),o.setAttribute(g.DATA_HIGHLIGHT_CLASS,i);let e=E[o.id];e&&(e.classList.add(i),o.setAttribute(g.DATA_HIGHLIGHT_LABEL,"true")),s&&(o.focus(),s=!1),u.addEventListener(o,"click input",n)}}}g.apply=a;function t(){let h=document.getElementsByTagName("LABEL"),i={};for(let s of Array.from(h)){let w=s.htmlFor;w&&(i[w]=s)}return i}function r(h){let i=document.getElementById(h);if(!i){let s=document.getElementsByName(h);s?.length&&(i=s[0])}return i}function n(){u.removeEventListener(this,"click input",n);let h=this.getAttribute(g.DATA_HIGHLIGHT_CLASS);h&&(this.removeAttribute(g.DATA_HIGHLIGHT_CLASS),this.classList.remove(h),this.getAttribute(g.DATA_HIGHLIGHT_LABEL)&&(this.removeAttribute(g.DATA_HIGHLIGHT_LABEL),E[this.id].classList.remove(h)))}})(M||(M={}));var I;(t=>{let d=[];class l{constructor(n,g,h,i,s,w){this.url=n,this.crossorigin=g,this.integrity=h,this.begin=i,this.success=s,this.error=w}}function E(r,n,g,h,i,s){d.push(new l(r,n,g,h,i,s)),d.length==1&&u.addOnloadListener(function(){a(0)})}t.add=E;function a(r){if(r<0||r>=d.length)return;let n=d[r],g=function(){a(r+1)};u.loadScript(n.url,n.crossorigin,n.integrity,n.begin,n.success,n.error,g)}})(I||(I={}));var _;(s=>{let d="OmniFaces-Event",l="OmniFaces-View-Scope",E="OmniFaces-View-State",t,r,n;function g(w){if(window.XMLHttpRequest){if(t==null){if(!u.getFacesForm())return;let o=function(){if(!n)try{let e=u.getFacesForm();if(!e)return;let m=e.action,p=e[T].value,y=R+"=unload&id="+t+"&"+T+"="+encodeURIComponent(p),v="application/x-www-form-urlencoded",f={"Content-Type":v},S=p.length<=1024;n=!0,S&&(f[d]="unload",f[l]=t,f[E]=p);let c=function(){return navigator.sendBeacon?(navigator.sendBeacon(m,new Blob([y],{type:v})),!0):!1};if(S&&window.Request&&"keepalive"in Request.prototype)fetch(m,{method:"POST",keepalive:!0,credentials:"same-origin",headers:f,body:y}).catch(c);else if(!c()){let x=new XMLHttpRequest;x.open("POST",m,!1),x.setRequestHeader("X-Requested-With","XMLHttpRequest");for(let F in f)f.hasOwnProperty(F)&&x.setRequestHeader(F,f[F]);x.send(y)}}catch{}};u.addOnloadListener(function(){u.addEventListener(window,"beforeunload",function(e){!r&&!e.defaultPrevented&&!e.returnValue&&o()}),u.addEventListener(window,"pagehide",function(){if(r){i();return}o()})}),u.addSubmitListener(function(){h()})}t=w,r=!1,n=!1}}s.init=g;function h(){r=!0}s.disable=h;function i(){r=!1}s.reenable=i})(_||(_={}));var O;(v=>{let d=window.location.protocol.replace("http","ws")+"//",l="/omnifaces.socket",E="/omnifaces.sse",a=500,t=25,r="Expired",n="Unknown channel",g={};class h{constructor(S,c,x,F,b,L,N){this.url=S,this.channel=c,this.onopen=x,this.onmessage=F,this.onerror=b,this.onclose=L,this.behaviors=N}handleMessage(S){let c=JSON.parse(S.data);this.onmessage(c,this.channel,S),this.behaviors[c]?.forEach(x=>x())}}class i extends h{constructor(){super(...arguments);this.socket=null;this.reconnectAttempts=null}open(){this.socket?.readyState!=1&&(this.socket=new WebSocket(this.url),this.socket.onopen=()=>{this.reconnectAttempts==null&&this.onopen(this.channel),this.reconnectAttempts=0},this.socket.onmessage=c=>this.handleMessage(c),this.socket.onclose=c=>{!this.socket||c.code==1e3&&c.reason==r||c.code==1008&&c.reason==n||this.reconnectAttempts==null||this.reconnectAttempts>=t?this.onclose(c.code,this.channel,c):(this.onerror(c.code,this.channel,c),setTimeout(this.open.bind(this),a*this.reconnectAttempts++))})}close(){if(this.socket){let c=this.socket;this.socket=null,this.reconnectAttempts=null,c.close()}}}class s extends h{constructor(){super(...arguments);this.eventSource=null}open(){this.eventSource||(this.eventSource=new EventSource(this.url),this.eventSource.onopen=()=>{this.onopen(this.channel)},this.eventSource.onmessage=c=>this.handleMessage(c),this.eventSource.addEventListener("close",c=>{let x=Number.parseInt(c.data);this.eventSource?.close(),this.eventSource=null,this.onclose(x,this.channel,c)}),this.eventSource.onerror=c=>{this.eventSource?.readyState==EventSource.CLOSED?(this.eventSource=null,this.onclose(200,this.channel,c)):this.onerror(500,this.channel,c)})}close(){if(this.eventSource){let c=this.eventSource;this.eventSource=null,c.close(),this.onclose(204,this.channel)}}}function w(f,S,c,x,F,b,L,N,$){L=u.resolveFunction(L);let A=c.split(/\?/)[0];if(f?!window.EventSource:!window.WebSocket){L(-1,A);return}g[A]||(x=u.resolveFunction(x),F=u.resolveFunction(F),b=u.resolveFunction(b),f?g[A]=new s(m(S,c),A,x,F,b,L,N):g[A]=new i(p(S,c),A,x,F,b,L,N)),$!==!1&&o(A)}v.init=w;function o(f){y(f).open()}v.open=o;function e(f){y(f).close()}v.close=e;function m(f,S){return f+E+"/"+S}function p(f,S){f=f??"";let c="";return!f||f.startsWith("/")?c=window.location.host:f.startsWith(":")&&(c=window.location.hostname),`${d}${c}${f}${l}/${S}`}function y(f){let S=g[f];if(S)return S;throw new Error(`Unknown channel: ${f}`)}})(O||(O={}));var k;(l=>{function d(E,a,t,r){if(!window.FileReader)return!0;document.getElementById(t).innerHTML="";let n=a.files,g=a.form;for(let h of n)if(h.size>r){let i=h.name,s;window.mojarra&&(s=g.enctype,g.enctype="application/x-www-form-urlencoded"),a.type="text",a.type="file";let w={fileName:i};return w[R]="validationFailed",window.faces.ajax.request(a.id,E,w),s&&(g.enctype=s),!1}return!0}l.validate=d})(k||(k={}));var C;(E=>{function d(){let a=window.faces;if(a){let t=a.ajax.request;a.ajax.request=function(r,n,g){let h=a.getViewState;a.getViewState=function(i){let s=h(i);if(i.dataset.partialsubmit!=="true")return s;let w=g?.execute;if(!w||w.includes("@form")||w.includes("@all"))return s;let o=[],e=[];if(!w.includes("@none")){let p=r instanceof HTMLElement?r.id:r;o=w.replace("@this",p).split(" "),e=o.map(encodeURIComponent)}e.push(T,D);let m=[];return s.replace(/([^=&]+)=([^&]*)/g,function(p,y,v){(e.includes(y)||l(o,y))&&m.push(`${y}=${v}`)}),m.join("&")},t(r,n,g)}}}function l(a,t){let r=t.replace(/%3A/g,String.raw`\:`);try{for(let n of a)if(document.getElementById(n)?.querySelector("[name='"+r+"']"))return!0}catch(n){console.warn(`Cannot determine if ${a} contains child ${r}`,n)}return!1}u.addOnloadListener(d)})(C||(C={}));var H;(r=>{let d,l;function E(n){d=n,u.getFacesForm()&&(window.location.hash&&t(),u.addEventListener(window,"hashchange",t))}r.init=E;function a(n,g){l=!0;let h=window.location,i=h.hash;i.startsWith("#")&&(i=i.substring(1));let s=u.updateParameter(i,n,g);if(s!=i){let w=window.history;if(w?.pushState){let o=h.href.split(/#/,2)[0]+(s?"#":"")+s;w.pushState(null,document.title,o)}h.hash!=s&&(h.hash=s)}l=!1}r.update=a;function t(){if(!l){let n={execute:d,hash:window.location.hash.substring(1)};n[R]="setHashParamValues",window.faces.ajax.request(u.getFacesForm(),null,n)}}})(H||(H={}));var P;(a=>{function d(t,r){u.addOnloadListener(()=>l(t,r))}a.init=d;function l(t,r){let n=document.getElementById(t);n&&u.addIntersectionListener(()=>[n],()=>E(t,r),{once:!0})}function E(t,r){if(!u.getFacesForm())return;let n={execute:t,render:t,params:r??{}};n[R]="loadLazyPanel",window.faces.ajax.request(t,null,n)}})(P||(P={}));var U;(E=>{function d(a,t){let r=u.getFacesForm();if(!r)return;let n={};for(let g in t)n[g]=JSON.stringify(l(t[g]));n.execute=a,n[R]="setScriptParamValues",window.faces.ajax.request(r,null,n)}E.run=d;function l(a){if(!(a instanceof Object))return a;let t={};for(let r in a){let n=a[r];(n===null||typeof n!="function"&&typeof n!="object")&&(t[r]=n)}return t}})(U||(U={}));var W;(l=>{function d(E,a){navigator.serviceWorker&&(navigator.serviceWorker.register(E,{scope:a}),navigator.serviceWorker.addEventListener("message",function(t){t.data?.type==R&&window.dispatchEvent(new CustomEvent(t.data.name,{detail:t.data.detail}))}))}l.init=d})(W||(W={}));var V;(a=>{function d(){l().length!=0&&u.addIntersectionListener(l,E)}function l(){return document.querySelectorAll("img[src][data-src][data-lazy]")}function E(t){let r=t.dataset;r.lazy&&r.src&&(t.src=r.src),delete r.src,delete r.lazy}u.addOnloadListener(d)})(V||(V={}));var q;(w=>{let E=["errorStack","errorMessage"],a={},t=[];function r(o,e,m,p){a.endpointURL=o,a.ignoreSelector=e,a.maxRecentErrors=m,a.errorExpiry=p,t.length=0,window.onerror=(y,v,f,S,c)=>(s({pageURL:window.location.href,errorMessage:n(y,c),errorName:c?.name??null,errorStack:c?.stack??null,sourceURL:v??null,lineNumber:f!=null?String(f):null,columnNumber:S!=null?String(S):null}),!1),window.addEventListener("unhandledrejection",y=>{let v=y.reason;s({pageURL:window.location.href,errorMessage:g(v),errorName:v instanceof Error?v.name:"UnhandledRejection",errorStack:v instanceof Error?v.stack??null:null})})}w.init=r;function n(o,e){return typeof o=="string"?o:e?e.message:o instanceof ErrorEvent&&o.message?o.message:o instanceof Event?`${o.constructor.name}: ${o.type}`:String(o)}function g(o){if(o instanceof Error)return o.message;if(typeof o!="object"||o===null)return String(o);try{return JSON.stringify(o)??String(o)}catch{return String(o)}}function h(o){let e=new URLSearchParams;for(let[m,p]of Object.entries(o))p!=null&&e.append(m,p);return e}function i(o){for(let e of E){let m=h(o).toString().length-6e4;if(m<=0)return;let p=o[e];p!=null&&(o[e]=p.substring(0,Math.max(0,p.length-m-3))+"...")}}function s(o){try{if(a.ignoreSelector&&document.querySelector(a.ignoreSelector))return;i(o);let e=`${o.errorMessage}${o.sourceURL}${o.lineNumber}`,m=Date.now();for(;t.length>0&&m-t[0].time>a.errorExpiry;)t.shift();if(t.some(p=>p.key===e))return;t.length>=a.maxRecentErrors&&t.shift(),t.push({key:e,time:m}),navigator.sendBeacon(a.endpointURL,h(o))}catch{}}})(q||(q={}));var j;(h=>{let d=new Map,l=!1;function E(i,s){if(d.set(i,s),!window.Notification||!navigator.serviceWorker){u.resolveFunction(s.onunsupported)();return}g()}h.init=E;async function a(i){return window.Notification?window.Notification.requestPermission().then(function(s){return i?u.resolveFunction(d.get(i)?.onpermissionchange)(s):d.forEach(function(w){u.resolveFunction(w.onpermissionchange)(s)}),s}):"denied"}h.requestPermission=a;function t(i,s,w,o){if(!i)throw new Error("OmniFaces.Notification.show: channel is required.");if(!s)throw new Error("OmniFaces.Notification.show: title is required.");if(window.Notification?.permission!=="granted"||!navigator.serviceWorker)return;let e=d.get(i)??{};navigator.serviceWorker.ready.then(function(m){m.showNotification(s,{tag:e.tag,body:w,requireInteraction:e.requireInteraction,silent:e.silent,icon:e.icon,data:{channel:i,url:o??void 0}})})}h.show=t;function r(i,s){t(s,i.title,i.body,i.url)}h.handle=r;function n(){return window.Notification?window.Notification.permission:"unsupported"}h.getPermission=n;function g(){l||(l=!0,window.addEventListener("omnifaces.notificationclick",function(i){let s=d.get(i.detail.data?.channel);u.resolveFunction(s?.onclick)(i)}),window.addEventListener("omnifaces.notificationclose",function(i){let s=d.get(i.detail.data?.channel);u.resolveFunction(s?.onclose)(i)}))}})(j||(j={}));var R="omnifaces.event",T="jakarta.faces.ViewState",D="jakarta.faces.ClientWindow";return J(Y);})();
