inertiax-core 10.0.0-beta.0 → 10.0.0-beta.2
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 +12 -12
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +12 -12
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/types/eventHandler.d.ts +5 -0
- package/types/types.d.ts +11 -10
package/dist/index.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
function T(r,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>r.apply(this,i),e)}}function P(r,e){return document.dispatchEvent(new CustomEvent(`inertia:${r}`,e))}var Z=r=>P("before",{cancelable:!0,detail:{visit:r}}),pe=r=>P("error",{detail:{errors:r}}),de=r=>P("exception",{cancelable:!0,detail:{exception:r}}),he=r=>P("finish",{detail:{visit:r}}),me=r=>P("invalid",{cancelable:!0,detail:{response:r}}),R=r=>P("navigate",{detail:{page:r}}),fe=r=>P("progress",{detail:{progress:r}}),ge=r=>P("start",{detail:{visit:r}}),ve=r=>P("success",{detail:{page:r}}),be=(r,e)=>P("prefetched",{detail:{fetchedAt:Date.now(),response:r.data,visit:e}}),Pe=r=>P("prefetching",{detail:{visit:r}});var p=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 i=this.get(e);i===null?this.set(e,t):this.set(e,{...i,...t})}static remove(e){typeof window<"u"&&window.sessionStorage.removeItem(e)}static removeNested(e,t){let i=this.get(e);i!==null&&(delete i[t],this.set(e,i))}static exists(e){try{return this.get(e)!==null}catch{return!1}}static clear(){typeof window<"u"&&window.sessionStorage.clear()}};p.locationVisitKey="inertiaLocationVisit";var ye=async r=>{if(typeof window>"u")throw new Error("Unable to encrypt history");let e=Se(),t=await Ee(),i=await je(t);if(!i)throw new Error("Unable to encrypt history");return await $e(e,i,r)},C={key:"historyKey",iv:"historyIv"},we=async r=>{let e=Se(),t=await Ee();if(!t)throw new Error("Unable to decrypt history");return await Be(e,t,r)},$e=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 i=new TextEncoder,s=JSON.stringify(t),n=new Uint8Array(s.length*3),a=i.encodeInto(s,n);return window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},e,n.subarray(0,a.written))},Be=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 i=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:r},e,t);return JSON.parse(new TextDecoder().decode(i))},Se=()=>{let r=p.get(C.iv);if(r)return new Uint8Array(r);let e=window.crypto.getRandomValues(new Uint8Array(12));return p.set(C.iv,Array.from(e)),e},Ge=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);p.set(C.key,Array.from(new Uint8Array(e)))},je=async r=>{if(r)return r;let e=await Ge();return e?(await Ke(e),e):null},Ee=async()=>{let r=p.get(C.key);return r?await window.crypto.subtle.importKey("raw",new Uint8Array(r),{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]):null};var q=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 A=typeof window>"u",M=new q,Re=!A&&/CriOS/.test(window.navigator.userAgent),ee=class{constructor(){this.rememberedState="rememberedState";this.scrollRegions="scrollRegions";this.preserveUrl=!1;this.counter=A?0:window.history.state?.c??0;this.lastChangedFrames=[];this.current={};this.initialState=null}remember(e,t,i){this.preserveUrl=!0,this.replaceState(e,{...this.current[e],rememberedState:{...this.current[e]?.rememberedState??{},[i]:t}})}restore(e,t){if(!A)return this.current?.[e]?.rememberedState?.[t]}pushState(e,t,i=null){A||(this.current[e]=t,M.add(()=>this.getFramesData(this.current,t.encryptHistory).then(s=>{let n=()=>{this.doPushState({frames:s,changedFrames:[e]},this.preserveUrl?window.location.href:t.url),i&&i()};Re?setTimeout(n):n()})))}removeFrame(e){delete this.current[e]}getFramesData(e,t){return new Promise(i=>t?ye(e).then(i):i(e))}processQueue(){return M.process()}decrypt(e=null){if(A)return Promise.resolve(e??l.asFrames());let t=e??window.history.state?.frames;return this.decryptPageData(t).then(i=>{if(!i)throw new Error("Unable to decrypt history");return this.initialState===null?this.initialState=i??void 0:this.current=i??{},i})}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},document.location.href)}))}saveDocumentScrollPosition(e){M.add(()=>Promise.resolve().then(()=>{window.history.state?.page&&this.doReplaceState({...window.history.state,documentScrollPosition:e},window.location.href)}))}getScrollRegions(){return window.history.state?.scrollRegions||[]}getDocumentScrollPosition(){return window.history.state?.documentScrollPosition||{top:0,left:0}}replaceState(e,t,i=null){l.for(e).currentPage.merge(t),!A&&(this.current[e]=l.for(e).currentPage.get(),this.getFramesData(this.current,t.encryptHistory).then(s=>{let n=()=>{let a=window.history.state?.changedFrames||[];a.includes(e)||a.push(e),this.doReplaceState({frames:s,changedFrames:a},this.preserveUrl?window.location.href:t.url),i&&i()};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(){p.remove(C.key),p.remove(C.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 g=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(){typeof window<"u"&&window.scrollTo(0,0),this.regions().forEach(e=>{typeof e.scrollTo=="function"?e.scrollTo(0,0):(e.scrollTop=0,e.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,i)=>{let s=e[i];s&&(typeof t.scrollTo=="function"?t.scrollTo(s.left,s.top):(t.scrollTop=s.top,t.scrollLeft=s.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})}};var te=class{constructor(){this.internalListeners=[]}init(){typeof window<"u"&&(window.addEventListener("popstate",this.handlePopstateEvent.bind(this)),window.addEventListener("scroll",T(g.onWindowScroll.bind(g),100),!0)),typeof document<"u"&&document.addEventListener("scroll",T(g.onScroll.bind(g),100),!0)}onGlobalEvent(e,t,i){let s=n=>{let a=i(n);n.cancelable&&!n.defaultPrevented&&a===!1&&n.preventDefault()};return this.registerListener(`inertia:${e}:${t}`,s)}on(e,t){return this.internalListeners.push({event:e,listener:t}),()=>{this.internalListeners=this.internalListeners.filter(i=>i.listener!==t)}}onMissingHistoryItem(){l.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(t===null)throw new Error("Inertia X: Missing state in popstate event");if(!o.isValidState(t))return this.onMissingHistoryItem();let i=[];t.c<o.counter&&(i=o.lastChangedFrames||[]),t.c>o.counter&&(i=window.history.state?.changedFrames||[]),o.counter=t.c,o.lastChangedFrames=t.changedFrames||[],o.decrypt(t.frames).then(s=>{for(let n of i){if(!s[n])continue;let a=l.for(n)?.currentPage;a&&a.setQuietly(s[n],{preserveState:!1}).then(()=>{g.restore(o.getScrollRegions()),R(a.get())})}}).catch(()=>{this.onMissingHistoryItem()})}},y=new te;var re=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"}},N=new re;var $=class{static handle(){this.clearRememberedStateOnReload(),[this.handleBackForward,this.handleLocation,this.handleDefault].find(t=>t.bind(this)())}static clearRememberedStateOnReload(){N.isReload()&&o.deleteState(o.rememberedState)}static handleBackForward(){if(!N.isBackForward()||!o.hasAnyState())return!1;let e=l.for("_top").currentPage,t=o.getScrollRegions();return o.decrypt().then(i=>{l.set(i,{preserveScroll:!0,preserveState:!0}).then(()=>{g.restore(t),R(e.get())})}).catch(()=>{y.onMissingHistoryItem()}),!0}static handleLocation(){if(!p.exists(p.locationVisitKey))return!1;let e=p.get(p.locationVisitKey)||{};p.remove(p.locationVisitKey);let t=l.for("_top").currentPage;return typeof window<"u"&&t.setUrlHash(window.location.hash),o.decrypt().then(()=>{let i=o.getState(o.rememberedState,{}),s=o.getScrollRegions();t.remember(i),t.set(t.get(),{preserveScroll:e.preserveScroll,preserveState:!0}).then(()=>{e.preserveScroll&&g.restore(s),R(t.get())})}).catch(()=>{y.onMissingHistoryItem()}),!0}static handleDefault(){let e=l.for("_top").currentPage;typeof window<"u"&&e.setUrlHash(window.location.hash),e.set(e.get(),{preserveScroll:!0,preserveState:!0}).then(()=>{N.isReload()&&g.restore(o.getScrollRegions()),R(e.get())})}};import We from"deepmerge";import*as G from"qs";function B(r){return r instanceof File||r instanceof Blob||r instanceof FileList&&r.length>0||r instanceof FormData&&Array.from(r.values()).some(e=>B(e))||typeof r=="object"&&r!==null&&Object.values(r).some(e=>B(e))}var ie=r=>r instanceof FormData;function se(r,e=new FormData,t=null){r=r||{};for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&xe(e,Fe(t,i),r[i]);return e}function Fe(r,e){return r?r+"["+e+"]":e}function xe(r,e,t){if(Array.isArray(t))return Array.from(t.keys()).forEach(i=>xe(r,Fe(e,i.toString()),t[i]));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,"");se(t,r,e)}function w(r){return new URL(r.toString(),typeof window>"u"?void 0:window.location.toString())}var Ce=(r,e,t,i,s)=>{let n=typeof r=="string"?w(r):r;if((B(e)||i)&&!ie(e)&&(e=se(e)),ie(e))return[n,e];let[a,h]=qe(t,n,e,s);return[w(a),h]};function qe(r,e,t,i="brackets"){let s=/^https?:\/\//.test(e.toString()),n=s||e.toString().startsWith("/"),a=!n&&!e.toString().startsWith("#")&&!e.toString().startsWith("?"),h=e.toString().includes("?")||r==="get"&&Object.keys(t).length,v=e.toString().includes("#"),u=new URL(e.toString(),"http://localhost");return r==="get"&&Object.keys(t).length&&(u.search=G.stringify(We(G.parse(u.search,{ignoreQueryPrefix:!0}),t),{encodeValuesOnly:!0,arrayFormat:i}),t={}),[[s?`${u.protocol}//${u.host}`:"",n?u.pathname:"",a?u.pathname.substring(1):"",h?u.search:"",v?u.hash:""].join(""),t]}function V(r){return r=new URL(r.href),r.hash="",r}var ne=(r,e)=>{r.hash&&!e.hash&&V(r).href===e.href&&(e.hash=r.hash)},L=(r,e)=>V(r).href===V(e).href;var K=class{constructor({name:e,initialPage:t,swapComponent:i,resolveComponent:s}){this.componentId={};this.listeners=[];this.isFirstPageLoad=!0;this.cleared=!1;return this.name=e,this.page=t,this.swapComponent=i,this.resolveComponent=s,this}set(e,{replace:t=!1,preserveScroll:i=!1,preserveState:s=!1,preserveUrl:n=!1}={}){this.componentId={};let a=this.componentId;return e.clearHistory&&o.clear(),this.resolve(e.component).then(h=>{if(a!==this.componentId)return;let v=typeof window<"u"?window.location:new URL(e.url);return t=t||!n&&L(w(e.url),v),new Promise(u=>{t?o.replaceState(this.name,e,()=>u(null)):o.pushState(this.name,e,()=>u(null))}).then(()=>{let u=!this.isTheSame(e);return this.page=e,this.cleared=!1,u&&this.fireEventsFor("newComponent"),this.isFirstPageLoad&&this.fireEventsFor("firstLoad"),this.isFirstPageLoad=!1,this.swap({component:h,page:e,preserveState:s}).then(()=>{i||g.reset(),y.fireInternalEvent(`${this.name}:loadDeferredProps`),t||R(e)})})})}setQuietly(e,{preserveState:t=!1}={}){return this.resolve(e.component).then(i=>(this.page=e,this.cleared=!1,o.setCurrent(this.name,e),this.swap({component:i,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:i}){return this.swapComponent({component:e,page:t,preserveState:i})}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(i=>i.event!==e&&i.callback!==t)}}fireEventsFor(e){this.listeners.filter(t=>t.event===e).forEach(t=>t.callback())}};var j=class{constructor(e,t,i){this.id=null;this.throttle=!1;this.keepAlive=!1;this.cbCount=0;this.keepAlive=i.keepAlive??!1,this.cb=t,this.interval=e,(i.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,i){let s=new j(e,t,i);return this.polls.push(s),{stop:()=>s.stop(),start:()=>s.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)}},Te=new oe;var ae=(r,e,t)=>{if(r===e)return!0;for(let i in r)if(!t.includes(i)&&r[i]!==e[i]&&!_e(r[i],e[i]))return!1;return!0},_e=(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:i}){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,h]=this.extractStaleValues(i),v=new Promise((u,c)=>{t({...e,onCancel:()=>{this.remove(e),e.onCancel(),c()},onError:f=>{this.remove(e),e.onError(f),c()},onPrefetching(f){e.onPrefetching(f)},onPrefetched(f,Y){e.onPrefetched(f,Y)},onPrefetchResponse(f){u(f)}})}).then(u=>(this.remove(e),this.cached.push({params:{...e},staleTimestamp:Date.now()+a,response:v,singleUse:i===0,timestamp:Date.now(),inFlight:!1}),this.scheduleForRemoval(e,h),this.inFlightRequests=this.inFlightRequests.filter(c=>!this.paramsAreEqual(c.params,e)),u.handlePrefetch(),u));return this.inFlightRequests.push({params:{...e},response:v,staleTimestamp:null,inFlight:!0}),v}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,i]=this.cacheForToStaleAndExpires(e);return[le(t),le(i)]}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(i=>this.paramsAreEqual(i.params,e));t&&(clearTimeout(t.timer),this.removalTimers=this.removalTimers.filter(i=>i!==t))}scheduleForRemoval(e,t){if(!(typeof window>"u")&&(this.clearTimer(e),t>0)){let i=window.setTimeout(()=>this.remove(e),t);this.removalTimers.push({params:e,timer:i})}}get(e){return this.findCached(e)||this.findInFlight(e)}use(e,t){let i=`${t.url.pathname}-${Date.now()}-${Math.random().toString(36).substring(7)}`;return this.currentUseId=i,e.response.then(s=>{if(this.currentUseId===i)return s.mergeParams({...t,onPrefetched:()=>{}}),this.removeSingleUseItems(t),s.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"])}},F=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"?{}: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"]=l.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(...i)=>{this.recordCallback(t,i),e[t](...i)}}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(i=>i.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 q,k=class r{constructor(e,t,i){this.requestParams=e;this.response=t;this.originatingPage=i}static create(e,t,i){return new r(e,t,i)}async handlePrefetch(){L(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=l.for(e).currentPage,i=t.get().props.errors||{};if(Object.keys(i).length>0){let s=this.getScopedErrors(i);return pe(s),this.requestParams.all().onError(s)}ve(t.get()),await this.requestParams.all().onSuccess(t.get()),o.preserveUrl=!1}mergeParams(e){this.requestParams.merge(e)}async handleNonInertiaResponse(){if(this.isLocationVisit()){let t=w(this.getHeader("x-inertia-location"));return ne(this.requestParams.all().url,t),this.locationVisit(t)}let e={...this.response,data:this.getDataFromResponse(this.response.data)};if(me(e))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(p.set(p.locationVisitKey,{preserveScroll:this.requestParams.all().preserveScroll===!0}),typeof window>"u")return;L(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,i=l.for(t).currentPage;return this.mergeProps(e),await this.setRememberedState(e),this.requestParams.setPreserveOptions(e),i.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=l.for(this.requestParams.all().frame).currentPage;if(this.originatingPage.component!==t.get().component)return!1;let i=w(this.originatingPage.url),s=w(t.get().url);return i.origin===s.origin&&i.pathname===s.pathname}pageUrl(e){let t=w(e.url);return ne(this.requestParams.all().url,t),t.pathname+t.search+t.hash}mergeProps(e){let t=l.for(this.requestParams.all().frame).currentPage;this.requestParams.isPartial()&&e.component===t.get().component&&((e.mergeProps||[]).forEach(s=>{let n=e.props[s];Array.isArray(n)?e.props[s]=[...t.get().props[s]||[],...n]:typeof n=="object"&&(e.props[s]={...t.get().props[s]||[],...n})}),e.props={...t.get().props,...e.props})}async setRememberedState(e){let t=await o.getState(o.rememberedState,{}),i=l.for(this.requestParams.all().frame).currentPage;this.requestParams.all().preserveState&&t&&e.component===i.get().component&&(e.rememberedState=t)}getScopedErrors(e){return this.requestParams.all().errorBag?e[this.requestParams.all().errorBag||""]||{}:e}};var U=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:V(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=k.create(this.requestParams,t,this.page),this.response.handle())).catch(t=>t?.response?(this.response=k.create(this.requestParams,t.response,this.page),this.response.handle()):Promise.reject(t)).catch(t=>{if(!Ve.isCancel(t)&&de(t))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().onProgress(e))}getHeaders(){let e={...this.requestParams.headers(),Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0},t=l.for("_top").currentPage.get(),i=l.for(this.requestParams.all().frame).currentPage.get();return t.version&&(e["X-Inertia-Version"]=t.version),i.url&&(e["X-Inertia-Frame-Src"]=i.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}={},i){if(!this.shouldCancel(i))return;this.requests.shift()?.cancel({interrupted:t,cancelled:e})}shouldCancel(e){return e?!0:this.interruptible&&this.requests.length>=this.maxConcurrent}};var I={},l=class{constructor({name:e,initialPage:t,resolveComponent:i,swapComponent:s}){this.syncRequestStream=new H({maxConcurrent:1,interruptible:!0});this.asyncRequestStream=new H({maxConcurrent:1/0,interruptible:!1});this.name=e,this.currentPage=new K({name:e,initialPage:t,resolveComponent:i,swapComponent:s}),I[e]=this,e=="_top"&&($.handle(),y.init(),y.on("missingHistoryItem",()=>{typeof window<"u"&&this.visit(window.location.href,{preserveState:!0,preserveScroll:!0,replace:!0})})),y.on(`${e}:loadDeferredProps`,()=>{this.loadDeferredProps()})}static asFrames(){return Object.entries(I).reduce((e,[t,i])=>(e[t]=i.currentPage.get(),e),{})}static for(e){return I[e]}static setQuietly(e,{preserveState:t=!1}={}){return Promise.all(Object.entries(I).map(([i,s])=>e[i]?s.currentPage.setQuietly(e[i],{preserveState:t}):(console.log("no page for router",i),Promise.resolve())))}static set(e,{replace:t=!1,preserveScroll:i=!1,preserveState:s=!1}={}){return Promise.all(Object.entries(I).map(([n,a])=>a.currentPage.set(e[n],{replace:t,preserveScroll:i,preserveState:s})))}destroy(){this.cancelAll(),o.removeFrame(this.name),delete I[this.name]}get(e,t={},i={}){return this.visit(e,{...i,method:"get",data:t})}post(e,t={},i={}){return this.visit(e,{preserveState:!0,...i,method:"post",data:t})}put(e,t={},i={}){return this.visit(e,{preserveState:!0,...i,method:"put",data:t})}patch(e,t={},i={}){return this.visit(e,{preserveState:!0,...i,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(window.location.href,{...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"?()=>{}:y.onGlobalEvent(this.name,e,t)}cancel(){this.syncRequestStream.cancelInFlight()}cancelAll(){this.asyncRequestStream.cancelInFlight(),this.syncRequestStream.cancelInFlight()}poll(e,t={},i={}){return Te.add(e,()=>this.reload(t),{autoStart:i.autoStart??!0,keepAlive:i.keepAlive??!1})}visit(e,t={}){let i=this.getPendingVisit(e,{...t,showProgress:t.showProgress??!t.async}),s=this.getVisitEvents(t);if(s.onBefore(i)===!1||!Z(i))return;let n=i.async?this.asyncRequestStream:this.syncRequestStream;n.interruptInFlight(),!this.currentPage.isCleared()&&!i.preserveUrl&&g.save();let a={...i,...s},h=F.get(a);h?(_(h.inFlight),F.use(h,a)):(_(!0),n.send(U.create(a,this.currentPage.get())))}getCached(e,t={}){return F.findCached(this.getPrefetchParams(e,t))}flush(e,t={}){F.remove(this.getPrefetchParams(e,t))}flushAll(){F.removeAll()}getPrefetching(e,t={}){return F.findInFlight(this.getPrefetchParams(e,t))}prefetch(e,t={},{cacheFor:i=3e4}){if(t.method!=="get")throw new Error("Prefetch requests must use the GET method");let s=this.getPendingVisit(e,{...t,async:!0,showProgress:!1,prefetch:!0}),n=s.url.origin+s.url.pathname+s.url.search,a=window.location.origin+window.location.pathname+window.location.search;if(n===a)return;let h=this.getVisitEvents(t);if(h.onBefore(s)===!1||!Z(s))return;X(),this.asyncRequestStream.interruptInFlight();let v={...s,...h};new Promise(c=>{let f=()=>{this.currentPage.get()?c():setTimeout(f,50)};f()}).then(()=>{F.add(v,c=>{this.asyncRequestStream.send(U.create(c,this.currentPage.get()))},{cacheFor:i})})}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 i=this.currentPage.get(),s=typeof e.props=="function"?e.props(i.props):e.props??i.props;this.currentPage.set({...i,...e,props:s},{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,i={}){let s={method:"get",data:{},replace:!1,preserveScroll:!1,preserveState:!1,only:[],except:[],headers:{},errorBag:"",forceFormData:!1,queryStringArrayFormat:"brackets",async:!1,showProgress:!0,fresh:!1,reset:[],preserveUrl:!1,prefetch:!1,frame:this.name,...t},[n,a]=Ce(e,s.data,s.method,s.forceFormData,s.queryStringArrayFormat);return{cancelled:!1,completed:!1,interrupted:!1,...s,...i,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,i])=>{this.reload({only:i})})}};var Je={buildDOMElement(r){let e=document.createElement("template");e.innerHTML=r;let t=e.content.firstChild;if(!r.startsWith("<script "))return t;let i=document.createElement("script");return i.innerHTML=t.innerHTML,t.getAttributeNames().forEach(s=>{i.setAttribute(s,t.getAttribute(s)||"")}),i},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(i=>i.getAttribute("inertia")===t):-1},update:T(function(r){let e=r.map(i=>this.buildDOMElement(i));Array.from(document.head.childNodes).filter(i=>this.isInertiaManagedElement(i)).forEach(i=>{let s=this.findMatchingElementIndex(i,e);if(s===-1){i?.parentNode?.removeChild(i);return}let n=e.splice(s,1)[0];n&&!i.isEqualNode(n)&&i?.parentNode?.replaceChild(n,i)}),e.forEach(i=>document.head.appendChild(i))},1)};function Ie(r,e,t){let i={},s=0;function n(){let c=s+=1;return i[c]=[],c.toString()}function a(c){c===null||Object.keys(i).indexOf(c)===-1||(delete i[c],u())}function h(c,f=[]){c!==null&&Object.keys(i).indexOf(c)>-1&&(i[c]=f),u()}function v(){let c=e(""),f={...c?{title:`<title inertia="">${c}</title>`}:{}},Y=Object.values(i).reduce((S,E)=>S.concat(E),[]).reduce((S,E)=>{if(E.indexOf("<")===-1)return S;if(E.indexOf("<title ")===0){let D=E.match(/(<title [^>]+>)(.*?)(<\/title>)/);return S.title=D?`${D[1]}${e(D[2])}${D[3]}`:E,S}let ue=E.match(/ inertia="[^"]+"/);return ue?S[ue[0]]=E:S[Object.keys(S).length]=E,S},f);return Object.values(Y)}function u(){r?t(v()):Je.update(v())}return u(),{forceUpdate:u,createProvider:function(){let c=n();return{update:f=>h(c,f),disconnect:()=>a(c)}}}}var d="nprogress",m={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("")},x=null,ze=r=>{Object.assign(m,r),m.includeCSS&&it(m.color)},J=r=>{let e=Oe();r=De(r,m.minimum,1),x=r===1?null:r;let t=Ze(!e),i=t.querySelector(m.barSelector),s=m.speed,n=m.easing;t.offsetWidth,rt(a=>{let h=m.positionUsing==="translate3d"?{transition:`all ${s}ms ${n}`,transform:`translate3d(${Q(r)}%,0,0)`}:m.positionUsing==="translate"?{transition:`all ${s}ms ${n}`,transform:`translate(${Q(r)}%,0)`}:{marginLeft:`${Q(r)}%`};for(let v in h)i.style[v]=h[v];if(r!==1)return setTimeout(a,s);t.style.transition="none",t.style.opacity="1",t.offsetWidth,setTimeout(()=>{t.style.transition=`all ${s}ms linear`,t.style.opacity="0",setTimeout(()=>{He(),a()},s)},s)})},Oe=()=>typeof x=="number",Le=()=>{x||J(0);let r=function(){setTimeout(function(){x&&(ke(),r())},m.trickleSpeed)};m.trickle&&r()},Ye=r=>{!r&&!x||(ke(.3+.5*Math.random()),J(1))},ke=r=>{let e=x;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 i in t)if(e>=t[i][0]&&e<t[i][1])return parseFloat(i);return 0})(),J(De(e+r,0,.994))},Ze=r=>{if(et())return document.getElementById(d);document.documentElement.classList.add(`${d}-busy`);let e=document.createElement("div");e.id=d,e.innerHTML=m.template;let t=e.querySelector(m.barSelector),i=r?"-100":Q(x||0),s=Ue();return t.style.transition="all 0 linear",t.style.transform=`translate3d(${i}%,0,0)`,m.showSpinner||e.querySelector(m.spinnerSelector)?.remove(),s!==document.body&&s.classList.add(`${d}-custom-parent`),s.appendChild(e),e},Ue=()=>tt(m.parent)?m.parent:document.querySelector(m.parent),He=()=>{document.documentElement.classList.remove(`${d}-busy`),Ue().classList.remove(`${d}-custom-parent`),document.getElementById(d)?.remove()},et=()=>document.getElementById(d)!==null,tt=r=>typeof HTMLElement=="object"?r instanceof HTMLElement:r&&typeof r=="object"&&r.nodeType===1&&typeof r.nodeName=="string";function De(r,e,t){return r<e?e:r>t?t:r}var Q=r=>(-1+r)*100,rt=(()=>{let r=[],e=()=>{let t=r.shift();t&&t(e)};return t=>{r.push(t),r.length===1&&e()}})(),it=r=>{let e=document.createElement("style");e.textContent=`
|
|
2
|
-
#${
|
|
1
|
+
function T(r,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>r.apply(this,i),e)}}function d(r,e){return document.dispatchEvent(new CustomEvent(`inertia:${r}`,e))}var Z=r=>d("before",{cancelable:!0,detail:{visit:r}})&&d(`${r.frame}:before`,{cancelable:!0,detail:{visit:r}}),pe=(r,e)=>d("error",{detail:{errors:r}})&&d(`${e}:error`,{detail:{errors:r}}),de=(r,e)=>d("exception",{cancelable:!0,detail:{exception:r}})&&d(`${e}:exception`,{cancelable:!0,detail:{exception:r}}),he=r=>d("finish",{detail:{visit:r}})&&d(`${r.frame}:finish`,{detail:{visit:r}}),me=(r,e)=>d("invalid",{cancelable:!0,detail:{response:r}})&&d(`${e}:invalid`,{cancelable:!0,detail:{response:r}}),R=(r,e)=>d("navigate",{detail:{page:r}})&&d(`${e}:navigate`,{detail:{page:r}}),fe=(r,e)=>d("progress",{detail:{progress:r}})&&d(`${e}:progress`,{detail:{progress:r}}),ge=r=>d("start",{detail:{visit:r}})&&d(`${r.frame}:start`,{detail:{visit:r}}),ve=(r,e)=>d("success",{detail:{page:r}})&&d(`${e}:success`,{detail:{page:r}}),be=(r,e)=>d("prefetched",{detail:{fetchedAt:Date.now(),response:r.data,visit:e}})&&d(`${e.frame}:prefetched`,{detail:{fetchedAt:Date.now(),response:r.data,visit:e}}),Pe=r=>d("prefetching",{detail:{visit:r}})&&d(`${r.frame}:prefetching`,{detail:{visit:r}});var h=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 i=this.get(e);i===null?this.set(e,t):this.set(e,{...i,...t})}static remove(e){typeof window<"u"&&window.sessionStorage.removeItem(e)}static removeNested(e,t){let i=this.get(e);i!==null&&(delete i[t],this.set(e,i))}static exists(e){try{return this.get(e)!==null}catch{return!1}}static clear(){typeof window<"u"&&window.sessionStorage.clear()}};h.locationVisitKey="inertiaLocationVisit";var ye=async r=>{if(typeof window>"u")throw new Error("Unable to encrypt history");let e=Se(),t=await Ee(),i=await _e(t);if(!i)throw new Error("Unable to encrypt history");return await Me(e,i,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)},Me=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 i=new TextEncoder,s=JSON.stringify(t),n=new Uint8Array(s.length*3),a=i.encodeInto(s,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 i=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:r},e,t);return JSON.parse(new TextDecoder().decode(i))},Se=()=>{let r=h.get(q.iv);if(r)return new Uint8Array(r);let e=window.crypto.getRandomValues(new Uint8Array(12));return h.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);h.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=h.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 A=typeof window>"u",$=new C,Re=!A&&/CriOS/.test(window.navigator.userAgent),ee=class{constructor(){this.rememberedState="rememberedState";this.scrollRegions="scrollRegions";this.preserveUrl=!1;this.counter=A?0:window.history.state?.c??0;this.lastChangedFrames=[];this.current={};this.initialState=null}remember(e,t,i){this.preserveUrl=!0,this.replaceState(e,{...this.current[e],rememberedState:{...this.current[e]?.rememberedState??{},[i]:t}})}restore(e,t){if(!A)return this.current?.[e]?.rememberedState?.[t]}pushState(e,t,i=null){A||(this.current[e]=t,$.add(()=>this.getFramesData(this.current,t.encryptHistory).then(s=>{let n=()=>{this.doPushState({frames:s,changedFrames:[e]},this.preserveUrl?window.location.href:t.url),i&&i()};Re?setTimeout(n):n()})))}removeFrame(e){delete this.current[e]}getFramesData(e,t){return new Promise(i=>t?ye(e).then(i):i(e))}processQueue(){return $.process()}decrypt(e=null){if(A)return Promise.resolve(e??l.asFrames());let t=e??window.history.state?.frames;return this.decryptPageData(t).then(i=>{if(!i)throw new Error("Unable to decrypt history");return this.initialState===null?this.initialState=i??void 0:this.current=i??{},i})}decryptPageData(e){return e instanceof ArrayBuffer?we(e):Promise.resolve(e)}saveScrollPositions(e){$.add(()=>Promise.resolve().then(()=>{window.history.state?.frames&&this.doReplaceState({frames:window.history.state.frames,scrollRegions:e},document.location.href)}))}saveDocumentScrollPosition(e){$.add(()=>Promise.resolve().then(()=>{window.history.state?.frames&&this.doReplaceState({...window.history.state,documentScrollPosition:e},window.location.href)}))}getScrollRegions(){return window.history.state?.scrollRegions||[]}getDocumentScrollPosition(){return window.history.state?.documentScrollPosition||{top:0,left:0}}replaceState(e,t,i=null){l.for(e).currentPage.merge(t),!A&&(this.current[e]=l.for(e).currentPage.get(),this.getFramesData(this.current,t.encryptHistory).then(s=>{let n=()=>{let a=window.history.state?.changedFrames||[];a.includes(e)||a.push(e),this.doReplaceState({frames:s,changedFrames:a},this.preserveUrl?window.location.href:t.url),i&&i()};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(){h.remove(q.key),h.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 g=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(){typeof window<"u"&&window.scrollTo(0,0),this.regions().forEach(e=>{typeof e.scrollTo=="function"?e.scrollTo(0,0):(e.scrollTop=0,e.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,i)=>{let s=e[i];s&&(typeof t.scrollTo=="function"?t.scrollTo(s.left,s.top):(t.scrollTop=s.top,t.scrollLeft=s.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 je from"deepmerge";import*as M 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 i in r)Object.prototype.hasOwnProperty.call(r,i)&&xe(e,Fe(t,i),r[i]);return e}function Fe(r,e){return r?r+"["+e+"]":e}function xe(r,e,t){if(Array.isArray(t))return Array.from(t.keys()).forEach(i=>xe(r,Fe(e,i.toString()),t[i]));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,i,s)=>{let n=typeof r=="string"?y(r):r;if((N(e)||i)&&!te(e)&&(e=re(e)),te(e))return[n,e];let[a,p]=Ce(t,n,e,s);return[y(a),p]};function Ce(r,e,t,i="brackets"){let s=/^https?:\/\//.test(e.toString()),n=s||e.toString().startsWith("/"),a=!n&&!e.toString().startsWith("#")&&!e.toString().startsWith("?"),p=e.toString().includes("?")||r==="get"&&Object.keys(t).length,b=e.toString().includes("#"),u=new URL(e.toString(),"http://localhost");return r==="get"&&Object.keys(t).length&&(u.search=M.stringify(je(M.parse(u.search,{ignoreQueryPrefix:!0}),t),{encodeValuesOnly:!0,arrayFormat:i}),t={}),[[s?`${u.protocol}//${u.host}`:"",n?u.pathname:"",a?u.pathname.substring(1):"",p?u.search:"",b?u.hash:""].join(""),t]}function V(r){return r=new URL(r.href),r.hash="",r}var ie=(r,e)=>{r.hash&&!e.hash&&V(r).href===e.href&&(e.hash=r.hash)},k=(r,e)=>V(r).href===V(e).href;var se=class{constructor(){this.internalListeners=[]}init(){typeof window<"u"&&(window.addEventListener("popstate",e=>setTimeout(this.handlePopstateEvent.bind(this,e))),window.addEventListener("scroll",T(g.onWindowScroll.bind(g),100),!0)),typeof document<"u"&&document.addEventListener("scroll",T(g.onScroll.bind(g),100),!0)}onGlobalEvent(e,t,i){let s=n=>{let a=i(n);n.cancelable&&!n.defaultPrevented&&a===!1&&n.preventDefault()};return this.registerListener(`inertia:${e}:${t}`,s)}on(e,t){return this.internalListeners.push({event:e,listener:t}),()=>{this.internalListeners=this.internalListeners.filter(i=>i.listener!==t)}}onMissingHistoryItem(){l.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 s=y(l.for("_top").currentPage.get().url);s.hash=window.location.hash,o.replaceState("_top",{...l.for("_top").currentPage.get(),url:s.href}),g.reset();return}if(!o.isValidState(t))return this.onMissingHistoryItem();let i=[];t.c<o.counter&&(i=o.lastChangedFrames||[]),t.c>o.counter&&(i=window.history.state?.changedFrames||[]),o.counter=t.c,o.lastChangedFrames=t.changedFrames||[],o.decrypt(t.frames).then(s=>{let n=i.map(async a=>{if(!s[a])return;let p=l.for(a)?.currentPage;p&&(await p.setQuietly(s[a],{preserveState:!1}),R(p.get(),a))});Promise.all(n).then(()=>{g.restore(o.getScrollRegions())})}).catch(()=>{this.onMissingHistoryItem()})}},w=new se;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"}},G=new ne;var B=class{static handle(){this.clearRememberedStateOnReload(),[this.handleBackForward,this.handleLocation,this.handleDefault].find(t=>t.bind(this)())}static clearRememberedStateOnReload(){G.isReload()&&o.deleteState(o.rememberedState)}static handleBackForward(){if(!G.isBackForward()||!o.hasAnyState())return!1;let e=l.for("_top").currentPage,t=o.getScrollRegions();return o.decrypt().then(i=>{l.set(i,{preserveScroll:!0,preserveState:!0}).then(()=>{g.restore(t),R(e.get(),"_top")})}).catch(()=>{w.onMissingHistoryItem()}),!0}static handleLocation(){if(!h.exists(h.locationVisitKey))return!1;let e=h.get(h.locationVisitKey)||{};h.remove(h.locationVisitKey);let t=l.for("_top").currentPage;return typeof window<"u"&&t.setUrlHash(window.location.hash),o.decrypt().then(()=>{let i=o.getState(o.rememberedState,{}),s=o.getScrollRegions();t.remember(i),t.set(t.get(),{preserveScroll:e.preserveScroll,preserveState:!0}).then(()=>{e.preserveScroll&&g.restore(s),R(t.get(),"_top")})}).catch(()=>{w.onMissingHistoryItem()}),!0}static handleDefault(){let e=l.for("_top").currentPage;typeof window<"u"&&e.setUrlHash(window.location.hash),e.set(e.get(),{preserveScroll:!0,preserveState:!0}).then(()=>{G.isReload()&&g.restore(o.getScrollRegions()),R(e.get(),"_top")})}};var K=class{constructor({name:e,initialPage:t,swapComponent:i,resolveComponent:s}){this.componentId={};this.listeners=[];this.isFirstPageLoad=!0;this.cleared=!1;return this.name=e,this.page=t,this.swapComponent=i,this.resolveComponent=s,this}set(e,{replace:t=!1,preserveScroll:i=!1,preserveState:s=!1,preserveUrl:n=!1}={}){this.componentId={};let a=this.componentId;return e.clearHistory&&o.clear(),this.resolve(e.component).then(p=>{if(a!==this.componentId)return;let b=typeof window<"u"?window.location:new URL(e.url);return t=t||!n&&k(y(e.url),b),new Promise(u=>{t?o.replaceState(this.name,e,()=>u(null)):o.pushState(this.name,e,()=>u(null))}).then(()=>{let u=!this.isTheSame(e);return this.page=e,this.cleared=!1,u&&this.fireEventsFor("newComponent"),this.isFirstPageLoad&&this.fireEventsFor("firstLoad"),this.isFirstPageLoad=!1,this.swap({component:p,page:e,preserveState:s}).then(()=>{i||g.reset(),w.fireInternalEvent(`${this.name}:loadDeferredProps`),t||R(e,this.name)})})})}setQuietly(e,{preserveState:t=!1}={}){return this.resolve(e.component).then(i=>(this.page=e,this.cleared=!1,o.setCurrent(this.name,e),this.swap({component:i,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:i}){return this.swapComponent({component:e,page:t,preserveState:i})}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(i=>i.event!==e&&i.callback!==t)}}fireEventsFor(e){this.listeners.filter(t=>t.event===e).forEach(t=>t.callback())}};var _=class{constructor(e,t,i){this.id=null;this.throttle=!1;this.keepAlive=!1;this.cbCount=0;this.keepAlive=i.keepAlive??!1,this.cb=t,this.interval=e,(i.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,i){let s=new _(e,t,i);return this.polls.push(s),{stop:()=>s.stop(),start:()=>s.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)}},Te=new oe;var ae=(r,e,t)=>{if(r===e)return!0;for(let i in r)if(!t.includes(i)&&r[i]!==e[i]&&!We(r[i],e[i]))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:i}){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,p]=this.extractStaleValues(i),b=new Promise((u,c)=>{t({...e,onCancel:()=>{this.remove(e),e.onCancel(),c()},onError:v=>{this.remove(e),e.onError(v,e.frame),c()},onPrefetching(v){e.onPrefetching(v)},onPrefetched(v,Y){e.onPrefetched(v,Y)},onPrefetchResponse(v){u(v)}})}).then(u=>(this.remove(e),this.cached.push({params:{...e},staleTimestamp:Date.now()+a,response:b,singleUse:i===0,timestamp:Date.now(),inFlight:!1}),this.scheduleForRemoval(e,p),this.inFlightRequests=this.inFlightRequests.filter(c=>!this.paramsAreEqual(c.params,e)),u.handlePrefetch(),u));return this.inFlightRequests.push({params:{...e},response:b,staleTimestamp:null,inFlight:!0}),b}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,i]=this.cacheForToStaleAndExpires(e);return[le(t),le(i)]}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(i=>this.paramsAreEqual(i.params,e));t&&(clearTimeout(t.timer),this.removalTimers=this.removalTimers.filter(i=>i!==t))}scheduleForRemoval(e,t){if(!(typeof window>"u")&&(this.clearTimer(e),t>0)){let i=window.setTimeout(()=>this.remove(e),t);this.removalTimers.push({params:e,timer:i})}}get(e){return this.findCached(e)||this.findInFlight(e)}use(e,t){let i=`${t.url.pathname}-${Date.now()}-${Math.random().toString(36).substring(7)}`;return this.currentUseId=i,e.response.then(s=>{if(this.currentUseId===i)return s.mergeParams({...t,onPrefetched:()=>{}}),this.removeSingleUseItems(t),s.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"])}},F=new ce;import{default as Ve}from"axios";var j=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"?{}: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"]=l.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(...i)=>{this.recordCallback(t,i),e[t](...i)}}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(i=>i.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,O=class r{constructor(e,t,i){this.requestParams=e;this.response=t;this.originatingPage=i}static create(e,t,i){return new r(e,t,i)}async handlePrefetch(){k(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=l.for(e).currentPage,i=t.get().props.errors||{};if(Object.keys(i).length>0){let s=this.getScopedErrors(i);return pe(s,e),this.requestParams.all().onError(s,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 ie(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(h.set(h.locationVisitKey,{preserveScroll:this.requestParams.all().preserveScroll===!0}),typeof window>"u")return;k(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,i=l.for(t).currentPage;return this.mergeProps(e),await this.setRememberedState(e),this.requestParams.setPreserveOptions(e),i.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=l.for(this.requestParams.all().frame).currentPage;if(this.originatingPage.component!==t.get().component)return!1;let i=y(this.originatingPage.url),s=y(t.get().url);return i.origin===s.origin&&i.pathname===s.pathname}pageUrl(e){let t=y(e.url);return ie(this.requestParams.all().url,t),t.pathname+t.search+t.hash}mergeProps(e){let t=l.for(this.requestParams.all().frame).currentPage;this.requestParams.isPartial()&&e.component===t.get().component&&((e.mergeProps||[]).forEach(s=>{let n=e.props[s];Array.isArray(n)?e.props[s]=[...t.get().props[s]||[],...n]:typeof n=="object"&&(e.props[s]={...t.get().props[s]||[],...n})}),e.props={...t.get().props,...e.props})}async setRememberedState(e){let t=await o.getState(o.rememberedState,{}),i=l.for(this.requestParams.all().frame).currentPage;this.requestParams.all().preserveState&&t&&e.component===i.get().component&&(e.rememberedState=t)}getScopedErrors(e){return this.requestParams.all().errorBag?e[this.requestParams.all().errorBag||""]||{}:e}};var U=class r{constructor(e,t){this.page=t;this.requestHasFinished=!1;this.requestParams=j.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:V(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=O.create(this.requestParams,t,this.page),this.response.handle())).catch(t=>t?.response?(this.response=O.create(this.requestParams,t.response,this.page),this.response.handle()):Promise.reject(t)).catch(t=>{if(!Ve.isCancel(t)&&de(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=l.for("_top").currentPage.get(),i=l.for(this.requestParams.all().frame).currentPage.get();return t.version&&(e["X-Inertia-Version"]=t.version),i.url&&(e["X-Inertia-Frame-Src"]=i.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}={},i){if(!this.shouldCancel(i))return;this.requests.shift()?.cancel({interrupted:t,cancelled:e})}shouldCancel(e){return e?!0:this.interruptible&&this.requests.length>=this.maxConcurrent}};var I={},l=class{constructor({name:e,initialPage:t,resolveComponent:i,swapComponent:s}){this.syncRequestStream=new H({maxConcurrent:1,interruptible:!0});this.asyncRequestStream=new H({maxConcurrent:1/0,interruptible:!1});this.name=e,this.currentPage=new K({name:e,initialPage:t,resolveComponent:i,swapComponent:s}),I[e]=this,e=="_top"&&(B.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,i])=>(e[t]=i.currentPage.get(),e),{})}static for(e){return I[e]}static setQuietly(e,{preserveState:t=!1}={}){return Promise.all(Object.entries(I).map(([i,s])=>e[i]?s.currentPage.setQuietly(e[i],{preserveState:t}):(console.log("no page for router",i),Promise.resolve())))}static set(e,{replace:t=!1,preserveScroll:i=!1,preserveState:s=!1}={}){return Promise.all(Object.entries(I).map(([n,a])=>a.currentPage.set(e[n],{replace:t,preserveScroll:i,preserveState:s})))}destroy(){this.cancelAll(),o.removeFrame(this.name),delete I[this.name]}get(e,t={},i={}){return this.visit(e,{...i,method:"get",data:t})}post(e,t={},i={}){return this.visit(e,{preserveState:!0,...i,method:"post",data:t})}put(e,t={},i={}){return this.visit(e,{preserveState:!0,...i,method:"put",data:t})}patch(e,t={},i={}){return this.visit(e,{preserveState:!0,...i,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(window.location.href,{...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={},i={}){return Te.add(e,()=>this.reload(t),{autoStart:i.autoStart??!0,keepAlive:i.keepAlive??!1})}visit(e,t={}){let i=this.getPendingVisit(e,{...t,showProgress:t.showProgress??!t.async}),s=this.getVisitEvents(t);if(s.onBefore(i)===!1||!Z(i))return;let n=i.async?this.asyncRequestStream:this.syncRequestStream;n.interruptInFlight(),!this.currentPage.isCleared()&&!i.preserveUrl&&g.save();let a={...i,...s},p=F.get(a);p?(W(p.inFlight),F.use(p,a)):(W(!0),n.send(U.create(a,this.currentPage.get())))}getCached(e,t={}){return F.findCached(this.getPrefetchParams(e,t))}flush(e,t={}){F.remove(this.getPrefetchParams(e,t))}flushAll(){F.removeAll()}getPrefetching(e,t={}){return F.findInFlight(this.getPrefetchParams(e,t))}prefetch(e,t={},{cacheFor:i=3e4}){if(t.method!=="get")throw new Error("Prefetch requests must use the GET method");let s=this.getPendingVisit(e,{...t,async:!0,showProgress:!1,prefetch:!0}),n=s.url.origin+s.url.pathname+s.url.search,a=window.location.origin+window.location.pathname+window.location.search;if(n===a)return;let p=this.getVisitEvents(t);if(p.onBefore(s)===!1||!Z(s))return;X(),this.asyncRequestStream.interruptInFlight();let b={...s,...p};new Promise(c=>{let v=()=>{this.currentPage.get()?c():setTimeout(v,50)};v()}).then(()=>{F.add(b,c=>{this.asyncRequestStream.send(U.create(c,this.currentPage.get()))},{cacheFor:i})})}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 i=this.currentPage.get(),s=typeof e.props=="function"?e.props(i.props):e.props??i.props;this.currentPage.set({...i,...e,props:s},{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,i={}){let s={method:"get",data:{},replace:!1,preserveScroll:!1,preserveState:!1,only:[],except:[],headers:{},errorBag:"",forceFormData:!1,queryStringArrayFormat:"brackets",async:!1,showProgress:!0,fresh:!1,reset:[],preserveUrl:!1,prefetch:!1,frame:this.name,...t},[n,a]=qe(e,s.data,s.method,s.forceFormData,s.queryStringArrayFormat);return{cancelled:!1,completed:!1,interrupted:!1,...s,...i,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,i])=>{this.reload({only:i})})}};var Je={buildDOMElement(r){let e=document.createElement("template");e.innerHTML=r;let t=e.content.firstChild;if(!r.startsWith("<script "))return t;let i=document.createElement("script");return i.innerHTML=t.innerHTML,t.getAttributeNames().forEach(s=>{i.setAttribute(s,t.getAttribute(s)||"")}),i},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(i=>i.getAttribute("inertia")===t):-1},update:T(function(r){let e=r.map(i=>this.buildDOMElement(i));Array.from(document.head.childNodes).filter(i=>this.isInertiaManagedElement(i)).forEach(i=>{let s=this.findMatchingElementIndex(i,e);if(s===-1){i?.parentNode?.removeChild(i);return}let n=e.splice(s,1)[0];n&&!i.isEqualNode(n)&&i?.parentNode?.replaceChild(n,i)}),e.forEach(i=>document.head.appendChild(i))},1)};function Ie(r,e,t){let i={},s=0;function n(){let c=s+=1;return i[c]=[],c.toString()}function a(c){c===null||Object.keys(i).indexOf(c)===-1||(delete i[c],u())}function p(c,v=[]){c!==null&&Object.keys(i).indexOf(c)>-1&&(i[c]=v),u()}function b(){let c=e(""),v={...c?{title:`<title inertia="">${c}</title>`}:{}},Y=Object.values(i).reduce((S,E)=>S.concat(E),[]).reduce((S,E)=>{if(E.indexOf("<")===-1)return S;if(E.indexOf("<title ")===0){let D=E.match(/(<title [^>]+>)(.*?)(<\/title>)/);return S.title=D?`${D[1]}${e(D[2])}${D[3]}`:E,S}let ue=E.match(/ inertia="[^"]+"/);return ue?S[ue[0]]=E:S[Object.keys(S).length]=E,S},v);return Object.values(Y)}function u(){r?t(b()):Je.update(b())}return u(),{forceUpdate:u,createProvider:function(){let c=n();return{update:v=>p(c,v),disconnect:()=>a(c)}}}}var m="nprogress",f={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("")},x=null,ze=r=>{Object.assign(f,r),f.includeCSS&&it(f.color)},J=r=>{let e=Le();r=De(r,f.minimum,1),x=r===1?null:r;let t=Ze(!e),i=t.querySelector(f.barSelector),s=f.speed,n=f.easing;t.offsetWidth,rt(a=>{let p=f.positionUsing==="translate3d"?{transition:`all ${s}ms ${n}`,transform:`translate3d(${Q(r)}%,0,0)`}:f.positionUsing==="translate"?{transition:`all ${s}ms ${n}`,transform:`translate(${Q(r)}%,0)`}:{marginLeft:`${Q(r)}%`};for(let b in p)i.style[b]=p[b];if(r!==1)return setTimeout(a,s);t.style.transition="none",t.style.opacity="1",t.offsetWidth,setTimeout(()=>{t.style.transition=`all ${s}ms linear`,t.style.opacity="0",setTimeout(()=>{He(),a()},s)},s)})},Le=()=>typeof x=="number",ke=()=>{x||J(0);let r=function(){setTimeout(function(){x&&(Oe(),r())},f.trickleSpeed)};f.trickle&&r()},Ye=r=>{!r&&!x||(Oe(.3+.5*Math.random()),J(1))},Oe=r=>{let e=x;if(e===null)return ke();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 i in t)if(e>=t[i][0]&&e<t[i][1])return parseFloat(i);return 0})(),J(De(e+r,0,.994))},Ze=r=>{if(et())return document.getElementById(m);document.documentElement.classList.add(`${m}-busy`);let e=document.createElement("div");e.id=m,e.innerHTML=f.template;let t=e.querySelector(f.barSelector),i=r?"-100":Q(x||0),s=Ue();return t.style.transition="all 0 linear",t.style.transform=`translate3d(${i}%,0,0)`,f.showSpinner||e.querySelector(f.spinnerSelector)?.remove(),s!==document.body&&s.classList.add(`${m}-custom-parent`),s.appendChild(e),e},Ue=()=>tt(f.parent)?f.parent:document.querySelector(f.parent),He=()=>{document.documentElement.classList.remove(`${m}-busy`),Ue().classList.remove(`${m}-custom-parent`),document.getElementById(m)?.remove()},et=()=>document.getElementById(m)!==null,tt=r=>typeof HTMLElement=="object"?r instanceof HTMLElement:r&&typeof r=="object"&&r.nodeType===1&&typeof r.nodeName=="string";function De(r,e,t){return r<e?e:r>t?t:r}var Q=r=>(-1+r)*100,rt=(()=>{let r=[],e=()=>{let t=r.shift();t&&t(e)};return t=>{r.push(t),r.length===1&&e()}})(),it=r=>{let e=document.createElement("style");e.textContent=`
|
|
2
|
+
#${m} {
|
|
3
3
|
pointer-events: none;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
#${
|
|
6
|
+
#${m} .bar {
|
|
7
7
|
background: ${r};
|
|
8
8
|
|
|
9
9
|
position: fixed;
|
|
@@ -15,7 +15,7 @@ function T(r,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>r.a
|
|
|
15
15
|
height: 2px;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
#${
|
|
18
|
+
#${m} .peg {
|
|
19
19
|
display: block;
|
|
20
20
|
position: absolute;
|
|
21
21
|
right: 0px;
|
|
@@ -27,7 +27,7 @@ function T(r,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>r.a
|
|
|
27
27
|
transform: rotate(3deg) translate(0px, -4px);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
#${
|
|
30
|
+
#${m} .spinner {
|
|
31
31
|
display: block;
|
|
32
32
|
position: fixed;
|
|
33
33
|
z-index: 1031;
|
|
@@ -35,7 +35,7 @@ function T(r,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>r.a
|
|
|
35
35
|
right: 15px;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
#${
|
|
38
|
+
#${m} .spinner-icon {
|
|
39
39
|
width: 18px;
|
|
40
40
|
height: 18px;
|
|
41
41
|
box-sizing: border-box;
|
|
@@ -45,24 +45,24 @@ function T(r,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>r.a
|
|
|
45
45
|
border-left-color: ${r};
|
|
46
46
|
border-radius: 50%;
|
|
47
47
|
|
|
48
|
-
animation: ${
|
|
48
|
+
animation: ${m}-spinner 400ms linear infinite;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
.${
|
|
51
|
+
.${m}-custom-parent {
|
|
52
52
|
overflow: hidden;
|
|
53
53
|
position: relative;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
.${
|
|
57
|
-
.${
|
|
56
|
+
.${m}-custom-parent #${m} .spinner,
|
|
57
|
+
.${m}-custom-parent #${m} .bar {
|
|
58
58
|
position: absolute;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
@keyframes ${
|
|
61
|
+
@keyframes ${m}-spinner {
|
|
62
62
|
0% { transform: rotate(0deg); }
|
|
63
63
|
100% { transform: rotate(360deg); }
|
|
64
64
|
}
|
|
65
|
-
`,document.head.appendChild(e)},
|
|
65
|
+
`,document.head.appendChild(e)},L=(()=>{if(typeof document>"u")return null;let r=document.createElement("style");return r.innerHTML=`#${m} { display: none; }`,r})(),st=()=>{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:Le,done:Ye,set:J,remove:He,start:ke,status:x,show:st,hide:nt};var z=0,W=(r=!1)=>{z=Math.max(0,z-1),(r||z===0)&&P.show()},X=()=>{z++,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||X();let t=setTimeout(()=>P.start(),e);document.addEventListener("inertia:_top:finish",i=>ct(i,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:i=!1}={}){ot(r),P.configure({showSpinner:i,includeCSS:t,color:e})}function Ne(r){let e=r.target.closest("[href]")?.hasAttribute("href");return!(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{l as Router,Ie as createHeadManager,X as hideProgress,y as hrefToUrl,Ce as mergeDataIntoQueryString,W as revealProgress,$e as setupProgress,Ne as shouldIntercept,V 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
|