inertiax-core 10.0.1 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function A(r,e){let t;return function(...s){clearTimeout(t),t=setTimeout(()=>r.apply(this,s),e)}}function h(r,e){return document.dispatchEvent(new CustomEvent(`inertia:${r}`,e))}var Z=r=>h("before",{cancelable:!0,detail:{visit:r}})&&h(`${r.frame}:before`,{cancelable:!0,detail:{visit:r}}),de=(r,e)=>h("error",{detail:{errors:r}})&&h(`${e}:error`,{detail:{errors:r}}),pe=(r,e)=>h("exception",{cancelable:!0,detail:{exception:r}})&&h(`${e}:exception`,{cancelable:!0,detail:{exception:r}}),he=r=>h("finish",{detail:{visit:r}})&&h(`${r.frame}:finish`,{detail:{visit:r}}),me=(r,e)=>h("invalid",{cancelable:!0,detail:{response:r}})&&h(`${e}:invalid`,{cancelable:!0,detail:{response:r}}),R=(r,e)=>h("navigate",{detail:{page:r}})&&h(`${e}:navigate`,{detail:{page:r}}),fe=(r,e)=>h("progress",{detail:{progress:r}})&&h(`${e}:progress`,{detail:{progress:r}}),ge=r=>h("start",{detail:{visit:r}})&&h(`${r.frame}:start`,{detail:{visit:r}}),ve=(r,e)=>h("success",{detail:{page:r}})&&h(`${e}:success`,{detail:{page:r}}),be=(r,e)=>h("prefetched",{detail:{fetchedAt:Date.now(),response:r.data,visit:e}})&&h(`${e.frame}:prefetched`,{detail:{fetchedAt:Date.now(),response:r.data,visit:e}}),Pe=r=>h("prefetching",{detail:{visit:r}})&&h(`${r.frame}:prefetching`,{detail:{visit:r}});var m=class{static set(e,t){typeof window<"u"&&window.sessionStorage.setItem(e,JSON.stringify(t))}static get(e){if(typeof window<"u")return JSON.parse(window.sessionStorage.getItem(e)||"null")}static merge(e,t){let s=this.get(e);s===null?this.set(e,t):this.set(e,{...s,...t})}static remove(e){typeof window<"u"&&window.sessionStorage.removeItem(e)}static removeNested(e,t){let s=this.get(e);s!==null&&(delete s[t],this.set(e,s))}static exists(e){try{return this.get(e)!==null}catch{return!1}}static clear(){typeof window<"u"&&window.sessionStorage.clear()}};m.locationVisitKey="inertiaLocationVisit";var ye=async r=>{if(typeof window>"u")throw new Error("Unable to encrypt history");let e=Se(),t=await Ee(),s=await _e(t);if(!s)throw new Error("Unable to encrypt history");return await Ne(e,s,r)},F={key:"historyKey",iv:"historyIv"},we=async r=>{let e=Se(),t=await Ee();if(!t)throw new Error("Unable to decrypt history");return await Ge(e,t,r)},Ne=async(r,e,t)=>{if(typeof window>"u")throw new Error("Unable to encrypt history");if(typeof window.crypto.subtle>"u")return console.warn("Encryption is not supported in this environment. SSL is required."),Promise.resolve(t);let s=new TextEncoder,i=JSON.stringify(t),n=new Uint8Array(i.length*3),a=s.encodeInto(i,n);return window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},e,n.subarray(0,a.written))},Ge=async(r,e,t)=>{if(typeof window.crypto.subtle>"u")return console.warn("Decryption is not supported in this environment. SSL is required."),Promise.resolve(t);let s=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:r},e,t);return JSON.parse(new TextDecoder().decode(s))},Se=()=>{let r=m.get(F.iv);if(r)return new Uint8Array(r);let e=window.crypto.getRandomValues(new Uint8Array(12));return m.set(F.iv,Array.from(e)),e},Be=async()=>typeof window.crypto.subtle>"u"?(console.warn("Encryption is not supported in this environment. SSL is required."),Promise.resolve(null)):window.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),Ke=async r=>{if(typeof window.crypto.subtle>"u")return console.warn("Encryption is not supported in this environment. SSL is required."),Promise.resolve();let e=await window.crypto.subtle.exportKey("raw",r);m.set(F.key,Array.from(new Uint8Array(e)))},_e=async r=>{if(r)return r;let e=await Be();return e?(await Ke(e),e):null},Ee=async()=>{let r=m.get(F.key);return r?await window.crypto.subtle.importKey("raw",new Uint8Array(r),{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]):null};var C=class{constructor(){this.items=[];this.processingPromise=null}add(e){return this.items.push(e),this.process()}process(){return this.processingPromise??(this.processingPromise=this.processNext().then(()=>{this.processingPromise=null})),this.processingPromise}processNext(){let e=this.items.shift();return e?Promise.resolve(e()).then(()=>this.processNext()):Promise.resolve()}};var V=typeof window>"u",M=new C,Re=!V&&/CriOS/.test(window.navigator.userAgent),ee=class{constructor(){this.rememberedState="rememberedState";this.scrollRegions="scrollRegions";this.preserveUrl=!1;this.counter=V?0:window.history.state?.c??0;this.externalCallbacks=[];this.lastChangedFrames=[];this.current={};this.initialState=null}remember(e,t,s){this.preserveUrl=!0,this.replaceState(e,{...this.current[e],rememberedState:{...this.current[e]?.rememberedState??{},[s]:t}})}restore(e,t){if(!V)return this.current?.[e]?.rememberedState?.[t]}pushExternal(e,{arrive:t,recede:s}){this.doPushState({...window.history.state},e),this.externalCallbacks=this.externalCallbacks.slice(0,this.counter),this.externalCallbacks[this.counter]={arrive:t,recede:s},t()}pushState(e,t,s=null){V||(this.current[e]=t,M.add(()=>this.getFramesData(this.current,t.encryptHistory).then(i=>{let n=()=>{this.doPushState({frames:i,changedFrames:[e]},this.preserveUrl?window.location.href:t.url),s&&s()};Re?setTimeout(n):n()})))}removeFrame(e){delete this.current[e]}getFramesData(e,t){return new Promise(s=>t?ye(e).then(s):s(e))}processQueue(){return M.process()}decrypt(e=null){if(V)return Promise.resolve(e??u.asFrames());let t=e??window.history.state?.frames;return this.decryptPageData(t).then(s=>{if(!s)throw new Error("Unable to decrypt history");return this.initialState===null?this.initialState=s??void 0:this.current=s??{},s})}decryptPageData(e){return e instanceof ArrayBuffer?we(e):Promise.resolve(e)}saveScrollPositions(e){M.add(()=>Promise.resolve().then(()=>{window.history.state?.frames&&this.doReplaceState({frames:window.history.state.frames,scrollRegions:e})}))}saveDocumentScrollPosition(e){M.add(()=>Promise.resolve().then(()=>{window.history.state?.frames&&this.doReplaceState({...window.history.state,documentScrollPosition:e})}))}getScrollRegions(){return window.history.state?.scrollRegions||[]}getDocumentScrollPosition(){return window.history.state?.documentScrollPosition||{top:0,left:0}}replaceState(e,t,s=null){u.for(e).currentPage.merge(t),!V&&(this.current[e]=u.for(e).currentPage.get(),this.getFramesData(this.current,t.encryptHistory).then(i=>{let n=()=>{let a=window.history.state?.changedFrames||[];a.includes(e)||a.push(e),this.doReplaceState({frames:i,changedFrames:a},this.preserveUrl?window.location.href:t.url),s&&s()};Re?setTimeout(n):n()}))}doReplaceState(e,t){window.history.replaceState({...window.history.state,...e},"",t),this.lastChangedFrames=window.history.state.changedFrames||[]}doPushState(e,t){this.lastChangedFrames=e.changedFrames||[],window.history.pushState({...e,c:++this.counter},"",t)}getState(e,t){return this.current?._top?.[e]??t}deleteState(e){this.current._top?.[e]!==void 0&&(delete this.current._top[e],this.replaceState("_top",this.current._top))}hasAnyState(){return!!this.getAllState()}clear(){m.remove(F.key),m.remove(F.iv)}setCurrent(e,t){this.current[e]=t}isValidState(e){return!!e.frames}getAllState(){return this.current._top}};typeof window<"u"&&window.history.scrollRestoration&&(window.history.scrollRestoration="manual");var o=new ee;var b=class{static save(){o.saveScrollPositions(Array.from(this.regions()).map(e=>({top:e.scrollTop,left:e.scrollLeft})))}static regions(){return document.querySelectorAll("[scroll-region]")}static reset(e){e=="_top"&&typeof window<"u"&&window.scrollTo(0,0),this.regions().forEach(t=>{typeof t.scrollTo=="function"?t.scrollTo(0,0):(t.scrollTop=0,t.scrollLeft=0)}),this.save(),window.location.hash&&setTimeout(()=>document.getElementById(window.location.hash.slice(1))?.scrollIntoView())}static restore(e){this.restoreDocument(),this.regions().forEach((t,s)=>{let i=e[s];i&&(typeof t.scrollTo=="function"?t.scrollTo(i.left,i.top):(t.scrollTop=i.top,t.scrollLeft=i.left))})}static restoreDocument(){let e=o.getDocumentScrollPosition();typeof window<"u"&&window.scrollTo(e.left,e.top)}static onScroll(e){let t=e.target;typeof t.hasAttribute=="function"&&t.hasAttribute("scroll-region")&&this.save()}static onWindowScroll(){o.saveDocumentScrollPosition({top:window.scrollY,left:window.scrollX})}};import{merge as je}from"es-toolkit";import*as G from"qs";function N(r){return r instanceof File||r instanceof Blob||r instanceof FileList&&r.length>0||r instanceof FormData&&Array.from(r.values()).some(e=>N(e))||typeof r=="object"&&r!==null&&Object.values(r).some(e=>N(e))}var te=r=>r instanceof FormData;function re(r,e=new FormData,t=null){r=r||{};for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&Te(e,xe(t,s),r[s]);return e}function xe(r,e){return r?r+"["+e+"]":e}function Te(r,e,t){if(Array.isArray(t))return Array.from(t.keys()).forEach(s=>Te(r,xe(e,s.toString()),t[s]));if(t instanceof Date)return r.append(e,t.toISOString());if(t instanceof File)return r.append(e,t,t.name);if(t instanceof Blob)return r.append(e,t);if(typeof t=="boolean")return r.append(e,t?"1":"0");if(typeof t=="string")return r.append(e,t);if(typeof t=="number")return r.append(e,`${t}`);if(t==null)return r.append(e,"");re(t,r,e)}function y(r){return new URL(r.toString(),typeof window>"u"?void 0:window.location.toString())}var qe=(r,e,t,s,i)=>{let n=typeof r=="string"?y(r):r;if((N(e)||s)&&!te(e)&&(e=re(e)),te(e))return[n,e];let[a,d]=Fe(t,n,e,i);return[y(a),d]};function Fe(r,e,t,s="brackets"){let i=/^https?:\/\//.test(e.toString()),n=i||e.toString().startsWith("/"),a=!n&&!e.toString().startsWith("#")&&!e.toString().startsWith("?"),d=e.toString().includes("?")||r==="get"&&Object.keys(t).length,p=e.toString().includes("#"),c=new URL(e.toString(),"http://localhost");return r==="get"&&Object.keys(t).length&&(c.search=G.stringify(je(G.parse(c.search,{ignoreQueryPrefix:!0}),t),{encodeValuesOnly:!0,arrayFormat:s}),t={}),[[i?`${c.protocol}//${c.host}`:"",n?c.pathname:"",a?c.pathname.substring(1):"",d?c.search:"",p?c.hash:""].join(""),t]}function k(r){return r=new URL(r.href),r.hash="",r}var se=(r,e)=>{r.hash&&!e.hash&&k(r).href===e.href&&(e.hash=r.hash)},O=(r,e)=>k(r).href===k(e).href;var ie=class{constructor(){this.internalListeners=[]}init(){typeof window<"u"&&(window.addEventListener("popstate",e=>setTimeout(this.handlePopstateEvent.bind(this,e))),window.addEventListener("scroll",A(b.onWindowScroll.bind(b),100),!0)),typeof document<"u"&&document.addEventListener("scroll",A(b.onScroll.bind(b),100),!0)}onGlobalEvent(e,t,s){let i=n=>{let a=s(n);n.cancelable&&!n.defaultPrevented&&a===!1&&n.preventDefault()};return this.registerListener(`inertia:${e}:${t}`,i)}on(e,t){return this.internalListeners.push({event:e,listener:t}),()=>{this.internalListeners=this.internalListeners.filter(s=>s.listener!==t)}}onMissingHistoryItem(){u.for("_top").currentPage.clear(),this.fireInternalEvent("missingHistoryItem")}fireInternalEvent(e){this.internalListeners.filter(t=>t.event===e).forEach(t=>t.listener())}registerListener(e,t){return document.addEventListener(e,t),()=>document.removeEventListener(e,t)}handlePopstateEvent(e){let t=e.state||null;if(e.skipInertia)return;if(t===null){let n=y(u.for("_top").currentPage.get().url);n.hash=window.location.hash,o.replaceState("_top",{...u.for("_top").currentPage.get(),url:n.href}),b.reset("_top");return}if(!o.isValidState(t))return this.onMissingHistoryItem();let s=[],i=!1;(!t.c||t.c<o.counter)&&(s=o.lastChangedFrames||[],o.externalCallbacks[o.counter]&&(o.externalCallbacks[o.counter]?.recede(),i=!0)),t.c>o.counter&&(s=window.history.state?.changedFrames||[],o.externalCallbacks[t.c]&&(o.externalCallbacks[t.c]?.arrive(),i=!0)),o.counter=t.c||0,o.lastChangedFrames=t.changedFrames||[],!i&&o.decrypt(t.frames).then(n=>{let a=s.map(async d=>{if(!n[d])return;let p=u.for(d)?.currentPage;p&&(await p.setQuietly(n[d],{preserveState:!1}),R(p.get(),d))});Promise.all(a).then(()=>{b.restore(o.getScrollRegions())})}).catch(()=>{this.onMissingHistoryItem()})}},w=new ie;var ne=class{constructor(){this.type=this.resolveType()}resolveType(){return typeof window>"u"?"navigate":window.performance&&window.performance.getEntriesByType&&window.performance.getEntriesByType("navigation").length>0?window.performance.getEntriesByType("navigation")[0].type:"navigate"}get(){return this.type}isBackForward(){return this.type==="back_forward"}isReload(){return this.type==="reload"}},B=new ne;var K=class{static handle(){this.clearRememberedStateOnReload(),[this.handleBackForward,this.handleLocation,this.handleDefault].find(t=>t.bind(this)())}static clearRememberedStateOnReload(){B.isReload()&&o.deleteState(o.rememberedState)}static handleBackForward(){if(!B.isBackForward()||!o.hasAnyState())return!1;let e=u.for("_top").currentPage,t=o.getScrollRegions();return o.decrypt().then(s=>{u.set(s,{preserveScroll:!0,preserveState:!0}).then(()=>{b.restore(t),R(e.get(),"_top")})}).catch(()=>{w.onMissingHistoryItem()}),!0}static handleLocation(){if(!m.exists(m.locationVisitKey))return!1;let e=m.get(m.locationVisitKey)||{};m.remove(m.locationVisitKey);let t=u.for("_top").currentPage;return typeof window<"u"&&t.setUrlHash(window.location.hash),o.decrypt(u.asFrames()).then(()=>{let s=o.getState(o.rememberedState,{}),i=o.getScrollRegions();t.remember(s),t.set(t.get(),{preserveScroll:e.preserveScroll,preserveState:!0}).then(()=>{e.preserveScroll&&b.restore(i),R(t.get(),"_top")})}).catch(()=>{w.onMissingHistoryItem()}),!0}static handleDefault(){let e=u.for("_top").currentPage;typeof window<"u"&&e.setUrlHash(window.location.hash),e.set(e.get(),{preserveScroll:!0,preserveState:!0}).then(()=>{B.isReload()&&b.restore(o.getScrollRegions()),R(e.get(),"_top")})}};var _=class{constructor({name:e,initialPage:t,swapComponent:s,resolveComponent:i}){this.componentId={};this.listeners=[];this.isFirstPageLoad=!0;this.cleared=!1;return this.name=e,this.page=t,this.swapComponent=s,this.resolveComponent=i,this}set(e,{replace:t=!1,preserveScroll:s=!1,preserveState:i=!1,preserveUrl:n=!1}={}){this.componentId={};let a=this.componentId;return e.clearHistory&&o.clear(),this.resolve(e.component).then(d=>{if(a!==this.componentId)return;let p=typeof window<"u"?window.location:new URL(e.url);return t=t||!n&&O(y(e.url),p),new Promise(c=>{t?o.replaceState(this.name,e,()=>c(null)):o.pushState(this.name,e,()=>c(null))}).then(()=>{let c=!this.isTheSame(e);return this.page=e,this.cleared=!1,c&&this.fireEventsFor("newComponent"),this.isFirstPageLoad&&this.fireEventsFor("firstLoad"),this.isFirstPageLoad=!1,this.swap({component:d,page:e,preserveState:i}).then(()=>{s||b.reset(this.name),w.fireInternalEvent(`${this.name}:loadDeferredProps`),t||R(e,this.name)})})})}setQuietly(e,{preserveState:t=!1}={}){return this.resolve(e.component).then(s=>(this.page=e,this.cleared=!1,o.setCurrent(this.name,e),this.swap({component:s,page:e,preserveState:t})))}clear(){this.cleared=!0}isCleared(){return this.cleared}get(){return this.page}merge(e){this.page={...this.page,...e}}setUrlHash(e){this.page.url.includes(e)||(this.page.url+=e)}remember(e){this.page.rememberedState=e}swap({component:e,page:t,preserveState:s}){return this.swapComponent({component:e,page:t,preserveState:s})}resolve(e){return Promise.resolve(this.resolveComponent(e))}isTheSame(e){return this.page.component===e.component}on(e,t){return this.listeners.push({event:e,callback:t}),()=>{this.listeners=this.listeners.filter(s=>s.event!==e&&s.callback!==t)}}fireEventsFor(e){this.listeners.filter(t=>t.event===e).forEach(t=>t.callback())}};var j=class{constructor(e,t,s){this.id=null;this.throttle=!1;this.keepAlive=!1;this.cbCount=0;this.keepAlive=s.keepAlive??!1,this.cb=t,this.interval=e,(s.autoStart??!0)&&this.start()}stop(){this.id&&clearInterval(this.id)}start(){typeof window>"u"||(this.stop(),this.id=window.setInterval(()=>{(!this.throttle||this.cbCount%10===0)&&this.cb(),this.throttle&&this.cbCount++},this.interval))}isInBackground(e){this.throttle=this.keepAlive?!1:e,this.throttle&&(this.cbCount=0)}};var oe=class{constructor(){this.polls=[];this.setupVisibilityListener()}add(e,t,s){let i=new j(e,t,s);return this.polls.push(i),{stop:()=>i.stop(),start:()=>i.start()}}clear(){this.polls.forEach(e=>e.stop()),this.polls=[]}setupVisibilityListener(){typeof document>"u"||document.addEventListener("visibilitychange",()=>{this.polls.forEach(e=>e.isInBackground(document.hidden))},!1)}},Ce=new oe;var ae=(r,e,t)=>{if(r===e)return!0;for(let s in r)if(!t.includes(s)&&r[s]!==e[s]&&!We(r[s],e[s]))return!1;return!0},We=(r,e)=>{switch(typeof r){case"object":return ae(r,e,[]);case"function":return r.toString()===e.toString();default:return r===e}};var Xe={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},le=r=>{if(typeof r=="number")return r;for(let[e,t]of Object.entries(Xe))if(r.endsWith(e))return parseFloat(r)*t;return parseInt(r)};var ce=class{constructor(){this.cached=[];this.inFlightRequests=[];this.removalTimers=[];this.currentUseId=null}add(e,t,{cacheFor:s}){if(this.findInFlight(e))return Promise.resolve();let n=this.findCached(e);if(!e.fresh&&n&&n.staleTimestamp>Date.now())return Promise.resolve();let[a,d]=this.extractStaleValues(s),p=new Promise((c,l)=>{t({...e,onCancel:()=>{this.remove(e),e.onCancel(),l()},onError:g=>{this.remove(e),e.onError(g,e.frame),l()},onPrefetching(g){e.onPrefetching(g)},onPrefetched(g,q){e.onPrefetched(g,q)},onPrefetchResponse(g){c(g)}})}).then(c=>(this.remove(e),this.cached.push({params:{...e},staleTimestamp:Date.now()+a,response:p,singleUse:s===0,timestamp:Date.now(),inFlight:!1}),this.scheduleForRemoval(e,d),this.inFlightRequests=this.inFlightRequests.filter(l=>!this.paramsAreEqual(l.params,e)),c.handlePrefetch(),c));return this.inFlightRequests.push({params:{...e},response:p,staleTimestamp:null,inFlight:!0}),p}removeAll(){this.cached=[],this.removalTimers.forEach(e=>{clearTimeout(e.timer)}),this.removalTimers=[]}remove(e){this.cached=this.cached.filter(t=>!this.paramsAreEqual(t.params,e)),this.clearTimer(e)}extractStaleValues(e){let[t,s]=this.cacheForToStaleAndExpires(e);return[le(t),le(s)]}cacheForToStaleAndExpires(e){if(!Array.isArray(e))return[e,e];switch(e.length){case 0:return[0,0];case 1:return[e[0],e[0]];default:return[e[0],e[1]]}}clearTimer(e){let t=this.removalTimers.find(s=>this.paramsAreEqual(s.params,e));t&&(clearTimeout(t.timer),this.removalTimers=this.removalTimers.filter(s=>s!==t))}scheduleForRemoval(e,t){if(!(typeof window>"u")&&(this.clearTimer(e),t>0)){let s=window.setTimeout(()=>this.remove(e),t);this.removalTimers.push({params:e,timer:s})}}get(e){return this.findCached(e)||this.findInFlight(e)}use(e,t){let s=`${t.url.pathname}-${Date.now()}-${Math.random().toString(36).substring(7)}`;return this.currentUseId=s,e.response.then(i=>{if(this.currentUseId===s)return i.mergeParams({...t,onPrefetched:()=>{}}),this.removeSingleUseItems(t),i.handle()})}removeSingleUseItems(e){this.cached=this.cached.filter(t=>this.paramsAreEqual(t.params,e)?!t.singleUse:!0)}findCached(e){return this.cached.find(t=>this.paramsAreEqual(t.params,e))||null}findInFlight(e){return this.inFlightRequests.find(t=>this.paramsAreEqual(t.params,e))||null}paramsAreEqual(e,t){return ae(e,t,["showProgress","replace","prefetch","onBefore","onStart","onProgress","onFinish","onCancel","onSuccess","onError","onPrefetched","onCancelToken","onPrefetching","async"])}},x=new ce;import{default as Ve}from"axios";var W=class r{constructor(e){this.callbacks=[];if(!e.prefetch)this.params=e;else{let t={onBefore:this.wrapCallback(e,"onBefore"),onStart:this.wrapCallback(e,"onStart"),onProgress:this.wrapCallback(e,"onProgress"),onFinish:this.wrapCallback(e,"onFinish"),onCancel:this.wrapCallback(e,"onCancel"),onSuccess:this.wrapCallback(e,"onSuccess"),onError:this.wrapCallback(e,"onError"),onCancelToken:this.wrapCallback(e,"onCancelToken"),onPrefetched:this.wrapCallback(e,"onPrefetched"),onPrefetching:this.wrapCallback(e,"onPrefetching")};this.params={...e,...t,onPrefetchResponse:e.onPrefetchResponse||(()=>{})}}}static create(e){return new r(e)}data(){return this.params.method==="get"?null:this.params.data}queryParams(){return this.params.method==="get"?this.params.data:{}}isPartial(){return this.params.only.length>0||this.params.except.length>0||this.params.reset.length>0}onCancelToken(e){this.params.onCancelToken({cancel:e})}markAsFinished(){this.params.completed=!0,this.params.cancelled=!1,this.params.interrupted=!1}markAsCancelled({cancelled:e=!0,interrupted:t=!1}){this.params.onCancel(),this.params.completed=!1,this.params.cancelled=e,this.params.interrupted=t}wasCancelledAtAll(){return this.params.cancelled||this.params.interrupted}onFinish(){this.params.onFinish(this.params)}onStart(){this.params.onStart(this.params)}onPrefetching(){this.params.onPrefetching(this.params)}onPrefetchResponse(e){this.params.onPrefetchResponse&&this.params.onPrefetchResponse(e)}all(){return this.params}headers(){let e={...this.params.headers};this.isPartial()&&(e["X-Inertia-Partial-Component"]=u.for(this.all().frame).currentPage.get().component);let t=this.params.only.concat(this.params.reset);return t.length>0&&(e["X-Inertia-Partial-Data"]=t.join(",")),this.params.except.length>0&&(e["X-Inertia-Partial-Except"]=this.params.except.join(",")),this.params.reset.length>0&&(e["X-Inertia-Reset"]=this.params.reset.join(",")),this.params.errorBag&&this.params.errorBag.length>0&&(e["X-Inertia-Error-Bag"]=this.params.errorBag),e}setPreserveOptions(e){this.params.preserveScroll=this.resolvePreserveOption(this.params.preserveScroll,e),this.params.preserveState=this.resolvePreserveOption(this.params.preserveState,e)}runCallbacks(){this.callbacks.forEach(({name:e,args:t})=>{this.params[e](...t)})}merge(e){this.params={...this.params,...e}}wrapCallback(e,t){return(...s)=>{this.recordCallback(t,s),e[t](...s)}}recordCallback(e,t){this.callbacks.push({name:e,args:t})}resolvePreserveOption(e,t){return typeof e=="function"?e(t):e==="errors"?Object.keys(t.props.errors||{}).length>0:e}};var Ae={modal:null,listener:null,show(r){typeof r=="object"&&(r=`All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.<hr>${JSON.stringify(r)}`);let e=document.createElement("html");e.innerHTML=r,e.querySelectorAll("a").forEach(s=>s.setAttribute("target","_top")),this.modal=document.createElement("div"),this.modal.style.position="fixed",this.modal.style.width="100vw",this.modal.style.height="100vh",this.modal.style.padding="50px",this.modal.style.boxSizing="border-box",this.modal.style.backgroundColor="rgba(0, 0, 0, .6)",this.modal.style.zIndex=2e5,this.modal.addEventListener("click",()=>this.hide());let t=document.createElement("iframe");if(t.style.backgroundColor="white",t.style.borderRadius="5px",t.style.width="100%",t.style.height="100%",this.modal.appendChild(t),document.body.prepend(this.modal),document.body.style.overflow="hidden",!t.contentWindow)throw new Error("iframe not yet ready.");t.contentWindow.document.open(),t.contentWindow.document.write(e.outerHTML),t.contentWindow.document.close(),this.listener=this.hideOnEscape.bind(this),document.addEventListener("keydown",this.listener)},hide(){this.modal.outerHTML="",this.modal=null,document.body.style.overflow="visible",document.removeEventListener("keydown",this.listener)},hideOnEscape(r){r.keyCode===27&&this.hide()}};var Qe=new C,U=class r{constructor(e,t,s){this.requestParams=e;this.response=t;this.originatingPage=s}static create(e,t,s){return new r(e,t,s)}async handlePrefetch(){O(this.requestParams.all().url,window.location)&&this.handle()}async handle(){return Qe.add(()=>this.process())}async process(){if(this.requestParams.all().prefetch)return this.requestParams.all().prefetch=!1,this.requestParams.all().onPrefetched(this.response,this.requestParams.all()),be(this.response,this.requestParams.all()),Promise.resolve();if(this.requestParams.runCallbacks(),!this.isInertiaResponse())return this.handleNonInertiaResponse();await o.processQueue(),o.preserveUrl=this.requestParams.all().preserveUrl,await this.setPage();let e=this.response.headers["x-inertia-frame"]||this.requestParams.all().frame,t=u.for(e).currentPage,s=t.get().props.errors||{};if(Object.keys(s).length>0){let i=this.getScopedErrors(s);return de(i,e),this.requestParams.all().onError(i,e)}ve(t.get(),e),await this.requestParams.all().onSuccess(t.get(),e),o.preserveUrl=!1}mergeParams(e){this.requestParams.merge(e)}async handleNonInertiaResponse(){if(this.isLocationVisit()){let t=y(this.getHeader("x-inertia-location"));return se(this.requestParams.all().url,t),this.locationVisit(t)}let e={...this.response,data:this.getDataFromResponse(this.response.data)};if(me(e,this.requestParams.all().frame))return Ae.show(e.data)}isInertiaResponse(){return this.hasHeader("x-inertia")}hasStatus(e){return this.response.status===e}getHeader(e){return this.response.headers[e]}hasHeader(e){return this.getHeader(e)!==void 0}isLocationVisit(){return this.hasStatus(409)&&this.hasHeader("x-inertia-location")}locationVisit(e){try{if(m.set(m.locationVisitKey,{preserveScroll:this.requestParams.all().preserveScroll===!0}),typeof window>"u")return;O(window.location,e)?window.location.reload():window.location.href=e.href}catch{return!1}}async setPage(){let e=this.getDataFromResponse(this.response.data);if(!this.shouldSetPage(e))return Promise.resolve();let t=this.response.headers["x-inertia-frame"]||this.requestParams.all().frame,s=u.for(t).currentPage;return this.mergeProps(e),await this.setRememberedState(e),this.requestParams.setPreserveOptions(e),s.set(e,{replace:this.requestParams.all().replace,preserveScroll:this.requestParams.all().preserveScroll,preserveState:this.requestParams.all().preserveState,preserveUrl:this.requestParams.all().preserveUrl})}getDataFromResponse(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}shouldSetPage(e){if(!this.requestParams.all().async||this.originatingPage.component!==e.component)return!0;let t=u.for(this.requestParams.all().frame).currentPage;if(this.originatingPage.component!==t.get().component)return!1;let s=y(this.originatingPage.url),i=y(t.get().url);return s.origin===i.origin&&s.pathname===i.pathname}pageUrl(e){let t=y(e.url);return se(this.requestParams.all().url,t),t.pathname+t.search+t.hash}mergeProps(e){let t=u.for(this.requestParams.all().frame).currentPage;if(!this.requestParams.isPartial()||e.component!==t.get().component)return;let s=e.mergeProps||[],i=e.deepMergeProps||[];s.forEach(n=>{let a=e.props[n];Array.isArray(a)?e.props[n]=[...t.get().props[n]||[],...a]:typeof a=="object"&&a!==null&&(e.props[n]={...t.get().props[n]||[],...a})}),i.forEach(n=>{let a=e.props[n],d=t.get().props[n],p=(c,l)=>Array.isArray(l)?[...Array.isArray(c)?c:[],...l]:typeof l=="object"&&l!==null?Object.keys(l).reduce((g,q)=>(g[q]=p(c?c[q]:void 0,l[q]),g),{...c}):l;e.props[n]=p(d,a)}),e.props={...t.get().props,...e.props}}async setRememberedState(e){let t=await o.getState(o.rememberedState,{}),s=u.for(this.requestParams.all().frame).currentPage;this.requestParams.all().preserveState&&t&&e.component===s.get().component&&(e.rememberedState=t)}getScopedErrors(e){return this.requestParams.all().errorBag?e[this.requestParams.all().errorBag||""]||{}:e}};var D=class r{constructor(e,t){this.page=t;this.requestHasFinished=!1;this.requestParams=W.create(e),this.cancelToken=new AbortController}static create(e,t){return new r(e,t)}async send(){this.requestParams.onCancelToken(()=>this.cancel({cancelled:!0})),ge(this.requestParams.all()),this.requestParams.onStart(),this.requestParams.all().prefetch&&(this.requestParams.onPrefetching(),Pe(this.requestParams.all()));let e=this.requestParams.all().prefetch;return Ve({method:this.requestParams.all().method,url:k(this.requestParams.all().url).href,data:this.requestParams.data(),params:this.requestParams.queryParams(),signal:this.cancelToken.signal,headers:this.getHeaders(),onUploadProgress:this.onProgress.bind(this),responseType:"text"}).then(t=>(this.response=U.create(this.requestParams,t,this.page),this.response.handle())).catch(t=>t?.response?(this.response=U.create(this.requestParams,t.response,this.page),this.response.handle()):Promise.reject(t)).catch(t=>{if(!Ve.isCancel(t)&&pe(t,this.requestParams.all().frame))return Promise.reject(t)}).finally(()=>{this.finish(),e&&this.response&&this.requestParams.onPrefetchResponse(this.response)})}finish(){this.requestParams.wasCancelledAtAll()||(this.requestParams.markAsFinished(),this.fireFinishEvents())}fireFinishEvents(){this.requestHasFinished||(this.requestHasFinished=!0,he(this.requestParams.all()),this.requestParams.onFinish())}cancel({cancelled:e=!1,interrupted:t=!1}){this.requestHasFinished||(this.cancelToken.abort(),this.requestParams.markAsCancelled({cancelled:e,interrupted:t}),this.fireFinishEvents())}onProgress(e){this.requestParams.data()instanceof FormData&&(e.percentage=e.progress?Math.round(e.progress*100):0,fe(e,this.requestParams.all().frame),this.requestParams.all().onProgress(e,this.requestParams.all().frame))}getHeaders(){let e={...this.requestParams.headers(),Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0},t=u.for("_top").currentPage.get(),s=u.for(this.requestParams.all().frame).currentPage.get();return t.version&&(e["X-Inertia-Version"]=t.version),s.url&&(e["X-Inertia-Frame-Src"]=s.url),e}};var H=class{constructor({maxConcurrent:e,interruptible:t}){this.requests=[];this.maxConcurrent=e,this.interruptible=t}send(e){this.requests.push(e),e.send().then(()=>{this.requests=this.requests.filter(t=>t!==e)})}interruptInFlight(){this.cancel({interrupted:!0},!1)}cancelInFlight(){this.cancel({cancelled:!0},!0)}cancel({cancelled:e=!1,interrupted:t=!1}={},s){if(!this.shouldCancel(s))return;this.requests.shift()?.cancel({interrupted:t,cancelled:e})}shouldCancel(e){return e?!0:this.interruptible&&this.requests.length>=this.maxConcurrent}};var I={},u=class{constructor({name:e,initialPage:t,resolveComponent:s,swapComponent:i}){this.syncRequestStream=new H({maxConcurrent:1,interruptible:!0});this.asyncRequestStream=new H({maxConcurrent:1/0,interruptible:!1});this.name=e,this.currentPage=new _({name:e,initialPage:t,resolveComponent:s,swapComponent:i}),I[e]=this,e=="_top"&&(K.handle(),w.init(),w.on("missingHistoryItem",()=>{typeof window<"u"&&this.visit(window.location.href,{preserveState:!0,preserveScroll:!0,replace:!0})})),w.on(`${e}:loadDeferredProps`,()=>{this.loadDeferredProps()})}static asFrames(){return Object.entries(I).reduce((e,[t,s])=>(e[t]=s.currentPage.get(),e),{})}static for(e){return I[e]}static setQuietly(e,{preserveState:t=!1}={}){return Promise.all(Object.entries(I).map(([s,i])=>e[s]?i.currentPage.setQuietly(e[s],{preserveState:t}):(console.log("no page for router",s),Promise.resolve())))}static set(e,{replace:t=!1,preserveScroll:s=!1,preserveState:i=!1}={}){return Promise.all(Object.entries(I).map(([n,a])=>a.currentPage.set(e[n],{replace:t,preserveScroll:s,preserveState:i})))}destroy(){this.cancelAll(),o.removeFrame(this.name),delete I[this.name]}get(e,t={},s={}){return this.visit(e,{...s,method:"get",data:t})}post(e,t={},s={}){return this.visit(e,{preserveState:!0,...s,method:"post",data:t})}put(e,t={},s={}){return this.visit(e,{preserveState:!0,...s,method:"put",data:t})}patch(e,t={},s={}){return this.visit(e,{preserveState:!0,...s,method:"patch",data:t})}delete(e,t={}){return this.visit(e,{preserveState:!0,...t,method:"delete"})}reload(e={}){if(!(typeof window>"u"))return this.visit(this.currentPage.get().url,{...e,preserveScroll:!0,preserveState:!0,async:!0,headers:{...e.headers||{},"Cache-Control":"no-cache"}})}remember(e,t="default"){o.remember(this.name,e,t)}restore(e="default"){return o.restore(this.name,e)}on(e,t){return typeof window>"u"?()=>{}:w.onGlobalEvent(this.name,e,t)}cancel(){this.syncRequestStream.cancelInFlight()}cancelAll(){this.asyncRequestStream.cancelInFlight(),this.syncRequestStream.cancelInFlight()}poll(e,t={},s={}){return Ce.add(e,()=>this.reload(t),{autoStart:s.autoStart??!0,keepAlive:s.keepAlive??!1})}visit(e,t={}){let s=this.getPendingVisit(e,{...t,showProgress:t.showProgress??!t.async}),i=this.getVisitEvents(t);if(i.onBefore(s)===!1||!Z(s))return;let n=s.async?this.asyncRequestStream:this.syncRequestStream;n.interruptInFlight(),!this.currentPage.isCleared()&&!s.preserveUrl&&b.save();let a={...s,...i},d=x.get(a);d?(X(d.inFlight),x.use(d,a)):(X(!0),n.send(D.create(a,this.currentPage.get())))}getCached(e,t={}){return x.findCached(this.getPrefetchParams(e,t))}flush(e,t={}){x.remove(this.getPrefetchParams(e,t))}flushAll(){x.removeAll()}getPrefetching(e,t={}){return x.findInFlight(this.getPrefetchParams(e,t))}prefetch(e,t={},{cacheFor:s=3e4}){if(t.method!=="get")throw new Error("Prefetch requests must use the GET method");let i=this.getPendingVisit(e,{...t,async:!0,showProgress:!1,prefetch:!0}),n=i.url.origin+i.url.pathname+i.url.search,a=window.location.origin+window.location.pathname+window.location.search;if(n===a)return;let d=this.getVisitEvents(t);if(d.onBefore(i)===!1||!Z(i))return;Q(),this.asyncRequestStream.interruptInFlight();let p={...i,...d};new Promise(l=>{let g=()=>{this.currentPage.get()?l():setTimeout(g,50)};g()}).then(()=>{x.add(p,l=>{this.asyncRequestStream.send(D.create(l,this.currentPage.get()))},{cacheFor:s})})}clearHistory(){o.clear()}static decryptHistory(){return o.decrypt()}replace(e){this.clientVisit(e,{replace:!0})}push(e){this.clientVisit(e)}clientVisit(e,{replace:t=!1}={}){let s=this.currentPage.get(),i=typeof e.props=="function"?e.props(s.props):e.props??s.props;this.currentPage.set({...s,...e,props:i},{replace:t,preserveScroll:e.preserveScroll,preserveState:e.preserveState})}getPrefetchParams(e,t){return{...this.getPendingVisit(e,{...t,async:!0,showProgress:!1,prefetch:!0}),...this.getVisitEvents(t)}}getPendingVisit(e,t,s={}){let i={method:"get",data:{},replace:this.name!=="_top",preserveUrl:this.name!=="_top",preserveScroll:!1,preserveState:!1,only:[],except:[],headers:{},errorBag:"",forceFormData:!1,queryStringArrayFormat:"brackets",async:!1,showProgress:!0,fresh:!1,reset:[],prefetch:!1,frame:this.name,...t},[n,a]=qe(e,i.data,i.method,i.forceFormData,i.queryStringArrayFormat);return{cancelled:!1,completed:!1,interrupted:!1,...i,...s,url:n,data:a}}getVisitEvents(e){return{onCancelToken:e.onCancelToken||(()=>{}),onBefore:e.onBefore||(()=>{}),onStart:e.onStart||(()=>{}),onProgress:e.onProgress||(()=>{}),onFinish:e.onFinish||(()=>{}),onCancel:e.onCancel||(()=>{}),onSuccess:e.onSuccess||(()=>{}),onError:e.onError||(()=>{}),onPrefetched:e.onPrefetched||(()=>{}),onPrefetching:e.onPrefetching||(()=>{})}}loadDeferredProps(){let e=this.currentPage.get()?.deferredProps;e&&Object.entries(e).forEach(([t,s])=>{this.reload({only:s})})}};var Je={buildDOMElement(r){let e=document.createElement("template");e.innerHTML=r;let t=e.content.firstChild;if(!r.startsWith("<script "))return t;let s=document.createElement("script");return s.innerHTML=t.innerHTML,t.getAttributeNames().forEach(i=>{s.setAttribute(i,t.getAttribute(i)||"")}),s},isInertiaManagedElement(r){return r.nodeType===Node.ELEMENT_NODE&&r.getAttribute("inertia")!==null},findMatchingElementIndex(r,e){let t=r.getAttribute("inertia");return t!==null?e.findIndex(s=>s.getAttribute("inertia")===t):-1},update:A(function(r){let e=r.map(s=>this.buildDOMElement(s));Array.from(document.head.childNodes).filter(s=>this.isInertiaManagedElement(s)).forEach(s=>{let i=this.findMatchingElementIndex(s,e);if(i===-1){s?.parentNode?.removeChild(s);return}let n=e.splice(i,1)[0];n&&!s.isEqualNode(n)&&s?.parentNode?.replaceChild(n,s)}),e.forEach(s=>document.head.appendChild(s))},1)};function ke(r,e,t){let s={},i=0;function n(){let l=i+=1;return s[l]=[],l.toString()}function a(l){l===null||Object.keys(s).indexOf(l)===-1||(delete s[l],c())}function d(l,g=[]){l!==null&&Object.keys(s).indexOf(l)>-1&&(s[l]=g),c()}function p(){let l=e(""),g={...l?{title:`<title inertia="">${l}</title>`}:{}},q=Object.values(s).reduce((S,E)=>S.concat(E),[]).reduce((S,E)=>{if(E.indexOf("<")===-1)return S;if(E.indexOf("<title ")===0){let $=E.match(/(<title [^>]+>)(.*?)(<\/title>)/);return S.title=$?`${$[1]}${e($[2])}${$[3]}`:E,S}let ue=E.match(/ inertia="[^"]+"/);return ue?S[ue[0]]=E:S[Object.keys(S).length]=E,S},g);return Object.values(q)}function c(){r?t(p()):Je.update(p())}return c(),{forceUpdate:c,createProvider:function(){let l=n();return{update:g=>d(l,g),disconnect:()=>a(l)}}}}var f="nprogress",v={minimum:.08,easing:"linear",positionUsing:"translate3d",speed:200,trickle:!0,trickleSpeed:200,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",color:"#29d",includeCSS:!0,template:['<div class="bar" role="bar">','<div class="peg"></div>',"</div>",'<div class="spinner" role="spinner">','<div class="spinner-icon"></div>',"</div>"].join("")},T=null,ze=r=>{Object.assign(v,r),v.includeCSS&&st(v.color)},z=r=>{let e=Ie();r=He(r,v.minimum,1),T=r===1?null:r;let t=Ze(!e),s=t.querySelector(v.barSelector),i=v.speed,n=v.easing;t.offsetWidth,rt(a=>{let d=v.positionUsing==="translate3d"?{transition:`all ${i}ms ${n}`,transform:`translate3d(${J(r)}%,0,0)`}:v.positionUsing==="translate"?{transition:`all ${i}ms ${n}`,transform:`translate(${J(r)}%,0)`}:{marginLeft:`${J(r)}%`};for(let p in d)s.style[p]=d[p];if(r!==1)return setTimeout(a,i);t.style.transition="none",t.style.opacity="1",t.offsetWidth,setTimeout(()=>{t.style.transition=`all ${i}ms linear`,t.style.opacity="0",setTimeout(()=>{De(),a()},i)},i)})},Ie=()=>typeof T=="number",Le=()=>{T||z(0);let r=function(){setTimeout(function(){T&&(Oe(),r())},v.trickleSpeed)};v.trickle&&r()},Ye=r=>{!r&&!T||(Oe(.3+.5*Math.random()),z(1))},Oe=r=>{let e=T;if(e===null)return Le();if(!(e>1))return r=typeof r=="number"?r:(()=>{let t={.1:[0,.2],.04:[.2,.5],.02:[.5,.8],.005:[.8,.99]};for(let s in t)if(e>=t[s][0]&&e<t[s][1])return parseFloat(s);return 0})(),z(He(e+r,0,.994))},Ze=r=>{if(et())return document.getElementById(f);document.documentElement.classList.add(`${f}-busy`);let e=document.createElement("div");e.id=f,e.innerHTML=v.template;let t=e.querySelector(v.barSelector),s=r?"-100":J(T||0),i=Ue();return t.style.transition="all 0 linear",t.style.transform=`translate3d(${s}%,0,0)`,v.showSpinner||e.querySelector(v.spinnerSelector)?.remove(),i!==document.body&&i.classList.add(`${f}-custom-parent`),i.appendChild(e),e},Ue=()=>tt(v.parent)?v.parent:document.querySelector(v.parent),De=()=>{document.documentElement.classList.remove(`${f}-busy`),Ue().classList.remove(`${f}-custom-parent`),document.getElementById(f)?.remove()},et=()=>document.getElementById(f)!==null,tt=r=>typeof HTMLElement=="object"?r instanceof HTMLElement:r&&typeof r=="object"&&r.nodeType===1&&typeof r.nodeName=="string";function He(r,e,t){return r<e?e:r>t?t:r}var J=r=>(-1+r)*100,rt=(()=>{let r=[],e=()=>{let t=r.shift();t&&t(e)};return t=>{r.push(t),r.length===1&&e()}})(),st=r=>{let e=document.createElement("style");e.textContent=`
|
|
1
|
+
function A(r,e){let t;return function(...s){clearTimeout(t),t=setTimeout(()=>r.apply(this,s),e)}}function h(r,e){return document.dispatchEvent(new CustomEvent(`inertia:${r}`,e))}var Z=r=>h("before",{cancelable:!0,detail:{visit:r}})&&h(`${r.frame}:before`,{cancelable:!0,detail:{visit:r}}),de=(r,e)=>h("error",{detail:{errors:r}})&&h(`${e}:error`,{detail:{errors:r}}),pe=(r,e)=>h("exception",{cancelable:!0,detail:{exception:r}})&&h(`${e}:exception`,{cancelable:!0,detail:{exception:r}}),he=r=>h("finish",{detail:{visit:r}})&&h(`${r.frame}:finish`,{detail:{visit:r}}),me=(r,e)=>h("invalid",{cancelable:!0,detail:{response:r}})&&h(`${e}:invalid`,{cancelable:!0,detail:{response:r}}),R=(r,e)=>h("navigate",{detail:{page:r}})&&h(`${e}:navigate`,{detail:{page:r}}),fe=(r,e)=>h("progress",{detail:{progress:r}})&&h(`${e}:progress`,{detail:{progress:r}}),ge=r=>h("start",{detail:{visit:r}})&&h(`${r.frame}:start`,{detail:{visit:r}}),ve=(r,e)=>h("success",{detail:{page:r}})&&h(`${e}:success`,{detail:{page:r}}),be=(r,e)=>h("prefetched",{detail:{fetchedAt:Date.now(),response:r.data,visit:e}})&&h(`${e.frame}:prefetched`,{detail:{fetchedAt:Date.now(),response:r.data,visit:e}}),Pe=r=>h("prefetching",{detail:{visit:r}})&&h(`${r.frame}:prefetching`,{detail:{visit:r}});var m=class{static set(e,t){typeof window<"u"&&window.sessionStorage.setItem(e,JSON.stringify(t))}static get(e){if(typeof window<"u")return JSON.parse(window.sessionStorage.getItem(e)||"null")}static merge(e,t){let s=this.get(e);s===null?this.set(e,t):this.set(e,{...s,...t})}static remove(e){typeof window<"u"&&window.sessionStorage.removeItem(e)}static removeNested(e,t){let s=this.get(e);s!==null&&(delete s[t],this.set(e,s))}static exists(e){try{return this.get(e)!==null}catch{return!1}}static clear(){typeof window<"u"&&window.sessionStorage.clear()}};m.locationVisitKey="inertiaLocationVisit";var ye=async r=>{if(typeof window>"u")throw new Error("Unable to encrypt history");let e=Se(),t=await Ee(),s=await _e(t);if(!s)throw new Error("Unable to encrypt history");return await Ne(e,s,r)},q={key:"historyKey",iv:"historyIv"},we=async r=>{let e=Se(),t=await Ee();if(!t)throw new Error("Unable to decrypt history");return await Ge(e,t,r)},Ne=async(r,e,t)=>{if(typeof window>"u")throw new Error("Unable to encrypt history");if(typeof window.crypto.subtle>"u")return console.warn("Encryption is not supported in this environment. SSL is required."),Promise.resolve(t);let s=new TextEncoder,i=JSON.stringify(t),n=new Uint8Array(i.length*3),a=s.encodeInto(i,n);return window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},e,n.subarray(0,a.written))},Ge=async(r,e,t)=>{if(typeof window.crypto.subtle>"u")return console.warn("Decryption is not supported in this environment. SSL is required."),Promise.resolve(t);let s=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:r},e,t);return JSON.parse(new TextDecoder().decode(s))},Se=()=>{let r=m.get(q.iv);if(r)return new Uint8Array(r);let e=window.crypto.getRandomValues(new Uint8Array(12));return m.set(q.iv,Array.from(e)),e},Be=async()=>typeof window.crypto.subtle>"u"?(console.warn("Encryption is not supported in this environment. SSL is required."),Promise.resolve(null)):window.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),Ke=async r=>{if(typeof window.crypto.subtle>"u")return console.warn("Encryption is not supported in this environment. SSL is required."),Promise.resolve();let e=await window.crypto.subtle.exportKey("raw",r);m.set(q.key,Array.from(new Uint8Array(e)))},_e=async r=>{if(r)return r;let e=await Be();return e?(await Ke(e),e):null},Ee=async()=>{let r=m.get(q.key);return r?await window.crypto.subtle.importKey("raw",new Uint8Array(r),{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]):null};var C=class{constructor(){this.items=[];this.processingPromise=null}add(e){return this.items.push(e),this.process()}process(){return this.processingPromise??(this.processingPromise=this.processNext().then(()=>{this.processingPromise=null})),this.processingPromise}processNext(){let e=this.items.shift();return e?Promise.resolve(e()).then(()=>this.processNext()):Promise.resolve()}};var V=typeof window>"u",M=new C,Re=!V&&/CriOS/.test(window.navigator.userAgent),ee=class{constructor(){this.rememberedState="rememberedState";this.scrollRegions="scrollRegions";this.preserveUrl=!1;this.counter=V?0:window.history.state?.c??0;this.externalCallbacks=[];this.lastChangedFrames=[];this.current={};this.initialState=null}remember(e,t,s){this.preserveUrl=!0,this.replaceState(e,{...this.current[e],rememberedState:{...this.current[e]?.rememberedState??{},[s]:t}})}restore(e,t){if(!V)return this.current?.[e]?.rememberedState?.[t]}pushExternal(e,{arrive:t,recede:s}){this.doPushState({...window.history.state},e),this.externalCallbacks=this.externalCallbacks.slice(0,this.counter),this.externalCallbacks[this.counter]={arrive:t,recede:s},t()}pushState(e,t,s=null){V||(this.current[e]=t,M.add(()=>this.getFramesData(this.current,t.encryptHistory).then(i=>{let n=()=>{this.doPushState({frames:i,changedFrames:[e]},this.preserveUrl?window.location.href:t.url),s&&s()};Re?setTimeout(n):n()})))}removeFrame(e){delete this.current[e]}getFramesData(e,t){return new Promise(s=>t?ye(e).then(s):s(e))}processQueue(){return M.process()}decrypt(e=null){if(V)return Promise.resolve(e??u.asFrames());let t=e??window.history.state?.frames;return this.decryptPageData(t).then(s=>{if(!s)throw new Error("Unable to decrypt history");return this.initialState===null?this.initialState=s??void 0:this.current=s??{},s})}decryptPageData(e){return e instanceof ArrayBuffer?we(e):Promise.resolve(e)}saveScrollPositions(e){M.add(()=>Promise.resolve().then(()=>{window.history.state?.frames&&this.doReplaceState({frames:window.history.state.frames,scrollRegions:e})}))}saveDocumentScrollPosition(e){M.add(()=>Promise.resolve().then(()=>{window.history.state?.frames&&this.doReplaceState({...window.history.state,documentScrollPosition:e})}))}getScrollRegions(){return window.history.state?.scrollRegions||[]}getDocumentScrollPosition(){return window.history.state?.documentScrollPosition||{top:0,left:0}}replaceState(e,t,s=null){u.for(e).currentPage.merge(t),!V&&(this.current[e]=u.for(e).currentPage.get(),this.getFramesData(this.current,t.encryptHistory).then(i=>{let n=()=>{let a=window.history.state?.changedFrames||[];a.includes(e)||a.push(e),this.doReplaceState({frames:i,changedFrames:a},this.preserveUrl?window.location.href:t.url),s&&s()};Re?setTimeout(n):n()}))}doReplaceState(e,t){window.history.replaceState({...window.history.state,...e},"",t),this.lastChangedFrames=window.history.state.changedFrames||[]}doPushState(e,t){this.lastChangedFrames=e.changedFrames||[],window.history.pushState({...e,c:++this.counter},"",t)}getState(e,t){return this.current?._top?.[e]??t}deleteState(e){this.current._top?.[e]!==void 0&&(delete this.current._top[e],this.replaceState("_top",this.current._top))}hasAnyState(){return!!this.getAllState()}clear(){m.remove(q.key),m.remove(q.iv)}setCurrent(e,t){this.current[e]=t}isValidState(e){return!!e.frames}getAllState(){return this.current._top}};typeof window<"u"&&window.history.scrollRestoration&&(window.history.scrollRestoration="manual");var o=new ee;var b=class{static save(){o.saveScrollPositions(Array.from(this.regions()).map(e=>({top:e.scrollTop,left:e.scrollLeft})))}static regions(){return document.querySelectorAll("[scroll-region]")}static reset(e){e=="_top"&&typeof window<"u"&&window.scrollTo(0,0),this.regions().forEach(t=>{typeof t.scrollTo=="function"?t.scrollTo(0,0):(t.scrollTop=0,t.scrollLeft=0)}),this.save(),window.location.hash&&setTimeout(()=>document.getElementById(window.location.hash.slice(1))?.scrollIntoView())}static restore(e){this.restoreDocument(),this.regions().forEach((t,s)=>{let i=e[s];i&&(typeof t.scrollTo=="function"?t.scrollTo(i.left,i.top):(t.scrollTop=i.top,t.scrollLeft=i.left))})}static restoreDocument(){let e=o.getDocumentScrollPosition();typeof window<"u"&&window.scrollTo(e.left,e.top)}static onScroll(e){let t=e.target;typeof t.hasAttribute=="function"&&t.hasAttribute("scroll-region")&&this.save()}static onWindowScroll(){o.saveDocumentScrollPosition({top:window.scrollY,left:window.scrollX})}};import{merge as je}from"es-toolkit";import*as G from"qs";function N(r){return r instanceof File||r instanceof Blob||r instanceof FileList&&r.length>0||r instanceof FormData&&Array.from(r.values()).some(e=>N(e))||typeof r=="object"&&r!==null&&Object.values(r).some(e=>N(e))}var te=r=>r instanceof FormData;function re(r,e=new FormData,t=null){r=r||{};for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&Te(e,xe(t,s),r[s]);return e}function xe(r,e){return r?r+"["+e+"]":e}function Te(r,e,t){if(Array.isArray(t))return Array.from(t.keys()).forEach(s=>Te(r,xe(e,s.toString()),t[s]));if(t instanceof Date)return r.append(e,t.toISOString());if(t instanceof File)return r.append(e,t,t.name);if(t instanceof Blob)return r.append(e,t);if(typeof t=="boolean")return r.append(e,t?"1":"0");if(typeof t=="string")return r.append(e,t);if(typeof t=="number")return r.append(e,`${t}`);if(t==null)return r.append(e,"");re(t,r,e)}function y(r){return new URL(r.toString(),typeof window>"u"?void 0:window.location.toString())}var Fe=(r,e,t,s,i)=>{let n=typeof r=="string"?y(r):r;if((N(e)||s)&&!te(e)&&(e=re(e)),te(e))return[n,e];let[a,d]=qe(t,n,e,i);return[y(a),d]};function qe(r,e,t,s="brackets"){let i=/^https?:\/\//.test(e.toString()),n=i||e.toString().startsWith("/"),a=!n&&!e.toString().startsWith("#")&&!e.toString().startsWith("?"),d=e.toString().includes("?")||r==="get"&&Object.keys(t).length,p=e.toString().includes("#"),c=new URL(e.toString(),"http://localhost");return r==="get"&&Object.keys(t).length&&(c.search=G.stringify(je(G.parse(c.search,{ignoreQueryPrefix:!0}),t),{encodeValuesOnly:!0,arrayFormat:s}),t={}),[[i?`${c.protocol}//${c.host}`:"",n?c.pathname:"",a?c.pathname.substring(1):"",d?c.search:"",p?c.hash:""].join(""),t]}function k(r){return r=new URL(r.href),r.hash="",r}var se=(r,e)=>{r.hash&&!e.hash&&k(r).href===e.href&&(e.hash=r.hash)},O=(r,e)=>k(r).href===k(e).href;var ie=class{constructor(){this.internalListeners=[]}init(){typeof window<"u"&&(window.addEventListener("popstate",e=>setTimeout(this.handlePopstateEvent.bind(this,e))),window.addEventListener("scroll",A(b.onWindowScroll.bind(b),100),!0)),typeof document<"u"&&document.addEventListener("scroll",A(b.onScroll.bind(b),100),!0)}onGlobalEvent(e,t,s){let i=n=>{let a=s(n);n.cancelable&&!n.defaultPrevented&&a===!1&&n.preventDefault()};return this.registerListener(`inertia:${e}:${t}`,i)}on(e,t){return this.internalListeners.push({event:e,listener:t}),()=>{this.internalListeners=this.internalListeners.filter(s=>s.listener!==t)}}onMissingHistoryItem(){u.for("_top").currentPage.clear(),this.fireInternalEvent("missingHistoryItem")}fireInternalEvent(e){this.internalListeners.filter(t=>t.event===e).forEach(t=>t.listener())}registerListener(e,t){return document.addEventListener(e,t),()=>document.removeEventListener(e,t)}handlePopstateEvent(e){let t=e.state||null;if(e.skipInertia)return;if(t===null){let n=y(u.for("_top").currentPage.get().url);n.hash=window.location.hash,o.replaceState("_top",{...u.for("_top").currentPage.get(),url:n.href}),b.reset("_top");return}if(!o.isValidState(t))return this.onMissingHistoryItem();let s=[],i=!1;(!t.c||t.c<o.counter)&&(s=o.lastChangedFrames||[],o.externalCallbacks[o.counter]&&(o.externalCallbacks[o.counter]?.recede(),i=!0)),t.c>o.counter&&(s=window.history.state?.changedFrames||[],o.externalCallbacks[t.c]&&(o.externalCallbacks[t.c]?.arrive(),i=!0)),o.counter=t.c||0,o.lastChangedFrames=t.changedFrames||[],!i&&o.decrypt(t.frames).then(n=>{let a=s.map(async d=>{if(!n[d])return;let p=u.for(d)?.currentPage;p&&(await p.setQuietly(n[d],{preserveState:!1}),R(p.get(),d))});Promise.all(a).then(()=>{b.restore(o.getScrollRegions())})}).catch(()=>{this.onMissingHistoryItem()})}},w=new ie;var ne=class{constructor(){this.type=this.resolveType()}resolveType(){return typeof window>"u"?"navigate":window.performance&&window.performance.getEntriesByType&&window.performance.getEntriesByType("navigation").length>0?window.performance.getEntriesByType("navigation")[0].type:"navigate"}get(){return this.type}isBackForward(){return this.type==="back_forward"}isReload(){return this.type==="reload"}},B=new ne;var K=class{static handle(){this.clearRememberedStateOnReload(),[this.handleBackForward,this.handleLocation,this.handleDefault].find(t=>t.bind(this)())}static clearRememberedStateOnReload(){B.isReload()&&o.deleteState(o.rememberedState)}static handleBackForward(){if(!B.isBackForward()||!o.hasAnyState())return!1;let e=u.for("_top").currentPage,t=o.getScrollRegions();return o.decrypt().then(s=>{u.set(s,{preserveScroll:!0,preserveState:!0}).then(()=>{b.restore(t),R(e.get(),"_top")})}).catch(()=>{w.onMissingHistoryItem()}),!0}static handleLocation(){if(!m.exists(m.locationVisitKey))return!1;let e=m.get(m.locationVisitKey)||{};m.remove(m.locationVisitKey);let t=u.for("_top").currentPage;return typeof window<"u"&&t.setUrlHash(window.location.hash),o.decrypt(u.asFrames()).then(()=>{let s=o.getState(o.rememberedState,{}),i=o.getScrollRegions();t.remember(s),t.set(t.get(),{preserveScroll:e.preserveScroll,preserveState:!0}).then(()=>{e.preserveScroll&&b.restore(i),R(t.get(),"_top")})}).catch(()=>{w.onMissingHistoryItem()}),!0}static handleDefault(){let e=u.for("_top").currentPage;typeof window<"u"&&e.setUrlHash(window.location.hash),e.set(e.get(),{preserveScroll:!0,preserveState:!0}).then(()=>{B.isReload()&&b.restore(o.getScrollRegions()),R(e.get(),"_top")})}};var _=class{constructor({name:e,initialPage:t,swapComponent:s,resolveComponent:i}){this.componentId={};this.listeners=[];this.isFirstPageLoad=!0;this.cleared=!1;return this.name=e,this.page=t,this.swapComponent=s,this.resolveComponent=i,this}set(e,{replace:t=!1,preserveScroll:s=!1,preserveState:i=!1,preserveUrl:n=!1}={}){this.componentId={};let a=this.componentId;return e.clearHistory&&o.clear(),this.resolve(e.component).then(d=>{if(a!==this.componentId)return;let p=typeof window<"u"?window.location:new URL(e.url);return t=t||!n&&O(y(e.url),p),new Promise(c=>{t?o.replaceState(this.name,e,()=>c(null)):o.pushState(this.name,e,()=>c(null))}).then(()=>{let c=!this.isTheSame(e);return this.page=e,this.cleared=!1,c&&this.fireEventsFor("newComponent"),this.isFirstPageLoad&&this.fireEventsFor("firstLoad"),this.isFirstPageLoad=!1,this.swap({component:d,page:e,preserveState:i}).then(()=>{s||b.reset(this.name),w.fireInternalEvent(`${this.name}:loadDeferredProps`),t||R(e,this.name)})})})}setQuietly(e,{preserveState:t=!1}={}){return this.resolve(e.component).then(s=>(this.page=e,this.cleared=!1,o.setCurrent(this.name,e),this.swap({component:s,page:e,preserveState:t})))}clear(){this.cleared=!0}isCleared(){return this.cleared}get(){return this.page}merge(e){this.page={...this.page,...e}}setUrlHash(e){this.page.url.includes(e)||(this.page.url+=e)}remember(e){this.page.rememberedState=e}swap({component:e,page:t,preserveState:s}){return this.swapComponent({component:e,page:t,preserveState:s})}resolve(e){return Promise.resolve(this.resolveComponent(e))}isTheSame(e){return this.page.component===e.component}on(e,t){return this.listeners.push({event:e,callback:t}),()=>{this.listeners=this.listeners.filter(s=>s.event!==e&&s.callback!==t)}}fireEventsFor(e){this.listeners.filter(t=>t.event===e).forEach(t=>t.callback())}};var j=class{constructor(e,t,s){this.id=null;this.throttle=!1;this.keepAlive=!1;this.cbCount=0;this.keepAlive=s.keepAlive??!1,this.cb=t,this.interval=e,(s.autoStart??!0)&&this.start()}stop(){this.id&&clearInterval(this.id)}start(){typeof window>"u"||(this.stop(),this.id=window.setInterval(()=>{(!this.throttle||this.cbCount%10===0)&&this.cb(),this.throttle&&this.cbCount++},this.interval))}isInBackground(e){this.throttle=this.keepAlive?!1:e,this.throttle&&(this.cbCount=0)}};var oe=class{constructor(){this.polls=[];this.setupVisibilityListener()}add(e,t,s){let i=new j(e,t,s);return this.polls.push(i),{stop:()=>i.stop(),start:()=>i.start()}}clear(){this.polls.forEach(e=>e.stop()),this.polls=[]}setupVisibilityListener(){typeof document>"u"||document.addEventListener("visibilitychange",()=>{this.polls.forEach(e=>e.isInBackground(document.hidden))},!1)}},Ce=new oe;var ae=(r,e,t)=>{if(r===e)return!0;for(let s in r)if(!t.includes(s)&&r[s]!==e[s]&&!We(r[s],e[s]))return!1;return!0},We=(r,e)=>{switch(typeof r){case"object":return ae(r,e,[]);case"function":return r.toString()===e.toString();default:return r===e}};var Xe={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},le=r=>{if(typeof r=="number")return r;for(let[e,t]of Object.entries(Xe))if(r.endsWith(e))return parseFloat(r)*t;return parseInt(r)};var ce=class{constructor(){this.cached=[];this.inFlightRequests=[];this.removalTimers=[];this.currentUseId=null}add(e,t,{cacheFor:s}){if(this.findInFlight(e))return Promise.resolve();let n=this.findCached(e);if(!e.fresh&&n&&n.staleTimestamp>Date.now())return Promise.resolve();let[a,d]=this.extractStaleValues(s),p=new Promise((c,l)=>{t({...e,onCancel:()=>{this.remove(e),e.onCancel(),l()},onError:g=>{this.remove(e),e.onError(g,e.frame),l()},onPrefetching(g){e.onPrefetching(g)},onPrefetched(g,F){e.onPrefetched(g,F)},onPrefetchResponse(g){c(g)}})}).then(c=>(this.remove(e),this.cached.push({params:{...e},staleTimestamp:Date.now()+a,response:p,singleUse:s===0,timestamp:Date.now(),inFlight:!1}),this.scheduleForRemoval(e,d),this.inFlightRequests=this.inFlightRequests.filter(l=>!this.paramsAreEqual(l.params,e)),c.handlePrefetch(),c));return this.inFlightRequests.push({params:{...e},response:p,staleTimestamp:null,inFlight:!0}),p}removeAll(){this.cached=[],this.removalTimers.forEach(e=>{clearTimeout(e.timer)}),this.removalTimers=[]}remove(e){this.cached=this.cached.filter(t=>!this.paramsAreEqual(t.params,e)),this.clearTimer(e)}extractStaleValues(e){let[t,s]=this.cacheForToStaleAndExpires(e);return[le(t),le(s)]}cacheForToStaleAndExpires(e){if(!Array.isArray(e))return[e,e];switch(e.length){case 0:return[0,0];case 1:return[e[0],e[0]];default:return[e[0],e[1]]}}clearTimer(e){let t=this.removalTimers.find(s=>this.paramsAreEqual(s.params,e));t&&(clearTimeout(t.timer),this.removalTimers=this.removalTimers.filter(s=>s!==t))}scheduleForRemoval(e,t){if(!(typeof window>"u")&&(this.clearTimer(e),t>0)){let s=window.setTimeout(()=>this.remove(e),t);this.removalTimers.push({params:e,timer:s})}}get(e){return this.findCached(e)||this.findInFlight(e)}use(e,t){let s=`${t.url.pathname}-${Date.now()}-${Math.random().toString(36).substring(7)}`;return this.currentUseId=s,e.response.then(i=>{if(this.currentUseId===s)return i.mergeParams({...t,onPrefetched:()=>{}}),this.removeSingleUseItems(t),i.handle()})}removeSingleUseItems(e){this.cached=this.cached.filter(t=>this.paramsAreEqual(t.params,e)?!t.singleUse:!0)}findCached(e){return this.cached.find(t=>this.paramsAreEqual(t.params,e))||null}findInFlight(e){return this.inFlightRequests.find(t=>this.paramsAreEqual(t.params,e))||null}paramsAreEqual(e,t){return ae(e,t,["showProgress","replace","prefetch","onBefore","onStart","onProgress","onFinish","onCancel","onSuccess","onError","onPrefetched","onCancelToken","onPrefetching","async"])}},x=new ce;import{default as Ve}from"axios";var W=class r{constructor(e){this.callbacks=[];if(!e.prefetch)this.params=e;else{let t={onBefore:this.wrapCallback(e,"onBefore"),onStart:this.wrapCallback(e,"onStart"),onProgress:this.wrapCallback(e,"onProgress"),onFinish:this.wrapCallback(e,"onFinish"),onCancel:this.wrapCallback(e,"onCancel"),onSuccess:this.wrapCallback(e,"onSuccess"),onError:this.wrapCallback(e,"onError"),onCancelToken:this.wrapCallback(e,"onCancelToken"),onPrefetched:this.wrapCallback(e,"onPrefetched"),onPrefetching:this.wrapCallback(e,"onPrefetching")};this.params={...e,...t,onPrefetchResponse:e.onPrefetchResponse||(()=>{})}}}static create(e){return new r(e)}data(){return this.params.method==="get"?null:this.params.data}queryParams(){return this.params.method==="get"?this.params.data:{}}isPartial(){return this.params.only.length>0||this.params.except.length>0||this.params.reset.length>0}onCancelToken(e){this.params.onCancelToken({cancel:e})}markAsFinished(){this.params.completed=!0,this.params.cancelled=!1,this.params.interrupted=!1}markAsCancelled({cancelled:e=!0,interrupted:t=!1}){this.params.onCancel(),this.params.completed=!1,this.params.cancelled=e,this.params.interrupted=t}wasCancelledAtAll(){return this.params.cancelled||this.params.interrupted}onFinish(){this.params.onFinish(this.params)}onStart(){this.params.onStart(this.params)}onPrefetching(){this.params.onPrefetching(this.params)}onPrefetchResponse(e){this.params.onPrefetchResponse&&this.params.onPrefetchResponse(e)}all(){return this.params}headers(){let e={...this.params.headers};this.isPartial()&&(e["X-Inertia-Partial-Component"]=u.for(this.all().frame).currentPage.get().component);let t=this.params.only.concat(this.params.reset);return t.length>0&&(e["X-Inertia-Partial-Data"]=t.join(",")),this.params.except.length>0&&(e["X-Inertia-Partial-Except"]=this.params.except.join(",")),this.params.reset.length>0&&(e["X-Inertia-Reset"]=this.params.reset.join(",")),this.params.errorBag&&this.params.errorBag.length>0&&(e["X-Inertia-Error-Bag"]=this.params.errorBag),e}setPreserveOptions(e){this.params.preserveScroll=this.resolvePreserveOption(this.params.preserveScroll,e),this.params.preserveState=this.resolvePreserveOption(this.params.preserveState,e)}runCallbacks(){this.callbacks.forEach(({name:e,args:t})=>{this.params[e](...t)})}merge(e){this.params={...this.params,...e}}wrapCallback(e,t){return(...s)=>{this.recordCallback(t,s),e[t](...s)}}recordCallback(e,t){this.callbacks.push({name:e,args:t})}resolvePreserveOption(e,t){return typeof e=="function"?e(t):e==="errors"?Object.keys(t.props.errors||{}).length>0:e}};var Ae={modal:null,listener:null,show(r){typeof r=="object"&&(r=`All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.<hr>${JSON.stringify(r)}`);let e=document.createElement("html");e.innerHTML=r,e.querySelectorAll("a").forEach(s=>s.setAttribute("target","_top")),this.modal=document.createElement("div"),this.modal.style.position="fixed",this.modal.style.width="100vw",this.modal.style.height="100vh",this.modal.style.padding="50px",this.modal.style.boxSizing="border-box",this.modal.style.backgroundColor="rgba(0, 0, 0, .6)",this.modal.style.zIndex=2e5,this.modal.addEventListener("click",()=>this.hide());let t=document.createElement("iframe");if(t.style.backgroundColor="white",t.style.borderRadius="5px",t.style.width="100%",t.style.height="100%",this.modal.appendChild(t),document.body.prepend(this.modal),document.body.style.overflow="hidden",!t.contentWindow)throw new Error("iframe not yet ready.");t.contentWindow.document.open(),t.contentWindow.document.write(e.outerHTML),t.contentWindow.document.close(),this.listener=this.hideOnEscape.bind(this),document.addEventListener("keydown",this.listener)},hide(){this.modal.outerHTML="",this.modal=null,document.body.style.overflow="visible",document.removeEventListener("keydown",this.listener)},hideOnEscape(r){r.keyCode===27&&this.hide()}};var Qe=new C,U=class r{constructor(e,t,s){this.requestParams=e;this.response=t;this.originatingPage=s}static create(e,t,s){return new r(e,t,s)}async handlePrefetch(){O(this.requestParams.all().url,window.location)&&this.handle()}async handle(){return Qe.add(()=>this.process())}async process(){if(this.requestParams.all().prefetch)return this.requestParams.all().prefetch=!1,this.requestParams.all().onPrefetched(this.response,this.requestParams.all()),be(this.response,this.requestParams.all()),Promise.resolve();if(this.requestParams.runCallbacks(),!this.isInertiaResponse())return this.handleNonInertiaResponse();await o.processQueue(),o.preserveUrl=this.requestParams.all().preserveUrl,await this.setPage();let e=this.response.headers["x-inertia-frame"]||this.requestParams.all().frame,t=u.for(e).currentPage,s=t.get().props.errors||{};if(Object.keys(s).length>0){let i=this.getScopedErrors(s);return de(i,e),this.requestParams.all().onError(i,e)}ve(t.get(),e),await this.requestParams.all().onSuccess(t.get(),e),o.preserveUrl=!1}mergeParams(e){this.requestParams.merge(e)}async handleNonInertiaResponse(){if(this.isLocationVisit()){let t=y(this.getHeader("x-inertia-location"));return se(this.requestParams.all().url,t),this.locationVisit(t)}let e={...this.response,data:this.getDataFromResponse(this.response.data)};if(me(e,this.requestParams.all().frame))return Ae.show(e.data)}isInertiaResponse(){return this.hasHeader("x-inertia")}hasStatus(e){return this.response.status===e}getHeader(e){return this.response.headers[e]}hasHeader(e){return this.getHeader(e)!==void 0}isLocationVisit(){return this.hasStatus(409)&&this.hasHeader("x-inertia-location")}locationVisit(e){try{if(m.set(m.locationVisitKey,{preserveScroll:this.requestParams.all().preserveScroll===!0}),typeof window>"u")return;O(window.location,e)?window.location.reload():window.location.href=e.href}catch{return!1}}async setPage(){let e=this.getDataFromResponse(this.response.data);if(!this.shouldSetPage(e))return Promise.resolve();let t=this.response.headers["x-inertia-frame"]||this.requestParams.all().frame,s=u.for(t).currentPage;return this.mergeProps(e),await this.setRememberedState(e),this.requestParams.setPreserveOptions(e),s.set(e,{replace:this.requestParams.all().replace,preserveScroll:this.requestParams.all().preserveScroll,preserveState:this.requestParams.all().preserveState,preserveUrl:this.requestParams.all().preserveUrl})}getDataFromResponse(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}shouldSetPage(e){if(!this.requestParams.all().async||this.originatingPage.component!==e.component)return!0;let t=u.for(this.requestParams.all().frame).currentPage;if(this.originatingPage.component!==t.get().component)return!1;let s=y(this.originatingPage.url),i=y(t.get().url);return s.origin===i.origin&&s.pathname===i.pathname}pageUrl(e){let t=y(e.url);return se(this.requestParams.all().url,t),t.pathname+t.search+t.hash}mergeProps(e){let t=u.for(this.requestParams.all().frame).currentPage;if(!this.requestParams.isPartial()||e.component!==t.get().component)return;let s=e.mergeProps||[],i=e.deepMergeProps||[];s.forEach(n=>{let a=e.props[n];Array.isArray(a)?e.props[n]=[...t.get().props[n]||[],...a]:typeof a=="object"&&a!==null&&(e.props[n]={...t.get().props[n]||[],...a})}),i.forEach(n=>{let a=e.props[n],d=t.get().props[n],p=(c,l)=>Array.isArray(l)?[...Array.isArray(c)?c:[],...l]:typeof l=="object"&&l!==null?Object.keys(l).reduce((g,F)=>(g[F]=p(c?c[F]:void 0,l[F]),g),{...c}):l;e.props[n]=p(d,a)}),e.props={...t.get().props,...e.props}}async setRememberedState(e){let t=await o.getState(o.rememberedState,{}),s=u.for(this.requestParams.all().frame).currentPage;this.requestParams.all().preserveState&&t&&e.component===s.get().component&&(e.rememberedState=t)}getScopedErrors(e){return this.requestParams.all().errorBag?e[this.requestParams.all().errorBag||""]||{}:e}};var D=class r{constructor(e,t){this.page=t;this.requestHasFinished=!1;this.requestParams=W.create(e),this.cancelToken=new AbortController}static create(e,t){return new r(e,t)}async send(){this.requestParams.onCancelToken(()=>this.cancel({cancelled:!0})),ge(this.requestParams.all()),this.requestParams.onStart(),this.requestParams.all().prefetch&&(this.requestParams.onPrefetching(),Pe(this.requestParams.all()));let e=this.requestParams.all().prefetch;return Ve({method:this.requestParams.all().method,url:k(this.requestParams.all().url).href,data:this.requestParams.data(),params:this.requestParams.queryParams(),signal:this.cancelToken.signal,headers:this.getHeaders(),onUploadProgress:this.onProgress.bind(this),responseType:"text"}).then(t=>(this.response=U.create(this.requestParams,t,this.page),this.response.handle())).catch(t=>t?.response?(this.response=U.create(this.requestParams,t.response,this.page),this.response.handle()):Promise.reject(t)).catch(t=>{if(!Ve.isCancel(t)&&pe(t,this.requestParams.all().frame))return Promise.reject(t)}).finally(()=>{this.finish(),e&&this.response&&this.requestParams.onPrefetchResponse(this.response)})}finish(){this.requestParams.wasCancelledAtAll()||(this.requestParams.markAsFinished(),this.fireFinishEvents())}fireFinishEvents(){this.requestHasFinished||(this.requestHasFinished=!0,he(this.requestParams.all()),this.requestParams.onFinish())}cancel({cancelled:e=!1,interrupted:t=!1}){this.requestHasFinished||(this.cancelToken.abort(),this.requestParams.markAsCancelled({cancelled:e,interrupted:t}),this.fireFinishEvents())}onProgress(e){this.requestParams.data()instanceof FormData&&(e.percentage=e.progress?Math.round(e.progress*100):0,fe(e,this.requestParams.all().frame),this.requestParams.all().onProgress(e,this.requestParams.all().frame))}getHeaders(){let e={...this.requestParams.headers(),Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0},t=this.requestParams.all().frame,s=u.for("_top").currentPage.get(),i=u.for(t).currentPage.get();return s.version&&(e["X-Inertia-Version"]=s.version),i.url&&(e["X-Inertia-Frame-Src"]=i.url),e["X-Inertia-Frame"]=t,e}};var H=class{constructor({maxConcurrent:e,interruptible:t}){this.requests=[];this.maxConcurrent=e,this.interruptible=t}send(e){this.requests.push(e),e.send().then(()=>{this.requests=this.requests.filter(t=>t!==e)})}interruptInFlight(){this.cancel({interrupted:!0},!1)}cancelInFlight(){this.cancel({cancelled:!0},!0)}cancel({cancelled:e=!1,interrupted:t=!1}={},s){if(!this.shouldCancel(s))return;this.requests.shift()?.cancel({interrupted:t,cancelled:e})}shouldCancel(e){return e?!0:this.interruptible&&this.requests.length>=this.maxConcurrent}};var I={},u=class{constructor({name:e,initialPage:t,resolveComponent:s,swapComponent:i}){this.syncRequestStream=new H({maxConcurrent:1,interruptible:!0});this.asyncRequestStream=new H({maxConcurrent:1/0,interruptible:!1});this.name=e,this.currentPage=new _({name:e,initialPage:t,resolveComponent:s,swapComponent:i}),I[e]=this,e=="_top"&&(K.handle(),w.init(),w.on("missingHistoryItem",()=>{typeof window<"u"&&this.visit(window.location.href,{preserveState:!0,preserveScroll:!0,replace:!0})})),w.on(`${e}:loadDeferredProps`,()=>{this.loadDeferredProps()})}static asFrames(){return Object.entries(I).reduce((e,[t,s])=>(e[t]=s.currentPage.get(),e),{})}static for(e){return I[e]}static setQuietly(e,{preserveState:t=!1}={}){return Promise.all(Object.entries(I).map(([s,i])=>e[s]?i.currentPage.setQuietly(e[s],{preserveState:t}):(console.log("no page for router",s),Promise.resolve())))}static set(e,{replace:t=!1,preserveScroll:s=!1,preserveState:i=!1}={}){return Promise.all(Object.entries(I).map(([n,a])=>a.currentPage.set(e[n],{replace:t,preserveScroll:s,preserveState:i})))}destroy(){this.cancelAll(),o.removeFrame(this.name),delete I[this.name]}get(e,t={},s={}){return this.visit(e,{...s,method:"get",data:t})}post(e,t={},s={}){return this.visit(e,{preserveState:!0,...s,method:"post",data:t})}put(e,t={},s={}){return this.visit(e,{preserveState:!0,...s,method:"put",data:t})}patch(e,t={},s={}){return this.visit(e,{preserveState:!0,...s,method:"patch",data:t})}delete(e,t={}){return this.visit(e,{preserveState:!0,...t,method:"delete"})}reload(e={}){if(!(typeof window>"u"))return this.visit(this.currentPage.get().url,{...e,preserveScroll:!0,preserveState:!0,async:!0,headers:{...e.headers||{},"Cache-Control":"no-cache"}})}remember(e,t="default"){o.remember(this.name,e,t)}restore(e="default"){return o.restore(this.name,e)}on(e,t){return typeof window>"u"?()=>{}:w.onGlobalEvent(this.name,e,t)}cancel(){this.syncRequestStream.cancelInFlight()}cancelAll(){this.asyncRequestStream.cancelInFlight(),this.syncRequestStream.cancelInFlight()}poll(e,t={},s={}){return Ce.add(e,()=>this.reload(t),{autoStart:s.autoStart??!0,keepAlive:s.keepAlive??!1})}visit(e,t={}){let s=this.getPendingVisit(e,{...t,showProgress:t.showProgress??!t.async}),i=this.getVisitEvents(t);if(i.onBefore(s)===!1||!Z(s))return;let n=s.async?this.asyncRequestStream:this.syncRequestStream;n.interruptInFlight(),!this.currentPage.isCleared()&&!s.preserveUrl&&b.save();let a={...s,...i},d=x.get(a);d?(X(d.inFlight),x.use(d,a)):(X(!0),n.send(D.create(a,this.currentPage.get())))}getCached(e,t={}){return x.findCached(this.getPrefetchParams(e,t))}flush(e,t={}){x.remove(this.getPrefetchParams(e,t))}flushAll(){x.removeAll()}getPrefetching(e,t={}){return x.findInFlight(this.getPrefetchParams(e,t))}prefetch(e,t={},{cacheFor:s=3e4}){if(t.method!=="get")throw new Error("Prefetch requests must use the GET method");let i=this.getPendingVisit(e,{...t,async:!0,showProgress:!1,prefetch:!0}),n=i.url.origin+i.url.pathname+i.url.search,a=window.location.origin+window.location.pathname+window.location.search;if(n===a)return;let d=this.getVisitEvents(t);if(d.onBefore(i)===!1||!Z(i))return;Q(),this.asyncRequestStream.interruptInFlight();let p={...i,...d};new Promise(l=>{let g=()=>{this.currentPage.get()?l():setTimeout(g,50)};g()}).then(()=>{x.add(p,l=>{this.asyncRequestStream.send(D.create(l,this.currentPage.get()))},{cacheFor:s})})}clearHistory(){o.clear()}static decryptHistory(){return o.decrypt()}replace(e){this.clientVisit(e,{replace:!0})}push(e){this.clientVisit(e)}clientVisit(e,{replace:t=!1}={}){let s=this.currentPage.get(),i=typeof e.props=="function"?e.props(s.props):e.props??s.props;this.currentPage.set({...s,...e,props:i},{replace:t,preserveScroll:e.preserveScroll,preserveState:e.preserveState})}getPrefetchParams(e,t){return{...this.getPendingVisit(e,{...t,async:!0,showProgress:!1,prefetch:!0}),...this.getVisitEvents(t)}}getPendingVisit(e,t,s={}){let i={method:"get",data:{},replace:this.name!=="_top",preserveUrl:this.name!=="_top",preserveScroll:!1,preserveState:!1,only:[],except:[],headers:{},errorBag:"",forceFormData:!1,queryStringArrayFormat:"brackets",async:!1,showProgress:!0,fresh:!1,reset:[],prefetch:!1,frame:this.name,...t},[n,a]=Fe(e,i.data,i.method,i.forceFormData,i.queryStringArrayFormat);return{cancelled:!1,completed:!1,interrupted:!1,...i,...s,url:n,data:a}}getVisitEvents(e){return{onCancelToken:e.onCancelToken||(()=>{}),onBefore:e.onBefore||(()=>{}),onStart:e.onStart||(()=>{}),onProgress:e.onProgress||(()=>{}),onFinish:e.onFinish||(()=>{}),onCancel:e.onCancel||(()=>{}),onSuccess:e.onSuccess||(()=>{}),onError:e.onError||(()=>{}),onPrefetched:e.onPrefetched||(()=>{}),onPrefetching:e.onPrefetching||(()=>{})}}loadDeferredProps(){let e=this.currentPage.get()?.deferredProps;e&&Object.entries(e).forEach(([t,s])=>{this.reload({only:s})})}};var Je={buildDOMElement(r){let e=document.createElement("template");e.innerHTML=r;let t=e.content.firstChild;if(!r.startsWith("<script "))return t;let s=document.createElement("script");return s.innerHTML=t.innerHTML,t.getAttributeNames().forEach(i=>{s.setAttribute(i,t.getAttribute(i)||"")}),s},isInertiaManagedElement(r){return r.nodeType===Node.ELEMENT_NODE&&r.getAttribute("inertia")!==null},findMatchingElementIndex(r,e){let t=r.getAttribute("inertia");return t!==null?e.findIndex(s=>s.getAttribute("inertia")===t):-1},update:A(function(r){let e=r.map(s=>this.buildDOMElement(s));Array.from(document.head.childNodes).filter(s=>this.isInertiaManagedElement(s)).forEach(s=>{let i=this.findMatchingElementIndex(s,e);if(i===-1){s?.parentNode?.removeChild(s);return}let n=e.splice(i,1)[0];n&&!s.isEqualNode(n)&&s?.parentNode?.replaceChild(n,s)}),e.forEach(s=>document.head.appendChild(s))},1)};function ke(r,e,t){let s={},i=0;function n(){let l=i+=1;return s[l]=[],l.toString()}function a(l){l===null||Object.keys(s).indexOf(l)===-1||(delete s[l],c())}function d(l,g=[]){l!==null&&Object.keys(s).indexOf(l)>-1&&(s[l]=g),c()}function p(){let l=e(""),g={...l?{title:`<title inertia="">${l}</title>`}:{}},F=Object.values(s).reduce((S,E)=>S.concat(E),[]).reduce((S,E)=>{if(E.indexOf("<")===-1)return S;if(E.indexOf("<title ")===0){let $=E.match(/(<title [^>]+>)(.*?)(<\/title>)/);return S.title=$?`${$[1]}${e($[2])}${$[3]}`:E,S}let ue=E.match(/ inertia="[^"]+"/);return ue?S[ue[0]]=E:S[Object.keys(S).length]=E,S},g);return Object.values(F)}function c(){r?t(p()):Je.update(p())}return c(),{forceUpdate:c,createProvider:function(){let l=n();return{update:g=>d(l,g),disconnect:()=>a(l)}}}}var f="nprogress",v={minimum:.08,easing:"linear",positionUsing:"translate3d",speed:200,trickle:!0,trickleSpeed:200,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",color:"#29d",includeCSS:!0,template:['<div class="bar" role="bar">','<div class="peg"></div>',"</div>",'<div class="spinner" role="spinner">','<div class="spinner-icon"></div>',"</div>"].join("")},T=null,ze=r=>{Object.assign(v,r),v.includeCSS&&st(v.color)},z=r=>{let e=Ie();r=He(r,v.minimum,1),T=r===1?null:r;let t=Ze(!e),s=t.querySelector(v.barSelector),i=v.speed,n=v.easing;t.offsetWidth,rt(a=>{let d=v.positionUsing==="translate3d"?{transition:`all ${i}ms ${n}`,transform:`translate3d(${J(r)}%,0,0)`}:v.positionUsing==="translate"?{transition:`all ${i}ms ${n}`,transform:`translate(${J(r)}%,0)`}:{marginLeft:`${J(r)}%`};for(let p in d)s.style[p]=d[p];if(r!==1)return setTimeout(a,i);t.style.transition="none",t.style.opacity="1",t.offsetWidth,setTimeout(()=>{t.style.transition=`all ${i}ms linear`,t.style.opacity="0",setTimeout(()=>{De(),a()},i)},i)})},Ie=()=>typeof T=="number",Le=()=>{T||z(0);let r=function(){setTimeout(function(){T&&(Oe(),r())},v.trickleSpeed)};v.trickle&&r()},Ye=r=>{!r&&!T||(Oe(.3+.5*Math.random()),z(1))},Oe=r=>{let e=T;if(e===null)return Le();if(!(e>1))return r=typeof r=="number"?r:(()=>{let t={.1:[0,.2],.04:[.2,.5],.02:[.5,.8],.005:[.8,.99]};for(let s in t)if(e>=t[s][0]&&e<t[s][1])return parseFloat(s);return 0})(),z(He(e+r,0,.994))},Ze=r=>{if(et())return document.getElementById(f);document.documentElement.classList.add(`${f}-busy`);let e=document.createElement("div");e.id=f,e.innerHTML=v.template;let t=e.querySelector(v.barSelector),s=r?"-100":J(T||0),i=Ue();return t.style.transition="all 0 linear",t.style.transform=`translate3d(${s}%,0,0)`,v.showSpinner||e.querySelector(v.spinnerSelector)?.remove(),i!==document.body&&i.classList.add(`${f}-custom-parent`),i.appendChild(e),e},Ue=()=>tt(v.parent)?v.parent:document.querySelector(v.parent),De=()=>{document.documentElement.classList.remove(`${f}-busy`),Ue().classList.remove(`${f}-custom-parent`),document.getElementById(f)?.remove()},et=()=>document.getElementById(f)!==null,tt=r=>typeof HTMLElement=="object"?r instanceof HTMLElement:r&&typeof r=="object"&&r.nodeType===1&&typeof r.nodeName=="string";function He(r,e,t){return r<e?e:r>t?t:r}var J=r=>(-1+r)*100,rt=(()=>{let r=[],e=()=>{let t=r.shift();t&&t(e)};return t=>{r.push(t),r.length===1&&e()}})(),st=r=>{let e=document.createElement("style");e.textContent=`
|
|
2
2
|
#${f} {
|
|
3
3
|
pointer-events: none;
|
|
4
4
|
}
|
|
@@ -62,7 +62,7 @@ function A(r,e){let t;return function(...s){clearTimeout(t),t=setTimeout(()=>r.a
|
|
|
62
62
|
0% { transform: rotate(0deg); }
|
|
63
63
|
100% { transform: rotate(360deg); }
|
|
64
64
|
}
|
|
65
|
-
`,document.head.appendChild(e)},L=(()=>{if(typeof document>"u")return null;let r=document.createElement("style");return r.innerHTML=`#${f} { display: none; }`,r})(),it=()=>{if(L&&document.head.contains(L))return document.head.removeChild(L)},nt=()=>{L&&!document.head.contains(L)&&document.head.appendChild(L)},P={configure:ze,isStarted:Ie,done:Ye,set:z,remove:De,start:Le,status:T,show:it,hide:nt};var Y=0,X=(r=!1)=>{Y=Math.max(0,Y-1),(r||Y===0)&&P.show()},Q=()=>{Y++,P.hide()};function ot(r){document.addEventListener("inertia:_top:start",e=>at(e,r)),document.addEventListener("inertia:_top:progress",lt)}function at(r,e){r.detail.visit.showProgress||Q();let t=setTimeout(()=>P.start(),e);document.addEventListener("inertia:_top:finish",s=>ct(s,t),{once:!0})}function lt(r){let e=r;P.isStarted()&&e.detail.progress?.percentage&&P.set(Math.max(P.status,e.detail.progress.percentage/100*.9))}function ct(r,e){clearTimeout(e),P.isStarted()&&(r.detail.visit.completed?P.done():r.detail.visit.interrupted?P.set(0):r.detail.visit.cancelled&&(P.done(),P.remove()))}function $e({delay:r=250,color:e="#29d",includeCSS:t=!0,showSpinner:s=!1}={}){ot(r),P.configure({showSpinner:s,includeCSS:t,color:e})}function Me(r){let e=r.target.closest("[href]")?.getAttribute("href");return!(!e||!e.startsWith("/")&&!e.startsWith(window.location.origin)||r.target&&(r?.target).isContentEditable||r.defaultPrevented||e&&r.altKey||e&&r.ctrlKey||e&&r.metaKey||e&&r.shiftKey||e&&"button"in r&&r.button!==0)}export{u as Router,ke as createHeadManager,Q as hideProgress,o as history,y as hrefToUrl,
|
|
65
|
+
`,document.head.appendChild(e)},L=(()=>{if(typeof document>"u")return null;let r=document.createElement("style");return r.innerHTML=`#${f} { display: none; }`,r})(),it=()=>{if(L&&document.head.contains(L))return document.head.removeChild(L)},nt=()=>{L&&!document.head.contains(L)&&document.head.appendChild(L)},P={configure:ze,isStarted:Ie,done:Ye,set:z,remove:De,start:Le,status:T,show:it,hide:nt};var Y=0,X=(r=!1)=>{Y=Math.max(0,Y-1),(r||Y===0)&&P.show()},Q=()=>{Y++,P.hide()};function ot(r){document.addEventListener("inertia:_top:start",e=>at(e,r)),document.addEventListener("inertia:_top:progress",lt)}function at(r,e){r.detail.visit.showProgress||Q();let t=setTimeout(()=>P.start(),e);document.addEventListener("inertia:_top:finish",s=>ct(s,t),{once:!0})}function lt(r){let e=r;P.isStarted()&&e.detail.progress?.percentage&&P.set(Math.max(P.status,e.detail.progress.percentage/100*.9))}function ct(r,e){clearTimeout(e),P.isStarted()&&(r.detail.visit.completed?P.done():r.detail.visit.interrupted?P.set(0):r.detail.visit.cancelled&&(P.done(),P.remove()))}function $e({delay:r=250,color:e="#29d",includeCSS:t=!0,showSpinner:s=!1}={}){ot(r),P.configure({showSpinner:s,includeCSS:t,color:e})}function Me(r){let e=r.target.closest("[href]")?.getAttribute("href");return!(!e||!e.startsWith("/")&&!e.startsWith(window.location.origin)||r.target&&(r?.target).isContentEditable||r.defaultPrevented||e&&r.altKey||e&&r.ctrlKey||e&&r.metaKey||e&&r.shiftKey||e&&"button"in r&&r.button!==0)}export{u as Router,ke as createHeadManager,Q as hideProgress,o as history,y as hrefToUrl,qe as mergeDataIntoQueryString,X as revealProgress,$e as setupProgress,Me as shouldIntercept,k as urlWithoutHash};
|
|
66
66
|
/* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress
|
|
67
67
|
* @license MIT */
|
|
68
68
|
//# sourceMappingURL=index.esm.js.map
|