create-prisma-php-app 4.1.0-beta.6 → 4.2.0-beta

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.
@@ -12,7 +12,7 @@ MainLayout::$description = !empty(MainLayout::$description) ? MainLayout::$descr
12
12
 
13
13
  <head>
14
14
  <!-- Dynamic Meta Tags -->
15
- <link rel="icon" href="<?= Request::baseUrl; ?>/favicon.ico" type="image/x-icon" sizes="16x16" />
15
+ <link rel="icon" href="/favicon.ico" type="image/x-icon" sizes="16x16" />
16
16
  <!-- Dynamic Header Scripts -->
17
17
  </head>
18
18
 
package/dist/ts/main.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import "/js/pp-reactive-v1.js";
2
- import "/js/pp-utilities.js";
3
2
 
4
3
  // The following global names have already been declared elsewhere in the project:
5
4
  // - pp: Used for the Reactive Core functionality.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "4.1.0-beta.6",
3
+ "version": "4.2.0-beta",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- import{L as o,T as p,a as t}from"./pp-reactive-v1.js";import"./pp-portal.js";export{o as LoopManager,p as TemplateRenderer,t as TemplateUtils};
@@ -1 +0,0 @@
1
- class m{portals=new Map;portalCounter=0;componentManager;domBindingManager;cleanupObserver;stateManager;pphpInstance;constructor(){this.cleanupObserver=new MutationObserver(e=>{this.handleMutations(e)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}setDependencies(e,t,n,r){this.componentManager=e,this.domBindingManager=t,this.stateManager=n,this.pphpInstance=r}createPortal(e,t,n){const r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new Error(`Portal container not found: ${t}`);const o=this.componentManager?.getCurrentComponent()||"app",a=n?.key||`portal_${++this.portalCounter}_${Date.now()}`;this.portals.has(a)&&this.removePortal(a);const s={id:a,content:e,container:r,component:o};return this.portals.set(a,s),this.renderPortalWithHydration(s,n,a),a}async renderPortalWithHydration(e,t,n){if(!this.componentManager||!this.domBindingManager){console.warn("PortalManager dependencies not set");return}try{await this.renderPortal(e,t),await new Promise(r=>requestAnimationFrame(r)),this.domBindingManager.processPendingBindings(),await new Promise(r=>{this.stateManager?.onDOMUpdateComplete(()=>{r(void 0)})}),this.pphpInstance&&this.pphpInstance.markPortalHydrated&&this.pphpInstance.markPortalHydrated(n),t?.onMount&&t.onMount(e.container)}catch(r){console.error("Portal hydration error:",r),this.pphpInstance&&this.pphpInstance.markPortalHydrated&&this.pphpInstance.markPortalHydrated(n)}}renderPortal(e,t){return new Promise((n,r)=>{if(!this.componentManager||!this.domBindingManager){console.warn("PortalManager dependencies not set"),r(new Error("Dependencies not set"));return}try{e.renderedContent&&e.renderedContent.parentElement&&e.renderedContent.parentElement.removeChild(e.renderedContent);let o;if(typeof e.content=="string"){const s=document.createElement("template");if(s.innerHTML=e.content.trim(),o=s.content.firstElementChild,!o)throw new Error("Invalid HTML string for portal content")}else if(e.content instanceof DocumentFragment){const s=document.createElement("div");if(s.appendChild(e.content.cloneNode(!0)),o=s.firstElementChild,!o)throw new Error("DocumentFragment must contain at least one element")}else o=e.content;o.setAttribute("data-portal-id",e.id),o.setAttribute("data-portal-component",e.component),e.container.appendChild(o),e.renderedContent=o;const a=[...this.componentManager.componentStack];e.component!=="app"?this.componentManager.componentStack=["app",e.component]:this.componentManager.componentStack=["app"];try{this.componentManager.executePhpScripts(o),this.domBindingManager.processElement(o,!0);const s=o.querySelectorAll("template[pp-for]"),i=this.domBindingManager.loopManager;i&&(s.forEach(p=>{const c=p;if(i.loopBindings?.has(c))if(typeof i.updateTemplateParent=="function")i.updateTemplateParent(c);else{const l=i.loopBindings.get(c);l&&(l.subscriptionIds?.forEach(d=>{this.stateManager?.removeSubscription(d)}),i.loopBindings.delete(c)),i.processTemplate(c,e.component)}else i.queueTemplate(c,e.component)}),i.processPendingTemplates()),this.domBindingManager.processPendingBindings(),n()}finally{this.componentManager.componentStack=a}}catch(o){console.error("Portal rendering error:",o),this.portals.delete(e.id),r(o)}})}removePortal(e){const t=this.portals.get(e);if(!t)return!1;try{return t.cleanup&&t.cleanup(),t.renderedContent&&this.cleanupPortalElement(t.renderedContent),t.renderedContent&&t.renderedContent.parentElement&&t.renderedContent.parentElement.removeChild(t.renderedContent),this.portals.delete(e),!0}catch(n){return console.error("Portal cleanup error:",n),!1}}cleanupPortalElement(e){if(this.stateManager){const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let n=e;do n.nodeType===Node.ELEMENT_NODE&&this.stateManager.subscriptionManager?.cleanupElement(n);while(n=t.nextNode())}}updatePortal(e,t,n){const r=this.portals.get(e);return r?(r.content=t,this.renderPortal(r,n),!0):!1}getPortal(e){return this.portals.get(e)}hasPortal(e){return this.portals.has(e)}getAllPortals(){return Array.from(this.portals.values())}handleMutations(e){for(const t of e)t.type==="childList"&&t.removedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){const r=n;for(const[o,a]of this.portals)(a.container===r||r.contains(a.container))&&this.removePortal(o)}})}destroy(){for(const e of Array.from(this.portals.keys()))this.removePortal(e);this.cleanupObserver.disconnect(),this.portals.clear()}}export{m as P};
@@ -1 +0,0 @@
1
- import{P as ce}from"./pp-reactive-v1.js";import"./pp-portal.js";var ee=11;function le(i,e){var t=e.attributes,n,a,r,s,u;if(!(e.nodeType===ee||i.nodeType===ee)){for(var f=t.length-1;f>=0;f--)n=t[f],a=n.name,r=n.namespaceURI,s=n.value,r?(a=n.localName||a,u=i.getAttributeNS(r,a),u!==s&&(n.prefix==="xmlns"&&(a=n.name),i.setAttributeNS(r,a,s))):(u=i.getAttribute(a),u!==s&&i.setAttribute(a,s));for(var b=i.attributes,m=b.length-1;m>=0;m--)n=b[m],a=n.name,r=n.namespaceURI,r?(a=n.localName||a,e.hasAttributeNS(r,a)||i.removeAttributeNS(r,a)):e.hasAttribute(a)||i.removeAttribute(a)}}var D,de="http://www.w3.org/1999/xhtml",v=typeof document>"u"?void 0:document,ue=!!v&&"content"in v.createElement("template"),he=!!v&&v.createRange&&"createContextualFragment"in v.createRange();function fe(i){var e=v.createElement("template");return e.innerHTML=i,e.content.childNodes[0]}function pe(i){D||(D=v.createRange(),D.selectNode(v.body));var e=D.createContextualFragment(i);return e.childNodes[0]}function ve(i){var e=v.createElement("body");return e.innerHTML=i,e.childNodes[0]}function ge(i){return i=i.trim(),ue?fe(i):he?pe(i):ve(i)}function $(i,e){var t=i.nodeName,n=e.nodeName,a,r;return t===n?!0:(a=t.charCodeAt(0),r=n.charCodeAt(0),a<=90&&r>=97?t===n.toUpperCase():r<=90&&a>=97?n===t.toUpperCase():!1)}function me(i,e){return!e||e===de?v.createElement(i):v.createElementNS(e,i)}function ye(i,e){for(var t=i.firstChild;t;){var n=t.nextSibling;e.appendChild(t),t=n}return e}function j(i,e,t){i[t]!==e[t]&&(i[t]=e[t],i[t]?i.setAttribute(t,""):i.removeAttribute(t))}var te={OPTION:function(i,e){var t=i.parentNode;if(t){var n=t.nodeName.toUpperCase();n==="OPTGROUP"&&(t=t.parentNode,n=t&&t.nodeName.toUpperCase()),n==="SELECT"&&!t.hasAttribute("multiple")&&(i.hasAttribute("selected")&&!e.selected&&(i.setAttribute("selected","selected"),i.removeAttribute("selected")),t.selectedIndex=-1)}j(i,e,"selected")},INPUT:function(i,e){j(i,e,"checked"),j(i,e,"disabled"),i.value!==e.value&&(i.value=e.value),e.hasAttribute("value")||i.removeAttribute("value")},TEXTAREA:function(i,e){var t=e.value;i.value!==t&&(i.value=t);var n=i.firstChild;if(n){var a=n.nodeValue;if(a==t||!t&&a==i.placeholder)return;n.nodeValue=t}},SELECT:function(i,e){if(!e.hasAttribute("multiple")){for(var t=-1,n=0,a=i.firstChild,r,s;a;)if(s=a.nodeName&&a.nodeName.toUpperCase(),s==="OPTGROUP")r=a,a=r.firstChild,a||(a=r.nextSibling,r=null);else{if(s==="OPTION"){if(a.hasAttribute("selected")){t=n;break}n++}a=a.nextSibling,!a&&r&&(a=r.nextSibling,r=null)}i.selectedIndex=t}}},R=1,ne=11,ae=3,ie=8;function T(){}function we(i){if(i)return i.getAttribute&&i.getAttribute("id")||i.id}function be(i){return function(t,n,a){if(a||(a={}),typeof n=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var r=n;n=v.createElement("html"),n.innerHTML=r}else n=ge(n);else n.nodeType===ne&&(n=n.firstElementChild);var s=a.getNodeKey||we,u=a.onBeforeNodeAdded||T,f=a.onNodeAdded||T,b=a.onBeforeElUpdated||T,m=a.onElUpdated||T,I=a.onBeforeNodeDiscarded||T,g=a.onNodeDiscarded||T,y=a.onBeforeElChildrenUpdated||T,E=a.skipFromChildren||T,x=a.addChild||function(o,c){return o.appendChild(c)},q=a.childrenOnly===!0,C=Object.create(null),U=[];function _(o){U.push(o)}function X(o,c){if(o.nodeType===R)for(var h=o.firstChild;h;){var l=void 0;c&&(l=s(h))?_(l):(g(h),h.firstChild&&X(h,c)),h=h.nextSibling}}function K(o,c,h){I(o)!==!1&&(c&&c.removeChild(o),g(o),X(o,h))}function G(o){if(o.nodeType===R||o.nodeType===ne)for(var c=o.firstChild;c;){var h=s(c);h&&(C[h]=c),G(c),c=c.nextSibling}}G(t);function M(o){f(o);for(var c=o.firstChild;c;){var h=c.nextSibling,l=s(c);if(l){var d=C[l];d&&$(c,d)?(c.parentNode.replaceChild(d,c),H(d,c)):M(c)}else M(c);c=h}}function re(o,c,h){for(;c;){var l=c.nextSibling;(h=s(c))?_(h):K(c,o,!0),c=l}}function H(o,c,h){var l=s(c);if(l&&delete C[l],!h){var d=b(o,c);if(d===!1||(d instanceof HTMLElement&&(o=d,G(o)),i(o,c),m(o),y(o,c)===!1))return}o.nodeName!=="TEXTAREA"?se(o,c):te.TEXTAREA(o,c)}function se(o,c){var h=E(o,c),l=c.firstChild,d=o.firstChild,N,w,O,B,S;e:for(;l;){for(B=l.nextSibling,N=s(l);!h&&d;){if(O=d.nextSibling,l.isSameNode&&l.isSameNode(d)){l=B,d=O;continue e}w=s(d);var V=d.nodeType,A=void 0;if(V===l.nodeType&&(V===R?(N?N!==w&&((S=C[N])?O===S?A=!1:(o.insertBefore(S,d),w?_(w):K(d,o,!0),d=S,w=s(d)):A=!1):w&&(A=!1),A=A!==!1&&$(d,l),A&&H(d,l)):(V===ae||V==ie)&&(A=!0,d.nodeValue!==l.nodeValue&&(d.nodeValue=l.nodeValue))),A){l=B,d=O;continue e}w?_(w):K(d,o,!0),d=O}if(N&&(S=C[N])&&$(S,l))h||x(o,S),H(S,l);else{var W=u(l);W!==!1&&(W&&(l=W),l.actualize&&(l=l.actualize(o.ownerDocument||v)),x(o,l),M(l))}l=B,d=O}re(o,d,w);var Z=te[o.nodeName];Z&&Z(o,c)}var p=t,F=p.nodeType,Q=n.nodeType;if(!q){if(F===R)Q===R?$(t,n)||(g(t),p=ye(t,me(n.nodeName,n.namespaceURI))):p=n;else if(F===ae||F===ie){if(Q===F)return p.nodeValue!==n.nodeValue&&(p.nodeValue=n.nodeValue),p;p=n}}if(p===n)g(t);else{if(n.isSameNode&&n.isSameNode(p))return;if(H(p,n,q),U)for(var Y=0,oe=U.length;Y<oe;Y++){var J=C[U[Y]];J&&K(J,J.parentNode,!1)}}return!q&&p!==t&&t.parentNode&&(p.actualize&&(p=p.actualize(t.ownerDocument||v)),t.parentNode.replaceChild(p,t)),p}}var Se=be(le);class P extends ce{static instance=null;cryptoKey=null;activeAbortController=null;navigationEnabled=!1;boundHandleLinkClick=null;boundHandlePopState=null;isNavigating=!1;constructor(){super(),this.hydrated().then(()=>{this.isNavigating||(document.body.hidden=!1),this.enableSPANavigation()}).catch(e=>{console.error("PPHPUtilities hydration error:",e),document.body.hidden=!1})}static resetInstance(){this.instance&&(this.instance.navigationEnabled&&this.instance.disableSPANavigation(),this.instance.activeAbortController&&(this.instance.activeAbortController.abort(),this.instance.activeAbortController=null),this.instance.destroy(),this.instance=null)}static getInstance(){return this.instance||(this.instance=new P),this.instance}enableSPANavigation(){this.navigationEnabled||(this.navigationEnabled=!0,this.boundHandleLinkClick=this.handleLinkClick.bind(this),this.boundHandlePopState=this.handlePopState.bind(this),document.addEventListener("click",this.boundHandleLinkClick),window.addEventListener("popstate",this.boundHandlePopState))}disableSPANavigation(){this.navigationEnabled=!1,this.boundHandleLinkClick&&(document.removeEventListener("click",this.boundHandleLinkClick),this.boundHandleLinkClick=null),this.boundHandlePopState&&(window.removeEventListener("popstate",this.boundHandlePopState),this.boundHandlePopState=null)}handleLinkClick(e){if(!this.navigationEnabled)return;const n=e.target.closest("a");if(!(!n||!n.href))try{const a=new URL(n.href),r=a.origin!==window.location.origin,s=a.pathname===window.location.pathname&&a.search===window.location.search;if(r||n.target==="_blank"||n.hasAttribute("download")||n.getAttribute("pp-no-spa")==="true"||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;if(e.preventDefault(),s){const u=a.hash;if(u){const f=document.querySelector(u);f&&f.scrollIntoView({behavior:"smooth"})}else window.scrollTo({top:0,behavior:"smooth"});return}this.navigateTo(a.pathname+a.search+a.hash)}catch(a){console.error("Link click navigation error:",a)}}async handlePopState(){const e=window.location.pathname+window.location.search+window.location.hash;await this.navigateTo(e,!1)}async navigateTo(e,t=!0){this.isNavigating=!0;try{this.dispatchNavigationEvent("start",e),await this.showLoadingTransition();const n=await this.fetchPageContent(e);this.performCleanup(),this.updateBrowserHistory(e,t);const a=document.getElementById("loading-file-1B87E"),r="startViewTransition"in document;!a&&r?await this.updatePageContentWithViewTransition(n):this.updatePageContent(n),await this.reinitializeApp(),await this.handleNavigationCompletion(e),this.dispatchNavigationEvent("complete",e)}catch(n){this.handleNavigationError(e,n)}finally{this.isNavigating=!1}}async updatePageContentWithViewTransition(e){if(this.isNavigating){this.updatePageContent(e);return}const t=document.startViewTransition(()=>{this.updatePageContent(e)});try{await t.finished}catch(n){console.warn("View transition failed, continuing anyway:",n)}}dispatchNavigationEvent(e,t,n){const a=`pp:navigation:${e}`,r=n?{url:t,error:n}:{url:t};document.dispatchEvent(new CustomEvent(a,{detail:r}))}async showLoadingTransition(){const e=document.getElementById("loading-file-1B87E");if(e){const n=this.findLoadingElement(e,window.location.pathname);if(n){await this.updateContentWithTransition(n);return}}const t=document.querySelector("[pp-loading-content='true']")||document.body;t&&!("startViewTransition"in document)&&await this.fadeOut(t,250)}async fetchPageContent(e){const t=await fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/html"}});if(!t.ok)throw new Error(`Navigation failed: ${t.status} ${t.statusText}`);const n=await t.text();return new DOMParser().parseFromString(n,"text/html")}performCleanup(){this.cleanup(),this.disableSPANavigation()}updateBrowserHistory(e,t){t&&history.pushState(null,"",e)}updatePageContent(e){e.title&&(document.title=e.title),this.reconcileHead(e);const t=e.body;Se(document.body,t,{childrenOnly:!0,onBeforeElUpdated:(n,a)=>!n.isEqualNode(a)})}async reinitializeApp(){window.pp=null,P.instance=null;const e=window.pp;return await e.hydrated(),e}async handleNavigationCompletion(e){const t=new URL(e,window.location.origin).hash;if(t){const a=document.querySelector(t);a&&a.scrollIntoView({behavior:"smooth"})}else window.scrollTo({top:0,behavior:"instant"});const n=document.querySelector("[pp-loading-content='true']")||document.body;n?requestAnimationFrame(()=>{document.body.hidden=!1,this.fadeIn(n,150)}):document.body.hidden=!1}handleNavigationError(e,t){console.error("Navigation error:",t),document.body.hidden=!1,this.dispatchNavigationEvent("error",e,t),window.location.href=e}findLoadingElement(e,t){let n=t;for(;;){const a=e.querySelector(`div[pp-loading-url='${n}']`);if(a)return a;if(n==="/")break;const r=n.lastIndexOf("/");r<=0?n="/":n=n.substring(0,r)}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:a}=this.parseTransition(e);await this.fadeOut(t,a),t.innerHTML=e.innerHTML,this.fadeIn(t,n)}parseTransition(e){let t=250,n=250;const r=e.querySelector("[pp-loading-transition]")?.getAttribute("pp-loading-transition");if(r){let s=JSON.parse(r);s&&typeof s=="object"?(t=this.parseTime(s.fadeIn??t),n=this.parseTime(s.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`,setTimeout(()=>{e.style.transition="",n()},t)})}fadeIn(e,t){e.style.transition=`opacity ${t}ms ease-in`,setTimeout(()=>{e.style.transition=""},t)}parseTime(e){if(typeof e=="number")return e;const t=e.match(/^(\d+)(ms|s|m)?$/);if(t){const n=parseInt(t[1],10);switch(t[2]||"ms"){case"ms":return n;case"s":return n*1e3;case"m":return n*60*1e3;default:return n}}return 0}reconcileHead(e){const t="pp-dynamic-script",n="pp-dynamic-meta",a="pp-dynamic-link";document.head.querySelectorAll(`[${n}]`).forEach(r=>r.remove()),document.head.querySelectorAll(`[${a}]`).forEach(r=>r.remove()),document.head.querySelectorAll(`[${t}]`).forEach(r=>r.remove()),Array.from(e.head.children).forEach(r=>{switch(r.tagName){case"SCRIPT":if(r.hasAttribute(t)){const s=document.createElement("script");Array.from(r.attributes).forEach(u=>s.setAttribute(u.name,u.value)),s.textContent=r.textContent,document.head.appendChild(s)}break;case"META":{const s=r;if(s.getAttribute("charset")||s.name==="viewport")break;const u=s.name?`meta[name="${s.name}"]`:`meta[property="${s.getAttribute("property")}"]`,f=s.cloneNode(!0),b=document.head.querySelector(u);b?document.head.replaceChild(f,b):document.head.insertBefore(f,document.head.querySelector("title")?.nextSibling||null);break}case"TITLE":{const s=r.cloneNode(!0),u=document.head.querySelector("title");u?document.head.replaceChild(s,u):document.head.appendChild(s);break}case"LINK":{const s=r;if(s.rel==="icon"){const u=s.cloneNode(!0),f=document.head.querySelector('link[rel="icon"]');f?document.head.replaceChild(u,f):document.head.appendChild(u)}else s.hasAttribute(a)&&document.head.appendChild(s.cloneNode(!0));break}}})}async redirect(e){if(e)try{const t=new URL(e,window.location.origin);t.origin!==window.location.origin?window.location.href=e:this.navigationEnabled?await this.navigateTo(t.pathname+t.search+t.hash):window.location.href=e}catch(t){console.error("Redirect error:",t)}}async initCryptoKey(){const e=document.cookie.split("; ").find(u=>u.startsWith("pp_function_call_jwt="))?.split("=",2)[1];if(!e)throw new Error("Missing function-call token");const[,t]=e.split("."),n=atob(t.replace(/-/g,"+").replace(/_/g,"/")),{k:a,exp:r}=JSON.parse(n);if(Date.now()/1e3>r)throw new Error("Function-call token expired");const s=Uint8Array.from(atob(a),u=>u.charCodeAt(0));this.cryptoKey=await crypto.subtle.importKey("raw",s,{name:"AES-CBC"},!1,["encrypt","decrypt"])}async encryptCallbackName(e){await this.initCryptoKey();const t=crypto.getRandomValues(new Uint8Array(16)),n=new TextEncoder().encode(e),a=await crypto.subtle.encrypt({name:"AES-CBC",iv:t},this.cryptoKey,n),r=btoa(String.fromCharCode(...t)),s=btoa(String.fromCharCode(...new Uint8Array(a)));return`${r}:${s}`}createFetchOptions(e){return{method:"POST",headers:{"Content-Type":"application/json",HTTP_PP_WIRE_REQUEST:"true"},body:JSON.stringify(e)}}async fetchFunction(e,t={},n=!1){let a=null;try{n&&this.activeAbortController&&(this.activeAbortController.abort(),this.activeAbortController=null),a=new AbortController,n&&(this.activeAbortController=a);const s={callback:await this.encryptCallbackName(e),...t},u=window.location.href;let f;if(Object.keys(s).some(g=>{const y=s[g];return y instanceof File||y instanceof FileList&&y.length>0})){const g=new FormData;Object.keys(s).forEach(y=>{const E=s[y];E instanceof File?g.append(y,E):E instanceof FileList?Array.from(E).forEach(x=>g.append(y,x)):g.append(y,E)}),f={method:"POST",headers:{HTTP_PP_WIRE_REQUEST:"true"},body:g,signal:a.signal}}else f={signal:a.signal,...this.createFetchOptions(s)};const m=await fetch(u,f);if(!m.ok)throw new Error(`Fetch failed with status: ${m.status} ${m.statusText}`);const I=await m.text();a&&this.activeAbortController===a&&(this.activeAbortController=null);try{return JSON.parse(I)}catch{return I}}catch(r){if(a&&this.activeAbortController===a&&(this.activeAbortController=null),r instanceof Error&&r.name==="AbortError")return console.log("Request was cancelled"),{cancelled:!0};throw console.error("Error in fetchFunction:",r),new Error("Failed to fetch data.")}}}class k{state;static instance=null;listeners;pp;STORAGE_KEY;lastSyncedState=null;constructor(e={}){this.state=e,this.listeners=[],this.pp=P.getInstance(),this.STORAGE_KEY=this.getCookie("pp_local_store_key")||"pp_local_store_59e13",this.lastSyncedState=localStorage.getItem(this.STORAGE_KEY),this.loadState()}static getInstance(e={}){return k.instance||(k.instance=new k(e)),k.instance}getCookie(e){return document.cookie.split("; ").find(t=>t.startsWith(e+"="))?.split("=")[1]||null}setState(e,t=!1){const n={...this.state,...e};if(JSON.stringify(n)!==JSON.stringify(this.state)&&(this.state=n,this.listeners.forEach(a=>a(this.state)),this.saveState(),t)){const a=localStorage.getItem(this.STORAGE_KEY);a&&a!==this.lastSyncedState&&(this.pp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:a}),this.lastSyncedState=a)}}saveState(){localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.state))}loadState(){const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.state=JSON.parse(e),this.listeners.forEach(t=>t(this.state)))}resetState(e,t=!1){if(e?(delete this.state[e],this.saveState()):(this.state={},localStorage.removeItem(this.STORAGE_KEY)),this.listeners.forEach(n=>n(this.state)),t){const n=e?localStorage.getItem(this.STORAGE_KEY):null;this.pp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:n}),this.lastSyncedState=n}}}class L{static instance=null;listeners=[];constructor(){}static getInstance(){return L.instance||(L.instance=new L),L.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 a=e[n];a!==null&&t.set(n,a)}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)})}}function z(i,e,t=window,n=!0){let a=null;if(Object.defineProperty(t,i,{get(){if(a!==null)return a;if(e&&typeof e=="object"&&!Array.isArray(e)&&"getInstance"in e&&typeof e.getInstance=="function")return a=e.getInstance(),a;if(typeof e=="function")try{return a=e.getInstance(),a}catch{return a=e,a}else return a=e,a},set(r){r===null?a=null:console.warn(`Cannot override global ${i}`)},configurable:!0,enumerable:!0}),n)try{t[i]}catch(r){console.error(`Failed to initialize ${i}:`,r)}}z("pp",P);z("store",k);z("searchParams",L);
File without changes