New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@inertiajs/core

Package Overview
Dependencies
Maintainers
4
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inertiajs/core - npm Package Compare versions

Comparing version 1.0.0-beta.2 to 1.0.0-beta.3

73

dist/index.esm.js

@@ -1,2 +0,73 @@

import e from"axios";import{stringify as t,parse as n}from"qs";import i from"deepmerge";import r from"nprogress";function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}var s,a={modal:null,listener:null,show:function(e){var t=this;"object"==typeof e&&(e="All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.<hr>"+JSON.stringify(e));var n=document.createElement("html");n.innerHTML=e,n.querySelectorAll("a").forEach(function(e){return e.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",function(){return t.hide()});var i=document.createElement("iframe");if(i.style.backgroundColor="white",i.style.borderRadius="5px",i.style.width="100%",i.style.height="100%",this.modal.appendChild(i),document.body.prepend(this.modal),document.body.style.overflow="hidden",!i.contentWindow)throw new Error("iframe not yet ready.");i.contentWindow.document.open(),i.contentWindow.document.write(n.outerHTML),i.contentWindow.document.close(),this.listener=this.hideOnEscape.bind(this),document.addEventListener("keydown",this.listener)},hide:function(){this.modal.outerHTML="",this.modal=null,document.body.style.overflow="visible",document.removeEventListener("keydown",this.listener)},hideOnEscape:function(e){27===e.keyCode&&this.hide()}};function l(e,t){var n;return function(){var i=arguments,r=this;clearTimeout(n),n=setTimeout(function(){return e.apply(r,[].slice.call(i))},t)}}function c(e,t,n){for(var i in void 0===t&&(t=new FormData),void 0===n&&(n=null),e=e||{})Object.prototype.hasOwnProperty.call(e,i)&&u(t,d(n,i),e[i]);return t}function d(e,t){return e?e+"["+t+"]":t}function u(e,t,n){return Array.isArray(n)?Array.from(n.keys()).forEach(function(i){return u(e,d(t,i.toString()),n[i])}):n instanceof Date?e.append(t,n.toISOString()):n instanceof File?e.append(t,n,n.name):n instanceof Blob?e.append(t,n):"boolean"==typeof n?e.append(t,n?"1":"0"):"string"==typeof n?e.append(t,n):"number"==typeof n?e.append(t,""+n):null==n?e.append(t,""):void c(n,e,t)}function p(e){return new URL(e.toString(),window.location.toString())}function h(e,r,o,a){void 0===a&&(a="brackets");var l=/^https?:\/\//.test(r.toString()),c=l||r.toString().startsWith("/"),d=!c&&!r.toString().startsWith("#")&&!r.toString().startsWith("?"),u=r.toString().includes("?")||e===s.GET&&Object.keys(o).length,p=r.toString().includes("#"),h=new URL(r.toString(),"http://localhost");return e===s.GET&&Object.keys(o).length&&(h.search=t(i(n(h.search,{ignoreQueryPrefix:!0}),o),{encodeValuesOnly:!0,arrayFormat:a}),o={}),[[l?h.protocol+"//"+h.host:"",c?h.pathname:"",d?h.pathname.substring(1):"",u?h.search:"",p?h.hash:""].join(""),o]}function f(e){return(e=new URL(e.href)).hash="",e}function v(e,t){return document.dispatchEvent(new CustomEvent("inertia:"+e,t))}!function(e){e.GET="get",e.POST="post",e.PUT="put",e.PATCH="patch",e.DELETE="delete"}(s||(s={}));var m=function(e){return v("finish",{detail:{visit:e}})},g=function(e){return v("navigate",{detail:{page:e}})},w="undefined"==typeof window,y=function(){function t(){this.visitId=null}var n=t.prototype;return n.init=function(e){var t=e.resolveComponent,n=e.swapComponent;this.page=e.initialPage,this.resolveComponent=t,this.swapComponent=n,this.setNavigationType(),this.clearRememberedStateOnReload(),this.isBackForwardVisit()?this.handleBackForwardVisit(this.page):this.isLocationVisit()?this.handleLocationVisit(this.page):this.handleInitialPageVisit(this.page),this.setupEventListeners()},n.setNavigationType=function(){this.navigationType=window.performance&&window.performance.getEntriesByType("navigation").length>0?window.performance.getEntriesByType("navigation")[0].type:"navigate"},n.clearRememberedStateOnReload=function(){var e;"reload"===this.navigationType&&null!=(e=window.history.state)&&e.rememberedState&&delete window.history.state.rememberedState},n.handleInitialPageVisit=function(e){this.page.url+=window.location.hash,this.setPage(e,{preserveState:!0}).then(function(){return g(e)})},n.setupEventListeners=function(){window.addEventListener("popstate",this.handlePopstateEvent.bind(this)),document.addEventListener("scroll",l(this.handleScrollEvent.bind(this),100),!0)},n.scrollRegions=function(){return document.querySelectorAll("[scroll-region]")},n.handleScrollEvent=function(e){"function"==typeof e.target.hasAttribute&&e.target.hasAttribute("scroll-region")&&this.saveScrollPositions()},n.saveScrollPositions=function(){this.replaceState(o({},this.page,{scrollRegions:Array.from(this.scrollRegions()).map(function(e){return{top:e.scrollTop,left:e.scrollLeft}})}))},n.resetScrollPositions=function(){var e;window.scrollTo(0,0),this.scrollRegions().forEach(function(e){"function"==typeof e.scrollTo?e.scrollTo(0,0):(e.scrollTop=0,e.scrollLeft=0)}),this.saveScrollPositions(),window.location.hash&&(null==(e=document.getElementById(window.location.hash.slice(1)))||e.scrollIntoView())},n.restoreScrollPositions=function(){var e=this;this.page.scrollRegions&&this.scrollRegions().forEach(function(t,n){var i=e.page.scrollRegions[n];i&&("function"==typeof t.scrollTo?t.scrollTo(i.left,i.top):(t.scrollTop=i.top,t.scrollLeft=i.left))})},n.isBackForwardVisit=function(){return window.history.state&&"back_forward"===this.navigationType},n.handleBackForwardVisit=function(e){var t=this;window.history.state.version=e.version,this.setPage(window.history.state,{preserveScroll:!0,preserveState:!0}).then(function(){t.restoreScrollPositions(),g(e)})},n.locationVisit=function(e,t){try{window.sessionStorage.setItem("inertiaLocationVisit",JSON.stringify({preserveScroll:t})),window.location.href=e.href,f(window.location).href===f(e).href&&window.location.reload()}catch(e){return!1}},n.isLocationVisit=function(){try{return null!==window.sessionStorage.getItem("inertiaLocationVisit")}catch(e){return!1}},n.handleLocationVisit=function(e){var t,n,i,r,o=this,s=JSON.parse(window.sessionStorage.getItem("inertiaLocationVisit")||"");window.sessionStorage.removeItem("inertiaLocationVisit"),e.url+=window.location.hash,e.rememberedState=null!=(t=null==(n=window.history.state)?void 0:n.rememberedState)?t:{},e.scrollRegions=null!=(i=null==(r=window.history.state)?void 0:r.scrollRegions)?i:[],this.setPage(e,{preserveScroll:s.preserveScroll,preserveState:!0}).then(function(){s.preserveScroll&&o.restoreScrollPositions(),g(e)})},n.isLocationVisitResponse=function(e){return!(!e||409!==e.status||!e.headers["x-inertia-location"])},n.isInertiaResponse=function(e){return!(null==e||!e.headers["x-inertia"])},n.createVisitId=function(){return this.visitId={},this.visitId},n.cancelVisit=function(e,t){var n=t.cancelled,i=void 0!==n&&n,r=t.interrupted,o=void 0!==r&&r;!e||e.completed||e.cancelled||e.interrupted||(e.cancelToken.cancel(),e.onCancel(),e.completed=!1,e.cancelled=i,e.interrupted=o,m(e),e.onFinish(e))},n.finishVisit=function(e){e.cancelled||e.interrupted||(e.completed=!0,e.cancelled=!1,e.interrupted=!1,m(e),e.onFinish(e))},n.resolvePreserveOption=function(e,t){return"function"==typeof e?e(t):"errors"===e?Object.keys(t.props.errors||{}).length>0:e},n.visit=function(t,n){var i=this,r=void 0===n?{}:n,l=r.method,d=void 0===l?s.GET:l,u=r.data,m=void 0===u?{}:u,g=r.replace,w=void 0!==g&&g,y=r.preserveScroll,S=void 0!==y&&y,b=r.preserveState,E=void 0!==b&&b,x=r.only,T=void 0===x?[]:x,P=r.headers,V=void 0===P?{}:P,L=r.errorBag,k=void 0===L?"":L,I=r.forceFormData,O=void 0!==I&&I,C=r.onCancelToken,R=void 0===C?function(){}:C,A=r.onBefore,F=void 0===A?function(){}:A,j=r.onStart,M=void 0===j?function(){}:j,D=r.onProgress,N=void 0===D?function(){}:D,B=r.onFinish,q=void 0===B?function(){}:B,H=r.onCancel,W=void 0===H?function(){}:H,G=r.onSuccess,U=void 0===G?function(){}:G,X=r.onError,z=void 0===X?function(){}:X,J=r.queryStringArrayFormat,K=void 0===J?"brackets":J,_="string"==typeof t?p(t):t;if(!function e(t){return t instanceof File||t instanceof Blob||t instanceof FileList&&t.length>0||t instanceof FormData&&Array.from(t.values()).some(function(t){return e(t)})||"object"==typeof t&&null!==t&&Object.values(t).some(function(t){return e(t)})}(m)&&!O||m instanceof FormData||(m=c(m)),!(m instanceof FormData)){var Q=h(d,_,m,K),Y=Q[1];_=p(Q[0]),m=Y}var Z={url:_,method:d,data:m,replace:w,preserveScroll:S,preserveState:E,only:T,headers:V,errorBag:k,forceFormData:O,queryStringArrayFormat:K,cancelled:!1,completed:!1,interrupted:!1};if(!1!==F(Z)&&function(e){return v("before",{cancelable:!0,detail:{visit:e}})}(Z)){this.activeVisit&&this.cancelVisit(this.activeVisit,{interrupted:!0}),this.saveScrollPositions();var $=this.createVisitId();this.activeVisit=o({},Z,{onCancelToken:R,onBefore:F,onStart:M,onProgress:N,onFinish:q,onCancel:W,onSuccess:U,onError:z,queryStringArrayFormat:K,cancelToken:e.CancelToken.source()}),R({cancel:function(){i.activeVisit&&i.cancelVisit(i.activeVisit,{cancelled:!0})}}),function(e){v("start",{detail:{visit:e}})}(Z),M(Z),e({method:d,url:f(_).href,data:d===s.GET?{}:m,params:d===s.GET?m:{},cancelToken:this.activeVisit.cancelToken.token,headers:o({},V,{Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0},T.length?{"X-Inertia-Partial-Component":this.page.component,"X-Inertia-Partial-Data":T.join(",")}:{},k&&k.length?{"X-Inertia-Error-Bag":k}:{},this.page.version?{"X-Inertia-Version":this.page.version}:{}),onUploadProgress:function(e){m instanceof FormData&&(e.percentage=Math.round(e.loaded/e.total*100),function(e){v("progress",{detail:{progress:e}})}(e),N(e))}}).then(function(e){var t;if(!i.isInertiaResponse(e))return Promise.reject({response:e});var n=e.data;T.length&&n.component===i.page.component&&(n.props=o({},i.page.props,n.props)),S=i.resolvePreserveOption(S,n),(E=i.resolvePreserveOption(E,n))&&null!=(t=window.history.state)&&t.rememberedState&&n.component===i.page.component&&(n.rememberedState=window.history.state.rememberedState);var r=_,s=p(n.url);return r.hash&&!s.hash&&f(r).href===s.href&&(s.hash=r.hash,n.url=s.href),i.setPage(n,{visitId:$,replace:w,preserveScroll:S,preserveState:E})}).then(function(){var e=i.page.props.errors||{};if(Object.keys(e).length>0){var t=k?e[k]?e[k]:{}:e;return function(e){v("error",{detail:{errors:e}})}(t),z(t)}return v("success",{detail:{page:i.page}}),U(i.page)}).catch(function(e){if(i.isInertiaResponse(e.response))return i.setPage(e.response.data,{visitId:$});if(i.isLocationVisitResponse(e.response)){var t=p(e.response.headers["x-inertia-location"]),n=_;n.hash&&!t.hash&&f(n).href===t.href&&(t.hash=n.hash),i.locationVisit(t,!0===S)}else{if(!e.response)return Promise.reject(e);v("invalid",{cancelable:!0,detail:{response:e.response}})&&a.show(e.response.data)}}).then(function(){i.activeVisit&&i.finishVisit(i.activeVisit)}).catch(function(t){if(!e.isCancel(t)){var n=v("exception",{cancelable:!0,detail:{exception:t}});if(i.activeVisit&&i.finishVisit(i.activeVisit),n)return Promise.reject(t)}})}},n.setPage=function(e,t){var n=this,i=void 0===t?{}:t,r=i.visitId,o=void 0===r?this.createVisitId():r,s=i.replace,a=void 0!==s&&s,l=i.preserveScroll,c=void 0!==l&&l,d=i.preserveState,u=void 0!==d&&d;return Promise.resolve(this.resolveComponent(e.component)).then(function(t){o===n.visitId&&(e.scrollRegions=e.scrollRegions||[],e.rememberedState=e.rememberedState||{},(a=a||p(e.url).href===window.location.href)?n.replaceState(e):n.pushState(e),n.swapComponent({component:t,page:e,preserveState:u}).then(function(){c||n.resetScrollPositions(),a||g(e)}))})},n.pushState=function(e){this.page=e,window.history.pushState(e,"",e.url)},n.replaceState=function(e){this.page=e,window.history.replaceState(e,"",e.url)},n.handlePopstateEvent=function(e){var t=this;if(null!==e.state){var n=e.state,i=this.createVisitId();Promise.resolve(this.resolveComponent(n.component)).then(function(e){i===t.visitId&&(t.page=n,t.swapComponent({component:e,page:n,preserveState:!1}).then(function(){t.restoreScrollPositions(),g(n)}))})}else{var r=p(this.page.url);r.hash=window.location.hash,this.replaceState(o({},this.page,{url:r.href})),this.resetScrollPositions()}},n.get=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),this.visit(e,o({},n,{method:s.GET,data:t}))},n.reload=function(e){return void 0===e&&(e={}),this.visit(window.location.href,o({},e,{preserveScroll:!0,preserveState:!0}))},n.replace=function(e,t){var n;return void 0===t&&(t={}),console.warn("Inertia.replace() has been deprecated and will be removed in a future release. Please use Inertia."+(null!=(n=t.method)?n:"get")+"() instead."),this.visit(e,o({preserveState:!0},t,{replace:!0}))},n.post=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),this.visit(e,o({preserveState:!0},n,{method:s.POST,data:t}))},n.put=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),this.visit(e,o({preserveState:!0},n,{method:s.PUT,data:t}))},n.patch=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),this.visit(e,o({preserveState:!0},n,{method:s.PATCH,data:t}))},n.delete=function(e,t){return void 0===t&&(t={}),this.visit(e,o({preserveState:!0},t,{method:s.DELETE}))},n.remember=function(e,t){var n,i;void 0===t&&(t="default"),w||this.replaceState(o({},this.page,{rememberedState:o({},null==(n=this.page)?void 0:n.rememberedState,(i={},i[t]=e,i))}))},n.restore=function(e){var t,n;if(void 0===e&&(e="default"),!w)return null==(t=window.history.state)||null==(n=t.rememberedState)?void 0:n[e]},n.on=function(e,t){var n=function(e){var n=t(e);e.cancelable&&!e.defaultPrevented&&!1===n&&e.preventDefault()};return document.addEventListener("inertia:"+e,n),function(){return document.removeEventListener("inertia:"+e,n)}},t}(),S=null;function b(e){document.addEventListener("inertia:start",E.bind(null,e)),document.addEventListener("inertia:progress",x),document.addEventListener("inertia:finish",T)}function E(e){S=setTimeout(function(){return r.start()},e)}function x(e){var t;r.isStarted()&&null!=(t=e.detail.progress)&&t.percentage&&r.set(Math.max(r.status,e.detail.progress.percentage/100*.9))}function T(e){clearTimeout(S),r.isStarted()&&(e.detail.visit.completed?r.done():e.detail.visit.interrupted?r.set(0):e.detail.visit.cancelled&&(r.done(),r.remove()))}function P(e){var t=void 0===e?{}:e,n=t.delay,i=t.color,o=void 0===i?"#29d":i,s=t.includeCSS,a=void 0===s||s,l=t.showSpinner,c=void 0!==l&&l;b(void 0===n?250:n),r.configure({showSpinner:c}),a&&function(e){var t=document.createElement("style");t.type="text/css",t.textContent="\n #nprogress {\n pointer-events: none;\n }\n\n #nprogress .bar {\n background: "+e+";\n\n position: fixed;\n z-index: 1031;\n top: 0;\n left: 0;\n\n width: 100%;\n height: 2px;\n }\n\n #nprogress .peg {\n display: block;\n position: absolute;\n right: 0px;\n width: 100px;\n height: 100%;\n box-shadow: 0 0 10px "+e+", 0 0 5px "+e+";\n opacity: 1.0;\n\n -webkit-transform: rotate(3deg) translate(0px, -4px);\n -ms-transform: rotate(3deg) translate(0px, -4px);\n transform: rotate(3deg) translate(0px, -4px);\n }\n\n #nprogress .spinner {\n display: block;\n position: fixed;\n z-index: 1031;\n top: 15px;\n right: 15px;\n }\n\n #nprogress .spinner-icon {\n width: 18px;\n height: 18px;\n box-sizing: border-box;\n\n border: solid 2px transparent;\n border-top-color: "+e+";\n border-left-color: "+e+";\n border-radius: 50%;\n\n -webkit-animation: nprogress-spinner 400ms linear infinite;\n animation: nprogress-spinner 400ms linear infinite;\n }\n\n .nprogress-custom-parent {\n overflow: hidden;\n position: relative;\n }\n\n .nprogress-custom-parent #nprogress .spinner,\n .nprogress-custom-parent #nprogress .bar {\n position: absolute;\n }\n\n @-webkit-keyframes nprogress-spinner {\n 0% { -webkit-transform: rotate(0deg); }\n 100% { -webkit-transform: rotate(360deg); }\n }\n @keyframes nprogress-spinner {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n ",document.head.appendChild(t)}(o)}var V={buildDOMElement:function(e){var t=document.createElement("template");t.innerHTML=e;var n=t.content.firstChild;if(!e.startsWith("<script "))return n;var i=document.createElement("script");return i.innerHTML=n.innerHTML,n.getAttributeNames().forEach(function(e){i.setAttribute(e,n.getAttribute(e)||"")}),i},isInertiaManagedElement:function(e){return e.nodeType===Node.ELEMENT_NODE&&null!==e.getAttribute("inertia")},findMatchingElementIndex:function(e,t){var n=e.getAttribute("inertia");return null!==n?t.findIndex(function(e){return e.getAttribute("inertia")===n}):-1},update:l(function(e){var t=this,n=e.map(function(e){return t.buildDOMElement(e)});Array.from(document.head.childNodes).filter(function(e){return t.isInertiaManagedElement(e)}).forEach(function(e){var i=t.findMatchingElementIndex(e,n);if(-1!==i){var r,o=n.splice(i,1)[0];o&&!e.isEqualNode(o)&&(null==e||null==(r=e.parentNode)||r.replaceChild(o,e))}else{var s;null==e||null==(s=e.parentNode)||s.removeChild(e)}}),n.forEach(function(e){return document.head.appendChild(e)})},1)};function L(e,t,n){var i={},r=0;function s(){var e=t(""),n=o({},e?{title:'<title inertia="">'+e+"</title>"}:{}),r=Object.values(i).reduce(function(e,t){return e.concat(t)},[]).reduce(function(e,n){if(-1===n.indexOf("<"))return e;if(0===n.indexOf("<title ")){var i=n.match(/(<title [^>]+>)(.*?)(<\/title>)/);return e.title=i?""+i[1]+t(i[2])+i[3]:n,e}var r=n.match(/ inertia="[^"]+"/);return r?e[r[0]]=n:e[Object.keys(e).length]=n,e},n);return Object.values(r)}function a(){e?n(s()):V.update(s())}return a(),{forceUpdate:a,createProvider:function(){var e=function(){var e=r+=1;return i[e]=[],e.toString()}();return{update:function(t){return function(e,t){void 0===t&&(t=[]),null!==e&&Object.keys(i).indexOf(e)>-1&&(i[e]=t),a()}(e,t)},disconnect:function(){return function(e){null!==e&&-1!==Object.keys(i).indexOf(e)&&(delete i[e],a())}(e)}}}}}function k(e){var t="a"===e.currentTarget.tagName.toLowerCase();return!(e.target&&null!=e&&e.target.isContentEditable||e.defaultPrevented||t&&e.which>1||t&&e.altKey||t&&e.ctrlKey||t&&e.metaKey||t&&e.shiftKey)}var I=new y;export{s as Method,L as createHeadManager,p as hrefToUrl,h as mergeDataIntoQueryString,I as router,P as setupProgress,k as shouldIntercept,f as urlWithoutHash};
import{default as _}from"axios";function T(t,e){let r;return function(...i){clearTimeout(r),r=setTimeout(()=>t.apply(this,i),e)}}function m(t,e){return document.dispatchEvent(new CustomEvent(`inertia:${t}`,e))}var H=t=>m("before",{cancelable:!0,detail:{visit:t}}),j=t=>m("error",{detail:{errors:t}}),q=t=>m("exception",{cancelable:!0,detail:{exception:t}}),O=t=>m("finish",{detail:{visit:t}}),$=t=>m("invalid",{cancelable:!0,detail:{response:t}}),w=t=>m("navigate",{detail:{page:t}}),W=t=>m("progress",{detail:{progress:t}}),B=t=>m("start",{detail:{visit:t}}),K=t=>m("success",{detail:{page:t}});function L(t){return t instanceof File||t instanceof Blob||t instanceof FileList&&t.length>0||t instanceof FormData&&Array.from(t.values()).some(e=>L(e))||typeof t=="object"&&t!==null&&Object.values(t).some(e=>L(e))}function k(t,e=new FormData,r=null){t=t||{};for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&J(e,X(r,i),t[i]);return e}function X(t,e){return t?t+"["+e+"]":e}function J(t,e,r){if(Array.isArray(r))return Array.from(r.keys()).forEach(i=>J(t,X(e,i.toString()),r[i]));if(r instanceof Date)return t.append(e,r.toISOString());if(r instanceof File)return t.append(e,r,r.name);if(r instanceof Blob)return t.append(e,r);if(typeof r=="boolean")return t.append(e,r?"1":"0");if(typeof r=="string")return t.append(e,r);if(typeof r=="number")return t.append(e,`${r}`);if(r==null)return t.append(e,"");k(r,t,e)}var z={modal:null,listener:null,show(t){typeof t=="object"&&(t=`All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.<hr>${JSON.stringify(t)}`);let e=document.createElement("html");e.innerHTML=t,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 r=document.createElement("iframe");if(r.style.backgroundColor="white",r.style.borderRadius="5px",r.style.width="100%",r.style.height="100%",this.modal.appendChild(r),document.body.prepend(this.modal),document.body.style.overflow="hidden",!r.contentWindow)throw new Error("iframe not yet ready.");r.contentWindow.document.open(),r.contentWindow.document.write(e.outerHTML),r.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(t){t.keyCode===27&&this.hide()}};var A=(n=>(n.GET="get",n.POST="post",n.PUT="put",n.PATCH="patch",n.DELETE="delete",n))(A||{});import re from"deepmerge";import*as C from"qs";function g(t){return new URL(t.toString(),window.location.toString())}function F(t,e,r,i="brackets"){let s=/^https?:\/\//.test(e.toString()),n=s||e.toString().startsWith("/"),u=!n&&!e.toString().startsWith("#")&&!e.toString().startsWith("?"),f=e.toString().includes("?")||t==="get"&&Object.keys(r).length,b=e.toString().includes("#"),l=new URL(e.toString(),"http://localhost");return t==="get"&&Object.keys(r).length&&(l.search=C.stringify(re(C.parse(l.search,{ignoreQueryPrefix:!0}),r),{encodeValuesOnly:!0,arrayFormat:i}),r={}),[[s?`${l.protocol}//${l.host}`:"",n?l.pathname:"",u?l.pathname.substring(1):"",f?l.search:"",b?l.hash:""].join(""),r]}function x(t){return t=new URL(t.href),t.hash="",t}var Q=typeof window>"u",N=class{constructor(){this.visitId=null}init({initialPage:e,resolveComponent:r,swapComponent:i}){this.page=e,this.resolveComponent=r,this.swapComponent=i,this.setNavigationType(),this.clearRememberedStateOnReload(),this.isBackForwardVisit()?this.handleBackForwardVisit(this.page):this.isLocationVisit()?this.handleLocationVisit(this.page):this.handleInitialPageVisit(this.page),this.setupEventListeners()}setNavigationType(){this.navigationType=window.performance&&window.performance.getEntriesByType("navigation").length>0?window.performance.getEntriesByType("navigation")[0].type:"navigate"}clearRememberedStateOnReload(){this.navigationType==="reload"&&window.history.state?.rememberedState&&delete window.history.state.rememberedState}handleInitialPageVisit(e){this.page.url+=window.location.hash,this.setPage(e,{preserveState:!0}).then(()=>w(e))}setupEventListeners(){window.addEventListener("popstate",this.handlePopstateEvent.bind(this)),document.addEventListener("scroll",T(this.handleScrollEvent.bind(this),100),!0)}scrollRegions(){return document.querySelectorAll("[scroll-region]")}handleScrollEvent(e){typeof e.target.hasAttribute=="function"&&e.target.hasAttribute("scroll-region")&&this.saveScrollPositions()}saveScrollPositions(){this.replaceState({...this.page,scrollRegions:Array.from(this.scrollRegions()).map(e=>({top:e.scrollTop,left:e.scrollLeft}))})}resetScrollPositions(){window.scrollTo(0,0),this.scrollRegions().forEach(e=>{typeof e.scrollTo=="function"?e.scrollTo(0,0):(e.scrollTop=0,e.scrollLeft=0)}),this.saveScrollPositions(),window.location.hash&&setTimeout(()=>document.getElementById(window.location.hash.slice(1))?.scrollIntoView())}restoreScrollPositions(){this.page.scrollRegions&&this.scrollRegions().forEach((e,r)=>{let i=this.page.scrollRegions[r];if(i)typeof e.scrollTo=="function"?e.scrollTo(i.left,i.top):(e.scrollTop=i.top,e.scrollLeft=i.left);else return})}isBackForwardVisit(){return window.history.state&&this.navigationType==="back_forward"}handleBackForwardVisit(e){window.history.state.version=e.version,this.setPage(window.history.state,{preserveScroll:!0,preserveState:!0}).then(()=>{this.restoreScrollPositions(),w(e)})}locationVisit(e,r){try{let i={preserveScroll:r};window.sessionStorage.setItem("inertiaLocationVisit",JSON.stringify(i)),window.location.href=e.href,x(window.location).href===x(e).href&&window.location.reload()}catch{return!1}}isLocationVisit(){try{return window.sessionStorage.getItem("inertiaLocationVisit")!==null}catch{return!1}}handleLocationVisit(e){let r=JSON.parse(window.sessionStorage.getItem("inertiaLocationVisit")||"");window.sessionStorage.removeItem("inertiaLocationVisit"),e.url+=window.location.hash,e.rememberedState=window.history.state?.rememberedState??{},e.scrollRegions=window.history.state?.scrollRegions??[],this.setPage(e,{preserveScroll:r.preserveScroll,preserveState:!0}).then(()=>{r.preserveScroll&&this.restoreScrollPositions(),w(e)})}isLocationVisitResponse(e){return!!(e&&e.status===409&&e.headers["x-inertia-location"])}isInertiaResponse(e){return!!e?.headers["x-inertia"]}createVisitId(){return this.visitId={},this.visitId}cancelVisit(e,{cancelled:r=!1,interrupted:i=!1}){e&&!e.completed&&!e.cancelled&&!e.interrupted&&(e.cancelToken.abort(),e.onCancel(),e.completed=!1,e.cancelled=r,e.interrupted=i,O(e),e.onFinish(e))}finishVisit(e){!e.cancelled&&!e.interrupted&&(e.completed=!0,e.cancelled=!1,e.interrupted=!1,O(e),e.onFinish(e))}resolvePreserveOption(e,r){return typeof e=="function"?e(r):e==="errors"?Object.keys(r.props.errors||{}).length>0:e}cancel(){this.activeVisit&&this.cancelVisit(this.activeVisit,{cancelled:!0})}visit(e,{method:r="get",data:i={},replace:s=!1,preserveScroll:n=!1,preserveState:u=!1,only:f=[],headers:b={},errorBag:l="",forceFormData:c=!1,onCancelToken:v=()=>{},onBefore:R=()=>{},onStart:d=()=>{},onProgress:p=()=>{},onFinish:V=()=>{},onCancel:y=()=>{},onSuccess:D=()=>{},onError:U=()=>{},queryStringArrayFormat:I="brackets"}={}){let P=typeof e=="string"?g(e):e;if((L(i)||c)&&!(i instanceof FormData)&&(i=k(i)),!(i instanceof FormData)){let[o,a]=F(r,P,i,I);P=g(o),i=a}let S={url:P,method:r,data:i,replace:s,preserveScroll:n,preserveState:u,only:f,headers:b,errorBag:l,forceFormData:c,queryStringArrayFormat:I,cancelled:!1,completed:!1,interrupted:!1};if(R(S)===!1||!H(S))return;this.activeVisit&&this.cancelVisit(this.activeVisit,{interrupted:!0}),this.saveScrollPositions();let M=this.createVisitId();this.activeVisit={...S,onCancelToken:v,onBefore:R,onStart:d,onProgress:p,onFinish:V,onCancel:y,onSuccess:D,onError:U,queryStringArrayFormat:I,cancelToken:new AbortController},v({cancel:()=>{this.activeVisit&&this.cancelVisit(this.activeVisit,{cancelled:!0})}}),B(S),d(S),_({method:r,url:x(P).href,data:r==="get"?{}:i,params:r==="get"?i:{},signal:this.activeVisit.cancelToken.signal,headers:{...b,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,...f.length?{"X-Inertia-Partial-Component":this.page.component,"X-Inertia-Partial-Data":f.join(",")}:{},...l&&l.length?{"X-Inertia-Error-Bag":l}:{},...this.page.version?{"X-Inertia-Version":this.page.version}:{}},onUploadProgress:o=>{i instanceof FormData&&(o.percentage=o.progress?Math.round(o.progress*100):0,W(o),p(o))}}).then(o=>{if(!this.isInertiaResponse(o))return Promise.reject({response:o});let a=o.data;f.length&&a.component===this.page.component&&(a.props={...this.page.props,...a.props}),n=this.resolvePreserveOption(n,a),u=this.resolvePreserveOption(u,a),u&&window.history.state?.rememberedState&&a.component===this.page.component&&(a.rememberedState=window.history.state.rememberedState);let E=P,G=g(a.url);return E.hash&&!G.hash&&x(E).href===G.href&&(G.hash=E.hash,a.url=G.href),this.setPage(a,{visitId:M,replace:s,preserveScroll:n,preserveState:u})}).then(()=>{let o=this.page.props.errors||{};if(Object.keys(o).length>0){let a=l?o[l]?o[l]:{}:o;return j(a),U(a)}return K(this.page),D(this.page)}).catch(o=>{if(this.isInertiaResponse(o.response))return this.setPage(o.response.data,{visitId:M});if(this.isLocationVisitResponse(o.response)){let a=g(o.response.headers["x-inertia-location"]),E=P;E.hash&&!a.hash&&x(E).href===a.href&&(a.hash=E.hash),this.locationVisit(a,n===!0)}else if(o.response)$(o.response)&&z.show(o.response.data);else return Promise.reject(o)}).then(()=>{this.activeVisit&&this.finishVisit(this.activeVisit)}).catch(o=>{if(!_.isCancel(o)){let a=q(o);if(this.activeVisit&&this.finishVisit(this.activeVisit),a)return Promise.reject(o)}})}setPage(e,{visitId:r=this.createVisitId(),replace:i=!1,preserveScroll:s=!1,preserveState:n=!1}={}){return Promise.resolve(this.resolveComponent(e.component)).then(u=>{r===this.visitId&&(e.scrollRegions=e.scrollRegions||[],e.rememberedState=e.rememberedState||{},i=i||g(e.url).href===window.location.href,i?this.replaceState(e):this.pushState(e),this.swapComponent({component:u,page:e,preserveState:n}).then(()=>{s||this.resetScrollPositions(),i||w(e)}))})}pushState(e){this.page=e,window.history.pushState(e,"",e.url)}replaceState(e){this.page=e,window.history.replaceState(e,"",e.url)}handlePopstateEvent(e){if(e.state!==null){let r=e.state,i=this.createVisitId();Promise.resolve(this.resolveComponent(r.component)).then(s=>{i===this.visitId&&(this.page=r,this.swapComponent({component:s,page:r,preserveState:!1}).then(()=>{this.restoreScrollPositions(),w(r)}))})}else{let r=g(this.page.url);r.hash=window.location.hash,this.replaceState({...this.page,url:r.href}),this.resetScrollPositions()}}get(e,r={},i={}){return this.visit(e,{...i,method:"get",data:r})}reload(e={}){return this.visit(window.location.href,{...e,preserveScroll:!0,preserveState:!0})}replace(e,r={}){return console.warn(`Inertia.replace() has been deprecated and will be removed in a future release. Please use Inertia.${r.method??"get"}() instead.`),this.visit(e,{preserveState:!0,...r,replace:!0})}post(e,r={},i={}){return this.visit(e,{preserveState:!0,...i,method:"post",data:r})}put(e,r={},i={}){return this.visit(e,{preserveState:!0,...i,method:"put",data:r})}patch(e,r={},i={}){return this.visit(e,{preserveState:!0,...i,method:"patch",data:r})}delete(e,r={}){return this.visit(e,{preserveState:!0,...r,method:"delete"})}remember(e,r="default"){Q||this.replaceState({...this.page,rememberedState:{...this.page?.rememberedState,[r]:e}})}restore(e="default"){if(!Q)return window.history.state?.rememberedState?.[e]}on(e,r){let i=s=>{let n=r(s);s.cancelable&&!s.defaultPrevented&&n===!1&&s.preventDefault()};return document.addEventListener(`inertia:${e}`,i),()=>document.removeEventListener(`inertia:${e}`,i)}};var ie={buildDOMElement(t){let e=document.createElement("template");e.innerHTML=t;let r=e.content.firstChild;if(!t.startsWith("<script "))return r;let i=document.createElement("script");return i.innerHTML=r.innerHTML,r.getAttributeNames().forEach(s=>{i.setAttribute(s,r.getAttribute(s)||"")}),i},isInertiaManagedElement(t){return t.nodeType===Node.ELEMENT_NODE&&t.getAttribute("inertia")!==null},findMatchingElementIndex(t,e){let r=t.getAttribute("inertia");return r!==null?e.findIndex(i=>i.getAttribute("inertia")===r):-1},update:T(function(t){let e=t.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 Y(t,e,r){let i={},s=0;function n(){let c=s+=1;return i[c]=[],c.toString()}function u(c){c===null||Object.keys(i).indexOf(c)===-1||(delete i[c],l())}function f(c,v=[]){c!==null&&Object.keys(i).indexOf(c)>-1&&(i[c]=v),l()}function b(){let c=e(""),v={...c?{title:`<title inertia="">${c}</title>`}:{}},R=Object.values(i).reduce((d,p)=>d.concat(p),[]).reduce((d,p)=>{if(p.indexOf("<")===-1)return d;if(p.indexOf("<title ")===0){let y=p.match(/(<title [^>]+>)(.*?)(<\/title>)/);return d.title=y?`${y[1]}${e(y[2])}${y[3]}`:p,d}let V=p.match(/ inertia="[^"]+"/);return V?d[V[0]]=p:d[Object.keys(d).length]=p,d},v);return Object.values(R)}function l(){t?r(b()):ie.update(b())}return l(),{forceUpdate:l,createProvider:function(){let c=n();return{update:v=>f(c,v),disconnect:()=>u(c)}}}}import h from"nprogress";var Z=null;function oe(t){document.addEventListener("inertia:start",ne.bind(null,t)),document.addEventListener("inertia:progress",se),document.addEventListener("inertia:finish",ae)}function ne(t){Z=setTimeout(()=>h.start(),t)}function se(t){h.isStarted()&&t.detail.progress?.percentage&&h.set(Math.max(h.status,t.detail.progress.percentage/100*.9))}function ae(t){if(clearTimeout(Z),h.isStarted())t.detail.visit.completed?h.done():t.detail.visit.interrupted?h.set(0):t.detail.visit.cancelled&&(h.done(),h.remove());else return}function le(t){let e=document.createElement("style");e.type="text/css",e.textContent=`
#nprogress {
pointer-events: none;
}
#nprogress .bar {
background: ${t};
position: fixed;
z-index: 1031;
top: 0;
left: 0;
width: 100%;
height: 2px;
}
#nprogress .peg {
display: block;
position: absolute;
right: 0px;
width: 100px;
height: 100%;
box-shadow: 0 0 10px ${t}, 0 0 5px ${t};
opacity: 1.0;
-webkit-transform: rotate(3deg) translate(0px, -4px);
-ms-transform: rotate(3deg) translate(0px, -4px);
transform: rotate(3deg) translate(0px, -4px);
}
#nprogress .spinner {
display: block;
position: fixed;
z-index: 1031;
top: 15px;
right: 15px;
}
#nprogress .spinner-icon {
width: 18px;
height: 18px;
box-sizing: border-box;
border: solid 2px transparent;
border-top-color: ${t};
border-left-color: ${t};
border-radius: 50%;
-webkit-animation: nprogress-spinner 400ms linear infinite;
animation: nprogress-spinner 400ms linear infinite;
}
.nprogress-custom-parent {
overflow: hidden;
position: relative;
}
.nprogress-custom-parent #nprogress .spinner,
.nprogress-custom-parent #nprogress .bar {
position: absolute;
}
@-webkit-keyframes nprogress-spinner {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes nprogress-spinner {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
`,document.head.appendChild(e)}function ee({delay:t=250,color:e="#29d",includeCSS:r=!0,showSpinner:i=!1}={}){oe(t),h.configure({showSpinner:i}),r&&le(e)}function te(t){let e=t.currentTarget.tagName.toLowerCase()==="a";return!(t.target&&(t?.target).isContentEditable||t.defaultPrevented||e&&t.which>1||e&&t.altKey||e&&t.ctrlKey||e&&t.metaKey||e&&t.shiftKey)}var Je=new N;export{A as Method,Y as createHeadManager,g as hrefToUrl,F as mergeDataIntoQueryString,Je as router,ee as setupProgress,te as shouldIntercept,x as urlWithoutHash};
//# sourceMappingURL=index.esm.js.map

@@ -1,2 +0,73 @@

function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("axios")),n=require("qs"),r=e(require("deepmerge")),i=e(require("nprogress"));function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var s,a={modal:null,listener:null,show:function(e){var t=this;"object"==typeof e&&(e="All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.<hr>"+JSON.stringify(e));var n=document.createElement("html");n.innerHTML=e,n.querySelectorAll("a").forEach(function(e){return e.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",function(){return t.hide()});var r=document.createElement("iframe");if(r.style.backgroundColor="white",r.style.borderRadius="5px",r.style.width="100%",r.style.height="100%",this.modal.appendChild(r),document.body.prepend(this.modal),document.body.style.overflow="hidden",!r.contentWindow)throw new Error("iframe not yet ready.");r.contentWindow.document.open(),r.contentWindow.document.write(n.outerHTML),r.contentWindow.document.close(),this.listener=this.hideOnEscape.bind(this),document.addEventListener("keydown",this.listener)},hide:function(){this.modal.outerHTML="",this.modal=null,document.body.style.overflow="visible",document.removeEventListener("keydown",this.listener)},hideOnEscape:function(e){27===e.keyCode&&this.hide()}};function l(e,t){var n;return function(){var r=arguments,i=this;clearTimeout(n),n=setTimeout(function(){return e.apply(i,[].slice.call(r))},t)}}function c(e,t,n){for(var r in void 0===t&&(t=new FormData),void 0===n&&(n=null),e=e||{})Object.prototype.hasOwnProperty.call(e,r)&&u(t,d(n,r),e[r]);return t}function d(e,t){return e?e+"["+t+"]":t}function u(e,t,n){return Array.isArray(n)?Array.from(n.keys()).forEach(function(r){return u(e,d(t,r.toString()),n[r])}):n instanceof Date?e.append(t,n.toISOString()):n instanceof File?e.append(t,n,n.name):n instanceof Blob?e.append(t,n):"boolean"==typeof n?e.append(t,n?"1":"0"):"string"==typeof n?e.append(t,n):"number"==typeof n?e.append(t,""+n):null==n?e.append(t,""):void c(n,e,t)}function p(e){return new URL(e.toString(),window.location.toString())}function h(e,t,i,o){void 0===o&&(o="brackets");var s=/^https?:\/\//.test(t.toString()),a=s||t.toString().startsWith("/"),l=!a&&!t.toString().startsWith("#")&&!t.toString().startsWith("?"),c=t.toString().includes("?")||e===exports.Method.GET&&Object.keys(i).length,d=t.toString().includes("#"),u=new URL(t.toString(),"http://localhost");return e===exports.Method.GET&&Object.keys(i).length&&(u.search=n.stringify(r(n.parse(u.search,{ignoreQueryPrefix:!0}),i),{encodeValuesOnly:!0,arrayFormat:o}),i={}),[[s?u.protocol+"//"+u.host:"",a?u.pathname:"",l?u.pathname.substring(1):"",c?u.search:"",d?u.hash:""].join(""),i]}function f(e){return(e=new URL(e.href)).hash="",e}function v(e,t){return document.dispatchEvent(new CustomEvent("inertia:"+e,t))}(s=exports.Method||(exports.Method={})).GET="get",s.POST="post",s.PUT="put",s.PATCH="patch",s.DELETE="delete";var m=function(e){return v("finish",{detail:{visit:e}})},g=function(e){return v("navigate",{detail:{page:e}})},w="undefined"==typeof window,y=function(){function e(){this.visitId=null}var n=e.prototype;return n.init=function(e){var t=e.resolveComponent,n=e.swapComponent;this.page=e.initialPage,this.resolveComponent=t,this.swapComponent=n,this.setNavigationType(),this.clearRememberedStateOnReload(),this.isBackForwardVisit()?this.handleBackForwardVisit(this.page):this.isLocationVisit()?this.handleLocationVisit(this.page):this.handleInitialPageVisit(this.page),this.setupEventListeners()},n.setNavigationType=function(){this.navigationType=window.performance&&window.performance.getEntriesByType("navigation").length>0?window.performance.getEntriesByType("navigation")[0].type:"navigate"},n.clearRememberedStateOnReload=function(){var e;"reload"===this.navigationType&&null!=(e=window.history.state)&&e.rememberedState&&delete window.history.state.rememberedState},n.handleInitialPageVisit=function(e){this.page.url+=window.location.hash,this.setPage(e,{preserveState:!0}).then(function(){return g(e)})},n.setupEventListeners=function(){window.addEventListener("popstate",this.handlePopstateEvent.bind(this)),document.addEventListener("scroll",l(this.handleScrollEvent.bind(this),100),!0)},n.scrollRegions=function(){return document.querySelectorAll("[scroll-region]")},n.handleScrollEvent=function(e){"function"==typeof e.target.hasAttribute&&e.target.hasAttribute("scroll-region")&&this.saveScrollPositions()},n.saveScrollPositions=function(){this.replaceState(o({},this.page,{scrollRegions:Array.from(this.scrollRegions()).map(function(e){return{top:e.scrollTop,left:e.scrollLeft}})}))},n.resetScrollPositions=function(){var e;window.scrollTo(0,0),this.scrollRegions().forEach(function(e){"function"==typeof e.scrollTo?e.scrollTo(0,0):(e.scrollTop=0,e.scrollLeft=0)}),this.saveScrollPositions(),window.location.hash&&(null==(e=document.getElementById(window.location.hash.slice(1)))||e.scrollIntoView())},n.restoreScrollPositions=function(){var e=this;this.page.scrollRegions&&this.scrollRegions().forEach(function(t,n){var r=e.page.scrollRegions[n];r&&("function"==typeof t.scrollTo?t.scrollTo(r.left,r.top):(t.scrollTop=r.top,t.scrollLeft=r.left))})},n.isBackForwardVisit=function(){return window.history.state&&"back_forward"===this.navigationType},n.handleBackForwardVisit=function(e){var t=this;window.history.state.version=e.version,this.setPage(window.history.state,{preserveScroll:!0,preserveState:!0}).then(function(){t.restoreScrollPositions(),g(e)})},n.locationVisit=function(e,t){try{window.sessionStorage.setItem("inertiaLocationVisit",JSON.stringify({preserveScroll:t})),window.location.href=e.href,f(window.location).href===f(e).href&&window.location.reload()}catch(e){return!1}},n.isLocationVisit=function(){try{return null!==window.sessionStorage.getItem("inertiaLocationVisit")}catch(e){return!1}},n.handleLocationVisit=function(e){var t,n,r,i,o=this,s=JSON.parse(window.sessionStorage.getItem("inertiaLocationVisit")||"");window.sessionStorage.removeItem("inertiaLocationVisit"),e.url+=window.location.hash,e.rememberedState=null!=(t=null==(n=window.history.state)?void 0:n.rememberedState)?t:{},e.scrollRegions=null!=(r=null==(i=window.history.state)?void 0:i.scrollRegions)?r:[],this.setPage(e,{preserveScroll:s.preserveScroll,preserveState:!0}).then(function(){s.preserveScroll&&o.restoreScrollPositions(),g(e)})},n.isLocationVisitResponse=function(e){return!(!e||409!==e.status||!e.headers["x-inertia-location"])},n.isInertiaResponse=function(e){return!(null==e||!e.headers["x-inertia"])},n.createVisitId=function(){return this.visitId={},this.visitId},n.cancelVisit=function(e,t){var n=t.cancelled,r=void 0!==n&&n,i=t.interrupted,o=void 0!==i&&i;!e||e.completed||e.cancelled||e.interrupted||(e.cancelToken.cancel(),e.onCancel(),e.completed=!1,e.cancelled=r,e.interrupted=o,m(e),e.onFinish(e))},n.finishVisit=function(e){e.cancelled||e.interrupted||(e.completed=!0,e.cancelled=!1,e.interrupted=!1,m(e),e.onFinish(e))},n.resolvePreserveOption=function(e,t){return"function"==typeof e?e(t):"errors"===e?Object.keys(t.props.errors||{}).length>0:e},n.visit=function(e,n){var r=this,i=void 0===n?{}:n,s=i.method,l=void 0===s?exports.Method.GET:s,d=i.data,u=void 0===d?{}:d,m=i.replace,g=void 0!==m&&m,w=i.preserveScroll,y=void 0!==w&&w,S=i.preserveState,b=void 0!==S&&S,x=i.only,E=void 0===x?[]:x,T=i.headers,P=void 0===T?{}:T,I=i.errorBag,V=void 0===I?"":I,L=i.forceFormData,k=void 0!==L&&L,O=i.onCancelToken,C=void 0===O?function(){}:O,M=i.onBefore,R=void 0===M?function(){}:M,A=i.onStart,j=void 0===A?function(){}:A,F=i.onProgress,D=void 0===F?function(){}:F,N=i.onFinish,q=void 0===N?function(){}:N,B=i.onCancel,H=void 0===B?function(){}:B,W=i.onSuccess,U=void 0===W?function(){}:W,G=i.onError,X=void 0===G?function(){}:G,z=i.queryStringArrayFormat,J=void 0===z?"brackets":z,K="string"==typeof e?p(e):e;if(!function e(t){return t instanceof File||t instanceof Blob||t instanceof FileList&&t.length>0||t instanceof FormData&&Array.from(t.values()).some(function(t){return e(t)})||"object"==typeof t&&null!==t&&Object.values(t).some(function(t){return e(t)})}(u)&&!k||u instanceof FormData||(u=c(u)),!(u instanceof FormData)){var _=h(l,K,u,J),Q=_[1];K=p(_[0]),u=Q}var Y={url:K,method:l,data:u,replace:g,preserveScroll:y,preserveState:b,only:E,headers:P,errorBag:V,forceFormData:k,queryStringArrayFormat:J,cancelled:!1,completed:!1,interrupted:!1};if(!1!==R(Y)&&function(e){return v("before",{cancelable:!0,detail:{visit:e}})}(Y)){this.activeVisit&&this.cancelVisit(this.activeVisit,{interrupted:!0}),this.saveScrollPositions();var Z=this.createVisitId();this.activeVisit=o({},Y,{onCancelToken:C,onBefore:R,onStart:j,onProgress:D,onFinish:q,onCancel:H,onSuccess:U,onError:X,queryStringArrayFormat:J,cancelToken:t.CancelToken.source()}),C({cancel:function(){r.activeVisit&&r.cancelVisit(r.activeVisit,{cancelled:!0})}}),function(e){v("start",{detail:{visit:e}})}(Y),j(Y),t({method:l,url:f(K).href,data:l===exports.Method.GET?{}:u,params:l===exports.Method.GET?u:{},cancelToken:this.activeVisit.cancelToken.token,headers:o({},P,{Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0},E.length?{"X-Inertia-Partial-Component":this.page.component,"X-Inertia-Partial-Data":E.join(",")}:{},V&&V.length?{"X-Inertia-Error-Bag":V}:{},this.page.version?{"X-Inertia-Version":this.page.version}:{}),onUploadProgress:function(e){u instanceof FormData&&(e.percentage=Math.round(e.loaded/e.total*100),function(e){v("progress",{detail:{progress:e}})}(e),D(e))}}).then(function(e){var t;if(!r.isInertiaResponse(e))return Promise.reject({response:e});var n=e.data;E.length&&n.component===r.page.component&&(n.props=o({},r.page.props,n.props)),y=r.resolvePreserveOption(y,n),(b=r.resolvePreserveOption(b,n))&&null!=(t=window.history.state)&&t.rememberedState&&n.component===r.page.component&&(n.rememberedState=window.history.state.rememberedState);var i=K,s=p(n.url);return i.hash&&!s.hash&&f(i).href===s.href&&(s.hash=i.hash,n.url=s.href),r.setPage(n,{visitId:Z,replace:g,preserveScroll:y,preserveState:b})}).then(function(){var e=r.page.props.errors||{};if(Object.keys(e).length>0){var t=V?e[V]?e[V]:{}:e;return function(e){v("error",{detail:{errors:e}})}(t),X(t)}return v("success",{detail:{page:r.page}}),U(r.page)}).catch(function(e){if(r.isInertiaResponse(e.response))return r.setPage(e.response.data,{visitId:Z});if(r.isLocationVisitResponse(e.response)){var t=p(e.response.headers["x-inertia-location"]),n=K;n.hash&&!t.hash&&f(n).href===t.href&&(t.hash=n.hash),r.locationVisit(t,!0===y)}else{if(!e.response)return Promise.reject(e);v("invalid",{cancelable:!0,detail:{response:e.response}})&&a.show(e.response.data)}}).then(function(){r.activeVisit&&r.finishVisit(r.activeVisit)}).catch(function(e){if(!t.isCancel(e)){var n=v("exception",{cancelable:!0,detail:{exception:e}});if(r.activeVisit&&r.finishVisit(r.activeVisit),n)return Promise.reject(e)}})}},n.setPage=function(e,t){var n=this,r=void 0===t?{}:t,i=r.visitId,o=void 0===i?this.createVisitId():i,s=r.replace,a=void 0!==s&&s,l=r.preserveScroll,c=void 0!==l&&l,d=r.preserveState,u=void 0!==d&&d;return Promise.resolve(this.resolveComponent(e.component)).then(function(t){o===n.visitId&&(e.scrollRegions=e.scrollRegions||[],e.rememberedState=e.rememberedState||{},(a=a||p(e.url).href===window.location.href)?n.replaceState(e):n.pushState(e),n.swapComponent({component:t,page:e,preserveState:u}).then(function(){c||n.resetScrollPositions(),a||g(e)}))})},n.pushState=function(e){this.page=e,window.history.pushState(e,"",e.url)},n.replaceState=function(e){this.page=e,window.history.replaceState(e,"",e.url)},n.handlePopstateEvent=function(e){var t=this;if(null!==e.state){var n=e.state,r=this.createVisitId();Promise.resolve(this.resolveComponent(n.component)).then(function(e){r===t.visitId&&(t.page=n,t.swapComponent({component:e,page:n,preserveState:!1}).then(function(){t.restoreScrollPositions(),g(n)}))})}else{var i=p(this.page.url);i.hash=window.location.hash,this.replaceState(o({},this.page,{url:i.href})),this.resetScrollPositions()}},n.get=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),this.visit(e,o({},n,{method:exports.Method.GET,data:t}))},n.reload=function(e){return void 0===e&&(e={}),this.visit(window.location.href,o({},e,{preserveScroll:!0,preserveState:!0}))},n.replace=function(e,t){var n;return void 0===t&&(t={}),console.warn("Inertia.replace() has been deprecated and will be removed in a future release. Please use Inertia."+(null!=(n=t.method)?n:"get")+"() instead."),this.visit(e,o({preserveState:!0},t,{replace:!0}))},n.post=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),this.visit(e,o({preserveState:!0},n,{method:exports.Method.POST,data:t}))},n.put=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),this.visit(e,o({preserveState:!0},n,{method:exports.Method.PUT,data:t}))},n.patch=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),this.visit(e,o({preserveState:!0},n,{method:exports.Method.PATCH,data:t}))},n.delete=function(e,t){return void 0===t&&(t={}),this.visit(e,o({preserveState:!0},t,{method:exports.Method.DELETE}))},n.remember=function(e,t){var n,r;void 0===t&&(t="default"),w||this.replaceState(o({},this.page,{rememberedState:o({},null==(n=this.page)?void 0:n.rememberedState,(r={},r[t]=e,r))}))},n.restore=function(e){var t,n;if(void 0===e&&(e="default"),!w)return null==(t=window.history.state)||null==(n=t.rememberedState)?void 0:n[e]},n.on=function(e,t){var n=function(e){var n=t(e);e.cancelable&&!e.defaultPrevented&&!1===n&&e.preventDefault()};return document.addEventListener("inertia:"+e,n),function(){return document.removeEventListener("inertia:"+e,n)}},e}(),S=null;function b(e){document.addEventListener("inertia:start",x.bind(null,e)),document.addEventListener("inertia:progress",E),document.addEventListener("inertia:finish",T)}function x(e){S=setTimeout(function(){return i.start()},e)}function E(e){var t;i.isStarted()&&null!=(t=e.detail.progress)&&t.percentage&&i.set(Math.max(i.status,e.detail.progress.percentage/100*.9))}function T(e){clearTimeout(S),i.isStarted()&&(e.detail.visit.completed?i.done():e.detail.visit.interrupted?i.set(0):e.detail.visit.cancelled&&(i.done(),i.remove()))}var P={buildDOMElement:function(e){var t=document.createElement("template");t.innerHTML=e;var n=t.content.firstChild;if(!e.startsWith("<script "))return n;var r=document.createElement("script");return r.innerHTML=n.innerHTML,n.getAttributeNames().forEach(function(e){r.setAttribute(e,n.getAttribute(e)||"")}),r},isInertiaManagedElement:function(e){return e.nodeType===Node.ELEMENT_NODE&&null!==e.getAttribute("inertia")},findMatchingElementIndex:function(e,t){var n=e.getAttribute("inertia");return null!==n?t.findIndex(function(e){return e.getAttribute("inertia")===n}):-1},update:l(function(e){var t=this,n=e.map(function(e){return t.buildDOMElement(e)});Array.from(document.head.childNodes).filter(function(e){return t.isInertiaManagedElement(e)}).forEach(function(e){var r=t.findMatchingElementIndex(e,n);if(-1!==r){var i,o=n.splice(r,1)[0];o&&!e.isEqualNode(o)&&(null==e||null==(i=e.parentNode)||i.replaceChild(o,e))}else{var s;null==e||null==(s=e.parentNode)||s.removeChild(e)}}),n.forEach(function(e){return document.head.appendChild(e)})},1)},I=new y;exports.createHeadManager=function(e,t,n){var r={},i=0;function s(){var e=t(""),n=o({},e?{title:'<title inertia="">'+e+"</title>"}:{}),i=Object.values(r).reduce(function(e,t){return e.concat(t)},[]).reduce(function(e,n){if(-1===n.indexOf("<"))return e;if(0===n.indexOf("<title ")){var r=n.match(/(<title [^>]+>)(.*?)(<\/title>)/);return e.title=r?""+r[1]+t(r[2])+r[3]:n,e}var i=n.match(/ inertia="[^"]+"/);return i?e[i[0]]=n:e[Object.keys(e).length]=n,e},n);return Object.values(i)}function a(){e?n(s()):P.update(s())}return a(),{forceUpdate:a,createProvider:function(){var e=function(){var e=i+=1;return r[e]=[],e.toString()}();return{update:function(t){return function(e,t){void 0===t&&(t=[]),null!==e&&Object.keys(r).indexOf(e)>-1&&(r[e]=t),a()}(e,t)},disconnect:function(){return function(e){null!==e&&-1!==Object.keys(r).indexOf(e)&&(delete r[e],a())}(e)}}}}},exports.hrefToUrl=p,exports.mergeDataIntoQueryString=h,exports.router=I,exports.setupProgress=function(e){var t=void 0===e?{}:e,n=t.delay,r=t.color,o=void 0===r?"#29d":r,s=t.includeCSS,a=void 0===s||s,l=t.showSpinner,c=void 0!==l&&l;b(void 0===n?250:n),i.configure({showSpinner:c}),a&&function(e){var t=document.createElement("style");t.type="text/css",t.textContent="\n #nprogress {\n pointer-events: none;\n }\n\n #nprogress .bar {\n background: "+e+";\n\n position: fixed;\n z-index: 1031;\n top: 0;\n left: 0;\n\n width: 100%;\n height: 2px;\n }\n\n #nprogress .peg {\n display: block;\n position: absolute;\n right: 0px;\n width: 100px;\n height: 100%;\n box-shadow: 0 0 10px "+e+", 0 0 5px "+e+";\n opacity: 1.0;\n\n -webkit-transform: rotate(3deg) translate(0px, -4px);\n -ms-transform: rotate(3deg) translate(0px, -4px);\n transform: rotate(3deg) translate(0px, -4px);\n }\n\n #nprogress .spinner {\n display: block;\n position: fixed;\n z-index: 1031;\n top: 15px;\n right: 15px;\n }\n\n #nprogress .spinner-icon {\n width: 18px;\n height: 18px;\n box-sizing: border-box;\n\n border: solid 2px transparent;\n border-top-color: "+e+";\n border-left-color: "+e+";\n border-radius: 50%;\n\n -webkit-animation: nprogress-spinner 400ms linear infinite;\n animation: nprogress-spinner 400ms linear infinite;\n }\n\n .nprogress-custom-parent {\n overflow: hidden;\n position: relative;\n }\n\n .nprogress-custom-parent #nprogress .spinner,\n .nprogress-custom-parent #nprogress .bar {\n position: absolute;\n }\n\n @-webkit-keyframes nprogress-spinner {\n 0% { -webkit-transform: rotate(0deg); }\n 100% { -webkit-transform: rotate(360deg); }\n }\n @keyframes nprogress-spinner {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n ",document.head.appendChild(t)}(o)},exports.shouldIntercept=function(e){var t="a"===e.currentTarget.tagName.toLowerCase();return!(e.target&&null!=e&&e.target.isContentEditable||e.defaultPrevented||t&&e.which>1||t&&e.altKey||t&&e.ctrlKey||t&&e.metaKey||t&&e.shiftKey)},exports.urlWithoutHash=f;
"use strict";var se=Object.create;var L=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,de=Object.prototype.hasOwnProperty;var pe=(t,e)=>{for(var r in e)L(t,r,{get:e[r],enumerable:!0})},K=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of le(e))!de.call(t,n)&&n!==r&&L(t,n,{get:()=>e[n],enumerable:!(i=ae(e,n))||i.enumerable});return t};var C=(t,e,r)=>(r=t!=null?se(ce(t)):{},K(e||!t||!t.__esModule?L(r,"default",{value:t,enumerable:!0}):r,t)),ue=t=>K(L({},"__esModule",{value:!0}),t);var xe={};pe(xe,{Method:()=>I,createHeadManager:()=>H,hrefToUrl:()=>f,mergeDataIntoQueryString:()=>k,router:()=>Ee,setupProgress:()=>j,shouldIntercept:()=>q,urlWithoutHash:()=>b});module.exports=ue(xe);var M=C(require("axios"));function T(t,e){let r;return function(...i){clearTimeout(r),r=setTimeout(()=>t.apply(this,i),e)}}function m(t,e){return document.dispatchEvent(new CustomEvent(`inertia:${t}`,e))}var X=t=>m("before",{cancelable:!0,detail:{visit:t}}),J=t=>m("error",{detail:{errors:t}}),z=t=>m("exception",{cancelable:!0,detail:{exception:t}}),D=t=>m("finish",{detail:{visit:t}}),_=t=>m("invalid",{cancelable:!0,detail:{response:t}}),w=t=>m("navigate",{detail:{page:t}}),Q=t=>m("progress",{detail:{progress:t}}),Y=t=>m("start",{detail:{visit:t}}),Z=t=>m("success",{detail:{page:t}});function N(t){return t instanceof File||t instanceof Blob||t instanceof FileList&&t.length>0||t instanceof FormData&&Array.from(t.values()).some(e=>N(e))||typeof t=="object"&&t!==null&&Object.values(t).some(e=>N(e))}function U(t,e=new FormData,r=null){t=t||{};for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&te(e,ee(r,i),t[i]);return e}function ee(t,e){return t?t+"["+e+"]":e}function te(t,e,r){if(Array.isArray(r))return Array.from(r.keys()).forEach(i=>te(t,ee(e,i.toString()),r[i]));if(r instanceof Date)return t.append(e,r.toISOString());if(r instanceof File)return t.append(e,r,r.name);if(r instanceof Blob)return t.append(e,r);if(typeof r=="boolean")return t.append(e,r?"1":"0");if(typeof r=="string")return t.append(e,r);if(typeof r=="number")return t.append(e,`${r}`);if(r==null)return t.append(e,"");U(r,t,e)}var re={modal:null,listener:null,show(t){typeof t=="object"&&(t=`All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.<hr>${JSON.stringify(t)}`);let e=document.createElement("html");e.innerHTML=t,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 r=document.createElement("iframe");if(r.style.backgroundColor="white",r.style.borderRadius="5px",r.style.width="100%",r.style.height="100%",this.modal.appendChild(r),document.body.prepend(this.modal),document.body.style.overflow="hidden",!r.contentWindow)throw new Error("iframe not yet ready.");r.contentWindow.document.open(),r.contentWindow.document.write(e.outerHTML),r.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(t){t.keyCode===27&&this.hide()}};var I=(s=>(s.GET="get",s.POST="post",s.PUT="put",s.PATCH="patch",s.DELETE="delete",s))(I||{});var ie=C(require("deepmerge")),O=C(require("qs"));function f(t){return new URL(t.toString(),window.location.toString())}function k(t,e,r,i="brackets"){let n=/^https?:\/\//.test(e.toString()),s=n||e.toString().startsWith("/"),u=!s&&!e.toString().startsWith("#")&&!e.toString().startsWith("?"),v=e.toString().includes("?")||t==="get"&&Object.keys(r).length,E=e.toString().includes("#"),l=new URL(e.toString(),"http://localhost");return t==="get"&&Object.keys(r).length&&(l.search=O.stringify((0,ie.default)(O.parse(l.search,{ignoreQueryPrefix:!0}),r),{encodeValuesOnly:!0,arrayFormat:i}),r={}),[[n?`${l.protocol}//${l.host}`:"",s?l.pathname:"",u?l.pathname.substring(1):"",v?l.search:"",E?l.hash:""].join(""),r]}function b(t){return t=new URL(t.href),t.hash="",t}var oe=typeof window>"u",A=class{constructor(){this.visitId=null}init({initialPage:e,resolveComponent:r,swapComponent:i}){this.page=e,this.resolveComponent=r,this.swapComponent=i,this.setNavigationType(),this.clearRememberedStateOnReload(),this.isBackForwardVisit()?this.handleBackForwardVisit(this.page):this.isLocationVisit()?this.handleLocationVisit(this.page):this.handleInitialPageVisit(this.page),this.setupEventListeners()}setNavigationType(){this.navigationType=window.performance&&window.performance.getEntriesByType("navigation").length>0?window.performance.getEntriesByType("navigation")[0].type:"navigate"}clearRememberedStateOnReload(){this.navigationType==="reload"&&window.history.state?.rememberedState&&delete window.history.state.rememberedState}handleInitialPageVisit(e){this.page.url+=window.location.hash,this.setPage(e,{preserveState:!0}).then(()=>w(e))}setupEventListeners(){window.addEventListener("popstate",this.handlePopstateEvent.bind(this)),document.addEventListener("scroll",T(this.handleScrollEvent.bind(this),100),!0)}scrollRegions(){return document.querySelectorAll("[scroll-region]")}handleScrollEvent(e){typeof e.target.hasAttribute=="function"&&e.target.hasAttribute("scroll-region")&&this.saveScrollPositions()}saveScrollPositions(){this.replaceState({...this.page,scrollRegions:Array.from(this.scrollRegions()).map(e=>({top:e.scrollTop,left:e.scrollLeft}))})}resetScrollPositions(){window.scrollTo(0,0),this.scrollRegions().forEach(e=>{typeof e.scrollTo=="function"?e.scrollTo(0,0):(e.scrollTop=0,e.scrollLeft=0)}),this.saveScrollPositions(),window.location.hash&&setTimeout(()=>document.getElementById(window.location.hash.slice(1))?.scrollIntoView())}restoreScrollPositions(){this.page.scrollRegions&&this.scrollRegions().forEach((e,r)=>{let i=this.page.scrollRegions[r];if(i)typeof e.scrollTo=="function"?e.scrollTo(i.left,i.top):(e.scrollTop=i.top,e.scrollLeft=i.left);else return})}isBackForwardVisit(){return window.history.state&&this.navigationType==="back_forward"}handleBackForwardVisit(e){window.history.state.version=e.version,this.setPage(window.history.state,{preserveScroll:!0,preserveState:!0}).then(()=>{this.restoreScrollPositions(),w(e)})}locationVisit(e,r){try{let i={preserveScroll:r};window.sessionStorage.setItem("inertiaLocationVisit",JSON.stringify(i)),window.location.href=e.href,b(window.location).href===b(e).href&&window.location.reload()}catch{return!1}}isLocationVisit(){try{return window.sessionStorage.getItem("inertiaLocationVisit")!==null}catch{return!1}}handleLocationVisit(e){let r=JSON.parse(window.sessionStorage.getItem("inertiaLocationVisit")||"");window.sessionStorage.removeItem("inertiaLocationVisit"),e.url+=window.location.hash,e.rememberedState=window.history.state?.rememberedState??{},e.scrollRegions=window.history.state?.scrollRegions??[],this.setPage(e,{preserveScroll:r.preserveScroll,preserveState:!0}).then(()=>{r.preserveScroll&&this.restoreScrollPositions(),w(e)})}isLocationVisitResponse(e){return!!(e&&e.status===409&&e.headers["x-inertia-location"])}isInertiaResponse(e){return!!e?.headers["x-inertia"]}createVisitId(){return this.visitId={},this.visitId}cancelVisit(e,{cancelled:r=!1,interrupted:i=!1}){e&&!e.completed&&!e.cancelled&&!e.interrupted&&(e.cancelToken.abort(),e.onCancel(),e.completed=!1,e.cancelled=r,e.interrupted=i,D(e),e.onFinish(e))}finishVisit(e){!e.cancelled&&!e.interrupted&&(e.completed=!0,e.cancelled=!1,e.interrupted=!1,D(e),e.onFinish(e))}resolvePreserveOption(e,r){return typeof e=="function"?e(r):e==="errors"?Object.keys(r.props.errors||{}).length>0:e}cancel(){this.activeVisit&&this.cancelVisit(this.activeVisit,{cancelled:!0})}visit(e,{method:r="get",data:i={},replace:n=!1,preserveScroll:s=!1,preserveState:u=!1,only:v=[],headers:E={},errorBag:l="",forceFormData:c=!1,onCancelToken:g=()=>{},onBefore:R=()=>{},onStart:d=()=>{},onProgress:p=()=>{},onFinish:V=()=>{},onCancel:y=()=>{},onSuccess:$=()=>{},onError:W=()=>{},queryStringArrayFormat:F="brackets"}={}){let P=typeof e=="string"?f(e):e;if((N(i)||c)&&!(i instanceof FormData)&&(i=U(i)),!(i instanceof FormData)){let[o,a]=k(r,P,i,F);P=f(o),i=a}let S={url:P,method:r,data:i,replace:n,preserveScroll:s,preserveState:u,only:v,headers:E,errorBag:l,forceFormData:c,queryStringArrayFormat:F,cancelled:!1,completed:!1,interrupted:!1};if(R(S)===!1||!X(S))return;this.activeVisit&&this.cancelVisit(this.activeVisit,{interrupted:!0}),this.saveScrollPositions();let B=this.createVisitId();this.activeVisit={...S,onCancelToken:g,onBefore:R,onStart:d,onProgress:p,onFinish:V,onCancel:y,onSuccess:$,onError:W,queryStringArrayFormat:F,cancelToken:new AbortController},g({cancel:()=>{this.activeVisit&&this.cancelVisit(this.activeVisit,{cancelled:!0})}}),Y(S),d(S),(0,M.default)({method:r,url:b(P).href,data:r==="get"?{}:i,params:r==="get"?i:{},signal:this.activeVisit.cancelToken.signal,headers:{...E,Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0,...v.length?{"X-Inertia-Partial-Component":this.page.component,"X-Inertia-Partial-Data":v.join(",")}:{},...l&&l.length?{"X-Inertia-Error-Bag":l}:{},...this.page.version?{"X-Inertia-Version":this.page.version}:{}},onUploadProgress:o=>{i instanceof FormData&&(o.percentage=o.progress?Math.round(o.progress*100):0,Q(o),p(o))}}).then(o=>{if(!this.isInertiaResponse(o))return Promise.reject({response:o});let a=o.data;v.length&&a.component===this.page.component&&(a.props={...this.page.props,...a.props}),s=this.resolvePreserveOption(s,a),u=this.resolvePreserveOption(u,a),u&&window.history.state?.rememberedState&&a.component===this.page.component&&(a.rememberedState=window.history.state.rememberedState);let x=P,G=f(a.url);return x.hash&&!G.hash&&b(x).href===G.href&&(G.hash=x.hash,a.url=G.href),this.setPage(a,{visitId:B,replace:n,preserveScroll:s,preserveState:u})}).then(()=>{let o=this.page.props.errors||{};if(Object.keys(o).length>0){let a=l?o[l]?o[l]:{}:o;return J(a),W(a)}return Z(this.page),$(this.page)}).catch(o=>{if(this.isInertiaResponse(o.response))return this.setPage(o.response.data,{visitId:B});if(this.isLocationVisitResponse(o.response)){let a=f(o.response.headers["x-inertia-location"]),x=P;x.hash&&!a.hash&&b(x).href===a.href&&(a.hash=x.hash),this.locationVisit(a,s===!0)}else if(o.response)_(o.response)&&re.show(o.response.data);else return Promise.reject(o)}).then(()=>{this.activeVisit&&this.finishVisit(this.activeVisit)}).catch(o=>{if(!M.default.isCancel(o)){let a=z(o);if(this.activeVisit&&this.finishVisit(this.activeVisit),a)return Promise.reject(o)}})}setPage(e,{visitId:r=this.createVisitId(),replace:i=!1,preserveScroll:n=!1,preserveState:s=!1}={}){return Promise.resolve(this.resolveComponent(e.component)).then(u=>{r===this.visitId&&(e.scrollRegions=e.scrollRegions||[],e.rememberedState=e.rememberedState||{},i=i||f(e.url).href===window.location.href,i?this.replaceState(e):this.pushState(e),this.swapComponent({component:u,page:e,preserveState:s}).then(()=>{n||this.resetScrollPositions(),i||w(e)}))})}pushState(e){this.page=e,window.history.pushState(e,"",e.url)}replaceState(e){this.page=e,window.history.replaceState(e,"",e.url)}handlePopstateEvent(e){if(e.state!==null){let r=e.state,i=this.createVisitId();Promise.resolve(this.resolveComponent(r.component)).then(n=>{i===this.visitId&&(this.page=r,this.swapComponent({component:n,page:r,preserveState:!1}).then(()=>{this.restoreScrollPositions(),w(r)}))})}else{let r=f(this.page.url);r.hash=window.location.hash,this.replaceState({...this.page,url:r.href}),this.resetScrollPositions()}}get(e,r={},i={}){return this.visit(e,{...i,method:"get",data:r})}reload(e={}){return this.visit(window.location.href,{...e,preserveScroll:!0,preserveState:!0})}replace(e,r={}){return console.warn(`Inertia.replace() has been deprecated and will be removed in a future release. Please use Inertia.${r.method??"get"}() instead.`),this.visit(e,{preserveState:!0,...r,replace:!0})}post(e,r={},i={}){return this.visit(e,{preserveState:!0,...i,method:"post",data:r})}put(e,r={},i={}){return this.visit(e,{preserveState:!0,...i,method:"put",data:r})}patch(e,r={},i={}){return this.visit(e,{preserveState:!0,...i,method:"patch",data:r})}delete(e,r={}){return this.visit(e,{preserveState:!0,...r,method:"delete"})}remember(e,r="default"){oe||this.replaceState({...this.page,rememberedState:{...this.page?.rememberedState,[r]:e}})}restore(e="default"){if(!oe)return window.history.state?.rememberedState?.[e]}on(e,r){let i=n=>{let s=r(n);n.cancelable&&!n.defaultPrevented&&s===!1&&n.preventDefault()};return document.addEventListener(`inertia:${e}`,i),()=>document.removeEventListener(`inertia:${e}`,i)}};var he={buildDOMElement(t){let e=document.createElement("template");e.innerHTML=t;let r=e.content.firstChild;if(!t.startsWith("<script "))return r;let i=document.createElement("script");return i.innerHTML=r.innerHTML,r.getAttributeNames().forEach(n=>{i.setAttribute(n,r.getAttribute(n)||"")}),i},isInertiaManagedElement(t){return t.nodeType===Node.ELEMENT_NODE&&t.getAttribute("inertia")!==null},findMatchingElementIndex(t,e){let r=t.getAttribute("inertia");return r!==null?e.findIndex(i=>i.getAttribute("inertia")===r):-1},update:T(function(t){let e=t.map(i=>this.buildDOMElement(i));Array.from(document.head.childNodes).filter(i=>this.isInertiaManagedElement(i)).forEach(i=>{let n=this.findMatchingElementIndex(i,e);if(n===-1){i?.parentNode?.removeChild(i);return}let s=e.splice(n,1)[0];s&&!i.isEqualNode(s)&&i?.parentNode?.replaceChild(s,i)}),e.forEach(i=>document.head.appendChild(i))},1)};function H(t,e,r){let i={},n=0;function s(){let c=n+=1;return i[c]=[],c.toString()}function u(c){c===null||Object.keys(i).indexOf(c)===-1||(delete i[c],l())}function v(c,g=[]){c!==null&&Object.keys(i).indexOf(c)>-1&&(i[c]=g),l()}function E(){let c=e(""),g={...c?{title:`<title inertia="">${c}</title>`}:{}},R=Object.values(i).reduce((d,p)=>d.concat(p),[]).reduce((d,p)=>{if(p.indexOf("<")===-1)return d;if(p.indexOf("<title ")===0){let y=p.match(/(<title [^>]+>)(.*?)(<\/title>)/);return d.title=y?`${y[1]}${e(y[2])}${y[3]}`:p,d}let V=p.match(/ inertia="[^"]+"/);return V?d[V[0]]=p:d[Object.keys(d).length]=p,d},g);return Object.values(R)}function l(){t?r(E()):he.update(E())}return l(),{forceUpdate:l,createProvider:function(){let c=s();return{update:g=>v(c,g),disconnect:()=>u(c)}}}}var h=C(require("nprogress")),ne=null;function me(t){document.addEventListener("inertia:start",fe.bind(null,t)),document.addEventListener("inertia:progress",ve),document.addEventListener("inertia:finish",ge)}function fe(t){ne=setTimeout(()=>h.default.start(),t)}function ve(t){h.default.isStarted()&&t.detail.progress?.percentage&&h.default.set(Math.max(h.default.status,t.detail.progress.percentage/100*.9))}function ge(t){if(clearTimeout(ne),h.default.isStarted())t.detail.visit.completed?h.default.done():t.detail.visit.interrupted?h.default.set(0):t.detail.visit.cancelled&&(h.default.done(),h.default.remove());else return}function be(t){let e=document.createElement("style");e.type="text/css",e.textContent=`
#nprogress {
pointer-events: none;
}
#nprogress .bar {
background: ${t};
position: fixed;
z-index: 1031;
top: 0;
left: 0;
width: 100%;
height: 2px;
}
#nprogress .peg {
display: block;
position: absolute;
right: 0px;
width: 100px;
height: 100%;
box-shadow: 0 0 10px ${t}, 0 0 5px ${t};
opacity: 1.0;
-webkit-transform: rotate(3deg) translate(0px, -4px);
-ms-transform: rotate(3deg) translate(0px, -4px);
transform: rotate(3deg) translate(0px, -4px);
}
#nprogress .spinner {
display: block;
position: fixed;
z-index: 1031;
top: 15px;
right: 15px;
}
#nprogress .spinner-icon {
width: 18px;
height: 18px;
box-sizing: border-box;
border: solid 2px transparent;
border-top-color: ${t};
border-left-color: ${t};
border-radius: 50%;
-webkit-animation: nprogress-spinner 400ms linear infinite;
animation: nprogress-spinner 400ms linear infinite;
}
.nprogress-custom-parent {
overflow: hidden;
position: relative;
}
.nprogress-custom-parent #nprogress .spinner,
.nprogress-custom-parent #nprogress .bar {
position: absolute;
}
@-webkit-keyframes nprogress-spinner {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes nprogress-spinner {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
`,document.head.appendChild(e)}function j({delay:t=250,color:e="#29d",includeCSS:r=!0,showSpinner:i=!1}={}){me(t),h.default.configure({showSpinner:i}),r&&be(e)}function q(t){let e=t.currentTarget.tagName.toLowerCase()==="a";return!(t.target&&(t?.target).isContentEditable||t.defaultPrevented||e&&t.which>1||e&&t.altKey||e&&t.ctrlKey||e&&t.metaKey||e&&t.shiftKey)}var Ee=new A;
//# sourceMappingURL=index.js.map

41

dist/server.esm.js

@@ -1,41 +0,2 @@

import { exit } from 'process';
import { createServer } from 'http';
const readableToString = readable => new Promise((resolve, reject) => {
let data = '';
readable.on('data', chunk => data += chunk);
readable.on('end', () => resolve(data));
readable.on('error', err => reject(err));
});
var server = ((render, port) => {
const _port = port || 13714;
const routes = {
'/health': async () => ({
status: 'OK',
timestamp: Date.now()
}),
'/shutdown': () => exit(),
'/render': async request => render(JSON.parse(await readableToString(request))),
'/404': async () => ({
status: 'NOT_FOUND',
timestamp: Date.now()
})
};
createServer(async (request, response) => {
const dispatchRoute = routes[request.url] || routes['/404'];
try {
response.writeHead(200, {
'Content-Type': 'application/json',
Server: 'Inertia.js SSR'
});
response.write(JSON.stringify(await dispatchRoute(request)));
} catch (e) {
console.error(e);
}
response.end();
}).listen(_port, () => console.log('Inertia SSR server started.'));
console.log(`Starting SSR server on port ${_port}...`);
});
export default server;
import{createServer as c}from"http";import*as s from"process";var g=t=>new Promise((o,n)=>{let r="";t.on("data",e=>r+=e),t.on("end",()=>o(r)),t.on("error",e=>n(e))}),d=(t,o)=>{let n=o||13714,r={"/health":async()=>({status:"OK",timestamp:Date.now()}),"/shutdown":()=>s.exit(),"/render":async e=>t(JSON.parse(await g(e))),"/404":async()=>({status:"NOT_FOUND",timestamp:Date.now()})};c(async(e,a)=>{let i=r[e.url]||r["/404"];try{a.writeHead(200,{"Content-Type":"application/json",Server:"Inertia.js SSR"}),a.write(JSON.stringify(await i(e)))}catch(p){console.error(p)}a.end()}).listen(n,()=>console.log("Inertia SSR server started.")),console.log(`Starting SSR server on port ${n}...`)};export{d as default};
//# sourceMappingURL=server.esm.js.map

@@ -1,41 +0,2 @@

var process = require('process');
var http = require('http');
const readableToString = readable => new Promise((resolve, reject) => {
let data = '';
readable.on('data', chunk => data += chunk);
readable.on('end', () => resolve(data));
readable.on('error', err => reject(err));
});
var server = ((render, port) => {
const _port = port || 13714;
const routes = {
'/health': async () => ({
status: 'OK',
timestamp: Date.now()
}),
'/shutdown': () => process.exit(),
'/render': async request => render(JSON.parse(await readableToString(request))),
'/404': async () => ({
status: 'NOT_FOUND',
timestamp: Date.now()
})
};
http.createServer(async (request, response) => {
const dispatchRoute = routes[request.url] || routes['/404'];
try {
response.writeHead(200, {
'Content-Type': 'application/json',
Server: 'Inertia.js SSR'
});
response.write(JSON.stringify(await dispatchRoute(request)));
} catch (e) {
console.error(e);
}
response.end();
}).listen(_port, () => console.log('Inertia SSR server started.'));
console.log(`Starting SSR server on port ${_port}...`);
});
module.exports = server;
"use strict";var m=Object.create;var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var y=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},i=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of S(t))!w.call(e,r)&&r!==n&&a(e,r,{get:()=>t[r],enumerable:!(o=d(t,r))||o.enumerable});return e};var R=(e,t,n)=>(n=e!=null?m(u(e)):{},i(t||!e||!e.__esModule?a(n,"default",{value:e,enumerable:!0}):n,e)),I=e=>i(a({},"__esModule",{value:!0}),e);var v={};y(v,{default:()=>h});module.exports=I(v);var p=require("http"),c=R(require("process")),f=e=>new Promise((t,n)=>{let o="";e.on("data",r=>o+=r),e.on("end",()=>t(o)),e.on("error",r=>n(r))}),h=(e,t)=>{let n=t||13714,o={"/health":async()=>({status:"OK",timestamp:Date.now()}),"/shutdown":()=>c.exit(),"/render":async r=>e(JSON.parse(await f(r))),"/404":async()=>({status:"NOT_FOUND",timestamp:Date.now()})};(0,p.createServer)(async(r,s)=>{let g=o[r.url]||o["/404"];try{s.writeHead(200,{"Content-Type":"application/json",Server:"Inertia.js SSR"}),s.write(JSON.stringify(await g(r)))}catch(l){console.error(l)}s.end()}).listen(n,()=>console.log("Inertia SSR server started.")),console.log(`Starting SSR server on port ${n}...`)};0&&(module.exports={});
//# sourceMappingURL=server.js.map
{
"name": "@inertiajs/core",
"version": "1.0.0-beta.2",
"version": "1.0.0-beta.3",
"license": "MIT",

@@ -26,18 +26,23 @@ "description": "A framework for creating server-driven single page apps.",

"main": "dist/index.js",
"unpkg": "dist/index.umd.js",
"types": "types/index.d.ts",
"exports": {
".": "./dist/index.js",
"./server": "./dist/server.js"
".": {
"import": "./dist/index.esm.js",
"require": "./dist/index.js",
"types": "./types/index.d.js"
},
"./server": {
"import": "./dist/server.esm.js",
"require": "./dist/server.js",
"types": "./types/server.d.js"
}
},
"scripts": {
"build": "npm run clean && npm run build:browser && npm run build:server",
"build:browser": "microbundle --format es,cjs",
"build:server": "microbundle --format es,cjs --target node --output ./dist/server.js ./src/server.ts",
"dev": "./build.js --watch",
"build": "npm run clean && ./build.js && tsc --emitDeclarationOnly",
"clean": "rm -rf types && rm -rf dist",
"prepublishOnly": "npm run build",
"watch": "microbundle watch --format es,cjs"
"prepublishOnly": "npm run build"
},
"dependencies": {
"axios": "^0.27.0",
"axios": "^1.2.0",
"deepmerge": "^4.0.0",

@@ -52,5 +57,6 @@ "nprogress": "^0.2.0",

"@types/qs": "^6.9.0",
"microbundle": "^0.12.0",
"typescript": "^4.2.4"
"esbuild": "^0.16.13",
"esbuild-node-externals": "^1.6.0",
"typescript": "^4.9.4"
}
}
export default function debounce<F extends (...params: any[]) => ReturnType<F>>(fn: F, delay: number): F;

@@ -0,0 +0,0 @@ import { GlobalEventTrigger } from './types';

import { FormDataConvertible, RequestPayload } from './types';
export declare function hasFiles(data: RequestPayload | FormDataConvertible): boolean;
import { FormDataConvertible } from './types';
export declare function objectToFormData(source: Record<string, FormDataConvertible>, form?: FormData, parentKey?: string | null): FormData;

@@ -0,0 +0,0 @@ export default function createHeadManager(isServer: boolean, titleCallback: (title: string) => string, onUpdate: (elements: string[]) => void): {

import { Router } from './router';
export * from './types';
export { default as createHeadManager } from './head';
export { default as setupProgress } from './progress';
export { default as createHeadManager } from './head';
export { default as shouldIntercept } from './shouldIntercept';
export * from './types';
export { hrefToUrl, mergeDataIntoQueryString, urlWithoutHash } from './url';
export { type Router };
export declare const router: Router;

@@ -0,0 +0,0 @@ declare const _default: {

@@ -0,0 +0,0 @@ export default function setupProgress({ delay, color, includeCSS, showSpinner, }?: {

@@ -38,2 +38,3 @@ import { AxiosResponse } from 'axios';

protected resolvePreserveOption(value: PreserveStateOption, page: Page): boolean | string;
cancel(): void;
visit(href: string | URL, { method, data, replace, preserveScroll, preserveState, only, headers, errorBag, forceFormData, onCancelToken, onBefore, onStart, onProgress, onFinish, onCancel, onSuccess, onError, queryStringArrayFormat, }?: VisitOptions): void;

@@ -40,0 +41,0 @@ protected setPage(page: Page, { visitId, replace, preserveScroll, preserveState, }?: {

@@ -1,4 +0,4 @@

import { Page, InertiaAppResponse } from './types';
declare type AppCallback = (page: Page) => InertiaAppResponse;
declare const _default: (render: AppCallback, port?: number | undefined) => void;
import { InertiaAppResponse, Page } from './types';
type AppCallback = (page: Page) => InertiaAppResponse;
declare const _default: (render: AppCallback, port?: number) => void;
export default _default;
export default function shouldIntercept(event: KeyboardEvent): boolean;

@@ -1,5 +0,10 @@

import { AxiosResponse, CancelTokenSource } from 'axios';
export declare type Errors = Record<string, string>;
export declare type ErrorBag = Record<string, Errors>;
export declare type FormDataConvertible = Array<FormDataConvertible> | Blob | FormDataEntryValue | Date | boolean | number | null | undefined;
import { AxiosProgressEvent, AxiosResponse } from 'axios';
declare module 'axios' {
interface AxiosProgressEvent {
percentage: number | undefined;
}
}
export type Errors = Record<string, string>;
export type ErrorBag = Record<string, Errors>;
export type FormDataConvertible = Array<FormDataConvertible> | Blob | FormDataEntryValue | Date | boolean | number | null | undefined;
export declare enum Method {

@@ -12,3 +17,3 @@ GET = "get",

}
export declare type RequestPayload = Record<string, FormDataConvertible> | FormData;
export type RequestPayload = Record<string, FormDataConvertible> | FormData;
export interface PageProps {

@@ -31,4 +36,4 @@ [key: string]: unknown;

}
export declare type PageResolver = (name: string) => Component;
export declare type PageHandler = ({ component, page, preserveState, }: {
export type PageResolver = (name: string) => Component;
export type PageHandler = ({ component, page, preserveState, }: {
component: Component;

@@ -38,10 +43,8 @@ page: Page;

}) => Promise<unknown>;
export declare type PreserveStateOption = boolean | string | ((page: Page) => boolean);
export declare type Progress = ProgressEvent & {
percentage: number;
};
export declare type LocationVisit = {
export type PreserveStateOption = boolean | string | ((page: Page) => boolean);
export type Progress = AxiosProgressEvent;
export type LocationVisit = {
preserveScroll: boolean;
};
export declare type Visit = {
export type Visit = {
method: Method;

@@ -58,3 +61,3 @@ data: RequestPayload;

};
export declare type GlobalEventsMap = {
export type GlobalEventsMap = {
before: {

@@ -129,10 +132,10 @@ parameters: [PendingVisit];

};
export declare type GlobalEventNames = keyof GlobalEventsMap;
export declare type GlobalEvent<TEventName extends GlobalEventNames> = CustomEvent<GlobalEventDetails<TEventName>>;
export declare type GlobalEventParameters<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['parameters'];
export declare type GlobalEventResult<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['result'];
export declare type GlobalEventDetails<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['details'];
export declare type GlobalEventTrigger<TEventName extends GlobalEventNames> = (...params: GlobalEventParameters<TEventName>) => GlobalEventResult<TEventName>;
export declare type GlobalEventCallback<TEventName extends GlobalEventNames> = (...params: GlobalEventParameters<TEventName>) => GlobalEventResult<TEventName>;
export declare type VisitOptions = Partial<Visit & {
export type GlobalEventNames = keyof GlobalEventsMap;
export type GlobalEvent<TEventName extends GlobalEventNames> = CustomEvent<GlobalEventDetails<TEventName>>;
export type GlobalEventParameters<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['parameters'];
export type GlobalEventResult<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['result'];
export type GlobalEventDetails<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['details'];
export type GlobalEventTrigger<TEventName extends GlobalEventNames> = (...params: GlobalEventParameters<TEventName>) => GlobalEventResult<TEventName>;
export type GlobalEventCallback<TEventName extends GlobalEventNames> = (...params: GlobalEventParameters<TEventName>) => GlobalEventResult<TEventName>;
export type VisitOptions = Partial<Visit & {
onCancelToken: {

@@ -151,3 +154,3 @@ ({ cancel }: {

}>;
export declare type PendingVisit = Visit & {
export type PendingVisit = Visit & {
url: URL;

@@ -158,8 +161,8 @@ completed: boolean;

};
export declare type ActiveVisit = PendingVisit & Required<VisitOptions> & {
cancelToken: CancelTokenSource;
export type ActiveVisit = PendingVisit & Required<VisitOptions> & {
cancelToken: AbortController;
};
export declare type VisitId = unknown;
export declare type Component = unknown;
export declare type InertiaAppResponse = Promise<{
export type VisitId = unknown;
export type Component = unknown;
export type InertiaAppResponse = Promise<{
head: string[];

@@ -166,0 +169,0 @@ body: string;

@@ -0,0 +0,0 @@ import { FormDataConvertible, Method } from './types';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc