create-prisma-php-app 2.4.5 → 3.0.0-alpha.1

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.
@@ -76,25 +76,20 @@ class TemplateCompiler
76
76
  1
77
77
  );
78
78
 
79
- $styleBlock = <<<HTML
80
- <style>
81
- html:not([data-initial-hydrated]) body {
82
- opacity: 0;
83
- }
84
- html[data-initial-hydrated] body {
85
- opacity: 1;
86
- }
87
- </style>
88
- HTML;
89
-
90
79
  $htmlContent = preg_replace(
91
80
  '/(<\/head\s*>)/i',
92
- $styleBlock
93
- . MainLayout::outputHeadScripts()
81
+ MainLayout::outputHeadScripts()
94
82
  . '$1',
95
83
  $htmlContent,
96
84
  1
97
85
  );
86
+
87
+ $htmlContent = preg_replace(
88
+ '/<body([^>]*)>/i',
89
+ '<body$1 hidden>',
90
+ $htmlContent,
91
+ 1
92
+ );
98
93
  }
99
94
 
100
95
  $patternBodyClose = '/(<\/body\s*>)/i';
@@ -184,7 +179,7 @@ class TemplateCompiler
184
179
  );
185
180
  }
186
181
 
187
- protected static function processNode(DOMNode $node, bool $inBody = false): string
182
+ protected static function processNode(DOMNode $node): string
188
183
  {
189
184
  if ($node instanceof DOMText) {
190
185
  return self::processTextNode($node);
@@ -194,7 +189,7 @@ class TemplateCompiler
194
189
  $pushed = false;
195
190
  $tag = strtolower($node->nodeName);
196
191
 
197
- if ($tag === 'script' && $inBody && !$node->hasAttribute('src')) {
192
+ if ($tag === 'script' && !$node->hasAttribute('src')) {
198
193
  $node->setAttribute('type', 'text/php');
199
194
  }
200
195
 
@@ -219,7 +214,7 @@ class TemplateCompiler
219
214
 
220
215
  $children = '';
221
216
  foreach ($node->childNodes as $c) {
222
- $children .= self::processNode($c, $inBody || $tag === 'body');
217
+ $children .= self::processNode($c);
223
218
  }
224
219
  $attrs = self::getNodeAttributes($node) + ['children' => $children];
225
220
  $out = self::renderAsHtml($node->nodeName, $attrs);
@@ -1,24 +1,7 @@
1
- /* Define fonts */
2
- @font-face {
3
- font-family: "GeistVF";
4
- src: url("../assets/fonts/GeistVF.woff") format("woff");
5
- }
6
-
7
- @font-face {
8
- font-family: "GeistMonoVF";
9
- src: url("../assets/fonts/GeistMonoVF.woff") format("woff");
10
- }
11
-
12
- /* Use GeistVF for body */
13
1
  body {
14
2
  font-family: Arial, Helvetica, sans-serif; /* Default font for body */
15
3
  }
16
4
 
17
- /* Example of using GeistMonoVF for code elements */
18
- code {
19
- font-family: "GeistMonoVF", monospace;
20
- }
21
-
22
5
  /*! tailwindcss v4.0.14 | MIT License | https://tailwindcss.com */@layer theme, base, components, utilities;@layer theme{:host,:root{--font-sans:var(--font-geist-sans);--font-mono:var(--font-geist-mono);--color-red-500:oklch(0.637 0.237 25.331);--color-red-600:oklch(0.577 0.245 27.325);--color-gray-50:oklch(0.985 0.002 247.839);--color-gray-100:oklch(0.967 0.003 264.542);--color-gray-200:oklch(0.928 0.006 264.531);--color-gray-300:oklch(0.872 0.01 258.338);--color-gray-400:oklch(0.707 0.022 261.325);--color-gray-500:oklch(0.551 0.027 264.364);--color-gray-800:oklch(0.278 0.033 256.848);--color-gray-900:oklch(0.21 0.034 264.665);--color-gray-950:oklch(0.13 0.028 261.692);--color-black:#000;--color-white:#fff;--spacing:0.25rem;--container-md:28rem;--text-xs:0.75rem;--text-xs--line-height:1.33333;--text-sm:0.875rem;--text-sm--line-height:1.42857;--text-base:1rem;--text-lg:1.125rem;--text-lg--line-height:1.55556;--text-xl:1.25rem;--text-xl--line-height:1.4;--text-3xl:1.875rem;--text-3xl--line-height:1.2;--text-4xl:2.25rem;--text-4xl--line-height:1.11111;--text-5xl:3rem;--text-5xl--line-height:1;--text-6xl:3.75rem;--text-6xl--line-height:1;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tighter:-0.05em;--leading-relaxed:1.625;--radius-md:0.375rem;--radius-lg:0.5rem;--ease-in:cubic-bezier(0.4,0,1,1);--ease-out:cubic-bezier(0,0,0.2,1);--default-transition-duration:150ms;--default-transition-timing-function:cubic-bezier(0.4,0,0.2,1);--default-font-family:var(--font-sans);--default-font-feature-settings:var(--font-sans--font-feature-settings);--default-font-variation-settings:var(
23
6
  --font-sans--font-variation-settings
24
7
  );--default-mono-font-family:var(--font-mono);--default-mono-font-feature-settings:var(
@@ -1,4 +1,4 @@
1
- @import "tailwindcss" source("../../../src/");
1
+ @import "tailwindcss";
2
2
 
3
3
  :root {
4
4
  --background: #ffffff;
@@ -8,8 +8,6 @@
8
8
  @theme inline {
9
9
  --color-background: var(--background);
10
10
  --color-foreground: var(--foreground);
11
- --font-sans: var(--font-geist-sans);
12
- --font-mono: var(--font-geist-mono);
13
11
  }
14
12
 
15
13
  @media (prefers-color-scheme: dark) {
@@ -19,25 +17,8 @@
19
17
  }
20
18
  }
21
19
 
22
- @layer base {
23
- /* Define fonts */
24
- @font-face {
25
- font-family: "GeistVF";
26
- src: url("../assets/fonts/GeistVF.woff") format("woff");
27
- }
28
-
29
- @font-face {
30
- font-family: "GeistMonoVF";
31
- src: url("../assets/fonts/GeistMonoVF.woff") format("woff");
32
- }
33
-
34
- body {
35
- background: var(--background);
36
- color: var(--foreground);
37
- font-family: Arial, Helvetica, sans-serif;
38
- }
39
-
40
- code {
41
- font-family: "GeistMonoVF", monospace;
42
- }
20
+ body {
21
+ background: var(--background);
22
+ color: var(--foreground);
23
+ font-family: Arial, Helvetica, sans-serif;
43
24
  }
@@ -1 +1 @@
1
- (()=>{const e=EventTarget.prototype.addEventListener,t=EventTarget.prototype.removeEventListener,n=new Map;EventTarget.prototype.addEventListener=function(t,s,r){n.has(this)||n.set(this,new Map);const i=n.get(this).get(t)||new Set;i.add(s),n.get(this).set(t,i),e.call(this,t,s,r)},EventTarget.prototype.removeEventListener=function(e,s,r){if(n.has(this)&&n.get(this).has(e)){const t=n.get(this).get(e);t&&(t.delete(s),0===t.size&&n.get(this).delete(e))}t.call(this,e,s,r)},EventTarget.prototype.removeAllEventListeners=function(e){if(n.has(this)&&n.get(this).has(e)){const s=n.get(this).get(e);s&&(s.forEach((n=>{t.call(this,e,n)})),n.get(this).delete(e))}};const s=Symbol("pphp_remove_all");EventTarget.prototype[s]||Object.defineProperty(EventTarget.prototype,s,{value(e){const s=n.get(this);if(!s)return;const r=e?[e]:[...s.keys()];for(const e of r){const n=s.get(e);n&&(n.forEach((n=>t.call(this,e,n))),s.delete(e))}},writable:!1,enumerable:!1,configurable:!0})})();class PPHP{props={};static _instance;_isNavigating=!1;_responseData=null;_activeAbortController=null;_rawProps={};_elementState={checkedElements:new Set};_reservedWords;_bindings=[];_pendingBindings=new Set;_updateScheduled=!1;_templateStore=new WeakMap;_proxyCache=new WeakMap;_scopedKeys=new Map;_processedPhpSections=new Set;_processedPhpScripts=new WeakSet;_effects=new Set;_pendingEffects=new Set;_refs=new Map;_declaredStateRoots=new Set;_eventHandlers;_redirectRegex=/redirect_7F834\s*=\s*(\/[^\s]*)/;_mustacheRe=/\{\{\s*([\s\S]+?)\s*\}\}/gu;_assignmentRe=/^\s*[\w.]+\s*=(?!=)/;_htmlEntitiesRe=/&quot;|&#039;|&amp;/g;_mutators;_arrayMethodCache=new WeakMap;static _mustacheTest=/\{\{\s*[\s\S]+?\s*\}\}/;static _mustachePattern=/\{\{\s*([\s\S]+?)\s*\}\}/g;constructor(){const e=["focus","blur","click","scrollIntoView","select","setSelectionRange","show","showModal","requestFullscreen"];for(const t of e){const e=HTMLElement.prototype;if("function"==typeof e[t]&&!e[`__pphp_${t}_patched`]){const n=e[t];e[t]=function(...e){requestAnimationFrame((()=>n.apply(this,e)))},e[`__pphp_${t}_patched`]=!0}}const t=Object.getOwnPropertyNames(HTMLElement.prototype).filter((e=>e.startsWith("on"))),n=Object.getOwnPropertyNames(Document.prototype).filter((e=>e.startsWith("on"))),s=Object.getOwnPropertyNames(Window.prototype).filter((e=>e.startsWith("on")));this._eventHandlers=new Set([...t,...n,...s].map((e=>e.toLowerCase()))),this._reservedWords=new Set(["null","undefined","true","false","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","async","await","implements","interface","event","NaN","Infinity","Number","String","Boolean","Object","Array","Function","Date","RegExp","Error","JSON","Math","Map","Set"]),this._mutators=new Set(["push","pop","shift","unshift","splice","sort","reverse","copyWithin","fill"]),this.handlePopState(),this.props=this.makeReactive(this._rawProps),this.scheduleInitialHydration()}static get instance(){return PPHP._instance||(PPHP._instance=new PPHP),PPHP._instance}scheduleInitialHydration(){const e=async()=>{this.initRefs(),await this.processInlineModuleScripts(),this.initializeAllReferencedProps(),this.initBindings(),this.initLoopBindings(),this.attachWireFunctionEvents(),this._bindings.forEach((e=>e.update())),requestAnimationFrame((()=>{document.documentElement.setAttribute("data-initial-hydrated",""),this.handlerAutofocusAttribute()}))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>e()),{once:!0}):e()}static _isBuiltIn=(()=>{const e=new Map,t=[Object.prototype,Function.prototype,Array.prototype,String.prototype,Number.prototype,Boolean.prototype,Date.prototype,RegExp.prototype,Map.prototype,Set.prototype,WeakMap.prototype,WeakSet.prototype,Error.prototype,Promise.prototype];return n=>{const s=e.get(n);if(void 0!==s)return s;const r=n in globalThis||t.some((e=>n in e));return e.set(n,r),r}})();_sectionRefs=new Map;initRefs(){document.querySelectorAll("[pp-ref]").forEach((e=>{const t=e.getAttribute("pp-ref"),n=e.closest("[pp-section-id]")?.getAttribute("pp-section-id")??"__global__",s=this._sectionRefs.get(n)??new Map,r=s.get(t)??[];r.push(e),s.set(t,r),this._sectionRefs.set(n,s);const i=this._refs.get(t)??[];i.push(e),this._refs.set(t,i),e.removeAttribute("pp-ref")}))}ref(e,t){const n=window.__PPHP_ACTIVE_SECTION??null;let s=[];if(n&&(s=this._sectionRefs.get(n)?.get(e)??[]),0===s.length&&(s=this._refs.get(e)??[]),null!=t){const n=s[t];if(!n)throw new Error(`pphp.ref('${e}', ${t}) — no element at that index`);return n}if(0===s.length)throw new Error(`pphp.ref('${e}') failed — no element was found`);return 1===s.length?s[0]:s}_currentSectionId(){const e=document.currentScript;return e?.closest("[pp-section-id]")?.getAttribute("pp-section-id")||null}getNested(e,t){return t.split(".").reduce(((e,t)=>e?e[t]:void 0),e)}setNested(e,t,n){const s=t.split("."),r=s.pop();s.reduce(((e,t)=>e[t]??={}),e)[r]=n}hasNested(e,t){return void 0!==this.getNested(e,t)}scopeKey(e){const t=this._currentSectionId();return t?e.startsWith(`${t}_`)?e:e.includes(".")?e.replace(/^([^\.]+)/,`${t}_$1`):`${t}_${e}`:e}alreadyScoped(e,t){const n=`${t}_${e}`;return this._scopedKeys.get(t)?.has(n)??!1}scheduleFlush(){this._updateScheduled||(this._updateScheduled=!0,requestAnimationFrame((()=>{this._updateScheduled=!1,this.flushBindings()})))}effect(e,t){const n=this._currentSectionId(),s=Array.isArray(t),r=s?t:[],i=s&&0===r.length,o=r.map((e=>{if("function"==typeof e&&e.__pphp_key)return e.__pphp_key;if("string"!=typeof e)return"";if(e.includes("_"))return e;for(const[t,n]of this._scopedKeys)if(n.has(e))return`${t}_${e}`;return n?`${n}_${e}`:e})).filter(Boolean);if(e.__deps=new Set(o),i){try{e()}catch(e){console.error("effect error:",e)}return()=>{}}const a=(window.__PPHP_INLINE_DEPTH__??0)>0?this._pendingEffects:this._effects;return a.delete(e),a.add(e),()=>{this._effects.delete(e),this._pendingEffects.delete(e)}}state(e,t){const n=this._currentSectionId(),s=e;if(this._reservedWords.has(s))throw new Error(`'${s}' is reserved (native object) – choose another state key.`);e=this.scopeKey(e),this._declaredStateRoots.add(e),n&&(this._scopedKeys.has(n)||this._scopedKeys.set(n,new Set),this._scopedKeys.get(n).add(s)),this.hasNested(pphp.props,e)||this.setNested(pphp.props,e,t),this._reservedWords.has(s)||Object.defineProperty(globalThis,s,{configurable:!0,enumerable:!0,get:()=>this.getNested(pphp.props,e),set:t=>{this.setNested(pphp.props,e,t),this.scheduleFlush()}});const r=()=>this.getNested(pphp.props,e),i=()=>r();return Object.defineProperties(i,{valueOf:{value:()=>r()},toString:{value:()=>String(r())}}),[i,t=>{const n="function"==typeof t?t(r()):t;this.setNested(pphp.props,e,n),this.scheduleFlush()}]}extractDependencies(e){let t=e.replace(/\?\./g,".");const n=new Set,s=/(?:^|[^\w$])(?:\(\s*([^)]*?)\s*\)|([A-Za-z_$][\w$]*))\s*=>/g;for(let e;e=s.exec(t);){(e[1]??e[2]??"").split(",").map((e=>e.trim())).filter(Boolean).forEach((e=>n.add(e)))}t=t.replace(/`([^`\\]|\\.)*`/g,(e=>[...e.matchAll(/\$\{([^}]*)\}/g)].map((e=>e[1])).join(" "))),t=t.replace(/(['"])(?:\\.|[^\\])*?\1/g,""),t=t.replace(/\/(?:\\.|[^\/\\])+\/[gimsuy]*/g,"");const r=new Set,i=/\b[A-Za-z_$]\w*(?:\.[A-Za-z_$]\w*)*\b/g;for(const e of t.match(i)??[]){const t=e.split(".")[0],s=PPHP._isBuiltIn(t);n.has(t)||s&&!(t in this.props)||r.add(e)}return r}formatValue(e){return"function"==typeof e?"":"boolean"==typeof e?e?"true":"false":Array.isArray(e)?e.map((e=>"object"==typeof e?JSON.stringify(e):String(e))).join(", "):e&&"object"==typeof e?Object.keys(e).length?JSON.stringify(e,null,2):"":e?.toString()??""}registerBinding(e,t,n="text",s){if(this._assignmentRe.test(t))return;const r=e.parentElement?.closest("[pp-section-id]"),i=r?.getAttribute("pp-section-id");let o=t;if(i){const e=this._scopedKeys.get(i)||new Set,n=new Set;Object.keys(this.props).forEach((e=>{e.startsWith(i+"_")&&n.add(e.slice(i.length+1))}));const s=t=>(e.has(t)||n.has(t))&&!t.startsWith(i+"_")&&!this._reservedWords.has(t);o=t.replace(/\b([A-Za-z_$][\w$]*)\b/g,((e,t,n,r)=>"."===r[n-1]?e:s(t)?`${i}_${t}`:e))}const a=new Set([...this.extractDependencies(o)].map((e=>e.split(".")[0])).filter((e=>e in this.props&&!this._reservedWords.has(e)))),c=this.makeSafeEvaluator(o);if("value"===s||"checked"===s){const t=this.makePrimitiveUpdater(e,s,c);return void this._bindings.push({dependencies:a,update:t})}if(s){const t=e.getAttribute(s)??"";if(this._mustacheRe.test(o)||this._mustacheRe.test(t)){const n=t.replace(this._mustacheRe,((e,t)=>{let n=t;if(i){const e=this._scopedKeys.get(i),s=e instanceof Set?e:new Set(Array.isArray(e)?e:[]);n=t.replace(/\b([A-Za-z_$][\w$]*)\b/g,((e,t,n,r)=>{const o=s.has(t),a=s.has(`${i}_${t}`);return o||a?"."===r[n-1]||this._reservedWords.has(t)||e.startsWith(`${i}_`)?e:`${i}_${t}`:e}))}return`{{ ${n} }}`})),r=this.makeAttrTemplateUpdater(e,s,a,n);return void this._bindings.push({dependencies:a,update:r})}const n=()=>{try{const t=c(this.props),n=this.formatValue(t);s in e&&(e[s]=n),e.setAttribute(s,n)}catch(e){console.error(`Error evaluating "${s}"="${o}"`,e)}};return void this._bindings.push({dependencies:a,update:n})}const l={text:(e,t)=>{e.textContent!==t&&(e.textContent=t)},value:(e,t)=>{e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value!==t&&(e.value=t):e.setAttribute("value",t)},checked:(e,t)=>{e instanceof HTMLInputElement?e.checked="true"===t:e.setAttribute("checked",t)},attr:(e,t)=>{e.setAttribute("attr",t)}};this._bindings.push({dependencies:a,update:()=>{try{const t=c(this.props),s=this.formatValue(t);l[n](e,s)}catch(e){console.error(`Error evaluating expression "${o}".`,e)}}})}makePrimitiveUpdater(e,t,n){const s={};return this._eventHandlers.forEach((e=>{if(e.startsWith("on")){const t=e.slice(2);s[t]=t}})),s.value="input",s.checked="change",()=>{try{const r=n(this.props),i=this.formatValue(r);let o=!1;if("value"===t){const t=e;"value"in e&&t.value!==i?(t.value=i,o=!0):"value"in e||(e.setAttribute("value",i),o=!0)}else{const t=e,n="true"===i;"checked"in e&&t.checked!==n?(t.checked=n,o=!0):"checked"in e||(e.setAttribute("checked",i),o=!0)}if(!o||e instanceof HTMLInputElement&&("hidden"===e.type||e.disabled||e.readOnly))return;const a=e.getAttribute("pp-dispatch-event")||s[t]||t,c="click"===a?new MouseEvent(a,{bubbles:!0,cancelable:!0}):new Event(a,{bubbles:!0});e.dispatchEvent(c)}catch(e){console.error(`Error evaluating attribute "${t}":`,e)}}}makeAttrTemplateUpdater(e,t,n,s){let r=this._templateStore.get(e);r||(r=new Map,this._templateStore.set(e,r)),r.has(t)||r.set(t,e.getAttribute(t)||"");const i=s??r.get(t)??"";return(i.match(this._mustacheRe)||[]).forEach((e=>{this.extractDependencies(e).forEach((e=>n.add(e)))})),()=>{try{const n=i.replace(this._mustacheRe,((e,t)=>{try{const e=this.makeSafeEvaluator(t);return this.formatValue(e(this.props))}catch(e){return console.error("Error token:",t,e),""}}));e.getAttribute(t)!==n&&e.setAttribute(t,n)}catch(e){console.error(`Error evaluating the template for attribute "${t}". Please check the template syntax and dependencies.`,e)}}}initBindings(){this._bindings=[];const e=new WeakSet;document.body.querySelectorAll("[pp-if]").forEach((t=>{if(e.has(t))return;const n=[];let s=t;for(;s;){if(s.hasAttribute("pp-if"))n.push({el:s,expr:s.getAttribute("pp-if")});else if(s.hasAttribute("pp-elseif"))n.push({el:s,expr:s.getAttribute("pp-elseif")});else{if(!s.hasAttribute("pp-else"))break;n.push({el:s,expr:null})}e.add(s),s=s.nextElementSibling}n.forEach((e=>{if(null!==e.expr){const t=e.expr.replace(/^{\s*|\s*}$/g,"");e.deps=this.extractDependencies(t);const n=this.makeSafeEvaluator(t);e.evaluate=()=>!!n(this.props)}}));const r=new Set;n.forEach((e=>e.deps?.forEach((e=>r.add(e)))));this._bindings.push({dependencies:r,update:()=>{let e=!1;for(const{el:t,expr:s,evaluate:r}of n)!e&&null!==s&&r()?(t.removeAttribute("hidden"),e=!0):e||null!==s?t.setAttribute("hidden",""):(t.removeAttribute("hidden"),e=!0)}})})),document.body.querySelectorAll("*").forEach((e=>{["pp-bind","pp-bind-expr"].forEach((t=>{const n=e.getAttribute(t);n&&this.registerBinding(e,n,"text")})),Array.from(e.attributes).forEach((t=>{if(!t.name.startsWith("pp-bind-"))return;if("pp-bind"===t.name||"pp-bind-expr"===t.name||"pp-bind-spread"===t.name)return;const n=t.value.replace(this._htmlEntitiesRe,(e=>"&quot;"===e?'"':"&#039;"===e?"'":"&")).replace(/^{{\s*|\s*}}$/g,"");let s=t.name.replace(/^(pp-bind-)+/,"");const r=s.toLowerCase();"html"!==r&&"innerhtml"!==r||(s="innerHTML");const i="value"===s?"value":"checked"===s?"checked":"text";this.registerBinding(e,n,i,s)})),Array.from(e.attributes).forEach((t=>{if("pp-bind-spread"!==t.name)return;const n=t.value.split(",").map((e=>e.trim())).filter(Boolean),s=new Set;n.forEach((e=>s.add(e.split(".")[0])));const r=new Set;this._bindings.push({dependencies:s,update:()=>{try{const t={};n.forEach((e=>{const n=this.getNested(this.props,e)??{};Object.assign(t,n)})),r.forEach((n=>{n in t||e.hasAttribute(n)||(e.removeAttribute(n),r.delete(n))})),Object.entries(t).forEach((([t,n])=>{if(!r.has(t)&&e.hasAttribute(t))return;if(!1===n||null==n)return void(r.has(t)&&(e.removeAttribute(t),r.delete(t)));const s="object"==typeof n?JSON.stringify(n):String(n);e.getAttribute(t)!==s&&e.setAttribute(t,s),r.add(t)}))}catch(e){console.error("pp-spread error:",e)}}})}))}))}safeNull=new Proxy({},{get:(e,t)=>t===Symbol.toPrimitive?()=>{}:PPHP._isBuiltIn(t.toString())?(console.warn(`PPHP Warning: The property or method name "${t.toString()}" conflicts with a JavaScript built-in object or function. Please choose a unique name to avoid unexpected behavior.`),()=>""):this.safeNull,apply:()=>""});safeTag=(e,...t)=>e.reduce(((e,n,s)=>{const r=t[s];return e+n+(null==r||"object"==typeof r?"":r)}),"");makeSafeEvaluator(e){let t=e.trim();const n=t.replace(/\?\./g,".");if(/^\(\s*\)\s*=>/.test(t)&&(t=`(${t})()`),t.startsWith("`")&&t.endsWith("`")){const e=new Function("props","safeTag",`\n try {\n with (props) {\n return safeTag${t};\n }\n } catch (e) {\n console.error("PPHP template eval error for:", ${JSON.stringify(t)}, e);\n return "";\n }\n `);return t=>e(t,this.safeTag.bind(this))}const s=n.replace(/(["'])(?:(?=(\\?))\2.)*?\1/g,"").match(/\b[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*\b/g)||[],r=new Set(s.map((e=>e.split(".")[0])).filter((e=>/^[A-Za-z_$][\w$]*$/.test(e)&&!this._reservedWords.has(e)&&"safeTag"!==e))),i=Array.from(r).map((e=>`\n const ${e} = ctx["${e}"] !== undefined\n ? ctx["${e}"]\n : (typeof window !== "undefined" && window["${e}"] !== undefined\n ? window["${e}"]\n : ${new RegExp(`\\b${e}\\.`).test(n)?"{}":"void 0"});\n if (typeof window !== "undefined" && window["${e}"] !== ${e}) {\n window["${e}"] = ${e};\n }\n `)).join("\n"),o=/^\s*[\w\.]+\s*=(?!=)/.test(t),a=new Function("ctx","safeTag",`\n "use strict";\n ${i}\n try {\n ${o?t+"; return '';":"const result = "+t+"; return result === undefined || result === null ? '' : result;"}\n } catch (e) {\n return "";\n }\n `);return e=>a(e,this.safeTag.bind(this))}setNestedProperty(e,t,n){const s=t.split(".");let r=e;for(let e=0;e<s.length-1;e++)s[e]in r||(r[s[e]]={}),r=r[s[e]];r[s[s.length-1]]=n}resetProps(){Object.keys(this._rawProps).forEach((e=>{if(window.hasOwnProperty(e)){const t=Object.getOwnPropertyDescriptor(window,e);t&&t.configurable&&delete window[e]}})),this._rawProps={},this._proxyCache=new WeakMap,this._templateStore=new WeakMap,this._processedPhpSections=new Set,this._processedPhpScripts=new WeakSet,this._scopedKeys=new Map,this._effects=new Set,this._pendingEffects=new Set,this._bindings=[],this.props=this.makeReactive(this._rawProps)}initializeAllReferencedProps(){const e=PPHP._mustachePattern,t=PPHP._mustacheTest,n=this.props,s=new Set,r=(e,t)=>{const n=e.getAttribute("pp-section-id"),s=e.parentElement?.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null,r=n??s;return r?`${r}_${t}`:t},i=(()=>{const e=new Set([...Object.getOwnPropertyNames(String.prototype),...Object.getOwnPropertyNames(Array.prototype),...Object.getOwnPropertyNames(Number.prototype),...Object.getOwnPropertyNames(Boolean.prototype),...Object.getOwnPropertyNames(Object.prototype),...Object.getOwnPropertyNames(Date.prototype),...Object.getOwnPropertyNames(RegExp.prototype)]);return t=>e.has(t)})(),o=(e,t)=>{const[n,o,...a]=t.split(".");if(PPHP._isBuiltIn(n)||this._reservedWords.has(n))return void console.warn(`Invalid path “${t}” while initialising props – the root identifier is reserved or built‑in.`);if(o&&i(o))return void s.add(r(e,n));const c=r(e,n);s.add(o?`${c}.${[o,...a].join(".")}`:c)};for(const n of document.body.getElementsByTagName("*"))for(const{name:s,value:r}of Array.from(n.attributes))if(r){if(t.test(r))for(const t of r.matchAll(e))this.extractDependencies(t[1]).forEach((e=>o(n,e)));"pp-if"!==s&&"pp-elseif"!==s||this.extractDependencies(r).forEach((e=>o(n,e))),s.startsWith("pp-bind")&&this.extractDependencies(r).forEach((e=>o(n,e)))}const a=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode:e=>e.parentElement?.closest("pre,code,[pp-ignore='true']")?NodeFilter.FILTER_REJECT:t.test(e.nodeValue||"")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT});for(let t;t=a.nextNode();){const n=t.parentElement;for(const s of t.nodeValue.matchAll(e))this.extractDependencies(s[1]).forEach((e=>o(n,e)))}const c=Array.from(s).sort(((e,t)=>t.split(".").length-e.split(".").length));for(const e of c){const t=e.split(".");let s=n;for(let n=0;n<t.length;n++){const r=t[n],i=n===t.length-1;if(0===n&&PPHP._isBuiltIn(r)){console.warn(`Skipping root “${r}” inside path “${e}” – collides with a JS built‑in.`);break}r in s&&(i||null!=s[r]&&"object"==typeof s[r])||(s[r]=i?void 0:{}),s=s[r]}}const l=new Set(c.map((e=>e.split(".")[0])));for(const e of this._declaredStateRoots)l.add(e);for(const e of l)e in globalThis||Object.defineProperty(globalThis,e,{configurable:!0,enumerable:!0,get:()=>n[e],set:t=>n[e]=t})}scheduleBindingUpdate(e){this._pendingBindings.add(e),this._updateScheduled||(this._updateScheduled=!0,requestAnimationFrame((()=>{this.flushBindings()})))}flushBindings(){const e=new Set;this._pendingBindings.forEach((t=>{t.dependencies.forEach((t=>e.add(t))),t.update()})),this._pendingBindings.clear(),this._updateScheduled=!1,this._effects.forEach((t=>{const n=t.__deps||new Set,s=window.__PPHP_ACTIVE_SECTION;if(window.__PPHP_ACTIVE_SECTION=t.__sectionId??null,0===n.size||[...n].some((t=>e.has(t))))try{t()}catch(e){console.error("effect error:",e)}finally{window.__PPHP_ACTIVE_SECTION=s}}))}initMakeReactive(){this.initRefs(),this.initializeAllReferencedProps(),this.initBindings(),this.initLoopBindings(),this.attachWireFunctionEvents(),this._bindings.forEach((e=>e.update()))}getProxiedProps(e){let t=this._proxyCache.get(e);if(t)return t;return t=new Proxy(e,{get:(e,t)=>t in e?e[t]:void 0,set:(e,t,n)=>(e[t]=n,!0)}),this._proxyCache.set(e,t),t}async invokeHandler(e,t,n){const s=e.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;window.__PPHP_ACTIVE_SECTION=s??null;const r=[];if(s){const e=new Set;(this._scopedKeys.get(s)||new Set).forEach((t=>{const n=t.startsWith(s+"_")?t.slice(s.length+1):t;e.add(n)})),Object.keys(pphp.props).forEach((t=>{t.startsWith(s+"_")&&e.add(t.slice(s.length+1))})),e.forEach((e=>{const t=`${s}_${e}`;t in pphp.props||this.setNested(pphp.props,t,{});const n=Object.getOwnPropertyDescriptor(globalThis,e);Object.defineProperty(globalThis,e,{configurable:!0,enumerable:!1,get:()=>this.getNested(pphp.props,t),set:e=>{this.setNested(pphp.props,t,e),this.scheduleFlush()}}),r.push((()=>{n?Object.defineProperty(globalThis,e,n):delete globalThis[e]}))}))}try{const s=t.trim(),r=s.replace(/(["'`])(?:\\.|(?!\1).)*\1/g,"").replace(/\/(?:\\.|[^\/])+\/[gimsuy]*/g,"");if(/^\(?\s*[^=]*?\)?\s*=>/.test(r.trim())){const t=new Function("event","proxy","props",`\n with (proxy) {\n const val = (${s});\n return (typeof val === "function")\n ? val.call(this, event, props)\n : val;\n }\n `),r=this.getProxiedProps(pphp.props);return void await t.call(e,n,r,pphp.props)}const i=t.match(/^(\w+(\.\w+)*)\((.*)\)$/);if(i){const s=i[1],r=i[3],o=s.split("."),{context:a,methodName:c}=this.resolveContext(o);if("function"==typeof a[c])if(this.isJsonLike(r)){const t=this.parseJson(r);t.element=e,t.event=n;const s=[t];await a[c](...s)}else new Function("event",t).call(e,n);else await this.handleParsedCallback(e,t)}else if(t.includes("=")){const s=t.match(/^\s*([\w\.]+)\s*=/);if(s){const e=s[1];if(e.includes(".")){const t=e.split(".");let n=pphp.props;for(let e=0;e<t.length-1;e++){const s=t[e];s in n&&null!=n[s]&&"object"==typeof n[s]||(n[s]={}),n=n[s]}}else e in pphp.props||(pphp.props[e]=void 0)}new Function("event","props",`\n with (new Proxy(props, {\n get(target, key) {\n return key in target ? target[key] : undefined;\n },\n set(target, key, value) {\n target[key] = value;\n return true;\n }\n })) {\n ${t}\n }\n `).call(e,n,pphp.props)}else await this.handleParsedCallback(e,t)}catch(e){console.error(`Error executing handler "${t}". Please ensure the handler is defined and valid.`,e)}finally{r.forEach((e=>e())),this.scheduleFlush()}}registerLoop(e){const t=e.getAttribute("pp-for").trim(),[n,s]=t.split(/\s+in\s+/),[r,i]=n.replace(/^\(|\)$/g,"").split(",").map((e=>e.trim())),o=e.parentNode,a=document.createComment("pp-for");o.insertBefore(a,e),o.removeChild(e);const c=this.makeSafeEvaluator(s),l=this.extractDependencies(s);this._bindings.push({dependencies:l,update:()=>{let t=a.nextSibling;for(;t&&t.nodeType!==Node.COMMENT_NODE;){const e=t.nextSibling;o.removeChild(t),t=e}(c(this.props)||[]).forEach(((t,n)=>{this.props[r]=t,i&&(this.props[i]=n);const s=e.content.cloneNode(!0),c=document.createTreeWalker(s,NodeFilter.SHOW_TEXT,null);let l;for(;l=c.nextNode();)l.nodeValue=(l.nodeValue||"").replace(PPHP._mustachePattern,((e,t)=>{try{const e=this.makeSafeEvaluator(t)(this.props);return this.formatValue(e)}catch{return""}}));s.querySelectorAll("*").forEach((e=>{Array.from(e.attributes).forEach((e=>{PPHP._mustacheTest.test(e.value)&&(e.value=e.value.replace(PPHP._mustachePattern,((e,t)=>{try{const e=this.makeSafeEvaluator(t)(this.props);return this.formatValue(e)}catch{return""}})))}))})),s.querySelectorAll("[pp-bind]").forEach((e=>{const t=e.getAttribute("pp-bind"),n=this.makeSafeEvaluator(t)(this.props);e.textContent=this.formatValue(n)})),s.querySelectorAll("[pp-bind-expr]").forEach((e=>{const t=e.getAttribute("pp-bind-expr"),n=this.makeSafeEvaluator(t)(this.props);e.textContent=this.formatValue(n)})),s.querySelectorAll("[pp-bind-class]").forEach((e=>{const t=e.getAttribute("pp-bind-class"),n=this.makeSafeEvaluator(t)(this.props);e.setAttribute("class",String(n))})),s.querySelectorAll("*").forEach((e=>{Array.from(e.attributes).forEach((t=>{if(t.name.startsWith("on")&&/\bidx?\b/.test(t.value)){const s=t.value.replace(/\bi\b/g,String(n)).replace(/\bidx\b/g,String(n));e.setAttribute(t.name,s)}}))})),o.insertBefore(s,a.nextSibling)})),this.attachWireFunctionEvents()}})}initLoopBindings(){document.querySelectorAll("[pp-for]").forEach((e=>this.registerLoop(e)))}makeReactive(e,t=[]){const n=this._proxyCache.get(e);if(n)return n;const s=this;if(e instanceof Map||e instanceof Set)return e;const r=new Proxy(e,{get(e,n,r){const i=Reflect.get(e,n,r);if(Array.isArray(e)&&s._mutators.has(n)){let o=s._arrayMethodCache.get(e);if(o||(o=new Map,s._arrayMethodCache.set(e,o)),!o.has(n)){const e=i,a=t.join("."),c=function(...t){const n=Reflect.apply(e,r,t);return queueMicrotask((()=>{s._bindings.forEach((e=>{e.dependencies.has(a)&&s.scheduleBindingUpdate(e)}))})),n};o.set(n,c)}return o.get(n)}return"object"==typeof i&&null!==i?s.makeReactive(i,[...t,n]):i},set(e,n,r){if(r&&"object"==typeof r&&(r=s.makeReactive(r,[...t,n.toString()])),e[n]=r,0===t.length){const e=n;s._reservedWords.has(e)||PPHP._isBuiltIn(e)||e in globalThis||Object.defineProperty(globalThis,e,{configurable:!0,enumerable:!0,get:()=>s.props[e],set(t){s.props[e]=t}})}const i=[...t,n].join(".");return s._bindings.forEach((e=>{for(const t of e.dependencies)if(i===t||i.startsWith(t+".")||t.startsWith(i+".")){s.scheduleBindingUpdate(e);break}})),!0}});return this._proxyCache.set(e,r),r}handlePopState(){window.addEventListener("popstate",(async()=>{await this.handleNavigation()}))}prefixFunctionCalls(e,t){return e.replace(/\b([A-Za-z_$][\w$]*)\s*\(/g,((e,n)=>this._reservedWords.has(n)||n.startsWith(`${t}_`)?e:this.alreadyScoped(n,t)?`${t}_${n}(`:e))}prefixIds(e,t){let n="",s=0,r=(e=this.prefixFunctionCalls(e,t)).length,i=!1,o=!1,a=!1;for(;s<r;){const c=e[s];if("'"!==c||o||a||"\\"===e[s-1])if('"'!==c||i||a||"\\"===e[s-1])if("`"!==c||i||o||"\\"===e[s-1])if(i||o||a)n+=c,s++;else if(/[A-Za-z_$]/.test(c)){let i=s+1;for(;i<r&&/[\w$]/.test(e[i]);)i++;const o=e.slice(s,i),a=e[s-1]??"",c=this._reservedWords.has(o),l="."===a;n+=!o.startsWith(`${t}_`)&&!l&&!c?`${t}_${o}`:o,s=i}else n+=c,s++;else a=!a,n+=c,s++;else o=!o,n+=c,s++;else i=!i,n+=c,s++}return n}attachWireFunctionEvents(){this.handleHiddenAttribute(),this.handleAnchorTag();const e=Array.from(this._eventHandlers).map((e=>`[${e}]`)).join(", ");document.body.querySelectorAll(e).forEach((e=>{const t=e.closest("[pp-section-id]")?.getAttribute("pp-section-id");if(Array.from(e.attributes).filter((e=>this._eventHandlers.has(e.name))).forEach((n=>{const s=n.name.slice(2);e.removeAllEventListeners(s);let r=n.value.trim();if(t){const e=r.indexOf("=>");if(-1!==e){const n=r.slice(0,e+2),s=r.slice(e+2);r=n+this.prefixIds(s,t)}else r=this.prefixIds(r,t)}e instanceof HTMLInputElement&&this.handleInputAppendParams(e,s),e.removeAttribute(n.name),this.handleDebounce(e,s,r)})),e instanceof HTMLFormElement){const n=e.getAttribute("onsubmit")?.trim();if(n){let s=n;t&&(s=s.replace(/^([A-Za-z_$][\w$]*)\s*\(/,((e,n)=>`${t}_${n}(`))),e.removeAttribute("onsubmit"),this.handleDebounce(e,"submit",s)}}}))}async handleDebounce(e,t,n){const s=e.getAttribute("pp-debounce")||"",r=e.getAttribute("pp-before-request")||"",i=e.getAttribute("pp-after-request")||"",o=async t=>{t.preventDefault();try{r&&await this.invokeHandler(e,r,t),await this.invokeHandler(e,n,t),i&&"@close"!==i&&await this.invokeHandler(e,i,t),this.handlerAutofocusAttribute()}catch(e){console.error("Error in debounced handler. Please check the handler logic and ensure it is functioning correctly.",e)}};if(s){const n=this.parseTime(s),r=this.debounce(o,n);e instanceof HTMLFormElement&&"submit"===t?e.addEventListener(t,(e=>{e.preventDefault(),r(e)})):e.addEventListener(t,r)}else e.addEventListener(t,o)}debounce(e,t=300,n=!1){let s;return function(...r){const i=this;s&&clearTimeout(s),s=setTimeout((()=>{s=null,n||e.apply(i,r)}),t),n&&!s&&e.apply(i,r)}}handlerAutofocusAttribute(){const e=document.querySelector("dialog[open]");let t=null;if(e&&(t=e.querySelector("[pp-autofocus]")),t||(t=document.querySelector("[pp-autofocus]")),!t)return;const n=t.getAttribute("pp-autofocus");if(!this.isJsonLike(n))return;const s=this.parseJson(n);requestAnimationFrame((()=>{t.focus(),(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&"function"==typeof this.setCursorPosition&&(t instanceof HTMLInputElement&&"number"===t.type?(t.type="text",this.setCursorPosition(t,s),t.type="number"):this.setCursorPosition(t,s))}))}async handleParsedCallback(e,t){const{funcName:n,data:s}=this.parseCallback(e,t);if(!n)return;const r=this[n],i=window[n];let o;if("function"==typeof r?o=r:"function"==typeof i&&(o=i),"function"==typeof o){const t=e.hasAttribute("pp-after-request"),n=Array.isArray(s.args)?s.args:[],r=this._responseData?this.parseJson(this._responseData):{response:this._responseData};let i={args:n,element:e,data:s};t&&(i={...i,...r}),await o.call(this,i)}else this._responseData=null,this._responseData=await this.handleUndefinedFunction(e,n,s)}async handleUndefinedFunction(e,t,n){const s={callback:t,...n},r=this.createFetchOptions(s),i=this.createFetchOptions({secondRequestC69CD:!0,...this.getUrlParams()});try{this.saveElementOriginalState(e),this.handleSuspenseElement(e);const s=new URL(window.location.href);let o="",a="",c={success:!1};const l=e.querySelector("input[type='file']");if(l){if(o=await this.fetchFileWithData(s.href,t,l,n),a=this.extractJson(o)||"",a)try{c=this.parseJson(a)}catch(e){console.error("Error parsing JSON response. Please ensure the response is in valid JSON format.",e)}}else{const e=await this.fetch(s.href,r);if(o=await e.text(),this.getRedirectUrl(o))return void await this.redirect(this.getRedirectUrl(o)||"");if(a=this.extractJson(o)||"",a)try{c=this.parseJson(a)}catch(e){console.error("Error parsing JSON response. Please ensure the response is in valid JSON format.",e)}}const p=e.getAttribute("pp-before-request")||"",h=e.getAttribute("pp-after-request")||"";if((p||h&&c.success)&&this.restoreSuspenseElement(e),p||h){let e="";if(c.success){e=o.replace(a,"")}else e=o;if(this.appendAfterbegin(e),!h&&!c.success)return}if(h&&c.success){this.handleAfterRequest(h,a);const e=o.replace(a,"");return this.appendAfterbegin(e),a}if("@close"===h)return c.success?a:void 0;const d=await this.fetch(s.href,i),u=await d.text();if(this.getRedirectUrl(u))return void await this.redirect(this.getRedirectUrl(u)||"");await this.handleResponseRedirectOrUpdate(o,u,a,c)}catch(e){console.error(`Error handling undefined function "${t}". Please ensure the function is defined and accessible.`,e)}}handleAfterRequest(e,t){if(!this.isJsonLike(e))return;const n=this.parseJson(e),s=t?this.parseJson(t):null,r=n.targets;Array.isArray(r)&&r.forEach((e=>{const{id:t,...n}=e,r=document.querySelector(t);let i={};if(s){for(const t in n)if(n.hasOwnProperty(t))switch(t){case"innerHTML":case"outerHTML":case"textContent":case"innerText":"response"===n[t]&&(i[t]=e.responseKey?s[e.responseKey]:s.response);break;default:i[t]=n[t]}}else i=n;r&&this.updateElementAttributes(r,i)}))}async handleResponseRedirectOrUpdate(e,t,n,s){const r=this.getUpdatedHTMLContent(e,n,s),i=(new DOMParser).parseFromString(t,"text/html");r&&i.body.insertAdjacentElement("afterbegin",r),this.updateBodyContent(i.body.outerHTML)}getUpdatedHTMLContent(e,t,n){const s=document.createElement("div");if(s.id="afterbegin-8D95D",n&&t?.success){const t=e.replace(n,"");s.innerHTML=t}else s.innerHTML=e;return s.innerHTML?s:null}async updateBodyContent(e){const t=this.saveScrollPositions();this.saveElementState();const n=(new DOMParser).parseFromString(e,"text/html");await this.appendCallbackResponse(n),this.restoreElementState(),this.restoreScrollPositions(t),await this.processInlineModuleScripts(),this.initMakeReactive()}restoreElementState(){if(this._elementState.focusId){const e=document.getElementById(this._elementState.focusId)||document.querySelector(`[name="${this._elementState.focusId}"]`);if(e instanceof HTMLInputElement){const t=e.value.length||0;void 0!==this._elementState.focusSelectionStart&&null!==this._elementState.focusSelectionEnd&&e.setSelectionRange(t,t),this._elementState.focusValue&&("checkbox"===e.type||"radio"===e.type?e.checked=!!this._elementState.focusChecked:"number"===e.type||"email"===e.type?(e.type="text",e.setSelectionRange(t,t),e.type="number"===e.type?"number":"email"):"date"===e.type||"month"===e.type||"week"===e.type||"time"===e.type||"datetime-local"===e.type||"color"===e.type||"file"===e.type||""!==e.value&&(e.value=this._elementState.focusValue)),e.focus()}else if(e instanceof HTMLTextAreaElement){const t=e.value.length||0;void 0!==this._elementState.focusSelectionStart&&null!==this._elementState.focusSelectionEnd&&e.setSelectionRange(t,t),this._elementState.focusValue&&""!==e.value&&(e.value=this._elementState.focusValue),e.focus()}else e instanceof HTMLSelectElement&&(this._elementState.focusValue&&""!==e.value&&(e.value=this._elementState.focusValue),e.focus())}this._elementState.checkedElements.forEach((e=>{const t=document.getElementById(e);t&&(t.checked=!0)}))}async appendCallbackResponse(e){const t=e.getElementById("afterbegin-8D95D");if(t){const e=document.getElementById("afterbegin-8D95D");e?e.innerHTML=t.innerHTML:document.body.insertAdjacentHTML("afterbegin",t.outerHTML)}await this.populateDocumentBody(e)}saveElementState(){const e=document.activeElement;this._elementState.focusId=e?.id||e?.name,this._elementState.focusValue=e?.value,this._elementState.focusChecked=e?.checked,this._elementState.focusType=e?.type,this._elementState.focusSelectionStart=e?.selectionStart,this._elementState.focusSelectionEnd=e?.selectionEnd,this._elementState.isSuspense=e.hasAttribute("pp-suspense"),this._elementState.checkedElements.clear(),document.querySelectorAll('input[type="checkbox"]:checked').forEach((e=>{this._elementState.checkedElements.add(e.id||e.name)})),document.querySelectorAll('input[type="radio"]:checked').forEach((e=>{this._elementState.checkedElements.add(e.id||e.name)}))}updateElementAttributes(e,t){for(const n in t)if(t.hasOwnProperty(n))switch(n){case"innerHTML":case"outerHTML":case"textContent":case"innerText":e[n]=this.decodeHTML(t[n]);break;case"insertAdjacentHTML":e.insertAdjacentHTML(t.position||"beforeend",this.decodeHTML(t[n].html));break;case"insertAdjacentText":e.insertAdjacentText(t.position||"beforeend",this.decodeHTML(t[n].text));break;case"setAttribute":e.setAttribute(t.attrName,this.decodeHTML(t[n]));break;case"removeAttribute":e.removeAttribute(t[n]);break;case"className":e.className=this.decodeHTML(t[n]);break;case"classList.add":e.classList.add(...this.decodeHTML(t[n]).split(","));break;case"classList.remove":e.classList.remove(...this.decodeHTML(t[n]).split(","));break;case"classList.toggle":e.classList.toggle(this.decodeHTML(t[n]));break;case"classList.replace":const[s,r]=this.decodeHTML(t[n]).split(",");e.classList.replace(s,r);break;case"dataset":e.dataset[t.attrName]=this.decodeHTML(t[n]);break;case"style":Object.assign(e.style,t[n]);break;case"value":e.value=this.decodeHTML(t[n]);break;case"checked":e.checked=t[n];break;default:e.setAttribute(n,this.decodeHTML(t[n]))}}decodeHTML(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}appendAfterbegin(e){if(!e)return;const t="afterbegin-8D95D";let n=document.getElementById(t);n?(n.innerHTML=e,document.body.insertAdjacentElement("afterbegin",n)):(n=document.createElement("div"),n.id=t,n.innerHTML=e,document.body.insertAdjacentElement("afterbegin",n))}restoreSuspenseElement(e){const t=e.getAttribute("pp-original-state");if(e.hasAttribute("pp-suspense")&&t){const n=(e,t)=>{for(const n in t)t.hasOwnProperty(n)&&("textContent"===n?e.textContent=t[n]:"innerHTML"===n?e.innerHTML=t[n]:"disabled"===n?!0===t[n]?e.setAttribute("disabled","true"):e.removeAttribute("disabled"):e.setAttribute(n,t[n]));for(const n of Array.from(e.attributes))t.hasOwnProperty(n.name)||e.removeAttribute(n.name)},s=(e,t)=>{for(const s in t)if(t.hasOwnProperty(s))for(const t of Array.from(e.elements))if(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){const e=t.getAttribute("pp-original-state")||"";if(e){if(this.isJsonLike(e)){const s=this.parseJson(e);n(t,s)}else r(t,e);t.removeAttribute("pp-original-state")}}},r=(e,t)=>{e instanceof HTMLInputElement?e.value=t:e.textContent=t},i=(e,t)=>{e instanceof HTMLFormElement?s(e,t):n(e,t)};try{const r=this.parseJson(t);if(r)if(e instanceof HTMLFormElement){const t=e.id;if(t){const e=document.querySelector(`[form="${t}"]`);if(e){const t=e.getAttribute("pp-original-state");if(t&&this.isJsonLike(t)){const s=this.parseJson(t);n(e,s)}}}const r=new FormData(e),i={};if(r.forEach(((e,t)=>{i[t]=e})),s(e,i),e.hasAttribute("pp-suspense")){const t=e.getAttribute("pp-suspense")||"";if(this.parseJson(t).disabled)for(const t of Array.from(e.elements))(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.removeAttribute("disabled")}}else if(r.targets){r.targets.forEach((e=>{const{id:t,...n}=e,s=document.querySelector(t);s&&i(s,n)}));const{targets:t,...s}=r;n(e,s)}else{const{empty:t,...s}=r;n(e,s)}}catch(e){console.error(`Error parsing JSON: ${e instanceof Error?e.message:"Unknown error"}. Please ensure the JSON string is valid.`,e)}}e.querySelectorAll("[pp-suspense]").forEach((e=>this.restoreSuspenseElement(e))),e.removeAttribute("pp-original-state")}extractJson(e){const t=e?.match(/\{[\s\S]*\}/);return t?t[0]:null}getRedirectUrl(e){const t=e.match(this._redirectRegex);return t?t[1]:null}async fetchFileWithData(e,t,n,s={}){const r=new FormData,i=n.files;if(i)for(let e=0;e<i.length;e++)r.append("file[]",i[e]);r.append("callback",t);for(const e in s)s.hasOwnProperty(e)&&r.append(e,s[e]);const o=await this.fetch(e,{method:"POST",headers:{HTTP_PPHP_WIRE_REQUEST:"true"},body:r});return await o.text()}async handleSuspenseElement(e){let t=e.getAttribute("pp-suspense")||"";const n=(e,t)=>{for(const n in t)if(t.hasOwnProperty(n))for(const t of e.elements)if(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){const e=t.getAttribute("pp-suspense")||"";if(e)if(this.isJsonLike(e)){const n=this.parseJson(e);"disabled"!==n.onsubmit&&this.updateElementAttributes(t,n),n.targets&&n.targets.forEach((e=>{const{id:t,...n}=e,s=document.querySelector(t);s&&r(s,n)}))}else s(t,e)}},s=(e,t)=>{e instanceof HTMLInputElement?e.value=t:e.textContent=t},r=(e,t)=>{e instanceof HTMLFormElement?n(e,t):this.updateElementAttributes(e,t)};try{if(t&&this.isJsonLike(t)){const s=this.parseJson(t);if(s)if(e instanceof HTMLFormElement){const t=new FormData(e),r={};t.forEach(((e,t)=>{r[t]=e})),s.disabled&&this.toggleFormElements(e,!0);const{disabled:i,...o}=s;this.updateElementAttributes(e,o),n(e,r)}else if(s.targets){s.targets.forEach((e=>{const{id:t,...n}=e,s=document.querySelector(t);s&&r(s,n)}));const{targets:t,...n}=s;this.updateElementAttributes(e,n)}else{if("disabled"===s.empty&&""===e.value)return;const{empty:t,...n}=s;this.updateElementAttributes(e,n)}}else if(t)s(e,t);else if(e instanceof HTMLFormElement){const t=new FormData(e),s={};t.forEach(((e,t)=>{s[t]=e})),n(e,s)}}catch(e){console.error(`Error parsing JSON: ${e instanceof Error?e.message:"Unknown error"}. Please ensure the JSON string is valid.`,e)}}toggleFormElements(e,t){Array.from(e.elements).forEach((e=>{(e instanceof HTMLInputElement||e instanceof HTMLButtonElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&(e.disabled=t)}))}saveElementOriginalState(e){if(e.hasAttribute("pp-suspense")&&!e.hasAttribute("pp-original-state")){const t={};e.textContent&&(t.textContent=e.textContent.trim()),e.innerHTML&&(t.innerHTML=e.innerHTML.trim()),(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(t.value=e.value);for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n];t[s.name]=s.value}e.setAttribute("pp-original-state",JSON.stringify(t))}if(e instanceof HTMLFormElement){let t=null;const n=e.id;n&&(t=document.querySelector(`[form="${n}"]`)),n&&t||(t=Array.from(e.elements).find((e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement))),t?t.hasAttribute("pp-original-state")||this.saveElementOriginalState(t):console.warn("Warning: No invoker detected for the form. Ensure the form has an associated invoker or an ID for proper handling.")}e.querySelectorAll("[pp-suspense]").forEach((e=>this.saveElementOriginalState(e)))}getUrlParams(){const e={};return new URLSearchParams(window.location.search).forEach(((t,n)=>{e[n]=t})),e}createFetchOptions(e){return{method:"POST",headers:{"Content-Type":"application/json",HTTP_PPHP_WIRE_REQUEST:"true"},body:JSON.stringify(e)}}parseCallback(e,t){let n={};const s=e.closest("form");if(s){new FormData(s).forEach(((e,t)=>{n[t]?Array.isArray(n[t])?n[t].push(e):n[t]=[n[t],e]:n[t]=e}))}else e instanceof HTMLInputElement?n=this.handleInputElement(e):(e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&(n[e.name]=e.value);const r=t.match(/(\w+)\((.*)\)/);if(r){const e=r[1];let t=r[2].trim();if(t.startsWith("{")&&t.endsWith("}"))try{const e=this.parseJson(t);"object"==typeof e&&null!==e&&(n={...n,...e})}catch(e){console.error(`Error parsing JSON: ${e instanceof Error?e.message:"Unknown error"}. Please ensure the JSON string is valid.`,e)}else{const e=t.split(/,(?=(?:[^'"]*['"][^'"]*['"])*[^'"]*$)/).map((e=>e.trim().replace(/^['"]|['"]$/g,"")));n.args=e}return{funcName:e,data:n}}return{funcName:t,data:n}}handleInputElement(e){let t={};if(e.name)if("checkbox"===e.type)t[e.name]={value:e.value,checked:e.checked};else if("radio"===e.type){const n=document.querySelector(`input[name="${e.name}"]:checked`);t[e.name]=n?n.value:null}else t[e.name]=e.value;else"checkbox"===e.type||"radio"===e.type?t.value=e.checked:t.value=e.value;return t}resolveContext(e){let t=window;for(let n=0;n<e.length-1;n++)if(t=t[e[n]],!t)throw new Error(`Cannot find object ${e[n]} in the context.`);return{context:t,methodName:e[e.length-1]}}setCursorPosition(e,t){if(t.start)e.setSelectionRange(0,0);else if(t.end){const t=e.value.length||0;e.setSelectionRange(t,t)}else if(t.length){const n=parseInt(t.length,10)||0;e.setSelectionRange(n,n)}}handleInputAppendParams(e,t){const n=e.getAttribute("pp-append-params"),s=e.getAttribute("pp-append-params-sync");if("true"===n){if("true"===s){const t=e.name||e.id;if(t){const n=new URL(window.location.href),s=new URLSearchParams(n.search);s.has(t)&&(e.value=s.get(t)||"")}}e.addEventListener(t,(e=>{const t=e.currentTarget,n=t.value,s=new URL(window.location.href),r=new URLSearchParams(s.search),i=t.name||t.id;if(i){n?r.set(i,n):r.delete(i);const e=r.toString()?`${s.pathname}?${r.toString()}`:s.pathname;history.replaceState(null,"",e)}}))}}handleHiddenAttribute(){const e=document.querySelectorAll("[pp-visibility]"),t=document.querySelectorAll("[pp-display]"),n=this.handleElementVisibility.bind(this),s=this.handleElementDisplay.bind(this);e.forEach((e=>this.handleVisibilityElementAttribute(e,"pp-visibility",n))),t.forEach((e=>this.handleVisibilityElementAttribute(e,"pp-display",s)))}handleVisibilityElementAttribute(e,t,n){const s=e.getAttribute(t);if(s)if(this.isJsonLike(s)){n(e,this.parseJson(s))}else{const n=this.parseTime(s);if(n>0){const s="pp-visibility"===t?"visibility":"display",r="visibility"===s?"hidden":"none";this.scheduleChange(e,n,s,r)}}}handleElementVisibility(e,t){this.handleElementChange(e,t,"visibility","hidden","visible")}handleElementDisplay(e,t){this.handleElementChange(e,t,"display","none","block")}handleElementChange(e,t,n,s,r){const i=t.start?this.parseTime(t.start):0,o=t.end?this.parseTime(t.end):0;i>0?(e.style[n]=s,this.scheduleChange(e,i,n,r),o>0&&this.scheduleChange(e,i+o,n,s)):o>0&&this.scheduleChange(e,o,n,s)}handleAnchorTag(){document.querySelectorAll("a").forEach((e=>{e.addEventListener("click",(async e=>{const t=e.currentTarget,n=t.getAttribute("href"),s=t.getAttribute("target");if(n&&"_blank"!==s&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),!this._isNavigating)){this._isNavigating=!0;try{if(/^(https?:)?\/\//i.test(n)&&!n.startsWith(window.location.origin))window.location.href=n;else{const e=t.getAttribute("pp-append-params");if(n.startsWith("?")&&"true"===e){const e=new URL(window.location.href),t=new URLSearchParams(e.search);let s="";const[r,i]=n.split("#");i&&(s=`#${i}`);new URLSearchParams(r.split("?")[1]).forEach(((e,n)=>{t.set(n,e)}));const o=`${e.pathname}?${t.toString()}${s}`;history.pushState(null,"",o)}else{const[e,t]=n.split("#"),s=`${e}${t?`#${t}`:""}`;history.pushState(null,"",s)}const s=n.indexOf("#");if(-1!==s){const e=n.slice(s+1),t=document.getElementById(e);if(t)t.scrollIntoView({behavior:"smooth"});else{await this.handleNavigation();const t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth"})}}else await this.handleNavigation()}}catch(e){console.error("Anchor click error:",e)}finally{this._isNavigating=!1}}}))}))}async handleNavigation(){try{const e=document.getElementById("loading-file-1B87E");if(e){const t=this.findLoadingElement(e,window.location.pathname);t&&await this.updateContentWithTransition(t)}const t=await this.fetch(window.location.href);if(!t.ok){console.error(`Navigation error: ${t.status} ${t.statusText}`);const e=await t.text();return void await this.updateDocumentContent(e)}const n=await t.text(),s=n.match(this._redirectRegex);if(s&&s[1])return void await this.redirect(s[1]);await this.updateDocumentContent(n)}catch(e){console.error("Navigation error:",e)}}findLoadingElement(e,t){let n=t;for(;;){const t=e.querySelector(`div[pp-loading-url='${n}']`);if(t)return t;if("/"===n)break;const s=n.lastIndexOf("/");n=s<=0?"/":n.substring(0,s)}return e.querySelector("div[pp-loading-url='/' ]")}async updateContentWithTransition(e){const t=document.querySelector("[pp-loading-content='true']")||document.body;if(!t)return;const{fadeIn:n,fadeOut:s}=this.parseTransition(e);await this.fadeOut(t,s),t.innerHTML=e.innerHTML,this.fadeIn(t,n)}parseTransition(e){let t=250,n=250;const s=e.querySelector("[pp-loading-transition]"),r=s?.getAttribute("pp-loading-transition");if(r){const e=this.parseJson(r);e&&"object"==typeof e?(t=this.parseTime(e.fadeIn??t),n=this.parseTime(e.fadeOut??n)):console.warn("pp-loading-transition is not valid JSON → default values (250 ms) will be used. String:",r)}return{fadeIn:t,fadeOut:n}}fadeOut(e,t){return new Promise((n=>{e.style.transition=`opacity ${t}ms ease-out`,e.style.opacity="0",setTimeout((()=>{e.style.transition="",n()}),t)}))}fadeIn(e,t){e.style.transition=`opacity ${t}ms ease-in`,e.style.opacity="1",setTimeout((()=>{e.style.transition=""}),t)}async updateDocumentContent(e){const t=this.saveScrollPositions(),n=(new DOMParser).parseFromString(e,"text/html"),s="pp-dynamic-script",r="pp-dynamic-link";document.head.querySelectorAll("[pp-dynamic-meta]").forEach((e=>e.remove()));document.head.querySelectorAll(`[${r}]`).forEach((e=>e.remove()));document.head.querySelectorAll(`[${s}]`).forEach((e=>e.remove()));await(async e=>{Array.from(e.head.children).forEach((e=>{const t=e.tagName;if("SCRIPT"===t&&e.hasAttribute(s)){const t=document.createElement("script");Array.from(e.attributes).forEach((e=>t.setAttribute(e.name,e.value))),e.textContent&&(t.textContent=e.textContent),document.head.appendChild(t)}else if("META"===t){if(e.getAttribute("charset")||"viewport"===e.getAttribute("name"))return;const t=e.name,n=e.getAttribute("property"),s=document.head.querySelector(t?`meta[name="${t}"]`:`meta[property="${n}"]`),r=document.head.querySelector("title");s?document.head.replaceChild(e.cloneNode(!0),s):r?.nextSibling?document.head.insertBefore(e.cloneNode(!0),r.nextSibling):document.head.appendChild(e.cloneNode(!0))}else if("TITLE"===t){const t=document.head.querySelector("title");t?document.head.replaceChild(e.cloneNode(!0),t):document.head.appendChild(e.cloneNode(!0))}else if("LINK"===t){const t=t=>{const n=document.head.querySelector('link[rel="icon"]');if(n)document.head.replaceChild(e.cloneNode(!0),n);else{const e=document.createElement("link");e.rel="icon",e.href=t,document.head.appendChild(e)}};if("icon"===e.getAttribute("rel")){t(e.href)}else if(e.hasAttribute(r)){const t=e.cloneNode(!0);document.head.appendChild(t)}}})),await this.populateDocumentBody(e)})(n),this.restoreScrollPositions(t),this.resetProps(),await this.processInlineModuleScripts(),this.initMakeReactive(),this.handlerAutofocusAttribute()}restoreScrollPositions(e){requestAnimationFrame((()=>{const t=e.window;t&&window.scrollTo(t.scrollLeft,t.scrollTop),document.querySelectorAll("*").forEach((t=>{const n=this.getElementKey(t);e[n]&&(t.scrollTop=e[n].scrollTop,t.scrollLeft=e[n].scrollLeft)}))}))}async populateDocumentBody(e){try{const t={DETAILS:(e,t)=>(t.open=e.open,!0),INPUT:(e,t)=>document.activeElement!==e||(t.value=e.value,"checked"in e&&(t.checked=e.checked),e.type.match(/^(text|search|url|email)$/)&&(t.selectionStart=e.selectionStart,t.selectionEnd=e.selectionEnd),!1),TEXTAREA:(e,n)=>t.INPUT(e,n),SELECT:(e,t)=>document.activeElement!==e||(t.selectedIndex=e.selectedIndex,!1),VIDEO:(e,t)=>(t.currentTime=e.currentTime,e.paused?t.pause():t.play(),!0),AUDIO:(e,n)=>t.VIDEO(e,n),CANVAS:()=>!1};morphdom(document.body,e.body,{getNodeKey(e){if(1===e.nodeType){const t=e;if(t.hasAttribute("pp-sync-script"))return`pp-sync-script:${t.getAttribute("pp-sync-script")}`;if(t.hasAttribute("key"))return t.getAttribute("key")}},onBeforeElUpdated(e,n){if("SCRIPT"===e.tagName)return!1;if(e.hasAttribute("data-nomorph"))return!1;const s=t[e.tagName];return!s||s(e,n)},onBeforeNodeDiscarded(e){if(e instanceof HTMLElement){const{timerId:t}=e.dataset;t&&clearTimeout(Number(t))}return!0}})}catch(e){console.error("Error populating document body:",e)}}saveScrollPositions(){const e={window:{scrollTop:window.scrollY||document.documentElement.scrollTop,scrollLeft:window.scrollX||document.documentElement.scrollLeft}};return document.querySelectorAll("*").forEach((t=>{(t.scrollTop||t.scrollLeft)&&(e[this.getElementKey(t)]={scrollTop:t.scrollTop,scrollLeft:t.scrollLeft})})),e}getElementKey(e){return e.id||e.className||e.tagName}async redirect(e){if(e)try{const t=new URL(e,window.location.origin);t.origin!==window.location.origin?window.location.href=e:(history.pushState(null,"",e),await this.handleNavigation())}catch(e){console.error("Redirect error:",e)}}abortActiveRequest(){this._activeAbortController&&this._activeAbortController.abort()}async fetch(e,t,n=!1){let s;return n?(this._activeAbortController&&this._activeAbortController.abort(),this._activeAbortController=new AbortController,s=this._activeAbortController):s=new AbortController,fetch(e,{...t,signal:s.signal,headers:{...t?.headers,"X-Requested-With":"XMLHttpRequest"}})}isJsonLike(e){return"string"==typeof e&&((e=e.trim()).startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))}parseJson(e){try{return JSON5.parse(e)}catch(e){return console.error(`Error parsing JSON: ${e.message}. Please ensure the JSON string is valid.`,e),{}}}parseTime(e){if("number"==typeof e)return e;const t=e.match(/^(\d+)(ms|s|m)?$/);if(t){const e=parseInt(t[1],10);switch(t[2]||"ms"){case"ms":default:return e;case"s":return 1e3*e;case"m":return 60*e*1e3}}return 0}scheduleChange(e,t,n,s){setTimeout((()=>{requestAnimationFrame((()=>{e.style[n]=s}))}),t)}async processInlineModuleScripts(){const e=window;e.__PPHP_INLINE_DEPTH__=(e.__PPHP_INLINE_DEPTH__??0)+1;try{const e=Array.from(document.body.querySelectorAll('script[type="text/php"]:not([src])')).filter((e=>{const t=e.getAttribute("pp-section-id")??e.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;return t?!this._processedPhpSections.has(t):!this._processedPhpScripts.has(e)}));if(0===e.length)return;const t={};for(const n of e){const e=n.getAttribute("pp-section-id")??n.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;if(!e)continue;const s=n.textContent||"";for(const[,n]of s.matchAll(/export\s+const\s+([A-Za-z_$]\w*)/g))t[n]=e}for(const n of e){const e=n.getAttribute("pp-section-id")??n.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;let s=(n.textContent||"").trim();e&&(s=s.replace(/(\bpphp\.state\(\s*['"])([^'"]+)(['"])/g,((t,n,s,r)=>n+(s.startsWith(`${e}_`)?s:`${e}_${s}`)+r))),s=s.replace(/\b([A-Za-z_$]\w*)\s*\(/g,((e,n)=>{const s=t[n];return s?`${s}_${n}(`:e}));const r=new Blob([s],{type:"application/javascript"}),i=URL.createObjectURL(r),o=PPHP.prototype._currentSectionId;e&&(PPHP.prototype._currentSectionId=()=>e);try{const t=await import(i);for(const[n,s]of Object.entries(t))if("function"==typeof s){const t=e?`${e}_${n}`:n;window[t]=s}}catch(e){console.error("Inline module import failed:",e)}finally{PPHP.prototype._currentSectionId=o,URL.revokeObjectURL(i),e?this._processedPhpSections.add(e):this._processedPhpScripts.add(n)}}}finally{e.__PPHP_INLINE_DEPTH__--,0===e.__PPHP_INLINE_DEPTH__&&requestAnimationFrame((()=>{this._pendingEffects.forEach((e=>{try{e()}catch(e){console.error("effect error:",e)}this._effects.add(e)})),this._pendingEffects.clear()}))}}async fetchFunction(e,t={},n=!1){try{const s={callback:e,...t},r=window.location.href;let i;if(Object.keys(s).some((e=>{const t=s[e];return t instanceof File||t instanceof FileList&&t.length>0}))){const e=new FormData;Object.keys(s).forEach((t=>{const n=s[t];n instanceof File?e.append(t,n):n instanceof FileList?Array.from(n).forEach((n=>e.append(t,n))):e.append(t,n)})),i={method:"POST",headers:{HTTP_PPHP_WIRE_REQUEST:"true"},body:e}}else i=this.createFetchOptions(s);const o=await this.fetch(r,i,n);if(!o.ok)throw new Error(`Fetch failed with status: ${o.status} ${o.statusText}`);const a=await o.text();try{return JSON.parse(a)}catch{return a}}catch(e){throw console.error("Error in fetchFunction:",e),new Error("Failed to fetch data.")}}processSyncScripts(e){e.forEach((e=>{const t=`script[pp-sync-script="${CSS.escape(e)}"]`,n=document.querySelector(t);if(n){n.remove();const e=document.createElement("script");Array.from(n.attributes).forEach((t=>{e.setAttribute(t.name,t.value)})),n.src?e.src=n.src:e.textContent=n.textContent,e.type=n.type||"module",document.body.appendChild(e)}}))}async sync(...e){try{const t=this.saveScrollPositions();this.saveElementState();const n=e.length>0?e.map((e=>`pp-sync="${e}"`)):['pp-sync="true"'],s=this.createFetchOptions({secondRequestC69CD:!0,...this.getUrlParams()}),r=await this.fetch(window.location.href,s),i=await r.text(),o=(new DOMParser).parseFromString(i,"text/html"),a=new Set;n.forEach((e=>{const t=document.querySelectorAll(`[${e}]`),n=o.body.querySelectorAll(`[${e}]`);t.forEach(((e,t)=>{const s=n[t];if(s){if(s.hasAttribute("pp-sync-script")){const e=s.getAttribute("pp-sync-script")||"";e&&a.add(e)}s.querySelectorAll("[pp-sync-script]").forEach((e=>{const t=e.getAttribute("pp-sync-script")||"";t&&a.add(t)})),e.innerHTML=s.innerHTML,this.reRunScripts(e)}}))})),this.processSyncScripts(a),this.restoreElementState(),this.restoreScrollPositions(t),this.attachWireFunctionEvents()}catch(e){console.error("Error in pphpSync:",e)}}async fetchAndUpdateBodyContent(){const e=this.createFetchOptions({secondRequestC69CD:!0,...this.getUrlParams()});this.abortActiveRequest();const t=await this.fetch(window.location.href,e,!0),n=await t.text();await this.updateBodyContent(n)}reRunScripts(e){e.querySelectorAll("script").forEach((e=>{const t=document.createElement("script");Array.from(e.attributes).forEach((e=>{t.setAttribute(e.name,e.value)})),e.hasAttribute("src")||(t.textContent=e.textContent),e.parentNode?.replaceChild(t,e)}))}copyCode(e,t,n,s,r="img",i=2e3){if(!(e instanceof HTMLElement))return;const o=e.closest(`.${t}`)?.querySelector("pre code"),a=o?.textContent?.trim()||"";a?navigator.clipboard.writeText(a).then((()=>{const t=e.querySelector(r);if(t)for(const[e,n]of Object.entries(s))e in t?t[e]=n:t.setAttribute(e,n);setTimeout((()=>{if(t)for(const[e,s]of Object.entries(n))e in t?t[e]=s:t.setAttribute(e,s)}),i)}),(()=>{alert("Failed to copy command to clipboard")})):alert("Failed to find the code block to copy")}getCookie(e){return document.cookie.split("; ").find((t=>t.startsWith(e+"=")))?.split("=")[1]||null}}class PPHPLocalStore{state;static instance=null;listeners;pphp;STORAGE_KEY;constructor(e={}){this.state=e,this.listeners=[],this.pphp=PPHP.instance,this.STORAGE_KEY=this.pphp.getCookie("pphp_local_store_key")||"pphp_local_store_59e13",this.loadState()}static getInstance(e={}){return PPHPLocalStore.instance||(PPHPLocalStore.instance=new PPHPLocalStore(e)),PPHPLocalStore.instance}setState(e,t=!1){if(this.state={...this.state,...e},this.listeners.forEach((e=>e(this.state))),this.saveState(),t){const e=localStorage.getItem(this.STORAGE_KEY);e&&this.pphp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:e})}}saveState(){localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.state))}loadState(){const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.state=this.pphp.parseJson(e),this.listeners.forEach((e=>e(this.state))))}resetState(e,t=!1){if(e?(delete this.state[e],this.saveState()):(this.state={},localStorage.removeItem(this.STORAGE_KEY)),this.listeners.forEach((e=>e(this.state))),t){const t=e?localStorage.getItem(this.STORAGE_KEY):null;this.pphp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:t})}}}class SearchParamsManager{static instance=null;listeners=[];constructor(){}static getInstance(){return SearchParamsManager.instance||(SearchParamsManager.instance=new SearchParamsManager),SearchParamsManager.instance}get params(){return new URLSearchParams(window.location.search)}get(e){return this.params.get(e)}set(e,t){const n=this.params;n.set(e,t),this.updateURL(n)}delete(e){const t=this.params;t.delete(e),this.updateURL(t)}replace(e){const t=new URLSearchParams;for(const n in e){const s=e[n];null!==s&&t.set(n,s)}this.updateURL(t,!0)}updateURL(e,t=!1){const n=`${window.location.pathname}?${e.toString()}`;t?history.replaceState(null,"",n):history.pushState(null,"",n),this.notifyListeners(e)}listen(e){this.listeners.push(e)}notifyListeners(e){for(const t of this.listeners)t(e)}enablePopStateListener(){window.addEventListener("popstate",(()=>{this.notifyListeners(this.params)}))}}var pphp=PPHP.instance,store=PPHPLocalStore.getInstance(),searchParams=SearchParamsManager.getInstance();
1
+ (()=>{const e=EventTarget.prototype.addEventListener,t=EventTarget.prototype.removeEventListener,s=new Map,n=new Set(["wheel","mousewheel","touchstart","touchmove","touchend","touchcancel","scroll"]);EventTarget.prototype.addEventListener=function(t,r,i){let o=i;n.has(t)&&(void 0===o?o={passive:!0}:"boolean"==typeof o?o={capture:o,passive:!0}:o&&void 0===o.passive&&(o={...o,passive:!0})),s.has(this)||s.set(this,new Map);const a=s.get(this),c=a.get(t)||new Set;c.add(r),a.set(t,c),e.call(this,t,r,o)},EventTarget.prototype.removeEventListener=function(e,n,r){if(s.has(this)&&s.get(this).has(e)){const t=s.get(this).get(e);t.delete(n),0===t.size&&s.get(this).delete(e)}t.call(this,e,n,r)},EventTarget.prototype.removeAllEventListeners=function(e){if(!s.has(this))return;const n=s.get(this).get(e);n&&(n.forEach((s=>{t.call(this,e,s)})),s.get(this).delete(e))}})();class PPHP{props={};_isNavigating=!1;_responseData=null;_elementState={checkedElements:new Set};_activeAbortController=null;_reservedWords;_declaredStateRoots=new Set;_arrayMethodCache=new WeakMap;_scopedKeys=new Map;_updateScheduled=!1;_pendingBindings=new Set;_effects=new Set;_pendingEffects=new Set;_processedPhpSections=new Set;_processedPhpScripts=new WeakSet;_bindings=[];_templateStore=new WeakMap;_inlineDepth=0;_activeSection=null;_inlineModuleFns=new Map;_proxyCache=new WeakMap;_rawProps={};_refs=new Map;_wheelHandlersStashed=!1;_evaluatorCache=new Map;_depsCache=new Map;_eventHandlers;_redirectRegex=/redirect_7F834\s*=\s*(\/[^\s]*)/;_assignmentRe=/^\s*[\w.]+\s*=(?!=)/;_mustacheRe=/\{\{\s*([\s\S]+?)\s*\}\}/gu;_htmlEntitiesRe=/&quot;|&#039;|&amp;/g;_mutators;_boolAttrs=new Set(["checked","selected","disabled","readonly","multiple","hidden"]);static _instance;static _effectCleanups;static debounceTimers=new Map;static _cancelableEvents=new Set(["click","submit","change"]);static _mustacheTest=/\{\{\s*[\s\S]+?\s*\}\}/;static _mustachePattern=/\{\{\s*([\s\S]+?)\s*\}\}/g;static _passiveEvents=new Set(["wheel","mousewheel","touchstart","touchmove","touchend","touchcancel","scroll"]);constructor(){const e=Object.getOwnPropertyNames(HTMLElement.prototype).filter((e=>e.startsWith("on"))),t=Object.getOwnPropertyNames(Document.prototype).filter((e=>e.startsWith("on"))),s=Object.getOwnPropertyNames(Window.prototype).filter((e=>e.startsWith("on")));this._eventHandlers=new Set([...e,...t,...s].map((e=>e.toLowerCase()))),this._reservedWords=new Set(["null","undefined","true","false","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","async","await","implements","interface","event","NaN","Infinity","Number","String","Boolean","Object","Array","Function","Date","RegExp","Error","JSON","Math","Map","Set"]),this._mutators=new Set(["push","pop","shift","unshift","splice","sort","reverse","copyWithin","fill"]),this.handlePopState(),this._proxyCache=new WeakMap,this._evaluatorCache.clear(),this._depsCache.clear(),this.props=this.makeReactive(this._rawProps),this.scheduleInitialHydration()}static get instance(){return PPHP._instance||(PPHP._instance=new PPHP),PPHP._instance}scheduleInitialHydration(){const e=async()=>{await this.initRefs(),await this.processInlineModuleScripts(),await this.initializeAllReferencedProps(),await this.initBindings(),await this.initLoopBindings(),this.attachWireFunctionEvents(),this._bindings.forEach((e=>e.update())),document.body.removeAttribute("hidden")};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}ref(e,t){const s=this._activeSection;let n=[];if(s&&(n=this._sectionRefs.get(s)?.get(e)??[]),0===n.length&&(n=this._refs.get(e)??[]),null!=t){const s=n[t];if(!s)throw new Error(`pphp.ref('${e}', ${t}) — no element at that index`);return s}if(0===n.length)throw new Error(`pphp.ref('${e}') failed — no element was found`);return 1===n.length?n[0]:n}effect(e,t){const s=this._currentSectionId(),n=Array.isArray(t),r=n?t:[],i=n&&0===r.length,o=r.map((e=>{if("function"==typeof e&&e.__pphp_key)return e.__pphp_key;if("string"!=typeof e)return"";if(e.includes("_"))return e;for(const[t,s]of this._scopedKeys)if(s.has(e))return`${t}_${e}`;return s?`${s}_${e}`:e})).filter(Boolean),a=new Set(o),c=new Map;for(const e of o)c.set(e,this.getNested(this.props,e));let l=0;PPHP._effectCleanups||(PPHP._effectCleanups=new WeakMap);const h=PPHP._effectCleanups,p=()=>{const t=h.get(p);if(t){try{t()}catch(e){console.error("cleanup error:",e)}h.delete(p)}if(++l>50)throw new Error("PPHP: effect ran >50 times — possible loop");if(!i&&o.length>0){let e=!1;for(const t of o){if(this.getNested(this.props,t)!==c.get(t)){e=!0;break}}if(!e)return;for(const e of o)c.set(e,this.getNested(this.props,e))}try{const t=e();"function"==typeof t&&h.set(p,t)}catch(e){console.error("effect error:",e)}};Object.assign(p,{__deps:a,__sectionId:s??null,__static:i});try{const t=e();"function"==typeof t&&h.set(p,t)}catch(e){console.error("effect error (initial):",e)}for(const e of o)c.set(e,this.getNested(this.props,e));const d=n&&this._inlineDepth>0?this._pendingEffects:this._effects;return i?this._effects.add(p):d.add(p),()=>{const e=h.get(p);if(e){try{e()}catch(e){console.error("cleanup error:",e)}h.delete(p)}this._effects.delete(p),this._pendingEffects.delete(p)}}getProxiedProps(e){let t=this._proxyCache.get(e);if(t)return t;return t=new Proxy(e,{get:(e,t)=>t in e?e[t]:void 0,set:(e,t,s)=>(e[t]=s,!0)}),this._proxyCache.set(e,t),t}resetProps(){Object.keys(this._rawProps).forEach((e=>{if(window.hasOwnProperty(e)){const t=Object.getOwnPropertyDescriptor(window,e);t&&t.configurable&&delete window[e]}})),this._rawProps={},this._proxyCache=new WeakMap,this._templateStore=new WeakMap,this._arrayMethodCache=new WeakMap,this._depsCache.clear(),this._evaluatorCache.clear(),this._processedPhpSections.clear(),this._processedPhpScripts=new WeakSet,this._scopedKeys=new Map,this._declaredStateRoots.clear(),this._inlineModuleFns.clear(),this._bindings=[],this._pendingBindings.clear(),this._effects.clear(),this._pendingEffects.clear(),this._refs.clear(),this._sectionRefs.clear(),this.props=this.makeReactive(this._rawProps)}async initMakeReactive(){await this.initRefs(),await this.initializeAllReferencedProps(),await this.initBindings(),await this.initLoopBindings(),this.attachWireFunctionEvents(),this._bindings.forEach((e=>e.update())),document.body.removeAttribute("hidden")}async initLoopBindings(){document.querySelectorAll("[pp-for]").forEach((e=>this.registerLoop(e)))}registerLoop(e){const t=e.getAttribute("pp-for").trim(),[s,n]=t.split(/\s+in\s+/),[r,i]=s.replace(/^\(|\)$/g,"").split(",").map((e=>e.trim())),o=e.parentNode,a=document.createComment("pp-for");o.insertBefore(a,e),o.removeChild(e);const c=this.makeSafeEvaluator(n),l=new Set(["value"]),h=this.extractDependencies(n);this._bindings.push({dependencies:h,update:()=>{const t=document.activeElement;let s=null,n=null;const h=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement;if(h&&o.contains(t)){const e=t.closest("[key]");e&&(s=e.getAttribute("key"),n=t.selectionStart)}for(let e=a.nextSibling;e&&e.nodeType!==Node.COMMENT_NODE;){const t=e.nextSibling;o.removeChild(e),e=t}if((c(this.props)??[]).forEach(((t,c)=>{this.props[r]=t,i&&(this.props[i]=c);const p=e.content.cloneNode(!0),d=document.createTreeWalker(p,NodeFilter.SHOW_TEXT);for(let e;e=d.nextNode();)e.nodeValue=(e.nodeValue||"").replace(PPHP._mustachePattern,((e,t)=>{try{return this.formatValue(this.makeSafeEvaluator(t)(this.props))}catch{return""}}));if(h&&null!==s){const e=o.querySelector(`[key="${s}"]`),t=e?.querySelector("input,textarea");if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.focus({preventScroll:!0}),null!==n)){const e=Math.min(n,t.value.length);t.setSelectionRange(e,e)}}p.querySelectorAll("*").forEach((e=>{Array.from(e.attributes).forEach((t=>{if(!PPHP._mustacheTest.test(t.value))return;const s=t.value.replace(PPHP._mustachePattern,((e,t)=>{try{return this.formatValue(this.makeSafeEvaluator(t)(this.props))}catch{return""}})),n=t.name.toLowerCase();if(this._boolAttrs.has(n)){const t=""!==s&&"false"!==s&&"0"!==s;e[n]=t,t?e.setAttribute(n,""):e.removeAttribute(n)}else l.has(n)&&(e[n]=s),t.value=s}))})),p.querySelectorAll("[pp-bind]").forEach((e=>{const t=e.getAttribute("pp-bind");e.textContent=this.formatValue(this.makeSafeEvaluator(t)(this.props))})),p.querySelectorAll("[pp-bind-expr]").forEach((e=>{const t=e.getAttribute("pp-bind-expr");e.textContent=this.formatValue(this.makeSafeEvaluator(t)(this.props))})),p.querySelectorAll("[pp-bind-class]").forEach((e=>{const t=e.getAttribute("pp-bind-class"),s=this.makeSafeEvaluator(t)(this.props);e.setAttribute("class",String(s))})),p.querySelectorAll("*").forEach((e=>{Array.from(e.attributes).forEach((t=>{t.name.startsWith("on")&&/\b(?:i|idx)\b/.test(t.value)&&e.setAttribute(t.name,((e,t)=>e.replace(/\[\s*(?:i|idx)\s*\]/g,`[${t}]`).replace(/(^|[^\w$])(?:i|idx)(?!\w)/g,((e,s)=>s+t)))(t.value,c))}))})),o.insertBefore(p,a.nextSibling)})),null!==s){const e=o.querySelector(`[key="${s}"]`),t=e?.querySelector("input,textarea");if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.focus({preventScroll:!0}),null!==n)){const e=Math.min(n,t.value.length);t.setSelectionRange(e,e)}}this.attachWireFunctionEvents()}})}_sectionRefs=new Map;async initRefs(){document.querySelectorAll("[pp-ref]").forEach((e=>{const t=e.getAttribute("pp-ref"),s=e.closest("[pp-section-id]")?.getAttribute("pp-section-id")??"__global__",n=this._sectionRefs.get(s)??new Map,r=n.get(t)??[];r.push(e),n.set(t,r),this._sectionRefs.set(s,n);const i=this._refs.get(t)??[];i.push(e),this._refs.set(t,i),e.removeAttribute("pp-ref")}))}scheduleBindingUpdate(e){this._pendingBindings.add(e),this._updateScheduled||(this._updateScheduled=!0,requestAnimationFrame((()=>{this.flushBindings()})))}makeReactive(e,t=[]){const s=this._proxyCache.get(e);if(s)return s;if(e instanceof Map||e instanceof Set||"object"!=typeof e||null===e)return e;const n=this,r=new Proxy(e,{get(e,s,r){const i=Reflect.get(e,s,r);if(Array.isArray(e)&&"string"==typeof s&&n._mutators.has(s)){let o=n._arrayMethodCache.get(e);if(o||(o=new Map,n._arrayMethodCache.set(e,o)),!o.has(s)){const e=i.bind(r),a=t.join("."),c=function(...t){const s=e(...t);return queueMicrotask((()=>{n._bindings.forEach((e=>{e.dependencies.has(a)&&n.scheduleBindingUpdate(e)}))})),s};o.set(s,c)}return o.get(s)}return null!==i&&"object"==typeof i?n.makeReactive(i,[...t,s]):i},set(e,s,r,i){let o=r;null!==r&&"object"==typeof r&&(o=n.makeReactive(r,[...t,s]));const a=e[s],c=Reflect.set(e,s,o,i);if(a===o)return c;const l=[...t,s].join(".");return n._bindings.forEach((e=>{for(const t of e.dependencies)if(l===t||l.startsWith(t+".")||t.startsWith(l+".")){n.scheduleBindingUpdate(e);break}})),c}});return this._proxyCache.set(e,r),r}makeAttrTemplateUpdater(e,t,s,n){let r=this._templateStore.get(e);r||(r=new Map,this._templateStore.set(e,r)),r.has(t)||r.set(t,e.getAttribute(t)||"");const i=n??r.get(t)??"";return(i.match(this._mustacheRe)||[]).forEach((e=>{this.extractDependencies(e).forEach((e=>s.add(e)))})),()=>{try{const s=i.replace(this._mustacheRe,((e,t)=>{try{const e=this.makeSafeEvaluator(t);return this.formatValue(e(this.props))}catch(e){return console.error("Error token:",t,e),""}}));e.getAttribute(t)!==s&&e.setAttribute(t,s)}catch(e){console.error(`Error evaluating the template for attribute "${t}". Please check the template syntax and dependencies.`,e)}}}makePrimitiveUpdater(e,t,s){const n={};return this._eventHandlers.forEach((e=>{if(e.startsWith("on")){const t=e.slice(2);n[t]=t}})),n.value="input",n.checked="change",()=>{try{const r=s(this.props),i=this.formatValue(r);let o=!1;if("value"===t){const t=e;"value"in e&&t.value!==i?(t.value=i,o=!0):"value"in e||(e.setAttribute("value",i),o=!0)}else{const t=e,s="true"===i;"checked"in e&&t.checked!==s?(t.checked=s,o=!0):"checked"in e||(e.setAttribute("checked",i),o=!0)}if(!o||e instanceof HTMLInputElement&&("hidden"===e.type||e.disabled||e.readOnly))return;const a=n[t]||t,c="click"===a?new MouseEvent(a,{bubbles:!0,cancelable:!0}):new Event(a,{bubbles:!0});e.dispatchEvent(c)}catch(e){console.error(`Error evaluating attribute "${t}":`,e)}}}formatValue(e){return null!==e&&"object"==typeof e&&1===Object.keys(e).length&&Object.prototype.hasOwnProperty.call(e,"value")?this.formatValue(e.value):"function"==typeof e?"":"boolean"==typeof e?e?"true":"false":Array.isArray(e)?e.map((e=>"object"==typeof e?JSON.stringify(e):String(e))).join(", "):e&&"object"==typeof e?Object.keys(e).length?JSON.stringify(e,null,2):"":e?.toString()??""}registerBinding(e,t,s="text",n){if(this._assignmentRe.test(t))return;const r=e.parentElement?.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;let i=t;if(r){const e=this._scopedKeys.get(r)||new Set,s=new Set;Object.keys(this.props).forEach((e=>{e.startsWith(r+"_")&&s.add(e.slice(r.length+1))}));const n=t=>(e.has(t)||s.has(t))&&!t.startsWith(r+"_")&&!this._reservedWords.has(t);i=t.replace(/\b([A-Za-z_$][\w$]*)\b/g,((e,t,s,i)=>"."===i[s-1]?e:n(t)?`${r}_${t}`:e))}const o=new Set([...this.extractDependencies(i)].map((e=>e.split(".")[0])).filter((e=>e in this.props&&!this._reservedWords.has(e)))),a=this.makeSafeEvaluator(i);if("value"===n||"checked"===n){const t=this.makePrimitiveUpdater(e,n,a);return void this._bindings.push({dependencies:o,update:t})}if(n){const s=n.toLowerCase();if(this._boolAttrs.has(s)){e.removeAttribute(s);const r=()=>{try{const t=!!a(this.props);e[n]!==t&&(e[n]=t),t?e.setAttribute(s,""):e.removeAttribute(s)}catch(e){console.error(`PPHP: error evaluating boolean attribute ${n}="${t}"`,e)}};return void this._bindings.push({dependencies:o,update:r})}const c=e.getAttribute(n)??"";if(this._mustacheRe.test(i)||this._mustacheRe.test(c)){const t=c.replace(this._mustacheRe,((e,t)=>{let s=t;if(r){const e=this._scopedKeys.get(r),n=e instanceof Set?e:new Set(Array.isArray(e)?e:[]);s=t.replace(/\b([A-Za-z_$][\w$]*)\b/g,((e,t,s,i)=>{const o=n.has(t),a=n.has(`${r}_${t}`);return o||a?"."===i[s-1]||this._reservedWords.has(t)||e.startsWith(`${r}_`)?e:`${r}_${t}`:e}))}return`{{ ${s} }}`})),s=this.makeAttrTemplateUpdater(e,n,o,t);return void this._bindings.push({dependencies:o,update:s})}const l=()=>{try{const t=a(this.props),s=this.formatValue(t);n in e&&(e[n]=s),e.setAttribute(n,s)}catch(e){console.error(`Error evaluating attribute ${n}="${t}"`,e)}};return void this._bindings.push({dependencies:o,update:l})}const c={text(e,t){e.textContent!==t&&(e.textContent=t)},value(e,t){e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value!==t&&(e.value=t):e.setAttribute("value",t)},checked(e,t){e instanceof HTMLInputElement?e.checked="true"===t:e.setAttribute("checked",t)},attr(e,t){e.setAttribute("attr",t)}};this._bindings.push({dependencies:o,update:()=>{try{const t=a(this.props),n=this.formatValue(t);c[s](e,n)}catch(e){console.error(`Error evaluating expression "${t}"`,e)}}})}safeTag=(e,...t)=>e.reduce(((e,s,n)=>{const r=t[n];return e+s+(null==r||"object"==typeof r?"":r)}),"");guardInterpolations=e=>{let t=0;const s=e.length,n=(s=0)=>e[t+s],r=()=>e[t++],i=e=>{let o=e;for(;t<s;){const a=r();if(o+=a,"\\"===a)o+=r();else{if(a===e)break;if("`"===e&&"$"===a&&"{"===n()){o+=r();let e=1;for(;t<s&&e;){const t=r();o+=t,"{"===t?e++:"}"===t?e--:"'"!==t&&'"'!==t&&"`"!==t||(o+=i(t).slice(1))}}}}return o},o=()=>{let e="",o=1;for(;t<s&&o;){const t=n();"'"!==t&&'"'!==t&&"`"!==t?(r(),"{"===t?o++:"}"===t&&o--,o&&(e+=t)):(r(),e+=i(t))}return`\${(()=>{try{return ${e}}catch{ return '' }})()}`};let a="";for(;t<s;){const e=n();"$"===e&&"{"===n(1)?(r(),r(),a+=o()):"'"===e||'"'===e||"`"===e?(r(),a+=i(e)):a+=r()}return a};makeSafeEvaluator(e){const t=e.trim(),s=/^\s*[\w.]+\s*=(?!=)/.test(t),n=new Function("ctx",`\n try {\n with (ctx) {\n ${s?`${t}; return "";`:`return (${t});`}\n }\n } catch {\n return "";\n }\n `);return e=>{try{const t=n(e);return null==t?"":t}catch{return""}}}async initBindings(){this._bindings=[];const e=new WeakSet;document.body.querySelectorAll("[pp-if]").forEach((t=>{if(e.has(t))return;const s=[];let n=t;for(;n;){if(n.hasAttribute("pp-if"))s.push({el:n,expr:n.getAttribute("pp-if")});else if(n.hasAttribute("pp-elseif"))s.push({el:n,expr:n.getAttribute("pp-elseif")});else{if(!n.hasAttribute("pp-else"))break;s.push({el:n,expr:null})}e.add(n),n=n.nextElementSibling}s.forEach((e=>{if(null!==e.expr){const t=e.expr.replace(/^{\s*|\s*}$/g,"");e.deps=this.extractDependencies(t);const s=this.makeSafeEvaluator(t);e.evaluate=()=>!!s(this.props)}}));const r=new Set;s.forEach((e=>e.deps?.forEach((e=>r.add(e)))));this._bindings.push({dependencies:r,update:()=>{let e=!1;for(const{el:t,expr:n,evaluate:r}of s)!e&&null!==n&&r()?(t.removeAttribute("hidden"),e=!0):e||null!==n?t.setAttribute("hidden",""):(t.removeAttribute("hidden"),e=!0)}})})),document.body.querySelectorAll("*").forEach((e=>{["pp-bind","pp-bind-expr"].forEach((t=>{const s=e.getAttribute(t);s&&this.registerBinding(e,s,"text")})),Array.from(e.attributes).forEach((t=>{if(!t.name.startsWith("pp-bind-"))return;if("pp-bind"===t.name||"pp-bind-expr"===t.name||"pp-bind-spread"===t.name)return;const s=t.value.replace(this._htmlEntitiesRe,(e=>"&quot;"===e?'"':"&#039;"===e?"'":"&")).replace(/^{{\s*|\s*}}$/g,"");let n=t.name.replace(/^(pp-bind-)+/,"");const r="value"===n?"value":"checked"===n?"checked":"text";this.registerBinding(e,s,r,n)})),Array.from(e.attributes).forEach((t=>{if("pp-bind-spread"!==t.name)return;const s=t.value.split(",").map((e=>e.trim())).filter(Boolean),n=new Set;s.forEach((e=>n.add(e.split(".")[0])));const r=new Set;this._bindings.push({dependencies:n,update:()=>{try{const t={};s.forEach((e=>{const s=this.getNested(this.props,e)??{};Object.assign(t,s)})),r.forEach((s=>{s in t||e.hasAttribute(s)||(e.removeAttribute(s),r.delete(s))})),Object.entries(t).forEach((([t,s])=>{if(!r.has(t)&&e.hasAttribute(t))return;if(!1===s||null==s)return void(r.has(t)&&(e.removeAttribute(t),r.delete(t)));const n="object"==typeof s?JSON.stringify(s):String(s);e.getAttribute(t)!==n&&e.setAttribute(t,n),r.add(t)}))}catch(e){console.error("pp-spread error:",e)}}})}))}))}callInlineModule(e,...t){const s=this._inlineModuleFns.get(e);if(!s)throw new Error(`PPHP: no inline module named "${e}"`);return s(...t)}async processInlineModuleScripts(){this._inlineDepth++;try{const e=Array.from(document.body.querySelectorAll('script[type="text/php"]:not([src])')).filter((e=>{const t=e.getAttribute("pp-section-id")??e.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;return t?!this._processedPhpSections.has(t):!this._processedPhpScripts.has(e)}));if(0===e.length)return;const t={};for(const s of e){const e=s.getAttribute("pp-section-id")??s.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;if(!e)continue;const n=s.textContent||"";for(const[,s]of n.matchAll(/export\s+const\s+([A-Za-z_$]\w*)/g))t[s]=e}for(const s of e){const e=s.getAttribute("pp-section-id")??s.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;let n=(s.textContent||"").trim();{n=n.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"");const t=/\b(?:const|let|var)\s*(?:\[\s*([A-Za-z_$]\w*)\s*,\s*([A-Za-z_$]\w*)\s*\]|\[\s*([A-Za-z_$]\w*)\s*\]|([A-Za-z_$]\w*))\s*=\s*pphp\.state\s*\(\s*/g;let s,r="",i=0;const o=[];for(;s=t.exec(n);){const e=s[1],a=s[2],c=s[3],l=s[4],h=e??c??l;let p;e&&a&&o.push(a),r+=n.slice(i,s.index);const d=s[0];p=e&&a||c?d.replace(/\bpphp\.state\s*\(\s*$/,`pphp.state('${h}', `):`const [${h}] = pphp.state('${h}', `,r+=p;let u=1,f=t.lastIndex;for(;f<n.length&&u>0;){const e=n[f++];"("===e?u++:")"===e&&u--}r+=n.slice(t.lastIndex,f-1).trim()+")",i=f,t.lastIndex=f}if(r+=n.slice(i),o.length){r+="\n\n";for(const t of o){r+=`pphp._inlineModuleFns.set('${e?`${e}_${t}`:t}', ${t});\n`}}n=r}e&&(n=n.replace(/(\bpphp\.state\(\s*['"])([^'"]+)(['"])/g,((t,s,n,r)=>s+(n.startsWith(`${e}_`)?n:`${e}_${n}`)+r))),n=n.replace(/\b([A-Za-z_$]\w*)\s*\(/g,((e,s)=>{const n=t[s];return n?`${n}_${s}(`:e}));const r=new Blob([n],{type:"application/javascript"}),i=URL.createObjectURL(r),o=PPHP.prototype._currentSectionId;e&&(PPHP.prototype._currentSectionId=()=>e);try{const t=await import(i);for(const[s,n]of Object.entries(t))if("function"==typeof n){const t=e?`${e}_${s}`:s;this._inlineModuleFns.set(t,n)}}catch(e){console.error("Inline module import failed:",e)}finally{PPHP.prototype._currentSectionId=o,URL.revokeObjectURL(i),e?this._processedPhpSections.add(e):this._processedPhpScripts.add(s)}}}finally{this._inlineDepth--,0===this._inlineDepth&&requestAnimationFrame((()=>{this._pendingEffects.forEach((e=>{try{e()}catch(e){console.error("effect error:",e)}this._effects.add(e)})),this._pendingEffects.clear()}))}}flushBindings(){const e=new Set;this._pendingBindings.forEach((t=>{t.dependencies.forEach((t=>e.add(t))),t.update()})),this._pendingBindings.clear(),this._updateScheduled=!1,this._effects.forEach((t=>{if(t.__static)return;const s=t.__deps||new Set,n=this._activeSection;if(this._activeSection=t.__sectionId??null,0===s.size||[...s].some((t=>e.has(t))))try{t()}catch(e){console.error("effect error:",e)}this._activeSection=n}))}scheduleFlush(){this._updateScheduled||(this._updateScheduled=!0,requestAnimationFrame((()=>{this._updateScheduled=!1,this.flushBindings()})))}scopeKey(e){const t=this._currentSectionId();return t?e.startsWith(`${t}_`)?e:e.includes(".")?e.replace(/^([^\.]+)/,`${t}_$1`):`${t}_${e}`:e}_currentSectionId(){const e=document.currentScript;return e?.closest("[pp-section-id]")?.getAttribute("pp-section-id")||null}getNested(e,t){return t.split(".").reduce(((e,t)=>e?e[t]:void 0),e)}setNested(e,t,s){const n=t.split("."),r=n.pop();n.reduce(((e,t)=>e[t]??={}),e)[r]=s}hasNested(e,t){return void 0!==this.getNested(e,t)}state(e,t){if("string"!=typeof e||""===e.trim())throw new Error("PPHP.state: missing or invalid key—make sure your build-time injector ran and you wrote `const [foo, setFoo] = pphp.state(0)` so it became `pphp.state('foo', 0)`.");arguments.length<2&&(t=void 0);const s=this._currentSectionId(),n=e;if(this._reservedWords.has(n))throw new Error(`'${n}' is reserved – choose another state key.`);const r=this.scopeKey(n);this._declaredStateRoots.add(r),s&&(this._scopedKeys.has(s)||this._scopedKeys.set(s,new Set),this._scopedKeys.get(s).add(n)),this.hasNested(pphp.props,r)||this.setNested(pphp.props,r,t);const i=()=>this.getNested(pphp.props,r),o=e=>{const t=i(),s="function"==typeof e?e(t):e;this.setNested(pphp.props,r,s),this.scheduleFlush()},a=()=>i();Object.defineProperty(a,"value",{get:()=>i(),set:e=>o(e)}),Object.defineProperties(a,{valueOf:{value:()=>i()},toString:{value:()=>String(i())}}),a.__pphp_key=r;const c=i();if(!(null!==c&&"object"==typeof c))return[a,o];return[new Proxy(a,{apply:(e,t,s)=>Reflect.apply(e,t,s),get(e,t,s){if("value"===t)return i();if(t in e)return Reflect.get(e,t,s);return i()[t]},set(e,t,s){if("value"===t)return o(s),!0;return i()[t]=s,!0},has(e,t){if("value"===t||t in a)return!0;return t in i()}}),o]}static _isBuiltIn=(()=>{const e=new Map,t=[Object.prototype,Function.prototype,Array.prototype,String.prototype,Number.prototype,Boolean.prototype,Date.prototype,RegExp.prototype,Map.prototype,Set.prototype,WeakMap.prototype,WeakSet.prototype,Error.prototype,Promise.prototype];return s=>{const n=e.get(s);if(void 0!==n)return n;const r=s in globalThis||t.some((e=>s in e));return e.set(s,r),r}})();extractDependencies(e){let t=e.replace(/\?\./g,".");const s=new Set,n=/(?:^|[^\w$])(?:\(\s*([^)]*?)\s*\)|([A-Za-z_$][\w$]*))\s*=>/g;for(let e;e=n.exec(t);){(e[1]??e[2]??"").split(",").map((e=>e.trim())).filter(Boolean).forEach((e=>s.add(e)))}const r=/function\s*(?:[A-Za-z_$][\w$]*\s*)?\(\s*([^)]*?)\s*\)/g;for(let e;e=r.exec(t);)e[1].split(",").map((e=>e.trim())).filter(Boolean).forEach((e=>s.add(e)));const i=e=>{let t="",s=0;for(;s<e.length;)if("`"===e[s])for(s++;s<e.length;)if("\\"===e[s])s+=2;else if("$"===e[s]&&"{"===e[s+1]){s+=2;let n=1;const r=s;for(;s<e.length&&n>0;)"{"===e[s]?n++:"}"===e[s]&&n--,s++;const o=e.slice(r,s-1);t+=i(o)+" "}else{if("`"===e[s]){s++;break}s++}else t+=e[s++];return t};t=i(t),t=t.replace(/(['"])(?:\\.|[^\\])*?\1/g,""),t=t.replace(/\/(?:\\.|[^\/\\])+\/[gimsuy]*/g,"");const o=new Set,a=/\b[A-Za-z_$]\w*(?:\.[A-Za-z_$]\w*)*\b/g;for(const n of t.match(a)??[]){const[t,...r]=n.split(".");s.has(t)||(0===r.length&&PPHP._isBuiltIn(t)&&new RegExp(`\\.${t}\\b`).test(e)||o.add(n))}return o}async initializeAllReferencedProps(){const e=PPHP._mustachePattern,t=PPHP._mustacheTest,s=this.props,n=new Set,r=(e,t)=>{const s=e.getAttribute("pp-section-id"),n=e.parentElement?.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;return s??n?`${s??n}_${t}`:t},i=(()=>{const e=new Set([...Object.getOwnPropertyNames(String.prototype),...Object.getOwnPropertyNames(Array.prototype),...Object.getOwnPropertyNames(Number.prototype),...Object.getOwnPropertyNames(Boolean.prototype),...Object.getOwnPropertyNames(Object.prototype),...Object.getOwnPropertyNames(Date.prototype),...Object.getOwnPropertyNames(RegExp.prototype)]);return t=>e.has(t)})(),o=(e,t)=>{const[s,o,...a]=t.split(".");if(this._reservedWords.has(s))return void console.warn(`Invalid path “${t}” – “${s}” is a reserved word.`);if(PPHP._isBuiltIn(s)&&console.warn(`Path “${t}” shadows the built-in “${s}”. It will be stored in pphp.props.`),o&&i(o))return void n.add(r(e,s));const c=r(e,s);n.add(o?`${c}.${[o,...a].join(".")}`:c)};for(const s of document.body.getElementsByTagName("*"))for(const{name:n,value:r}of Array.from(s.attributes))if(r){if(t.test(r))for(const t of r.matchAll(e))this.extractDependencies(t[1]).forEach((e=>o(s,e)));"pp-if"!==n&&"pp-elseif"!==n||this.extractDependencies(r).forEach((e=>o(s,e))),n.startsWith("pp-bind")&&this.extractDependencies(r).forEach((e=>o(s,e)))}const a=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode:e=>t.test(e.nodeValue??"")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT});for(let t;t=a.nextNode();){const s=t.parentElement;for(const n of t.nodeValue.matchAll(e))this.extractDependencies(n[1]).forEach((e=>o(s,e)))}const c=Array.from(n).sort(((e,t)=>t.split(".").length-e.split(".").length));for(const e of c){const t=e.split(".");let n=s;for(let e=0;e<t.length;e++){const s=t[e],r=e===t.length-1;0===e&&PPHP._isBuiltIn(s)&&console.warn(`Root “${s}” shadows the built-in. The placeholder will still be created in pphp.props.`),s in n&&(r||null!=n[s]&&"object"==typeof n[s])||(n[s]=r?void 0:{}),n=n[s]}}}setNestedProperty(e,t,s){const n=t.split(".");let r=e;for(let e=0;e<n.length-1;e++)n[e]in r||(r[n[e]]={}),r=r[n[e]];r[n[n.length-1]]=s}handlePopState(){window.addEventListener("popstate",(async()=>{await this.handleNavigation()}))}alreadyScoped(e,t){const s=`${t}_${e}`;return this._scopedKeys.get(t)?.has(s)??!1}prefixFunctionCalls(e,t){return e.replace(/\b([A-Za-z_$][\w$]*)\s*\(/g,((e,s)=>this._reservedWords.has(s)||s.startsWith(`${t}_`)?e:this.alreadyScoped(s,t)?`${t}_${s}(`:e))}prefixIds(e,t){let s="",n=0,r=(e=this.prefixFunctionCalls(e,t)).length,i=!1,o=!1,a=!1;for(;n<r;){const c=e[n];if("'"!==c||o||a||"\\"===e[n-1])if('"'!==c||i||a||"\\"===e[n-1])if("`"!==c||i||o||"\\"===e[n-1])if(i||o||a)s+=c,n++;else if(/[A-Za-z_$]/.test(c)){let i=n+1;for(;i<r&&/[\w$]/.test(e[i]);)i++;const o=e.slice(n,i),a=e[n-1]??"",c=this._reservedWords.has(o),l="."===a;s+=!o.startsWith(`${t}_`)&&!l&&!c?`${t}_${o}`:o,n=i}else s+=c,n++;else a=!a,s+=c,n++;else o=!o,s+=c,n++;else i=!i,s+=c,n++}return s}attachWireFunctionEvents(){this.handleHiddenAttribute(),this.handleAnchorTag();const e=Array.from(this._eventHandlers).map((e=>`[${e}]`)).join(", "),t=document.body.querySelectorAll(e),s=/^[^(]*(\([\w\s,]*\)|[A-Za-z_$][\w$]*)\s*=>/;t.forEach((e=>{const t=e.closest("[pp-section-id]")?.getAttribute("pp-section-id");if(Array.from(e.attributes).filter((e=>this._eventHandlers.has(e.name))).forEach((n=>{const r=n.name.slice(2);e.removeAllEventListeners(r);const i=n.value.trim();let o;if(s.test(i)||console.warn(`PPHP: Inline handler on [${n.name}] should use arrow syntax, e.g. onclick="() => { … }" or onclick="e => …".`,{element:e,handler:i}),o=s.test(i)?i:`() => { ${i} }`,t){const e=o.indexOf("=>");if(-1!==e){const s=o.slice(0,e+2),n=o.slice(e+2);o=s+this.prefixIds(n,t)}}e instanceof HTMLInputElement&&this.handleInputAppendParams(e,r),e.removeAttribute(n.name),this.handleDebounce(e,r,o)})),e instanceof HTMLFormElement){const n=e.getAttribute("onsubmit")?.trim();if(n){let r;if(s.test(n)||console.warn('PPHP: Inline handler on [onsubmit] should use arrow syntax, e.g. onsubmit="() => { … }" or onsubmit="e => …".'),r=s.test(n)?n:`() => { ${n} }`,t){const e=r.indexOf("=>");if(-1!==e){const s=r.slice(0,e+2),n=r.slice(e+2);r=s+this.prefixIds(n,t)}}e.removeAttribute("onsubmit"),this.handleDebounce(e,"submit",r)}}})),this.handlePassiveWheelStashes(document)}async handleDebounce(e,t,s){const n=e.getAttribute("pp-debounce"),r=n?this.parseTime(n):0,i=e.getAttribute("pp-before-request")??"",o=e.getAttribute("pp-after-request")??"",a=PPHP._cancelableEvents,c=async n=>{a.has(t)&&n.cancelable&&n.preventDefault();try{i&&await this.invokeHandler(e,i,n),await this.invokeHandler(e,s,n),o&&"@close"!==o&&await this.invokeHandler(e,o,n),this.handlerAutofocusAttribute()}catch(e){console.error("Error in debounced handler:",e)}},l={passive:PPHP._passiveEvents.has(t)&&!a.has(t)},h=`${t}::${e.__pphpId||e.tagName}`,p=e=>{if(r>0){const t=PPHP.debounceTimers.get(h);t&&clearTimeout(t);const s=setTimeout((()=>{PPHP.debounceTimers.delete(h),c(e)}),r);PPHP.debounceTimers.set(h,s)}else c(e)};e instanceof HTMLFormElement&&"submit"===t?e.addEventListener("submit",(e=>{e.cancelable&&e.preventDefault(),p(e)}),l):e.addEventListener(t,p,l)}debounce(e,t=300,s=!1){let n;return function(...r){const i=this;n&&clearTimeout(n),n=setTimeout((()=>{n=null,s||e.apply(i,r)}),t),s&&!n&&e.apply(i,r)}}handlerAutofocusAttribute(){const e=document.querySelector("dialog[open]");let t=null;if(e&&(t=e.querySelector("[pp-autofocus]")),t||(t=document.querySelector("[pp-autofocus]")),!t)return;const s=t.getAttribute("pp-autofocus");if(!this.isJsonLike(s))return;const n=this.parseJson(s);requestAnimationFrame((()=>{t.focus(),(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&"function"==typeof this.setCursorPosition&&(t instanceof HTMLInputElement&&"number"===t.type?(t.type="text",this.setCursorPosition(t,n),t.type="number"):this.setCursorPosition(t,n))}))}async invokeHandler(e,t,s){this._activeSection=e.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;{const e=t.trim().match(/^\s*\(\s*\)\s*=>\s*([A-Za-z_$][\w$]*\s*\([^)]*\))\s*$/);e&&(t=e[1].trim())}try{const n=t.trim(),r=n.replace(/(["'`])(?:\\.|(?!\1).)*\1/g,"").replace(/\/(?:\\.|[^\/])+\/[gimsuy]*/g,"");if(/^\(?\s*[^=]*?\)?\s*=>/.test(r.trim())){const t=this.getProxiedProps(pphp.props),r=this._inlineModuleFns,i=new Proxy(t,{get:(e,t)=>"string"==typeof t&&r.has(t)?r.get(t):Reflect.get(e,t),set:(e,t,s)=>Reflect.set(e,t,s),has:(e,t)=>!("string"!=typeof t||!r.has(t))||Reflect.has(e,t)}),o=new Function("event","proxy","props",`\n with (proxy) {\n const val = (${n});\n return (typeof val === "function")\n ? val.call(this, event, props)\n : val;\n }\n `);return void await o.call(e,s,i,pphp.props)}const i=t.match(/^(\w+(?:\.\w+)*)\(([\s\S]*)\)$/);if(i){const n=i[1],r=i[2].trim();if(this._inlineModuleFns.has(n)){if(r)if(this.isJsonLike(r)){const t={...this.parseJson(r)||{},element:e,event:s};await this.callInlineModule(n,t)}else{const e=this.makeSafeEvaluator(r)(pphp.props);await this.callInlineModule(n,e)}else await this.handleParsedCallback(e,t,s);return}const o=n.split("."),{context:a,methodName:c}=this.resolveContext(o);if("function"==typeof a[c])if(this.isJsonLike(r)){const t={...this.parseJson(r)||{},element:e,event:s};await a[c].call(a,t)}else new Function("event",t).call(e,s);else await this.handleParsedCallback(e,t,s)}else if(t.includes("=")){const n=t.match(/^\s*([\w.]+)\s*=/);if(n){const e=n[1];if(e.includes(".")){const t=e.split(".");let s=pphp.props;for(let e=0;e<t.length-1;e++){const n=t[e];n in s&&null!=s[n]&&"object"==typeof s[n]||(s[n]={}),s=s[n]}}else e in pphp.props||(pphp.props[e]=void 0)}new Function("event","props",`\n with (new Proxy(props, {\n get(target, key) {\n return key in target ? target[key] : undefined;\n },\n set(target, key, value) {\n target[key] = value;\n return true;\n }\n })) {\n ${t}\n }`).call(e,s,pphp.props)}else await this.handleParsedCallback(e,t,s)}catch(e){console.error(`Error executing handler "${t}". Please ensure the handler is defined and valid.`,e)}finally{this.scheduleFlush()}}async handleParsedCallback(e,t,s){const{funcName:n,data:r}=this.parseCallback(e,t);if(!n)return;const i=Array.isArray(n)?n:[n];let o;for(const e of i){const t=this._inlineModuleFns.get(e);if("function"==typeof t){o=t;break}const s=this[e];if("function"==typeof s){o=s;break}const n=window[e];if("function"==typeof n){o=n;break}}if(o){const t=e.hasAttribute("pp-after-request"),n=Array.isArray(r.args)?r.args:[],i=this._responseData?this.parseJson(this._responseData):{response:this._responseData};let a={args:n,element:e,data:r,event:s};return t&&(a={...a,...i}),void await o.call(this,a)}this._responseData=null,this._responseData=await this.handleUndefinedFunction(e,Array.isArray(n)?n[0]:n,r)}async handleUndefinedFunction(e,t,s){const n={callback:t,...s},r=this.createFetchOptions(n),i=this.createFetchOptions({secondRequestC69CD:!0,...this.getUrlParams()});try{this.saveElementOriginalState(e),this.handleSuspenseElement(e);const n=new URL(window.location.href);let o="",a="",c={success:!1};const l=e.querySelector("input[type='file']");if(l){if(o=await this.fetchFileWithData(n.href,t,l,s),a=this.extractJson(o)||"",a)try{c=this.parseJson(a)}catch(e){console.error("Error parsing JSON response. Please ensure the response is in valid JSON format.",e)}}else{const e=await this.fetch(n.href,r);if(o=await e.text(),this.getRedirectUrl(o))return void await this.redirect(this.getRedirectUrl(o)||"");if(a=this.extractJson(o)||"",a)try{c=this.parseJson(a)}catch(e){console.error("Error parsing JSON response. Please ensure the response is in valid JSON format.",e)}}const h=e.getAttribute("pp-before-request")||"",p=e.getAttribute("pp-after-request")||"";if((h||p&&c.success)&&this.restoreSuspenseElement(e),h||p){let e="";if(c.success){e=o.replace(a,"")}else e=o;if(this.appendAfterbegin(e),!p&&!c.success)return}if(p&&c.success){this.handleAfterRequest(p,a);const e=o.replace(a,"");return this.appendAfterbegin(e),a}if("@close"===p)return c.success?a:void 0;const d=await this.fetch(n.href,i),u=await d.text();if(this.getRedirectUrl(u))return void await this.redirect(this.getRedirectUrl(u)||"");await this.handleResponseRedirectOrUpdate(o,u,a,c)}catch(e){console.error(`Error handling undefined function "${t}". Please ensure the function is defined and accessible.`,e)}}handleAfterRequest(e,t){if(!this.isJsonLike(e))return;const s=this.parseJson(e),n=t?this.parseJson(t):null,r=s.targets;Array.isArray(r)&&r.forEach((e=>{const{id:t,...s}=e,r=document.querySelector(t);let i={};if(n){for(const t in s)if(s.hasOwnProperty(t))switch(t){case"innerHTML":case"outerHTML":case"textContent":case"innerText":"response"===s[t]&&(i[t]=e.responseKey?n[e.responseKey]:n.response);break;default:i[t]=s[t]}}else i=s;r&&this.updateElementAttributes(r,i)}))}sanitizePassiveHandlers(e){return e.replace(/\s+onwheel\s*=\s*(['"])([\s\S]*?)\1/gi,((e,t,s)=>` data-onwheel-code="${encodeURIComponent(s)}"`)).replace(/\s+onmousewheel\s*=\s*(['"])[\s\S]*?\1/gi,"")}handlePassiveWheelStashes(e){(e instanceof Document?e.body:e).querySelectorAll("[data-onwheel-code]").forEach((e=>{let t=decodeURIComponent(e.dataset.onwheelCode||"").trim();delete e.dataset.onwheelCode,e.onwheel=null;const s=e.closest("[pp-section-id]")?.getAttribute("pp-section-id");if(s){const e=t.indexOf("=>");if(e>=0){const n=t.slice(0,e+2),r=t.slice(e+2);t=n+this.prefixIds(r,s)}else t=this.prefixIds(t,s)}e.removeAllEventListeners("wheel"),this.handleDebounce(e,"wheel",t)}))}async handleResponseRedirectOrUpdate(e,t,s,n){const r=this.sanitizePassiveHandlers(t),i=this.getUpdatedHTMLContent(e,s,n),o=(new DOMParser).parseFromString(r,"text/html");i&&o.body.insertAdjacentElement("afterbegin",i),this.updateBodyContent(o.body.outerHTML)}getUpdatedHTMLContent(e,t,s){const n=document.createElement("div");if(n.id="afterbegin-8D95D",s&&t?.success){const t=e.replace(s,"");n.innerHTML=t}else n.innerHTML=e;return n.innerHTML?n:null}async updateBodyContent(e){const t=this.saveScrollPositions();this.saveElementState();const s=(new DOMParser).parseFromString(e,"text/html");await this.appendCallbackResponse(s),this.restoreElementState(),this.restoreScrollPositions(t),await this.processInlineModuleScripts(),await this.initMakeReactive()}restoreElementState(){if(this._elementState.focusId){const e=document.getElementById(this._elementState.focusId)||document.querySelector(`[name="${this._elementState.focusId}"]`);if(e instanceof HTMLInputElement){const t=e.value.length||0;void 0!==this._elementState.focusSelectionStart&&null!==this._elementState.focusSelectionEnd&&e.setSelectionRange(t,t),this._elementState.focusValue&&("checkbox"===e.type||"radio"===e.type?e.checked=!!this._elementState.focusChecked:"number"===e.type||"email"===e.type?(e.type="text",e.setSelectionRange(t,t),e.type="number"===e.type?"number":"email"):"date"===e.type||"month"===e.type||"week"===e.type||"time"===e.type||"datetime-local"===e.type||"color"===e.type||"file"===e.type||""!==e.value&&(e.value=this._elementState.focusValue)),e.focus()}else if(e instanceof HTMLTextAreaElement){const t=e.value.length||0;void 0!==this._elementState.focusSelectionStart&&null!==this._elementState.focusSelectionEnd&&e.setSelectionRange(t,t),this._elementState.focusValue&&""!==e.value&&(e.value=this._elementState.focusValue),e.focus()}else e instanceof HTMLSelectElement&&(this._elementState.focusValue&&""!==e.value&&(e.value=this._elementState.focusValue),e.focus())}this._elementState.checkedElements.forEach((e=>{const t=document.getElementById(e);t&&(t.checked=!0)}))}async appendCallbackResponse(e){const t=e.getElementById("afterbegin-8D95D");if(t){const e=document.getElementById("afterbegin-8D95D");e?e.innerHTML=t.innerHTML:document.body.insertAdjacentHTML("afterbegin",t.outerHTML)}await this.populateDocumentBody(e)}saveElementState(){const e=document.activeElement;this._elementState.focusId=e?.id||e?.name,this._elementState.focusValue=e?.value,this._elementState.focusChecked=e?.checked,this._elementState.focusType=e?.type,this._elementState.focusSelectionStart=e?.selectionStart,this._elementState.focusSelectionEnd=e?.selectionEnd,this._elementState.isSuspense=e.hasAttribute("pp-suspense"),this._elementState.checkedElements.clear(),document.querySelectorAll('input[type="checkbox"]:checked').forEach((e=>{this._elementState.checkedElements.add(e.id||e.name)})),document.querySelectorAll('input[type="radio"]:checked').forEach((e=>{this._elementState.checkedElements.add(e.id||e.name)}))}updateElementAttributes(e,t){for(const s in t)if(t.hasOwnProperty(s))switch(s){case"innerHTML":case"outerHTML":case"textContent":case"innerText":e[s]=this.decodeHTML(t[s]);break;case"insertAdjacentHTML":e.insertAdjacentHTML(t.position||"beforeend",this.decodeHTML(t[s].html));break;case"insertAdjacentText":e.insertAdjacentText(t.position||"beforeend",this.decodeHTML(t[s].text));break;case"setAttribute":e.setAttribute(t.attrName,this.decodeHTML(t[s]));break;case"removeAttribute":e.removeAttribute(t[s]);break;case"className":e.className=this.decodeHTML(t[s]);break;case"classList.add":e.classList.add(...this.decodeHTML(t[s]).split(","));break;case"classList.remove":e.classList.remove(...this.decodeHTML(t[s]).split(","));break;case"classList.toggle":e.classList.toggle(this.decodeHTML(t[s]));break;case"classList.replace":const[n,r]=this.decodeHTML(t[s]).split(",");e.classList.replace(n,r);break;case"dataset":e.dataset[t.attrName]=this.decodeHTML(t[s]);break;case"style":Object.assign(e.style,t[s]);break;case"value":e.value=this.decodeHTML(t[s]);break;case"checked":e.checked=t[s];break;default:e.setAttribute(s,this.decodeHTML(t[s]))}}decodeHTML(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}appendAfterbegin(e){if(!e)return;const t="afterbegin-8D95D";let s=document.getElementById(t);s?(s.innerHTML=e,document.body.insertAdjacentElement("afterbegin",s)):(s=document.createElement("div"),s.id=t,s.innerHTML=e,document.body.insertAdjacentElement("afterbegin",s))}restoreSuspenseElement(e){const t=e.getAttribute("pp-original-state");if(e.hasAttribute("pp-suspense")&&t){const s=(e,t)=>{for(const s in t)t.hasOwnProperty(s)&&("textContent"===s?e.textContent=t[s]:"innerHTML"===s?e.innerHTML=t[s]:"disabled"===s?!0===t[s]?e.setAttribute("disabled","true"):e.removeAttribute("disabled"):e.setAttribute(s,t[s]));for(const s of Array.from(e.attributes))t.hasOwnProperty(s.name)||e.removeAttribute(s.name)},n=(e,t)=>{for(const n in t)if(t.hasOwnProperty(n))for(const t of Array.from(e.elements))if(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){const e=t.getAttribute("pp-original-state")||"";if(e){if(this.isJsonLike(e)){const n=this.parseJson(e);s(t,n)}else r(t,e);t.removeAttribute("pp-original-state")}}},r=(e,t)=>{e instanceof HTMLInputElement?e.value=t:e.textContent=t},i=(e,t)=>{e instanceof HTMLFormElement?n(e,t):s(e,t)};try{const r=this.parseJson(t);if(r)if(e instanceof HTMLFormElement){const t=e.id;if(t){const e=document.querySelector(`[form="${t}"]`);if(e){const t=e.getAttribute("pp-original-state");if(t&&this.isJsonLike(t)){const n=this.parseJson(t);s(e,n)}}}const r=new FormData(e),i={};if(r.forEach(((e,t)=>{i[t]=e})),n(e,i),e.hasAttribute("pp-suspense")){const t=e.getAttribute("pp-suspense")||"";if(this.parseJson(t).disabled)for(const t of Array.from(e.elements))(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.removeAttribute("disabled")}}else if(r.targets){r.targets.forEach((e=>{const{id:t,...s}=e,n=document.querySelector(t);n&&i(n,s)}));const{targets:t,...n}=r;s(e,n)}else{const{empty:t,...n}=r;s(e,n)}}catch(e){console.error(`Error parsing JSON: ${e instanceof Error?e.message:"Unknown error"}. Please ensure the JSON string is valid.`,e)}}e.querySelectorAll("[pp-suspense]").forEach((e=>this.restoreSuspenseElement(e))),e.removeAttribute("pp-original-state")}extractJson(e){const t=e?.match(/\{[\s\S]*\}/);return t?t[0]:null}getRedirectUrl(e){const t=e.match(this._redirectRegex);return t?t[1]:null}async fetchFileWithData(e,t,s,n={}){const r=new FormData,i=s.files;if(i)for(let e=0;e<i.length;e++)r.append("file[]",i[e]);r.append("callback",t);for(const e in n)n.hasOwnProperty(e)&&r.append(e,n[e]);const o=await this.fetch(e,{method:"POST",headers:{HTTP_PPHP_WIRE_REQUEST:"true"},body:r});return await o.text()}async handleSuspenseElement(e){let t=e.getAttribute("pp-suspense")||"";const s=(e,t)=>{for(const s in t)if(t.hasOwnProperty(s))for(const t of e.elements)if(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){const e=t.getAttribute("pp-suspense")||"";if(e)if(this.isJsonLike(e)){const s=this.parseJson(e);"disabled"!==s.onsubmit&&this.updateElementAttributes(t,s),s.targets&&s.targets.forEach((e=>{const{id:t,...s}=e,n=document.querySelector(t);n&&r(n,s)}))}else n(t,e)}},n=(e,t)=>{e instanceof HTMLInputElement?e.value=t:e.textContent=t},r=(e,t)=>{e instanceof HTMLFormElement?s(e,t):this.updateElementAttributes(e,t)};try{if(t&&this.isJsonLike(t)){const n=this.parseJson(t);if(n)if(e instanceof HTMLFormElement){const t=new FormData(e),r={};t.forEach(((e,t)=>{r[t]=e})),n.disabled&&this.toggleFormElements(e,!0);const{disabled:i,...o}=n;this.updateElementAttributes(e,o),s(e,r)}else if(n.targets){n.targets.forEach((e=>{const{id:t,...s}=e,n=document.querySelector(t);n&&r(n,s)}));const{targets:t,...s}=n;this.updateElementAttributes(e,s)}else{if("disabled"===n.empty&&""===e.value)return;const{empty:t,...s}=n;this.updateElementAttributes(e,s)}}else if(t)n(e,t);else if(e instanceof HTMLFormElement){const t=new FormData(e),n={};t.forEach(((e,t)=>{n[t]=e})),s(e,n)}}catch(e){console.error(`Error parsing JSON: ${e instanceof Error?e.message:"Unknown error"}. Please ensure the JSON string is valid.`,e)}}toggleFormElements(e,t){Array.from(e.elements).forEach((e=>{(e instanceof HTMLInputElement||e instanceof HTMLButtonElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&(e.disabled=t)}))}saveElementOriginalState(e){if(e.hasAttribute("pp-suspense")&&!e.hasAttribute("pp-original-state")){const t={};e.textContent&&(t.textContent=e.textContent.trim()),e.innerHTML&&(t.innerHTML=e.innerHTML.trim()),(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(t.value=e.value);for(let s=0;s<e.attributes.length;s++){const n=e.attributes[s];t[n.name]=n.value}e.setAttribute("pp-original-state",JSON.stringify(t))}if(e instanceof HTMLFormElement){let t=null;const s=e.id;s&&(t=document.querySelector(`[form="${s}"]`)),s&&t||(t=Array.from(e.elements).find((e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement))),t?t.hasAttribute("pp-original-state")||this.saveElementOriginalState(t):console.warn("Warning: No invoker detected for the form. Ensure the form has an associated invoker or an ID for proper handling.")}e.querySelectorAll("[pp-suspense]").forEach((e=>this.saveElementOriginalState(e)))}getUrlParams(){const e={};return new URLSearchParams(window.location.search).forEach(((t,s)=>{e[s]=t})),e}createFetchOptions(e){return{method:"POST",headers:{"Content-Type":"application/json",HTTP_PPHP_WIRE_REQUEST:"true"},body:JSON.stringify(e)}}parseCallback(e,t){let s={};const n=e.closest("form");if(n){new FormData(n).forEach(((e,t)=>{s[t]?Array.isArray(s[t])?s[t].push(e):s[t]=[s[t],e]:s[t]=e}))}else e instanceof HTMLInputElement?s=this.handleInputElement(e):(e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&(s[e.name]=e.value);const r=t.match(/(\w+)\((.*)\)/);if(r){const e=r[1];let t=r[2].trim();if(t.startsWith("{")&&t.endsWith("}"))try{const e=this.parseJson(t);"object"==typeof e&&null!==e&&(s={...s,...e})}catch(e){console.error(`Error parsing JSON: ${e instanceof Error?e.message:"Unknown error"}. Please ensure the JSON string is valid.`,e)}else{const e=t.split(/,(?=(?:[^'"]*['"][^'"]*['"])*[^'"]*$)/).map((e=>e.trim().replace(/^['"]|['"]$/g,"")));s.args=e}return{funcName:e,data:s}}return{funcName:t,data:s}}handleInputElement(e){let t={};if(e.name)if("checkbox"===e.type)t[e.name]={value:e.value,checked:e.checked};else if("radio"===e.type){const s=document.querySelector(`input[name="${e.name}"]:checked`);t[e.name]=s?s.value:null}else t[e.name]=e.value;else"checkbox"===e.type||"radio"===e.type?t.value=e.checked:t.value=e.value;return t}resolveContext(e){let t=this._inlineModuleFns;for(let s=0;s<e.length-1;s++){const n=e[s];if(t instanceof Map)if(t.has(n))t=t.get(n);else{if(!window[n])throw new Error(`Cannot find object "${n}" in inline modules or window context.`);t=window[n]}else if(t=t[n],!t)throw new Error(`Cannot find object "${n}" in the context.`)}return{context:t,methodName:e[e.length-1]}}setCursorPosition(e,t){if(t.start)e.setSelectionRange(0,0);else if(t.end){const t=e.value.length||0;e.setSelectionRange(t,t)}else if(t.length){const s=parseInt(t.length,10)||0;e.setSelectionRange(s,s)}}handleInputAppendParams(e,t){const s=e.getAttribute("pp-append-params"),n=e.getAttribute("pp-append-params-sync");if("true"===s){if("true"===n){const t=e.name||e.id;if(t){const s=new URL(window.location.href),n=new URLSearchParams(s.search);n.has(t)&&(e.value=n.get(t)||"")}}e.addEventListener(t,(e=>{const t=e.currentTarget,s=t.value,n=new URL(window.location.href),r=new URLSearchParams(n.search),i=t.name||t.id;if(i){s?r.set(i,s):r.delete(i);const e=r.toString()?`${n.pathname}?${r.toString()}`:n.pathname;history.replaceState(null,"",e)}}))}}handleHiddenAttribute(){const e=document.querySelectorAll("[pp-visibility]"),t=document.querySelectorAll("[pp-display]"),s=this.handleElementVisibility.bind(this),n=this.handleElementDisplay.bind(this);e.forEach((e=>this.handleVisibilityElementAttribute(e,"pp-visibility",s))),t.forEach((e=>this.handleVisibilityElementAttribute(e,"pp-display",n)))}handleVisibilityElementAttribute(e,t,s){const n=e.getAttribute(t);if(n)if(this.isJsonLike(n)){s(e,this.parseJson(n))}else{const s=this.parseTime(n);if(s>0){const n="pp-visibility"===t?"visibility":"display",r="visibility"===n?"hidden":"none";this.scheduleChange(e,s,n,r)}}}handleElementVisibility(e,t){this.handleElementChange(e,t,"visibility","hidden","visible")}handleElementDisplay(e,t){this.handleElementChange(e,t,"display","none","block")}handleElementChange(e,t,s,n,r){const i=t.start?this.parseTime(t.start):0,o=t.end?this.parseTime(t.end):0;i>0?(e.style[s]=n,this.scheduleChange(e,i,s,r),o>0&&this.scheduleChange(e,i+o,s,n)):o>0&&this.scheduleChange(e,o,s,n)}handleAnchorTag(){document.querySelectorAll("a").forEach((e=>{e.addEventListener("click",(async e=>{const t=e.currentTarget,s=t.getAttribute("href"),n=t.getAttribute("target");if(s&&"_blank"!==n&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),!this._isNavigating)){this._isNavigating=!0;try{if(/^(https?:)?\/\//i.test(s)&&!s.startsWith(window.location.origin))window.location.href=s;else{const e=t.getAttribute("pp-append-params");if(s.startsWith("?")&&"true"===e){const e=new URL(window.location.href),t=new URLSearchParams(e.search);let n="";const[r,i]=s.split("#");i&&(n=`#${i}`);new URLSearchParams(r.split("?")[1]).forEach(((e,s)=>{t.set(s,e)}));const o=`${e.pathname}?${t.toString()}${n}`;history.pushState(null,"",o)}else{const[e,t]=s.split("#"),n=`${e}${t?`#${t}`:""}`;history.pushState(null,"",n)}const n=s.indexOf("#");if(-1!==n){const e=s.slice(n+1),t=document.getElementById(e);if(t)t.scrollIntoView({behavior:"smooth"});else{await this.handleNavigation();const t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth"})}}else await this.handleNavigation()}}catch(e){console.error("Anchor click error:",e)}finally{this._isNavigating=!1}}}))}))}async handleNavigation(){try{const e=document.getElementById("loading-file-1B87E");if(e){const t=this.findLoadingElement(e,window.location.pathname);t&&await this.updateContentWithTransition(t)}const t=await this.fetch(window.location.href);if(!t.ok)return void console.error(`Navigation error: ${t.status} ${t.statusText}`);const s=await t.text(),n=s.match(this._redirectRegex);if(n&&n[1])return void await this.redirect(n[1]);await this.updateDocumentContent(s)}catch(e){console.error("Navigation error:",e)}}findLoadingElement(e,t){let s=t;for(;;){const t=e.querySelector(`div[pp-loading-url='${s}']`);if(t)return t;if("/"===s)break;const n=s.lastIndexOf("/");s=n<=0?"/":s.substring(0,n)}return e.querySelector("div[pp-loading-url='/' ]")}async updateContentWithTransition(e){const t=document.querySelector("[pp-loading-content='true']")||document.body;if(!t)return;const{fadeIn:s,fadeOut:n}=this.parseTransition(e);await this.fadeOut(t,n),t.innerHTML=e.innerHTML,this.fadeIn(t,s)}parseTransition(e){let t=250,s=250;const n=e.querySelector("[pp-loading-transition]"),r=n?.getAttribute("pp-loading-transition");if(r){const e=this.parseJson(r);e&&"object"==typeof e?(t=this.parseTime(e.fadeIn??t),s=this.parseTime(e.fadeOut??s)):console.warn("pp-loading-transition is not valid JSON → default values (250 ms) will be used. String:",r)}return{fadeIn:t,fadeOut:s}}fadeOut(e,t){return new Promise((s=>{e.style.transition=`opacity ${t}ms ease-out`,e.style.opacity="0",setTimeout((()=>{e.style.transition="",s()}),t)}))}fadeIn(e,t){e.style.transition=`opacity ${t}ms ease-in`,e.style.opacity="1",setTimeout((()=>{e.style.transition=""}),t)}async updateDocumentContent(e){const t=this.saveScrollPositions(),s=this.sanitizePassiveHandlers(e),n=(new DOMParser).parseFromString(s,"text/html"),r="pp-dynamic-script",i="pp-dynamic-link";document.head.querySelectorAll("[pp-dynamic-meta]").forEach((e=>e.remove()));document.head.querySelectorAll(`[${i}]`).forEach((e=>e.remove()));document.head.querySelectorAll(`[${r}]`).forEach((e=>e.remove()));await(async e=>{Array.from(e.head.children).forEach((e=>{const t=e.tagName;if("SCRIPT"===t&&e.hasAttribute(r)){const t=document.createElement("script");Array.from(e.attributes).forEach((e=>t.setAttribute(e.name,e.value))),e.textContent&&(t.textContent=e.textContent),document.head.appendChild(t)}else if("META"===t){if(e.getAttribute("charset")||"viewport"===e.getAttribute("name"))return;const t=e.name,s=e.getAttribute("property"),n=document.head.querySelector(t?`meta[name="${t}"]`:`meta[property="${s}"]`),r=document.head.querySelector("title");n?document.head.replaceChild(e.cloneNode(!0),n):r?.nextSibling?document.head.insertBefore(e.cloneNode(!0),r.nextSibling):document.head.appendChild(e.cloneNode(!0))}else if("TITLE"===t){const t=document.head.querySelector("title");t?document.head.replaceChild(e.cloneNode(!0),t):document.head.appendChild(e.cloneNode(!0))}else if("LINK"===t){const t=t=>{const s=document.head.querySelector('link[rel="icon"]');if(s)document.head.replaceChild(e.cloneNode(!0),s);else{const e=document.createElement("link");e.rel="icon",e.href=t,document.head.appendChild(e)}};if("icon"===e.getAttribute("rel")){t(e.href)}else if(e.hasAttribute(i)){const t=e.cloneNode(!0);document.head.appendChild(t)}}})),await this.updateDocumentBody(e)})(n),this.restoreScrollPositions(t),this.resetProps(),await this.processInlineModuleScripts(),await this.initMakeReactive(),this.handlerAutofocusAttribute()}restoreScrollPositions(e){requestAnimationFrame((()=>{const t=e.window;t&&window.scrollTo(t.scrollLeft,t.scrollTop),document.querySelectorAll("*").forEach((t=>{const s=this.getElementKey(t);e[s]&&(t.scrollTop=e[s].scrollTop,t.scrollLeft=e[s].scrollLeft)}))}))}PRESERVE_HANDLERS={DETAILS:(e,t)=>(t.open=e.open,!0),INPUT(e,t){const s=e,n=t;return s.value!==n.value&&(n.value=s.value),n.checked=s.checked,document.activeElement!==s||(null!=s.selectionStart&&(n.selectionStart=s.selectionStart,n.selectionEnd=s.selectionEnd),!1)},TEXTAREA(e,t){const s=e,n=t;return s.value!==n.value&&(n.value=s.value),document.activeElement!==s||(n.selectionStart=s.selectionStart,n.selectionEnd=s.selectionEnd,!1)},SELECT(e,t){const s=e;return t.selectedIndex=s.selectedIndex,document.activeElement!==s},VIDEO(e,t){const s=e,n=t;return n.currentTime=s.currentTime,s.paused?n.pause():n.play(),!0},AUDIO:(e,t)=>this.PRESERVE_HANDLERS.VIDEO(e,t),CANVAS:()=>!1};async populateDocumentBody(e){try{const t=document.body,s=e.body;this._wheelHandlersStashed||(document.querySelectorAll("[onwheel]").forEach((e=>{const t=e.getAttribute("onwheel").trim();if(e.removeAttribute("onwheel"),t){const s=new Function("event",t);e.addEventListener("wheel",s,{passive:!0})}})),this._wheelHandlersStashed=!0);const n=this.PRESERVE_HANDLERS;morphdom(t,s,{getNodeKey(e){if(e.nodeType!==Node.ELEMENT_NODE)return;const t=e;return t.hasAttribute("pp-sync-script")?`pp-sync-script:${t.getAttribute("pp-sync-script")}`:t.getAttribute("key")||void 0},onBeforeElUpdated(e,t){const s=e.tagName;if("SCRIPT"===s||e.hasAttribute("data-nomorph"))return!1;const r=n[s];return!r||r(e,t)},onBeforeNodeDiscarded:e=>(e instanceof HTMLElement&&e.dataset.timerId&&clearTimeout(Number(e.dataset.timerId)),!0)})}catch(e){console.error("Error populating document body:",e)}}async updateDocumentBody(e){try{const t=e.body.cloneNode(!0);this.manageScriptTags(t),document.body.replaceWith(t)}catch(e){console.error("Error populating document body:",e)}}manageScriptTags(e,t){const s=e.querySelectorAll("script"),n=t?.querySelectorAll("script")||s;s.forEach(((e,t)=>{const s=document.createElement("script"),r=n[t]||e;Array.from(r.attributes).forEach((e=>{s.setAttribute(e.name,e.value)})),r.hasAttribute("src")||(s.textContent=r.textContent),e.parentNode?.replaceChild(s,e)}))}saveScrollPositions(){const e={window:{scrollTop:window.scrollY||document.documentElement.scrollTop,scrollLeft:window.scrollX||document.documentElement.scrollLeft}};return document.querySelectorAll("*").forEach((t=>{(t.scrollTop||t.scrollLeft)&&(e[this.getElementKey(t)]={scrollTop:t.scrollTop,scrollLeft:t.scrollLeft})})),e}getElementKey(e){return e.id||e.className||e.tagName}async redirect(e){if(e)try{const t=new URL(e,window.location.origin);t.origin!==window.location.origin?window.location.href=e:(history.pushState(null,"",e),await this.handleNavigation())}catch(e){console.error("Redirect error:",e)}}abortActiveRequest(){this._activeAbortController&&this._activeAbortController.abort()}async fetch(e,t,s=!1){let n;return s?(this._activeAbortController&&this._activeAbortController.abort(),this._activeAbortController=new AbortController,n=this._activeAbortController):n=new AbortController,fetch(e,{...t,signal:n.signal,headers:{...t?.headers,"X-Requested-With":"XMLHttpRequest"}})}isJsonLike(e){return"string"==typeof e&&((e=e.trim()).startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))}parseJson(e){try{return JSON5.parse(e)}catch(e){return console.error(`Error parsing JSON: ${e.message}. Please ensure the JSON string is valid.`,e),{}}}parseTime(e){if("number"==typeof e)return e;const t=e.match(/^(\d+)(ms|s|m)?$/);if(t){const e=parseInt(t[1],10);switch(t[2]||"ms"){case"ms":default:return e;case"s":return 1e3*e;case"m":return 60*e*1e3}}return 0}scheduleChange(e,t,s,n){setTimeout((()=>{requestAnimationFrame((()=>{e.style[s]=n}))}),t)}async fetchFunction(e,t={},s=!1){try{const n={callback:e,...t},r=window.location.href;let i;if(Object.keys(n).some((e=>{const t=n[e];return t instanceof File||t instanceof FileList&&t.length>0}))){const e=new FormData;Object.keys(n).forEach((t=>{const s=n[t];s instanceof File?e.append(t,s):s instanceof FileList?Array.from(s).forEach((s=>e.append(t,s))):e.append(t,s)})),i={method:"POST",headers:{HTTP_PPHP_WIRE_REQUEST:"true"},body:e}}else i=this.createFetchOptions(n);const o=await this.fetch(r,i,s);if(!o.ok)throw new Error(`Fetch failed with status: ${o.status} ${o.statusText}`);const a=await o.text();try{return JSON.parse(a)}catch{return a}}catch(e){throw console.error("Error in fetchFunction:",e),new Error("Failed to fetch data.")}}processSyncScripts(e){e.forEach((e=>{const t=`script[pp-sync-script="${CSS.escape(e)}"]`,s=document.querySelector(t);if(s){s.remove();const e=document.createElement("script");Array.from(s.attributes).forEach((t=>{e.setAttribute(t.name,t.value)})),s.src?e.src=s.src:e.textContent=s.textContent,e.type=s.type||"module",document.body.appendChild(e)}}))}async sync(...e){try{const t=this.saveScrollPositions();this.saveElementState();const s=e.length>0?e.map((e=>`pp-sync="${e}"`)):['pp-sync="true"'],n=this.createFetchOptions({secondRequestC69CD:!0,...this.getUrlParams()}),r=await this.fetch(window.location.href,n),i=await r.text(),o=(new DOMParser).parseFromString(i,"text/html"),a=new Set;s.forEach((e=>{const t=document.querySelectorAll(`[${e}]`),s=o.body.querySelectorAll(`[${e}]`);t.forEach(((e,t)=>{const n=s[t];if(n){if(n.hasAttribute("pp-sync-script")){const e=n.getAttribute("pp-sync-script")||"";e&&a.add(e)}n.querySelectorAll("[pp-sync-script]").forEach((e=>{const t=e.getAttribute("pp-sync-script")||"";t&&a.add(t)})),e.innerHTML=n.innerHTML,this.reRunScripts(e)}}))})),this.processSyncScripts(a),this.restoreElementState(),this.restoreScrollPositions(t),this.attachWireFunctionEvents()}catch(e){console.error("Error in pphpSync:",e)}}async fetchAndUpdateBodyContent(){const e=this.createFetchOptions({secondRequestC69CD:!0,...this.getUrlParams()});this.abortActiveRequest();const t=await this.fetch(window.location.href,e,!0),s=await t.text();await this.updateBodyContent(s)}reRunScripts(e){e.querySelectorAll("script").forEach((e=>{const t=document.createElement("script");Array.from(e.attributes).forEach((e=>{t.setAttribute(e.name,e.value)})),e.hasAttribute("src")||(t.textContent=e.textContent),e.parentNode?.replaceChild(t,e)}))}copyCode(e,t,s,n,r="img",i=2e3){if(!(e instanceof HTMLElement))return;const o=e.closest(`.${t}`)?.querySelector("pre code"),a=o?.textContent?.trim()||"";a?navigator.clipboard.writeText(a).then((()=>{const t=e.querySelector(r);if(t)for(const[e,s]of Object.entries(n))e in t?t[e]=s:t.setAttribute(e,s);setTimeout((()=>{if(t)for(const[e,n]of Object.entries(s))e in t?t[e]=n:t.setAttribute(e,n)}),i)}),(()=>{alert("Failed to copy command to clipboard")})):alert("Failed to find the code block to copy")}getCookie(e){return document.cookie.split("; ").find((t=>t.startsWith(e+"=")))?.split("=")[1]||null}}class PPHPLocalStore{state;static instance=null;listeners;pphp;STORAGE_KEY;constructor(e={}){this.state=e,this.listeners=[],this.pphp=PPHP.instance,this.STORAGE_KEY=this.pphp.getCookie("pphp_local_store_key")||"pphp_local_store_59e13",this.loadState()}static getInstance(e={}){return PPHPLocalStore.instance||(PPHPLocalStore.instance=new PPHPLocalStore(e)),PPHPLocalStore.instance}setState(e,t=!1){if(this.state={...this.state,...e},this.listeners.forEach((e=>e(this.state))),this.saveState(),t){const e=localStorage.getItem(this.STORAGE_KEY);e&&this.pphp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:e})}}saveState(){localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.state))}loadState(){const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.state=this.pphp.parseJson(e),this.listeners.forEach((e=>e(this.state))))}resetState(e,t=!1){if(e?(delete this.state[e],this.saveState()):(this.state={},localStorage.removeItem(this.STORAGE_KEY)),this.listeners.forEach((e=>e(this.state))),t){const t=e?localStorage.getItem(this.STORAGE_KEY):null;this.pphp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:t})}}}class SearchParamsManager{static instance=null;listeners=[];constructor(){}static getInstance(){return SearchParamsManager.instance||(SearchParamsManager.instance=new SearchParamsManager),SearchParamsManager.instance}get params(){return new URLSearchParams(window.location.search)}get(e){return this.params.get(e)}set(e,t){const s=this.params;s.set(e,t),this.updateURL(s)}delete(e){const t=this.params;t.delete(e),this.updateURL(t)}replace(e){const t=new URLSearchParams;for(const s in e){const n=e[s];null!==n&&t.set(s,n)}this.updateURL(t,!0)}updateURL(e,t=!1){const s=`${window.location.pathname}?${e.toString()}`;t?history.replaceState(null,"",s):history.pushState(null,"",s),this.notifyListeners(e)}listen(e){this.listeners.push(e)}notifyListeners(e){for(const t of this.listeners)t(e)}enablePopStateListener(){window.addEventListener("popstate",(()=>{this.notifyListeners(this.params)}))}}var pphp=PPHP.instance,store=PPHPLocalStore.getInstance(),searchParams=SearchParamsManager.getInstance();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "2.4.5",
3
+ "version": "3.0.0-alpha.1",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",