- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
2 lines
53 KiB
JavaScript
2 lines
53 KiB
JavaScript
var e,t=Object.defineProperty;class i{static log(...e){this._write("log","[LOG]",e)}static warn(...e){this._write("warn","[WARN]",e)}static info(...e){this._write("info","[INFO]",e)}static error(...e){this._write("error","[ERROR]",e)}static _write(e,t,i){if(!this.enabled)return;const n=`${t} [${(new Date).toLocaleTimeString("de-DE")}] ${i.map(e=>{if(e instanceof Error)return`${e.name}: ${e.message}\n${e.stack||""}`;if("object"==typeof e&&null!==e)try{return JSON.stringify(e)}catch(t){return"[Circular Object]"}return e}).join(" ")}`;if(console[e],l&&"function"==typeof l.log)try{l.log(n)}catch(r){}}}((e,i,n)=>{i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n})(i,"symbol"!=typeof(e="enabled")?e+"":e,!0);const n=new Map;let r=!1,s=!1;performance.now();const o=document.createElement("div");o.style.position="fixed",o.style.bottom="0",o.style.left="0",o.style.font="12px monospace",o.style.color="#0f0",o.style.background="rgba(0,0,0,0.75)",o.style.padding="0.25rem 0.5rem",o.style.zIndex="9999",o.style.pointerEvents="none",o.style.display="none";const a=`<div style="width:${Math.min(0,100)}%;height:4px;background:#0f0;margin-top:4px;"></div>`;o.innerHTML+=a,o.style.lineHeight="1.4",document.body.appendChild(o);const l=new class{constructor({fps:e=!0}={}){this.fpsEnabled=e,this.fps=0,this.frameCount=0,this.lastTime=performance.now(),this.visible=!1,this.taskTimings=new Map,this.logs=[],this.container=document.createElement("div"),this.container.style.position="fixed",this.container.style.bottom="0",this.container.style.left="0",this.container.style.font="12px Consolas, monospace",this.container.style.color="#0f0",this.container.style.background="rgba(0,0,0,0.75)",this.container.style.padding="0.5rem",this.container.style.zIndex="9999",this.container.style.pointerEvents="none",this.container.style.lineHeight="1.4",this.container.style.whiteSpace="pre",this.container.style.display="none",document.body.appendChild(this.container),window.addEventListener("keydown",e=>{"§"===e.key&&(this.visible=!this.visible,this.container.style.display=this.visible?"block":"none")})}log(e){const t=(new Date).toLocaleTimeString();this.logs.push(`[${t}] ${e}`),this.logs.length>5&&this.logs.shift()}update(e=new Map){this.frameCount++;const t=performance.now();if(t-this.lastTime>=1e3){this.fps=this.frameCount,this.frameCount=0,this.lastTime=t;const i=[];for(const[e,t]of this.taskTimings.entries())i.push(`${e}: ${t.toFixed(2)}ms`);const n=Math.min(2*this.fps,100),r=this.logs.slice().reverse().join("\n");this.container.innerHTML=`\nFPS: ${this.fps} | Tasks: ${e.size}\n${i.join("\n")}\n<div style="width:${n}%;height:4px;background:#0f0;margin-top:4px;"></div>\n${r?"\nLogs:\n"+r:""}\n `}}trackTask(e,t){const i=performance.now();t();const n=performance.now()-i;this.taskTimings.set(e,n)}};function d(e,t,o={}){n.set(e,t),o.autoStart&&!r&&function(){if(r)return;function e(){for(const[e,r]of n)try{s?l.trackTask(e,r):r()}catch(t){i.warn("[Frameloop] Fehler in Task:",t)}s&&l.update(n),requestAnimationFrame(e)}r=!0,requestAnimationFrame(e)}()}function c(e){n.delete(e)}window.addEventListener("keydown",e=>{"§"===e.key&&(s=!s,o.style.display=s?"block":"none")});let u="example-module",h=null,m=null;const f=Object.freeze(Object.defineProperty({__proto__:null,destroy:function(){i.info("[example-module] destroy"),h&&(window.removeEventListener("resize",h),h=null),c(u),m&&"function"==typeof m.cleanup&&m.cleanup(),m=null},init:function(e={},t=null){i.info("[example-module] init"),m=t,m&&(m.register("windowSize",{width:window.innerWidth,height:window.innerHeight}),m.register("scrollPosition",{x:0,y:0}),m.register("isVisible",!0)),h=()=>{const e={width:window.innerWidth,height:window.innerHeight};i.info("Fenstergröße geändert:",e),m&&m.set("windowSize",e)},window.addEventListener("resize",h),d(u,()=>{const e=window.scrollY,t=window.scrollX;if(m){const i=m.get("scrollPosition");i.x===t&&i.y===e||m.set("scrollPosition",{x:t,y:e})}},{autoStart:!0})}},Symbol.toStringTag,{value:"Module"}));class p{constructor(e){this.form=e,this.errors=new Map}static create(e){return new p(e)}validate(){this.errors.clear();const e=this.form.querySelectorAll("input, textarea, select");for(const t of e)"hidden"===t.type||t.disabled||this.validateField(t);return 0===this.errors.size}validateField(e){const t=e.value,i=e.name;if(e.hasAttribute("required")&&(!t||""===t.trim()))return void this.errors.set(i,this.getErrorMessage(e,"valueMissing")||`${this.getFieldLabel(e)} ist erforderlich`);if(!t||""===t.trim())return;if("email"===e.type&&!this.isValidEmail(t))return void this.errors.set(i,this.getErrorMessage(e,"typeMismatch")||"Bitte geben Sie eine gültige E-Mail-Adresse ein");if("url"===e.type&&!this.isValidUrl(t))return void this.errors.set(i,this.getErrorMessage(e,"typeMismatch")||"Bitte geben Sie eine gültige URL ein");const n=e.getAttribute("minlength");if(n&&t.length<parseInt(n))return void this.errors.set(i,this.getErrorMessage(e,"tooShort")||`Mindestens ${n} Zeichen erforderlich`);const r=e.getAttribute("maxlength");if(r&&t.length>parseInt(r))return void this.errors.set(i,this.getErrorMessage(e,"tooLong")||`Maximal ${r} Zeichen erlaubt`);if("number"===e.type){const n=e.getAttribute("min"),r=e.getAttribute("max"),s=parseFloat(t);if(n&&s<parseFloat(n))return void this.errors.set(i,this.getErrorMessage(e,"rangeUnderflow")||`Wert muss mindestens ${n} sein`);if(r&&s>parseFloat(r))return void this.errors.set(i,this.getErrorMessage(e,"rangeOverflow")||`Wert darf maximal ${r} sein`)}const s=e.getAttribute("pattern");if(s){if(!new RegExp(s).test(t))return void this.errors.set(i,this.getErrorMessage(e,"patternMismatch")||"Ungültiges Format")}const o=e.getAttribute("data-validate");if(o){const n=this.runCustomValidation(o,t,e);if(!n.valid)return void this.errors.set(i,n.message)}}runCustomValidation(e,t,n){switch(e){case"phone":return{valid:/^[\+]?[0-9\s\-\(\)]{10,}$/.test(t),message:"Bitte geben Sie eine gültige Telefonnummer ein"};case"postal-code-de":return{valid:/^[0-9]{5}$/.test(t),message:"Bitte geben Sie eine gültige Postleitzahl ein"};case"no-html":return{valid:!/<[^>]*>/g.test(t),message:"HTML-Code ist nicht erlaubt"};default:return i.warn(`Unknown custom validation: ${e}`),{valid:!0,message:""}}}isValidEmail(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}isValidUrl(e){try{return new URL(e),!0}catch{return!1}}getFieldLabel(e){const t=this.form.querySelector(`label[for="${e.id}"]`)||this.form.querySelector(`label:has([name="${e.name}"])`);return t?t.textContent.trim().replace(":",""):e.name}getErrorMessage(e,t){return e.getAttribute(`data-error-${t}`)||e.getAttribute("data-error")}getErrors(){return Object.fromEntries(this.errors)}getFieldError(e){return this.errors.get(e)}hasErrors(){return this.errors.size>0}clearErrors(){this.errors.clear()}validateWithHTML5(){const e=this.form.checkValidity();if(!e){const e=this.form.querySelectorAll("input, textarea, select");for(const t of e)t.validity.valid||this.errors.set(t.name,t.validationMessage)}return e}}class g{constructor(e){this.form=e,this.pristineValues=new Map,this.touchedFields=new Set,this.dirtyFields=new Set,this.init()}static create(e){return new g(e)}init(){this.captureInitialValues(),this.bindEvents(),i.info(`[FormState] Initialized for form: ${this.form.id||"unnamed"}`)}captureInitialValues(){this.form.querySelectorAll("input, textarea, select").forEach(e=>{if("hidden"===e.type)return;let t;switch(e.type){case"checkbox":case"radio":t=e.checked;break;default:t=e.value}this.pristineValues.set(e.name,t)})}bindEvents(){this.form.querySelectorAll("input, textarea, select").forEach(e=>{e.addEventListener("focus",()=>{this.markAsTouched(e.name)}),e.addEventListener("input",()=>{this.checkDirtyState(e)}),e.addEventListener("change",()=>{this.checkDirtyState(e)})})}markAsTouched(e){this.touchedFields.add(e),this.updateFormClasses()}checkDirtyState(e){const t=e.name;this.getFieldValue(e)!==this.pristineValues.get(t)?this.dirtyFields.add(t):this.dirtyFields.delete(t),this.updateFormClasses()}getFieldValue(e){switch(e.type){case"checkbox":case"radio":return e.checked;default:return e.value}}updateFormClasses(){this.isDirty()?(this.form.classList.add("form-dirty"),this.form.classList.remove("form-pristine")):(this.form.classList.add("form-pristine"),this.form.classList.remove("form-dirty")),this.hasTouchedFields()?this.form.classList.add("form-touched"):this.form.classList.remove("form-touched")}isPristine(){return 0===this.dirtyFields.size}isDirty(){return this.dirtyFields.size>0}hasTouchedFields(){return this.touchedFields.size>0}isFieldTouched(e){return this.touchedFields.has(e)}isFieldDirty(e){return this.dirtyFields.has(e)}isFieldPristine(e){return!this.dirtyFields.has(e)}getFieldState(e){return{pristine:this.isFieldPristine(e),dirty:this.isFieldDirty(e),touched:this.isFieldTouched(e),pristineValue:this.pristineValues.get(e),currentValue:this.getCurrentFieldValue(e)}}getCurrentFieldValue(e){const t=this.form.querySelector(`[name="${e}"]`);return t?this.getFieldValue(t):void 0}getFormState(){return{pristine:this.isPristine(),dirty:this.isDirty(),touched:this.hasTouchedFields(),dirtyFields:Array.from(this.dirtyFields),touchedFields:Array.from(this.touchedFields),totalFields:this.pristineValues.size}}reset(){this.touchedFields.clear(),this.dirtyFields.clear(),setTimeout(()=>{this.captureInitialValues(),this.updateFormClasses()},0),i.info("[FormState] State reset")}resetField(e){this.touchedFields.delete(e),this.dirtyFields.delete(e);const t=this.form.querySelector(`[name="${e}"]`),n=this.pristineValues.get(e);if(t&&void 0!==n)switch(t.type){case"checkbox":case"radio":t.checked=n;break;default:t.value=n}this.updateFormClasses(),i.info(`[FormState] Field "${e}" reset to pristine state`)}triggerStateEvent(e,t={}){const i=new CustomEvent(e,{detail:{...t,formState:this.getFormState()},bubbles:!0,cancelable:!0});this.form.dispatchEvent(i)}hasChanges(){return this.isDirty()}getChangedFields(){const e={};return this.dirtyFields.forEach(t=>{e[t]={pristineValue:this.pristineValues.get(t),currentValue:this.getCurrentFieldValue(t)}}),e}enableUnsavedChangesWarning(){window.addEventListener("beforeunload",e=>{if(this.isDirty())return e.preventDefault(),e.returnValue="Sie haben ungespeicherte Änderungen. Möchten Sie die Seite wirklich verlassen?",e.returnValue})}destroy(){this.pristineValues.clear(),this.touchedFields.clear(),this.dirtyFields.clear(),i.info("[FormState] Destroyed")}}class y{constructor(e,t={}){this.form=e,this.options={validateOnSubmit:!0,validateOnBlur:!1,validateOnInput:!1,showInlineErrors:!0,preventSubmitOnError:!0,submitMethod:"POST",ajaxSubmit:!0,...t},this.validator=p.create(e),this.state=g.create(e),this.isSubmitting=!1,this.init()}static create(e,t={}){return new y(e,t)}init(){this.bindEvents(),this.setupErrorDisplay(),this.form.setAttribute("data-enhanced","true"),i.info(`[FormHandler] Initialized for form: ${this.form.id||"unnamed"}`)}bindEvents(){if(this.form.addEventListener("submit",e=>this.handleSubmit(e)),this.options.validateOnBlur||this.options.validateOnInput){this.form.querySelectorAll("input, textarea, select").forEach(e=>{this.options.validateOnBlur&&e.addEventListener("blur",()=>this.validateSingleField(e)),this.options.validateOnInput&&e.addEventListener("input",()=>this.validateSingleField(e))})}}async handleSubmit(e){if(this.isSubmitting)e.preventDefault();else{if(this.options.validateOnSubmit){if(!this.validator.validate())return e.preventDefault(),void this.displayErrors()}this.options.ajaxSubmit&&(e.preventDefault(),await this.submitViaAjax())}}async submitViaAjax(){try{this.setSubmitState(!0),this.clearErrors();const e=new FormData(this.form),t=this.form.action||window.location.href,i=this.form.method||this.options.submitMethod,n=await fetch(t,{method:i.toUpperCase(),body:e,headers:{"X-Requested-With":"XMLHttpRequest"}}),r=await this.parseResponse(n);n.ok?this.handleSuccess(r):this.handleError(r)}catch(e){i.error("[FormHandler] Submit error:",e),this.handleError({message:"Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.",errors:{}})}finally{this.setSubmitState(!1)}}async parseResponse(e){const t=e.headers.get("content-type");if(null==t?void 0:t.includes("application/json"))return await e.json();const i=await e.text();try{return JSON.parse(i)}catch{return{message:i}}}handleSuccess(e){i.info("[FormHandler] Form submitted successfully"),!1!==e.clearForm&&(this.form.reset(),this.state.reset()),this.showMessage(e.message||"Formular erfolgreich gesendet!","success"),this.triggerEvent("form:success",{data:e})}handleError(e){if(i.warn("[FormHandler] Form submission error:",e),e.errors&&"object"==typeof e.errors){for(const[t,i]of Object.entries(e.errors))this.validator.errors.set(t,i);this.displayErrors()}this.showMessage(e.message||"Ein Fehler ist aufgetreten.","error"),this.triggerEvent("form:error",{data:e})}validateSingleField(e){this.validator.errors.delete(e.name),this.validator.validateField(e),this.displayFieldError(e)}displayErrors(){if(!this.options.showInlineErrors)return;const e=this.validator.getErrors();for(const[t,i]of Object.entries(e)){const e=this.form.querySelector(`[name="${t}"]`);e&&this.displayFieldError(e,i)}}displayFieldError(e,t=null){const i=t||this.validator.getFieldError(e.name),n=this.getOrCreateErrorElement(e);i?(n.textContent=i,n.style.display="block",e.classList.add("error"),e.setAttribute("aria-invalid","true"),e.setAttribute("aria-describedby",n.id)):(n.textContent="",n.style.display="none",e.classList.remove("error"),e.removeAttribute("aria-invalid"),e.removeAttribute("aria-describedby"))}getOrCreateErrorElement(e){const t=`error-${e.name}`;let i=document.getElementById(t);if(!i){i=document.createElement("div"),i.id=t,i.className="form-error",i.setAttribute("role","alert"),i.style.display="none";(e.closest(".form-group")||e.parentElement).appendChild(i)}return i}setupErrorDisplay(){if(!document.getElementById("form-handler-styles")){const e=document.createElement("style");e.id="form-handler-styles",e.textContent="\n .form-error {\n color: #dc2626;\n font-size: 0.875rem;\n margin-top: 0.25rem;\n }\n input.error, textarea.error, select.error {\n border-color: #dc2626;\n box-shadow: 0 0 0 1px #dc2626;\n }\n .form-message {\n padding: 0.75rem;\n border-radius: 0.375rem;\n margin: 1rem 0;\n }\n .form-message.success {\n background-color: #dcfce7;\n color: #166534;\n border: 1px solid #bbf7d0;\n }\n .form-message.error {\n background-color: #fef2f2;\n color: #dc2626;\n border: 1px solid #fecaca;\n }\n ",document.head.appendChild(e)}}showMessage(e,t="info"){let i=this.form.querySelector(".form-messages");i||(i=document.createElement("div"),i.className="form-messages",this.form.prepend(i));const n=document.createElement("div");n.className=`form-message ${t}`,n.textContent=e,n.setAttribute("role","error"===t?"alert":"status"),i.innerHTML="",i.appendChild(n),"success"===t&&setTimeout(()=>{n.parentElement&&n.remove()},5e3)}clearErrors(){this.validator.clearErrors();this.form.querySelectorAll(".error").forEach(e=>{e.classList.remove("error"),e.removeAttribute("aria-invalid"),e.removeAttribute("aria-describedby")});this.form.querySelectorAll(".form-error").forEach(e=>{e.style.display="none",e.textContent=""});const e=this.form.querySelector(".form-messages");e&&(e.innerHTML="")}setSubmitState(e){this.isSubmitting=e;this.form.querySelectorAll('button[type="submit"], input[type="submit"]').forEach(t=>{if(t.disabled=e,e)t.setAttribute("data-original-text",t.textContent),t.textContent="Wird gesendet...";else{const e=t.getAttribute("data-original-text");e&&(t.textContent=e,t.removeAttribute("data-original-text"))}})}triggerEvent(e,t={}){const i=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});this.form.dispatchEvent(i)}destroy(){this.form.removeAttribute("data-enhanced"),i.info("[FormHandler] Destroyed")}}const b={name:"form-handling",init(e,t={}){i.info(`[FormHandling] Initializing on form: ${e.id||"unnamed"}`);const n={validateOnSubmit:!0,validateOnBlur:!1,validateOnInput:!1,showInlineErrors:!0,preventSubmitOnError:!0,ajaxSubmit:!0,submitMethod:"POST",enableStateTracking:!0,enableUnsavedWarning:!1,...t},r=y.create(e,n);e._formHandler=r,e._formValidator=r.validator,e._formState=r.state,n.enableUnsavedWarning&&r.state.enableUnsavedChangesWarning(),e.classList.add("form-enhanced");const s=new CustomEvent("form:initialized",{detail:{handler:r,validator:r.validator,state:r.state,config:n},bubbles:!0});return e.dispatchEvent(s),i.info(`[FormHandling] Successfully initialized for form: ${e.id||"unnamed"}`),r},destroy(e){e._formHandler&&(e._formHandler.destroy(),delete e._formHandler,delete e._formValidator,delete e._formState),e.classList.remove("form-enhanced"),e.removeAttribute("data-enhanced"),i.info(`[FormHandling] Destroyed for form: ${e.id||"unnamed"}`)}},v=Object.freeze(Object.defineProperty({__proto__:null,FormHandler:y,FormHandlingModule:b,FormState:g,FormValidator:p,default:b},Symbol.toStringTag,{value:"Module"}));let w,S="inertia-scroll",E=0,M=window.scrollY,A=!1,k=.9,$=.2;function x(){A=!0,clearTimeout(w),w=setTimeout(()=>{A=!1},50)}const F=Object.freeze(Object.defineProperty({__proto__:null,destroy:function(){window.removeEventListener("scroll",x),c(S),E=0,M=window.scrollY,A=!1,clearTimeout(w);const e=document.documentElement;delete e.dataset.scrollState,delete e.dataset.scrollDirection,delete e.dataset.scrollSpeed},init:function(e={}){k="number"==typeof e.damping?e.damping:.9,$="number"==typeof e.minVelocity?contig.minVelocity:.1,window.addEventListener("scroll",x,{passive:!0}),d(S,()=>{const e=document.documentElement,t=window.scrollY,i=t-M,n=i>0?"down":i<0?"up":"none",r=Math.abs(i);!A&&Math.abs(E)>$?(window.scrollTo(0,t+E),E*=k,e.dataset.scrollState="inertia"):A?(E=i,M=t,e.dataset.scrollState="active"):delete e.dataset.scrollState,e.dataset.scrollDirection=n,e.dataset.scrollSpeed=r.toFixed(2)},{autoStart:!0})}},Symbol.toStringTag,{value:"Module"})),L=new Map,O={add(e,t,i,{module:n="global",options:r=!1}={}){e.addEventListener(t,i,r),L.has(n)||L.set(n,[]),L.get(n).push([e,t,i,r])},removeModule(e){const t=L.get(e);t&&(t.forEach(([e,t,i,n])=>{e.removeEventListener(t,i,n)}),L.delete(e))},clearAll(){for(const[e,t]of L.entries())t.forEach(([e,t,i,n])=>{e.removeEventListener(t,i,n)});L.clear()},debug(){}};function C(e,t,i,n=import.meta,r=!1){var s;const o="string"==typeof n?n:(null==(s=n.url)?void 0:s.split("/").slice(-2,-1)[0])||"unknown";return O.add(e,t,i,{module:o,options:r}),()=>{O.removeModule(o)}}class _{constructor({content:e="",className:t="",onClose:i=null}={}){this.onClose=i,this.dialog=document.createElement("dialog"),this.dialog.className=t,this.dialog.innerHTML=`\n <form method="dialog" class="${t}-content">\n ${e}\n <button class="${t}-close" value="close">×</button>\n </form>\n `,C(this.dialog,"click",e=>{!e.target.closest(t+"-content")&&this.close()}),C(this.dialog,"cancel",e=>{e.preventDefault(),this.close()})}open(){var e,t;document.body.appendChild(this.dialog),(null==(t=(e=this.dialog).showModal)?void 0:t.call(e))||this.dialog.setAttribute("open",""),document.documentElement.dataset[`${this.dialog.className}Open`]="true"}close(){var e,t,i;(null==(t=(e=this.dialog).close)?void 0:t.call(e))||this.dialog.removeAttribute("open"),this.dialog.remove(),delete document.documentElement.dataset[`${this.dialog.className}Open`],null==(i=this.onClose)||i.call(this)}}const z={modal:class extends _{constructor(e){super({...e,className:"modal"})}}},T={open(e,t={}){const n=z[e];if(!n)return i.warn(`[UIManager] Unknown type: ${e}`),null;const r=new n(t);return r.open(),r},close(e){(null==e?void 0:e.close)&&e.close()}};function j(e){const t=e.target.closest("[data-lightbox]");t&&"IMG"===t.tagName&&(e.preventDefault(),T.open("lightbox",{content:`<img src="${t.src}" alt="${t.alt||""}" />`}))}const D=Object.freeze(Object.defineProperty({__proto__:null,destroy:function(){i.info("[lightbox-trigger] destroy")},init:function(){i.info("[lightbox-trigger] init"),C(document,"click",j)}},Symbol.toStringTag,{value:"Module"}));const P=Object.freeze(Object.defineProperty({__proto__:null,init:function(e={}){i.log("Noise Toggle Init",e);const{selector:t=".noise-overlay",toggleKey:n="g",className:r="grainy",enableTransition:s=!0}=e,o=document.body,a=document.querySelector(t);if(!a)return;function l(){s?a.classList.toggle("hidden",!o.classList.contains(r)):a.style.display=o.classList.contains(r)?"block":"none"}l(),document.addEventListener("keydown",e=>{var t;e.key.toLowerCase()!==n||e.ctrlKey||e.metaKey||e.altKey||(t=e.target,["input","textarea"].includes(t.tagName.toLowerCase()))||(o.classList.toggle(r),l())})}},Symbol.toStringTag,{value:"Module"}));const R=Object.freeze(Object.defineProperty({__proto__:null,init:function(e={}){i.info("Parallax init");const t={selector:"[data-parallax]",speedAttr:"data-parallax-speed",defaultSpeed:.5,...e},n=document.querySelectorAll(t.selector);d("parallax",function(){const e=window.scrollY;n.forEach(i=>{const n=parseFloat(i.getAttribute(t.speedAttr))||t.defaultSpeed,r=e*n;i.style.transform=`translateY(${r}px)`})},{autoStart:!0})}},Symbol.toStringTag,{value:"Module"}));class I{constructor(){this.modules=new Map,this.dependents=new Map,this.initialized=new Set,this.initializing=new Set,this.initializationOrder=[]}register(e){this.modules.has(e.name)?i.warn(`[DependencyManager] Module '${e.name}' already registered`):this.validateDefinition(e)&&(this.modules.set(e.name,e),e.dependencies.forEach(t=>{this.dependents.has(t.name)||this.dependents.set(t.name,[]),this.dependents.get(t.name).push(e.name)}),i.info(`[DependencyManager] Registered '${e.name}' v${e.version}`))}calculateInitializationOrder(){const e=new Set,t=new Set,n=[],r=i=>{if(t.has(i))throw new Error(`Circular dependency detected involving '${i}'`);if(e.has(i))return;const s=this.modules.get(i);s&&(t.add(i),s.dependencies.forEach(e=>{e.optional&&!this.modules.has(e.name)||r(e.name)}),t.delete(i),e.add(i),n.push(i))};return Array.from(this.modules.entries()).sort(([,e],[,t])=>(t.priority||0)-(e.priority||0)).map(([e])=>e).forEach(t=>{e.has(t)||r(t)}),this.initializationOrder=n,i.info(`[DependencyManager] Initialization order: ${n.join(" → ")}`),n}checkDependencies(e){const t=this.modules.get(e);if(!t)return{satisfied:!1,missing:[],reason:`Module '${e}' not registered`};const i=[],n=[];return t.dependencies.forEach(e=>{this.modules.get(e.name)?this.initialized.has(e.name)||e.optional||i.push(`${e.name} (not initialized)`):e.optional?n.push(e.name):i.push(e.name)}),{satisfied:0===i.length,missing:i,optional:n,reason:i.length>0?`Missing: ${i.join(", ")}`:"OK"}}markInitialized(e){this.initialized.add(e),this.initializing.delete(e),i.info(`[DependencyManager] '${e}' initialized`)}markInitializing(e){this.initializing.add(e)}getDependents(e){return this.dependents.get(e)||[]}getModule(e){return this.modules.get(e)}isReadyToInitialize(e){if(this.initialized.has(e)||this.initializing.has(e))return!1;return this.checkDependencies(e).satisfied}getStatus(){const e=this.modules.size,t=this.initialized.size,i=this.initializing.size;return{total:e,initialized:t,initializing:i,pending:e-t-i,modules:{initialized:Array.from(this.initialized),initializing:Array.from(this.initializing),pending:Array.from(this.modules.keys()).filter(e=>!this.initialized.has(e)&&!this.initializing.has(e))}}}validateDefinition(e){if(!e.name||"string"!=typeof e.name)return i.error("[DependencyManager] Module name is required and must be string"),!1;if(!e.version||"string"!=typeof e.version)return i.error(`[DependencyManager] Version is required for module '${e.name}'`),!1;if(!Array.isArray(e.dependencies))return i.error(`[DependencyManager] Dependencies must be array for module '${e.name}'`),!1;for(const t of e.dependencies)if(!t.name||"string"!=typeof t.name)return i.error(`[DependencyManager] Invalid dependency in module '${e.name}': missing name`),!1;return!0}reset(){this.modules.clear(),this.dependents.clear(),this.initialized.clear(),this.initializing.clear(),this.initializationOrder=[],i.info("[DependencyManager] Reset complete")}static createDefinition(e,t){const i={name:e,version:t,dependencies:[],provides:[],priority:0},n={depends(e,t="*",n=!1){return i.dependencies.push({name:e,version:t,optional:n}),this},provides(...e){return i.provides.push(...e),this},priority(e){return i.priority=e,this},build:()=>i};return Object.setPrototypeOf(n,i),Object.keys(i).forEach(e=>{e in n||Object.defineProperty(n,e,{get:()=>i[e],set(t){i[e]=t},enumerable:!0,configurable:!0})}),n}}const H=new I;"undefined"!=typeof window&&(window.dependencyManager=H,window.depStatus=()=>H.getStatus());const q=I.createDefinition("scroll-dependent","1.0.0").depends("example-module","1.0.0").depends("scrollfx","1.0.0",!0).provides("scroll-coordination").priority(10);let V=null,N=null;const U=Object.freeze(Object.defineProperty({__proto__:null,definition:q,destroy:function(){i.info("[scroll-dependent] destroy"),V&&N&&(N.unsubscribe(V),V=null),N&&"function"==typeof N.cleanup&&N.cleanup(),N=null},init:function(e={},t=null){i.info("[scroll-dependent] init"),N=t,N&&(N.register("isScrolling",!1),N.register("scrollDirection","none"),V=N.subscribe("example-module.scrollPosition",(e,t)=>{if(t.y!==e.y){const n=e.y>t.y?"down":"up";N.set("scrollDirection",n),N.set("isScrolling",!0),setTimeout(()=>{N&&N.set("isScrolling",!1)},150),i.info(`[scroll-dependent] Scroll ${n}: ${e.y}`)}}))}},Symbol.toStringTag,{value:"Module"}));const B=Object.freeze(Object.defineProperty({__proto__:null,init:function(e={}){const t=document.querySelectorAll("[data-scroll-loop]");t.forEach(e=>{if("translate"===(e.dataset.scrollType||"translate")&&1===e.children.length){const t=e.firstElementChild.cloneNode(!0);t.setAttribute("aria-hidden","true"),e.appendChild(t)}}),d("scroll-loop",()=>{const i=window.scrollY,n=window.scrollX;t.forEach(t=>{const r=parseFloat(t.dataset.scrollSpeed||e.speed||.2),s=t.dataset.scrollAxis||"y",o=t.dataset.scrollType||"translate",a="true"===t.dataset.loopPause,l=parseFloat(t.dataset.loopOffset||0),d=parseFloat(t.dataset.loopLimit||0),c="x"===s?n:i;if(d&&c>d)return;if(a&&(t.matches(":hover")||t.matches(":active")))return;const u=(c+l)*r;switch(o){case"translate":{const e=-u%("x"===s?t.offsetWidth:t.offsetHeight),i="x"===s?`translateX(${e}px)`:`translateY(${e}px)`;t.style.transform=i;break}case"rotate":{const e=u%360;t.style.transform=`rotate(${e}deg)`;break}case"background":{const e=u%100;t.style.backgroundPosition="x"===s?`${e}% center`:`center ${e}%`;break}case"scale":{const e=1+.1*Math.sin(.01*u);t.style.transform=`scale(${e.toFixed(3)})`;break}}})},{autoStart:!0})}},Symbol.toStringTag,{value:"Module"})),W={onEnter(e,t){t.classList.add("active"),document.body.dataset.activeScrollStep=e,i.info(`[ScrollStep] Enter: ${e}`),1===e&&i.info("Intro sichtbar"),2===e&&i.info("Chart aktiviert"),3===e&&i.info("Zitat eingeblendet")},onLeave(e,t){t.classList.remove("active"),t.style.transitionDelay="",i.info(`[ScrollStep] Leave: ${e}`),document.body.dataset.activeScrollStep===String(e)&&delete document.body.dataset.activeScrollStep,1===e&&i.info("Intro ausgeblendet"),2===e&&i.info("Chart deaktiviert"),3===e&&i.info("Zitat ausgeblendet")}};const K=Object.freeze(Object.defineProperty({__proto__:null,destroy:function(){c("scroll-timeline")},init:function(e={}){i.info("ScrollTimeline init");const t={attribute:"data-scroll-step",triggerPoint:.4,once:!0,...e},n=Array.from(document.querySelectorAll(`[${t.attribute}]`)).map(e=>({el:e,index:parseInt(e.getAttribute(t.attribute),10),active:!1}));d("scroll-timeline",function(){const e=window.innerHeight*t.triggerPoint;n.forEach(n=>{var r,s;const o=n.el.getBoundingClientRect(),a=o.top<e&&o.bottom>0;a&&!n.active&&(n.active=!0,n.el.classList.add("active"),i.log(`➡️ ENTER step ${n.index}`),null==(r=W.onEnter)||r.call(W,n.index,n.el)),!a&&n.active&&(n.active=!1,n.el.classList.remove("active"),i.log(`⬅️ LEAVE step ${n.index}`),t.once||null==(s=W.onLeave)||s.call(W,n.index,n.el))})},{autoStart:!0})}},Symbol.toStringTag,{value:"Module"}));const Y=new class{constructor(){this.triggers=new Set,this.viewportHeight=window.innerHeight,this._loop=this._loop.bind(this),window.addEventListener("resize",()=>{this.viewportHeight=window.innerHeight}),requestAnimationFrame(this._loop)}register(e){this.triggers.add(e)}unregister(e){this.triggers.delete(e)}clear(){this.triggers.clear()}_loop(){this.triggers.forEach(e=>{e.update(this.viewportHeight)}),requestAnimationFrame(this._loop)}};class X{constructor(e){if(this.element=this.resolveElement(e.element),this.target=e.target?this.element.querySelector(e.target):this.element,e.target&&!this.target)throw new Error(`Target selector '${e.target}' not found inside element '${e.element}'.`);this.start=e.start||"top 80%",this.end=e.end||"bottom 20%",this.scrub=e.scrub||!1,this.onEnter=e.onEnter||null,this.onLeave=e.onLeave||null,this.onUpdate=e.onUpdate||null,this._wasVisible=!1,this._progress=0}resolveElement(e){if("string"==typeof e){const t=document.querySelectorAll(e);if(1===t.length)return t[0];throw new Error(`Selector '${e}' matched ${t.length} elements, expected exactly 1.`)}return e}getScrollProgress(e){const t=this.element.getBoundingClientRect(),i=this.parsePosition(this.start,e),n=this.parsePosition(this.end,e)-i,r=t.top-i;return 1-Math.min(Math.max(r/n,0),1)}parsePosition(e,t){const[i,n]=e.split(" ");return("top"===i?0:t)-t*(parseFloat(n)/100)}update(e){const t=this.element.getBoundingClientRect(),i=t.bottom>0&&t.top<e;if(i&&!this._wasVisible&&(this._wasVisible=!0,this.onEnter&&this.onEnter(this.target)),!i&&this._wasVisible&&(this._wasVisible=!1,this.onLeave&&this.onLeave(this.target)),this.scrub&&i){const t=this.getScrollProgress(e);this.onUpdate&&this.onUpdate(this.target,t)}}}const G=Object.freeze(Object.defineProperty({__proto__:null,createTrigger:function(e){const t="string"==typeof e.element?document.querySelectorAll(e.element):[e.element],i=[];return t.forEach(t=>{const n=new X({...e,element:t});Y.register(n),i.push(n)}),1===i.length?i[0]:i},init:function(e={}){const{selector:t=".fade-in-on-scroll, .zoom-in, .fade-out, .fade",offset:i=.85,baseDelay:n=.05,once:r=!0}=e,s=Array.from(document.querySelectorAll(t)).map(e=>({el:e,triggered:!1}));requestAnimationFrame(function e(){const t=window.innerHeight*i;s.forEach((e,i)=>{if(e.triggered&&r)return;e.el.getBoundingClientRect().top<t?(e.el.style.transitionDelay=i*n+"s",e.el.classList.add("visible","entered"),e.el.classList.remove("fade-out"),e.triggered=!0):r||(e.el.classList.remove("visible","entered"),e.triggered=!1)}),requestAnimationFrame(e)})}},Symbol.toStringTag,{value:"Module"}));let J=null,Z=null;const Q=Object.freeze(Object.defineProperty({__proto__:null,destroy:function(){var e;e="sidebar",Array.isArray(e)&&e.forEach(e=>{O.removeModule(e)})},init:function(){document.getElementById("sidebar-menu");const e=document.getElementById("menu-toggle"),t=document.getElementById("sidebar"),i=document.querySelector(".backdrop"),n=document.querySelector("footer"),r=document.querySelector("header a");C(e,"click",e=>{t.classList.toggle("show"),t.classList.contains("show")?(i.classList.add("visible"),n.setAttribute("inert","true"),r.setAttribute("inert","true")):(i.classList.remove("visible"),n.removeAttribute("inert"),r.removeAttribute("inert"))}),J=e=>{"Escape"===e.key&&t.classList.contains("show")&&(t.classList.remove("show"),i.classList.remove("visible"))},C(document,"keydown",J),Z=e=>{t.classList.remove("show"),i.classList.remove("visible"),n.removeAttribute("inert"),r.removeAttribute("inert")},C(i,"click",Z)}},Symbol.toStringTag,{value:"Module"})),ee=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));class te{constructor(e={}){this.options={containerSelector:"main",linkSelector:'a[href^="/"]',loadingClass:"spa-loading",excludeSelector:'[data-spa="false"], [download], [target="_blank"], [href^="mailto:"], [href^="tel:"], [href^="#"]',enableTransitions:!0,transitionDuration:300,skeletonTemplate:this.createSkeletonTemplate(),...e},this.container=null,this.isLoading=!1,this.currentUrl=window.location.href,this.abortController=null,this.init()}static create(e={}){return new te(e)}init(){this.container=document.querySelector(this.options.containerSelector),this.container?(this.bindEvents(),this.setupStyles(),this.updateHistoryState(window.location.href,document.title),i.info("[SPARouter] Initialized")):i.error(`[SPARouter] Container "${this.options.containerSelector}" not found`)}bindEvents(){document.addEventListener("click",e=>this.handleLinkClick(e)),window.addEventListener("popstate",e=>this.handlePopState(e)),document.addEventListener("submit",e=>this.handleFormSubmit(e))}handleLinkClick(e){const t=e.target.closest(this.options.linkSelector);if(!t)return;if(t.matches(this.options.excludeSelector))return;if(e.ctrlKey||e.metaKey||e.shiftKey)return;e.preventDefault();const i=t.href,n=t.title||t.textContent.trim();this.navigate(i,n)}handlePopState(e){const t=window.location.href;t!==this.currentUrl&&this.loadContent(t,!1)}handleFormSubmit(e){const t=e.target;t.hasAttribute("data-spa")&&"false"===t.getAttribute("data-spa")||t._moduleInstance}async navigate(e,t=""){var n;if(this.isLoading&&(null==(n=this.abortController)||n.abort()),e!==this.currentUrl){i.info(`[SPARouter] Navigating to: ${e}`);try{await this.loadContent(e,!0,t)}catch(r){"AbortError"!==r.name&&(i.error("[SPARouter] Navigation failed:",r),window.location.href=e)}}}async loadContent(e,t=!0,n=""){if(!this.isLoading){this.isLoading=!0,this.abortController=new AbortController;try{this.showLoadingState();const r=await fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest","X-SPA-Request":"true",Accept:"text/html"},signal:this.abortController.signal});if(!r.ok)throw new Error(`HTTP ${r.status}: ${r.statusText}`);const s=await r.text(),o=this.extractMainContent(s),a=this.extractTitle(s)||n;await this.updateContent(o,a),t&&this.updateHistoryState(e,a),this.currentUrl=e,i.info(`[SPARouter] Successfully loaded: ${e}`)}catch(r){if("AbortError"!==r.name)throw this.hideLoadingState(),r}finally{this.isLoading=!1,this.abortController=null}}}extractMainContent(e){const t=(new DOMParser).parseFromString(e,"text/html"),n=t.querySelector("main");if(n)return n.innerHTML;const r=['[role="main"]',".main-content","#main",".content"];for(const s of r){const e=t.querySelector(s);if(e)return i.warn(`[SPARouter] Using fallback selector: ${s}`),e.innerHTML}return i.warn("[SPARouter] No main element found, using entire body"),t.body.innerHTML}extractTitle(e){const t=(new DOMParser).parseFromString(e,"text/html").querySelector("title");return t?t.textContent.trim():""}async updateContent(e,t){t&&(document.title=t),this.options.enableTransitions&&await this.transitionOut(),this.container.innerHTML=e,this.reinitializeModules(),this.options.enableTransitions&&await this.transitionIn(),this.hideLoadingState(),window.scrollTo({top:0,behavior:"smooth"}),this.triggerNavigationEvent()}showLoadingState(){document.body.classList.add(this.options.loadingClass),this.options.enableTransitions&&this.container.classList.add("spa-transitioning-out")}hideLoadingState(){document.body.classList.remove(this.options.loadingClass)}async transitionOut(){return new Promise(e=>{this.container.style.transition=`opacity ${this.options.transitionDuration}ms ease-out`,this.container.style.opacity="0",setTimeout(()=>{e()},this.options.transitionDuration)})}async transitionIn(){return new Promise(e=>{this.container.style.opacity="0",setTimeout(()=>{this.container.style.opacity="1",setTimeout(()=>{this.container.style.transition="",this.container.classList.remove("spa-transitioning-out"),e()},this.options.transitionDuration)},50)})}updateHistoryState(e,t){const i={url:e,title:t,timestamp:Date.now()};e!==window.location.href?history.pushState(i,t,e):history.replaceState(i,t,e)}reinitializeModules(){window.initAutoFormHandling&&window.initAutoFormHandling();this.container.querySelectorAll("[data-module]").forEach(e=>{const t=e.dataset.module;i.info(`[SPARouter] Re-initializing module "${t}" on new content`);const n=new CustomEvent("spa:reinit-module",{detail:{element:e,moduleName:t},bubbles:!0});e.dispatchEvent(n)})}createSkeletonTemplate(){return'\n <div class="spa-skeleton">\n <div class="spa-skeleton-header"></div>\n <div class="spa-skeleton-content">\n <div class="spa-skeleton-line"></div>\n <div class="spa-skeleton-line"></div>\n <div class="spa-skeleton-line short"></div>\n </div>\n </div>\n '}setupStyles(){if(document.getElementById("spa-router-styles"))return;const e=document.createElement("style");e.id="spa-router-styles",e.textContent="\n /* SPA Router Transitions */\n .spa-loading {\n cursor: progress;\n }\n \n .spa-transitioning-out {\n pointer-events: none;\n }\n \n /* Skeleton Loading Styles */\n .spa-skeleton {\n animation: spa-pulse 1.5s ease-in-out infinite alternate;\n }\n \n .spa-skeleton-header {\n height: 2rem;\n background: #e5e7eb;\n border-radius: 0.375rem;\n margin-bottom: 1rem;\n width: 60%;\n }\n \n .spa-skeleton-content {\n space-y: 0.75rem;\n }\n \n .spa-skeleton-line {\n height: 1rem;\n background: #e5e7eb;\n border-radius: 0.375rem;\n margin-bottom: 0.75rem;\n }\n \n .spa-skeleton-line.short {\n width: 75%;\n }\n \n @keyframes spa-pulse {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0.4;\n }\n }\n \n /* Dark mode support */\n @media (prefers-color-scheme: dark) {\n .spa-skeleton-header,\n .spa-skeleton-line {\n background: #374151;\n }\n }\n ",document.head.appendChild(e)}triggerNavigationEvent(){const e=new CustomEvent("spa:navigated",{detail:{url:this.currentUrl,container:this.container,timestamp:Date.now()},bubbles:!0});document.dispatchEvent(e)}navigateTo(e,t){return this.navigate(e,t)}getCurrentUrl(){return this.currentUrl}isNavigating(){return this.isLoading}destroy(){var e;null==(e=this.abortController)||e.abort(),document.removeEventListener("click",this.handleLinkClick),window.removeEventListener("popstate",this.handlePopState),document.removeEventListener("submit",this.handleFormSubmit);const t=document.getElementById("spa-router-styles");t&&t.remove(),i.info("[SPARouter] Destroyed")}}const ie={name:"spa-router",router:null,init(e={}){i.info("[SPARouterModule] Initializing SPA Router");const t={containerSelector:"main",linkSelector:'a[href^="/"]',excludeSelector:'[data-spa="false"], [download], [target="_blank"], [href^="mailto:"], [href^="tel:"], [href^="#"]',enableTransitions:!0,transitionDuration:300,enableSkeletonLoading:!0,...e};return this.router=te.create(t),"undefined"!=typeof window&&(window.spaRouter=this.router),document.addEventListener("spa:reinit-module",this.handleModuleReinit.bind(this)),document.addEventListener("spa:navigated",this.handleNavigation.bind(this)),i.info("[SPARouterModule] SPA Router initialized successfully"),this.router},handleModuleReinit(e){const{element:t,moduleName:n}=e.detail;i.info(`[SPARouterModule] Re-initializing module: ${n}`,t);const r=new CustomEvent("module:reinit-needed",{detail:{element:t,moduleName:n},bubbles:!0});document.dispatchEvent(r)},handleNavigation(e){const{url:t,timestamp:n}=e.detail;i.info(`[SPARouterModule] Navigation completed to: ${t}`),"function"==typeof window.initAutoFormHandling&&setTimeout(()=>{window.initAutoFormHandling()},100),"function"==typeof window.gtag&&window.gtag("config","GA_TRACKING_ID",{page_path:new URL(t).pathname})},navigateTo(e,t){if(this.router)return this.router.navigateTo(e,t);i.warn("[SPARouterModule] Router not initialized")},getCurrentUrl(){var e;return(null==(e=this.router)?void 0:e.getCurrentUrl())||window.location.href},isNavigating(){var e;return(null==(e=this.router)?void 0:e.isNavigating())||!1},destroy(){this.router&&(this.router.destroy(),this.router=null),"undefined"!=typeof window&&window.spaRouter&&delete window.spaRouter,document.removeEventListener("spa:reinit-module",this.handleModuleReinit),document.removeEventListener("spa:navigated",this.handleNavigation),i.info("[SPARouterModule] SPA Router destroyed")}},ne=Object.freeze(Object.defineProperty({__proto__:null,SPARouter:te,SPARouterModule:ie,default:ie},Symbol.toStringTag,{value:"Module"}));let re="sticky-fade",se=[],oe=window.scrollY,ae=new WeakMap,le={direction:!1,reset:!1};const de=Object.freeze(Object.defineProperty({__proto__:null,destroy:function(){c(re),se.forEach(e=>{e.style.opacity="",e.style.transform="",e.classList.remove("visible"),delete e.dataset.scrollDir}),se=[],ae=new WeakMap},init:function(e={}){se=Array.from(document.querySelectorAll("[data-sticky-fade]")),0!==se.length&&(le.direction=e.direction??!1,le.reset=e.reset??!1,d(re,()=>{const e=window.scrollY,t=e>oe?"down":e<oe?"up":"none";oe=e;const i=window.innerHeight;se.forEach(e=>{const n=e.getBoundingClientRect(),r=1-Math.min(Math.max(n.top/i,0),1);if(e.style.opacity=r.toFixed(3),e.style.transform=`translateY(${20*(1-r)}px)`,le.direction&&(e.dataset.scrollDir=t),le.reset){const t=r>=1,i=ae.get(e)||!1;t&&!i?(e.classList.add("visible"),ae.set(e,!0)):!t&&i&&(e.classList.remove("visible"),ae.set(e,!1))}})},{autoStart:!0}))}},Symbol.toStringTag,{value:"Module"}));const ce=Object.freeze(Object.defineProperty({__proto__:null,destroy:function(){c("sticky-steps")},init:function(e={}){i.info("StickySteps init");const t={containerSelector:"[data-sticky-container]",stepSelector:"[data-sticky-step]",activeClass:"is-sticky-active",datasetKey:"activeStickyStep",...e};document.querySelectorAll(t.containerSelector).forEach(e=>{const i=e.querySelectorAll(t.stepSelector),n=e.offsetTop;d(`sticky-steps-${e.dataset.moduleId||Math.random()}`,function(){const r=window.scrollY,s=e.offsetHeight;i.forEach((o,a)=>{const l=n+a*(s/i.length),d=n+(a+1)*(s/i.length),c=r>=l&&r<d;o.classList.toggle(t.activeClass,c),c&&(e.dataset[t.datasetKey]=a)})},{autoStart:!0})})}},Symbol.toStringTag,{value:"Module"}));const ue=Object.freeze(Object.defineProperty({__proto__:null,init:function(){}},Symbol.toStringTag,{value:"Module"})),he=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),me={noise:{selector:".noise-overlay",toggleKey:"g",className:"grainy",enableTransition:!0},"shortcut-handler.js":{debug:!1},scrollfx:{selector:".fade-in-on-scroll, .zoom-in",offset:.8,baseDelay:.075,once:!0},"scroll-timeline":{attribute:"data-scroll-step",triggerPoint:.4,once:!1},"smooth-scroll":{speed:.2}};const fe=new class{constructor(){this.crashedModules=new Set,this.recoveryAttempts=new Map,this.maxRecoveryAttempts=3,this.recoveryDelay=1e3}wrapModule(e,t){return e&&"object"==typeof e?new Proxy(e,{get:(e,i,n)=>{const r=e[i];if("function"!=typeof r)return r;const s=Object.getOwnPropertyDescriptor(e,i);return s&&!s.configurable?r:(...n)=>{try{const s=r.apply(e,n);return s&&"function"==typeof s.catch?s.catch(e=>(this.handleModuleError(e,t,i,n),this.getRecoveryValue(t,i))):s}catch(s){return this.handleModuleError(s,t,i,n),this.getRecoveryValue(t,i)}}},getOwnPropertyDescriptor:(e,t)=>{const i=Object.getOwnPropertyDescriptor(e,t);return i&&i.configurable,i},has:(e,t)=>t in e,ownKeys:e=>Object.getOwnPropertyNames(e)}):(i.warn(`[ErrorBoundary] Cannot wrap non-object module: ${t}`),e)}handleModuleError(e,t,n,r){const s=`${t}.${n}`;i.error(`[ErrorBoundary] Module ${t} crashed in ${n}():`,e),this.crashedModules.add(t);const o=this.recoveryAttempts.get(s)||0;this.recoveryAttempts.set(s,o+1),window.dispatchEvent(new CustomEvent("module-error",{detail:{moduleName:t,method:n,error:e.message,args:r,attempts:o+1}})),o<this.maxRecoveryAttempts?this.scheduleRecovery(t,n,r):(i.error(`[ErrorBoundary] Module ${t} exceeded recovery attempts. Marking as permanently failed.`),this.markModuleAsPermanentlyFailed(t))}scheduleRecovery(e,t,n){setTimeout(()=>{try{i.info(`[ErrorBoundary] Attempting recovery for ${e}.${t}()`)}catch(n){i.error(`[ErrorBoundary] Recovery failed for ${e}.${t}():`,n)}},this.recoveryDelay)}getRecoveryValue(e,t){switch(t){case"init":case"destroy":case"update":case"render":return Promise.resolve();case"getData":case"getConfig":return{};case"isEnabled":case"isActive":return!1;default:return}}markModuleAsPermanentlyFailed(e){window.dispatchEvent(new CustomEvent("module-permanent-failure",{detail:{moduleName:e}}))}getHealthStatus(){return{totalCrashedModules:this.crashedModules.size,crashedModules:Array.from(this.crashedModules),recoveryAttempts:Object.fromEntries(this.recoveryAttempts),timestamp:(new Date).toISOString()}}resetModule(e){this.crashedModules.delete(e);for(const[t]of this.recoveryAttempts)t.startsWith(`${e}.`)&&this.recoveryAttempts.delete(t);i.info(`[ErrorBoundary] Reset error tracking for module: ${e}`)}reset(){this.crashedModules.clear(),this.recoveryAttempts.clear(),i.info("[ErrorBoundary] Reset all error tracking")}};window.addEventListener("error",e=>{i.error("[Global] Unhandled error:",e.error||e.message)}),window.addEventListener("unhandledrejection",e=>{i.error("[Global] Unhandled promise rejection:",e.reason)});const pe=new class{constructor(){this.state=new Map,this.subscribers=new Map,this.stateOwners=new Map,this.defaultValues=new Map,this.currentModule="unknown",this.subscriptionCounter=0}setContext(e){this.currentModule=e}register(e,t,n=this.currentModule){this.state.has(e)?i.warn(`[StateManager] State key '${e}' already registered by ${this.stateOwners.get(e)}`):(this.state.set(e,t),this.defaultValues.set(e,t),this.stateOwners.set(e,n),this.subscribers.set(e,[]),i.info(`[StateManager] Registered '${e}' (owner: ${n})`))}get(e){if(this.state.has(e))return this.state.get(e);i.warn(`[StateManager] Unknown state key: '${e}'`)}set(e,t,n=!1){if(!this.state.has(e))return i.warn(`[StateManager] Cannot set unknown state key: '${e}'`),!1;const r=this.stateOwners.get(e);if(!n&&r!==this.currentModule)return i.warn(`[StateManager] Module '${this.currentModule}' cannot modify '${e}' (owned by ${r})`),!1;const s=this.state.get(e);return s===t||(this.state.set(e,t),this.notifySubscribers(e,t,s),i.info(`[StateManager] Updated '${e}' by ${this.currentModule}`)),!0}subscribe(e,t,n=this.currentModule){if(!this.state.has(e))return i.warn(`[StateManager] Cannot subscribe to unknown state key: '${e}'`),null;const r=`${n}_${++this.subscriptionCounter}`,s={id:r,callback:t,subscriber:n};return this.subscribers.has(e)||this.subscribers.set(e,[]),this.subscribers.get(e).push(s),i.info(`[StateManager] Subscribed '${n}' to '${e}'`),r}unsubscribe(e){for(const[t,n]of this.subscribers.entries()){const r=n.findIndex(t=>t.id===e);if(-1!==r){const e=n[r];return n.splice(r,1),void i.info(`[StateManager] Unsubscribed '${e.subscriber}' from '${t}'`)}}i.warn(`[StateManager] Subscription ID not found: ${e}`)}notifySubscribers(e,t,n){(this.subscribers.get(e)||[]).forEach(r=>{try{r.callback(t,n,e)}catch(s){i.error(`[StateManager] Error in subscriber '${r.subscriber}' for '${e}':`,s)}})}reset(e){if(!this.state.has(e))return i.warn(`[StateManager] Cannot reset unknown state key: '${e}'`),!1;const t=this.defaultValues.get(e);return this.set(e,t,!0)}clearModuleSubscriptions(e){let t=0;for(const[i,n]of this.subscribers.entries()){const r=n.filter(t=>t.subscriber!==e);t+=n.length-r.length,this.subscribers.set(i,r)}t>0&&i.info(`[StateManager] Cleared ${t} subscriptions for module '${e}'`)}getSnapshot(){const e={state:Object.fromEntries(this.state),owners:Object.fromEntries(this.stateOwners),subscriptions:{}};for(const[t,i]of this.subscribers.entries())e.subscriptions[t]=i.map(e=>({id:e.id,subscriber:e.subscriber}));return e}resetAll(){this.state.clear(),this.subscribers.clear(),this.stateOwners.clear(),this.defaultValues.clear(),this.subscriptionCounter=0,i.info("[StateManager] Reset complete")}createScope(e){return{register:(t,i)=>(this.setContext(e),this.register(t,i,e)),get:e=>this.get(e),set:(t,i)=>(this.setContext(e),this.set(t,i)),subscribe:(t,i)=>(this.setContext(e),this.subscribe(t,i,e)),unsubscribe:e=>this.unsubscribe(e),reset:e=>this.reset(e),cleanup:()=>this.clearModuleSubscriptions(e)}}};"undefined"!=typeof window&&(window.stateManager=pe,window.stateSnapshot=()=>pe.getSnapshot());const ge=new Map;function ye(){const e=document.querySelectorAll("[data-module]");i.info(`[DOMInit] Found ${e.length} elements with data-module attributes`),e.forEach(e=>{const t=e.dataset.module,n=ge.get(t);if(!n||!n.mod)return void i.warn(`[DOMInit] Module "${t}" not found or failed to initialize`);let r={};try{e.dataset.options&&(r=JSON.parse(e.dataset.options))}catch(s){i.warn(`[DOMInit] Invalid JSON in data-options for ${t}:`,s)}try{const s=n.mod;if("function"==typeof s.init){const n=s.init(e,r);i.info(`[DOMInit] Initialized ${t} on element:`,e),e._moduleInstance=n,e._moduleName=t}else i.warn(`[DOMInit] Module ${t} has no init method for DOM elements`)}catch(s){i.error(`[DOMInit] Failed to initialize ${t} on element:`,s,e)}})}function be(){const e=document.querySelectorAll('form:not([data-form-handling="false"])');if(i.info(`[AutoForms] Found ${e.length} forms for auto-enhancement`),0===e.length)return;const t=ge.get("form-handling");t&&t.mod?e.forEach(e=>{if(e.hasAttribute("data-module"))return void i.info("[AutoForms] Skipping form with explicit data-module:",e);let n={};try{e.dataset.formOptions&&(n=JSON.parse(e.dataset.formOptions))}catch(s){i.warn("[AutoForms] Invalid JSON in data-form-options:",s)}const r={validateOnSubmit:!0,validateOnBlur:!1,validateOnInput:!1,showInlineErrors:!0,ajaxSubmit:!0,enableStateTracking:!1,...n};try{const n=t.mod.init(e,r);i.info("[AutoForms] Auto-enhanced form:",e),e.setAttribute("data-auto-enhanced","true"),e._moduleInstance=n,e._moduleName="form-handling"}catch(s){i.error("[AutoForms] Failed to auto-enhance form:",s,e)}}):i.warn("[AutoForms] form-handling module not available, skipping auto-init")}async function ve(){await async function(){var e;let t;t="undefined"!=typeof global&&(null==(e=global.importMeta)?void 0:e.glob)?global.importMeta.glob("./*/index.js",{eager:!0}):Object.assign({"./example-module/index.js":f,"./form-handling/index.js":v,"./inertia-scroll/index.js":F,"./lightbox-trigger/index.js":D,"./noise/index.js":P,"./parallax/index.js":R,"./scroll-dependent/index.js":U,"./scroll-loop/index.js":B,"./scroll-timeline/index.js":K,"./scrollfx/index.js":G,"./sidebar/index.js":Q,"./smooth-scroll/index.js":ee,"./spa-router/index.js":ne,"./sticky-fade/index.js":de,"./sticky-steps/index.js":ce,"./ui/index.js":ue,"./wheel-boost/index.js":he});const n=new Set(Array.from(document.querySelectorAll("[data-module]")).map(e=>e.dataset.module).filter(Boolean)),r=new Set(["spa-router","form-handling"]),s=new Set([...n,...r]),o=s.size===r.size&&0===n.size;Object.entries(t).forEach(([e,t])=>{const n=e.split("/").slice(-2,-1)[0];if(o||s.has(n))if("object"==typeof t.definition)H.register(t.definition);else{const e={name:n,version:"1.0.0",dependencies:[],provides:[],priority:0};H.register(e)}else i.info(`⏭️ [Module] Skipping unused module: ${n}`)});const a=H.calculateInitializationOrder();for(const d of a){if(!o&&!s.has(d)){i.info(`⏭️ [Module] Skipped (not used in DOM): ${d}`);continue}const e=Object.keys(t).find(e=>e.split("/").slice(-2,-1)[0]===d);if(!e){i.warn(`⛔ [Module] No implementation found for: ${d}`);continue}const n=t[e],r=me[d]||{},a=H.checkDependencies(d);if(a.satisfied)if("function"==typeof n.init)try{H.markInitializing(d);const e=pe.createScope(d),t=fe.wrapModule(n,d);await t.init(r,e),H.markInitialized(d),ge.set(d,{mod:t,config:r,state:e,original:n}),i.info(`✅ [Module] Initialized: ${d}`)}catch(l){i.error(`❌ [Module] Failed to initialize ${d}:`,l),ge.set(d,{mod:null,config:r,error:l,original:n})}else i.warn(`⛔ [Module] No init() in ${d}`);else i.error(`❌ [Module] Cannot initialize ${d}: ${a.reason}`),ge.set(d,{mod:null,config:r,error:new Error(a.reason),original:n})}o&&i.info("⚠️ [Module] No data-module usage detected, fallback to full init mode")}(),ye(),be(),function(){const e=ge.get("spa-router");if(e&&e.mod)try{e.mod.init({containerSelector:"main",enableTransitions:!0,transitionDuration:300}),window.initAutoFormHandling=be,window.initDataModuleElements=ye,i.info("[Init] SPA Router initialized successfully")}catch(t){i.error("[Init] Failed to initialize SPA Router:",t)}else i.info("[Init] SPA Router module not available, skipping")}(),function(){const e=document.querySelectorAll("video[data-src]"),t=window.innerWidth,i=(navigator.connection||{}).effectiveType||"4g";e.forEach(e=>{const n=e.dataset.src;let r="480";r="2g"===i||"slow-2g"===i?"480":"3g"===i?t>=1200?"720":"480":t>=1200?"1080":t>=800?"720":"480";const s=`${n}-${r}.webm`,o=document.createElement("video");o.autoplay=!0,o.loop=!0,o.muted=!0,o.playsInline=!0,o.poster=e.getAttribute("poster")||"",o.setAttribute("width",e.getAttribute("width")||"100%");const a=document.createElement("source");a.src=s,a.type="video/webm",o.appendChild(a),e.replaceWith(o)})}()}"undefined"!=typeof window&&(window.moduleHealth=function(){const e={total:ge.size,active:0,failed:0,modules:{},errorBoundary:fe.getHealthStatus()};for(const[t,{mod:i,error:n}]of ge.entries())n?(e.failed++,e.modules[t]={status:"failed",error:n.message}):i?(e.active++,e.modules[t]={status:"active"}):e.modules[t]={status:"unknown"};return e}),document.addEventListener("DOMContentLoaded",()=>{ve()});
|