@star-insure/sdk 5.0.7 → 5.0.9

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.
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("date-fns"),n=require("@inertiajs/react"),r=require("react"),a=e(r),o=require("uuid"),i=require("@headlessui/react"),s=e(require("classnames")),l=require("lodash"),c=require("react-icons/hi2"),u=require("react-tooltip"),d=e(require("react-select")),m=require("@inertiajs/core");function p(e,n){if(!e)return"";var r=n||"dd/MM/yyyy";if(e instanceof Date)return t.format(e,r);var a=e.substring(0,10).split("-").join("/").split(".").join("/"),o=t.parse(a,"dd/MM/yyyy",new Date);if("Invalid Date"!==o.toString())return t.format(o,r);var i=new Date(e);return"Invalid Date"!==i.toString()?t.format(i,r):""}function f(e,n){if(!e)return"";var r=n||"dd/MM/yyyy HH:mm";if(e instanceof Date)return t.format(e,r);var a=e.split(",").join("").substring(0,22).split("-").join("/").split(".").join("/"),o=["AM","PM"].includes(a.slice(-2).toUpperCase()),i=("dd/MM/yyyy "+(o?"hh":"HH")+":mm"+(3===a.split(":").length?":ss":"")+" "+(o?"a":"")).trim(),s=t.parse(a,i,new Date);if("Invalid Date"!==s.toString())return t.format(s,r);var l=new Date(e);return"Invalid Date"!==l.toString()?t.format(l,r):""}function h(e){return Number(Math.round(parseFloat(e+"e2"))+"e-2")}function v(e){return h(3*e/23)}function g(e){return h(1.15*e)}function y(e){return h(e-v(e))}function w(e,t){if(void 0===t&&(t=2),null==e)return"";var n=e;return"string"==typeof e&&(n=e.replace(/[^\d.-]/g,"")),Number(n).toLocaleString("en",{minimumFractionDigits:t,maximumFractionDigits:t})}function x(e){return parseFloat(e.replace(/[^0-9.]/g,""))}function b(e){var t;switch(e){case"Camper":case"Goods Van/Truck/Utility":case"Bus":case"Motor Caravan":case"Trailer/Caravan":case"TRAILER_CARAVAN":case"TRAILER_NOT_DESIGNED_FOR_HIGHWAY_USE":case"MOBILE_MACHINE":case"GOODS_VAN_TRUCK_UTILITY":case"BUS":case"MOTOR_CARAVAN":t="motorhome";break;case"Motorcycle":case"Moped":case"ATV":case"Agricultural Machine":case"MOTORCYCLE":case"MOPED":case"TRACTOR":case"AGRICULTURAL_MACHINE":case"HIGH_SPEED_AGRICULTURAL_VEHICLE":t="motorcycle";break;case"Passenger Car/Van":case"PASSENGER_CAR_VAN":case"SPECIAL_PURPOSE_VEHICLE":case"UNKNOWN":default:t="car"}return t}function E(){E=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",i=r.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var a=Object.create((t&&t.prototype instanceof d?t:d).prototype),o=new N(r||[]);return a._invoke=function(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var s=x(i,n);if(s){if(s===u)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=c(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===u)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}(e,n,o),a}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var u={};function d(){}function m(){}function p(){}var f={};s(f,a,(function(){return this}));var h=Object.getPrototypeOf,v=h&&h(h(k([])));v&&v!==t&&n.call(v,a)&&(f=v);var g=p.prototype=d.prototype=Object.create(f);function y(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){var r;this._invoke=function(a,o){function i(){return new t((function(r,i){!function r(a,o,i,s){var l=c(e[a],e,o);if("throw"!==l.type){var u=l.arg,d=u.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,i,s)}),(function(e){r("throw",e,i,s)})):t.resolve(d).then((function(e){u.value=e,i(u)}),(function(e){return r("throw",e,i,s)}))}s(l.arg)}(a,o,r,i)}))}return r=r?r.then(i,i):i()}}function x(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var r=c(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,u;var a=r.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function k(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return m.prototype=p,s(g,"constructor",p),s(p,"constructor",m),m.displayName=s(p,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,i,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},y(w.prototype),s(w.prototype,o,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(l(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},y(g),s(g,i,"Generator"),s(g,a,(function(){return this})),s(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=k,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(s&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),_(n),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;_(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:k(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),u}},e}function _(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function N(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){_(o,r,a,i,s,"next",e)}function s(e){_(o,r,a,i,s,"throw",e)}i(void 0)}))}}function k(){return(k=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)}function T(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(a[n]=e[n]);return a}function S(e,t){r.useEffect((function(){var n=function(n){e.current&&!e.current.contains(n.target)&&t(n)};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),function(){document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}}),[e,t])}var C=r.createContext({toasts:[],addToast:function(e){},removeToast:function(e){}}),L=function(){return r.useContext(C)},M={id:void 0,status:"new",source:"phone",reference:"",client_number:"",first_name:"",last_name:"",phone:"",mobile:"",email:"",licence:"",licence_other:"",promo_code:"",club_membership_number:"",length_of_insurance:"",dob:"",secondary_first_name:"",secondary_last_name:"",secondary_licence:"",secondary_licence_other:"",secondary_dob:"",club_id:void 0,street_address:{address:"",unit:"",suburb:"",city:"",post_code:""},declaration:{had_incident:void 0,incidents:[],has_demerit_points:void 0,demerit_points:"",has_lost_licence:void 0,lost_licence_details:"",was_refused_insurance:void 0,refused_insurance_details:"",has_criminal_conviction:void 0,criminal_conviction_details:"",has_vehicle_modifications:void 0,vehicle_modifications_details:"",has_previous_insurer:void 0,previous_insurer_details:"",previous_insurer_expires_at:"",additional_details:""},vehicles:[],purchase_options:[],theme:"",broker_fee:void 0,broker_id:void 0,broker_firm_id:void 0,agent_id:void 0,agent_firm_id:void 0,staff_member_id:void 0,sent_at:void 0,sold_at:void 0,referrer_id:void 0,referrer_category_id:void 0,pricing_expires_at:void 0,follow_up_at:void 0,is_follow_up_required:!0},O=a.createContext({clear:function(){return null}}),A=function(){return a.useContext(O)},j=a.createContext({setOptions:function(){}});function R(){return(R=N(E().mark((function e(t){var n,r,a;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=encodeURIComponent(t),e.next=4,fetch("https://api.addressfinder.io/api/nz/address/autocomplete/?key=XVAKN4Q9PREJD8CUTFBW&q="+n+"&format=json&strict=2");case 4:if((r=e.sent).ok){e.next=7;break}return e.abrupt("return",[]);case 7:return e.next=9,r.json();case 9:if(!(a=e.sent).completions){e.next=12;break}return e.abrupt("return",a.completions);case 12:return e.abrupt("return",[]);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function P(){return(P=N(E().mark((function e(t){var n;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,fetch("https://api.addressfinder.io/api/nz/address/metadata/?key=XVAKN4Q9PREJD8CUTFBW&pxid="+t.pxid+"&format=json");case 3:if((n=e.sent).ok){e.next=6;break}return e.abrupt("return",null);case 6:return e.next=8,n.json();case 8:return e.abrupt("return",e.sent);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function D(e){if(!e)return 0;try{var t=new Date,n=new Date(e),r=t.getFullYear()-n.getFullYear(),a=t.getMonth()-n.getMonth();return a<0||0===a&&t.getDate()<n.getDate()?r-1:r}catch(e){return console.error(e),0}}function F(e){if(!e.premium)return 0;var t=e.premium/100/12;return e.disable_rounding?Math.round(100*t):Math.round(100*Math.ceil(t))}function I(e){return e%100==1?e-1:e%100==99?e+1:e}function G(){return n.usePage()}function U(e){var t=e.className,r=e.href,o=e.target,i=e.onClick,s=e.type,l=e.children,c=e.status,u=void 0===c?"default":c,d=e.disabled,m=void 0!==d&&d,p=e.as,f=e.small,h=(null!=t?t:"")+" "+(void 0!==f&&f?"font-bold text-sm inline-flex items-center gap-3 justify-center text-white text-center px-3 py-1 rounded min-w-[80px] transition-all hover:brightness-110":"font-black inline-flex items-center gap-3 justify-center text-white text-center px-5 py-2 rounded-md min-w-[120px] transition-all hover:brightness-110")+" "+(("primary"===u?"bg-accent":"danger"===u&&"bg-red-500")||"warning"===u&&"bg-yellow-400"||"info"===u&&"bg-blue-400"||"bg-gray-600");return i?a.createElement("button",{className:h,type:null!=s?s:"button",onClick:function(e){return i(e)},disabled:m},l):s?a.createElement("button",{className:h,type:null!=s?s:"button",disabled:m},l):r?r.includes("http")||"_blank"===o||"a"===p?a.createElement("a",{href:r,target:null!=o?o:"_self",className:h},l):a.createElement(n.Link,{href:r,className:h},l):a.createElement("p",{className:"text-red-500 text-sm"},"[Invalid button]")}function H(e){var t=e.className;return a.createElement("div",{className:(null!=t?t:"")+" flex flex-col items-start bg-white rounded-md shadow-sm border border-gray-300 p-4 md:p-6"},e.children)}function q(e){var t=e._id,n=void 0===t?"":t,r=e.message,o=e.status,s=void 0===o?"default":o,l=L().removeToast;return a.createElement(i.Transition,{show:!0,appear:!0,enter:"transition-all duration-300",enterFrom:"opacity-0 translate-y-4",enterTo:"opacity-100 translate-y-0",leave:"transition-all duration-300",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 translate-y-2"},a.createElement("div",{className:"w-full min-w-[250px] p-4 shadow flex justify-between items-center font-black rounded-md not: "+(("success"===s?"bg-accent text-white":"error"===s&&"bg-red-500 text-white")||"warning"===s&&"bg-yellow-400 text-white"||"bg-white text-primary")},a.createElement("p",null,r),a.createElement("button",{className:"",onClick:function(){l(n)},title:"Close message"},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",className:"h-6 w-6"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})))))}var B=["children"],V=["children","className"],W=["children","className","condensed"],Y=["children","className"],z=["children","className","sort","textAlign","condensed"],K=["children","className","onClick"],J=["POOR","FAIR","AVERAGE","GOOD","VERY_GOOD","AS_NEW","NEW"];function Q(e){var t=e.back,r=e.className,o=a.useState("string"==typeof t?t:void 0),i=o[0],l=o[1],u=G().props.breadcrumbs;return a.useEffect((function(){if("undefined"!=typeof window){if(!u)return;if(t&&"boolean"==typeof t){var e=u.slice(u.length-2,u.length-1);if(e&&1===e.length){var n=e[0].url;n&&l(new URL(n).pathname)}}}}),[u]),a.createElement(n.Link,{href:i||"/",className:s(r,"flex items-center justify-center text-primary hover:text-accent transition-all")},a.createElement(c.HiArrowLeft,{className:"h-5 w-5 stroke-[1.25]"}))}function X(e){var t=e.search,r=e.active,o=e.onActive,i=e.placeholder,s=e.focusSearchShortcut,l=void 0!==s&&s,u=a.useState(""),d=u[0],m=u[1],p=a.useRef(null);function f(e,r){var a;if(null==e||e.preventDefault(),"string"==typeof t){var o=t;"/"!==o[0]&&(o="/"+o);var i=new URLSearchParams(null==(a=window)?void 0:a.location.search);i.set("search",null!=r?r:d),i.set("page","1"),n.router.get(o+"?"+i.toString())}}return a.useEffect((function(){if("undefined"!=typeof window){var e=new URLSearchParams(window.location.search).get("search");e&&(m(e),o(!0))}var t=function(e){l&&"/"===e.key&&(e.preventDefault(),o(!0)),"Escape"===e.key&&o(!1)};return window.addEventListener("keydown",t),function(){window.removeEventListener("keydown",t)}}),[l]),S(p,(function(){d||o(!1)})),a.createElement("div",{ref:p,className:""},!r&&a.createElement("button",{title:"Open Search Bar",type:"button",onClick:function(){return o(!0)},className:"flex items-center justify-center rounded-full hover:text-accent p-1 hover:bg-gray-100"},a.createElement(c.HiMagnifyingGlass,{className:"h-5 w-5 stroke-[1.25]"})),r&&a.createElement("form",{onSubmit:f,className:"group flex items-center gap-2 rounded-full bg-white pr-4 pl-1 shadow transition-all focus-within:outline-none focus-within:ring-1 focus-within:ring-accent"},a.createElement("input",{type:"text",name:"search",id:"search",value:d,onChange:function(e){return m(e.currentTarget.value||"")},className:"no-focus-shadow !focus:border-0 !border-0 !bg-transparent !shadow-none !ring-opacity-0 !transition-none placeholder:text-gray-400 !py-1.5 text-sm",autoFocus:!0,placeholder:i}),d&&a.createElement("button",{type:"button",title:"Clear Search",onClick:function(){m(""),f(void 0,"")}},a.createElement(c.HiXMark,{className:"h-5 w-5"})),a.createElement("button",{type:"submit"},a.createElement(c.HiMagnifyingGlass,{className:"h-5 w-5"}))))}function $(e){var t=e.title,r=e.href,o=e.as,i=void 0===o?"Link":o,s=e.target,l=void 0===s?"_self":s,c=e.type,d=e.onClick,m=void 0===d?function(){}:d,p=e.shortcutKey,f=e.actions,h="bg-white rounded-full font-bold px-4 py-1.5 text-sm whitespace-nowrap hover:bg-gray-100 hover:border-gray-400 transition-colors border border-gray-300",v="action-"+t,g=p?"Ctrl + "+p:void 0,y=a.useRef(null),w=f&&f.length>0,x=a.useState(!1),b=x[0],E=x[1];return S(y,(function(){return E(!1)})),a.useEffect((function(){if("undefined"!=typeof window&&p){var e=function(e){var t=e.ctrlKey||e.metaKey,a=e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLSelectElement,o=e.target instanceof Element&&e.target.closest("form");!t||a||o||e.key!==p||(e.preventDefault(),"Link"===i&&r?n.router.get(r):"a"===i&&r?window.location.href=r:m())};return window.addEventListener("keydown",e),function(){window.removeEventListener("keydown",e)}}}),[p]),a.createElement(a.Fragment,null,g&&a.createElement(u.Tooltip,{id:v,className:"z-10"}),w?a.createElement("div",{ref:y,"data-tooltip-id":v,"data-tooltip-content":g,className:"relative cursor-pointer bg-white rounded-full font-bold px-4 py-1.5 text-sm whitespace-nowrap hover:bg-gray-100 hover:border-gray-400 transition-colors border border-gray-300",onClick:function(){E(!b)}},t,b&&a.createElement("div",{className:"absolute top-[120%] right-[-20%] z-10"},a.createElement("div",{className:"flex flex-col gap-2 bg-white rounded-lg shadow-xl p-3"},f&&f.map((function(e,t){return e.hidden?null:a.createElement($,{key:t,title:e.title,as:e.as,href:e.href,target:e.target,onClick:e.onClick,type:"button"})}))))):"Link"===i&&r?a.createElement(n.Link,{"data-tooltip-id":v,"data-tooltip-content":g,className:h,href:r,onClick:function(){return m()}},t):"a"===i&&r?a.createElement("a",{"data-tooltip-id":v,"data-tooltip-content":g,className:h,target:l,href:r,onClick:function(){return m()}},t):a.createElement("button",{"data-tooltip-id":v,"data-tooltip-content":g,className:h,type:c,onClick:function(){return m()}},t))}function Z(e){var t=e.onClose,n=e.active,r=e.title,o=e.children,i=a.useRef(null),s=a.useRef(null);return S(i,(function(){return t(!1)})),a.useEffect((function(){var e=null==i?void 0:i.current,t=s.current;if(null==e||e.classList.toggle("active",n),e&&t){var r=null==e?void 0:e.getBoundingClientRect();t.style.setProperty("left",(null==r?void 0:r.left)+"px")}}),[n,i.current,s.current]),a.createElement("div",{ref:i,className:"static inline-block"},r,n&&a.createElement("div",{ref:s,className:"absolute children z-10 flex flex-col"},o))}function ee(e){var r,o,i,l,u,m,p=e.filter,f=a.useState(!1),h=f[0],v=f[1],g=a.useState([]),y=g[0],w=g[1],x=a.useState([]),b=x[0],E=x[1],_=y.length>0;function N(e){var t=e.currentTarget,n=t.value;w(t.checked?function(e){return[].concat(e,[n])}:y.filter((function(e){return e!==n})))}function T(e){var n=e.currentTarget,r=n.name,a=n.value;return r.includes("from")?w([a]):r.includes("to")?w(0===y.length?[t.format(t.subYears(new Date,1),"yyyy-MM-dd"),a]:[y[0],a]):w([])}function S(e){var t=e.currentTarget.value;w(t?[t]:[])}return a.useEffect((function(){if("undefined"!=typeof window){var e=new URLSearchParams(window.location.search);if("date"===p.type){var t=e.get(p.name+"[from]"),n=e.get(p.name+"[to]");t&&n&&w([t,n])}else if("greaterThan"===p.type){var r=e.getAll(p.name+"-GTE");r&&w(r)}else if("scope"===p.type){var a=e.getAll("scope"+p.name);a&&w(a)}else if("select"===p.type){var o=e.getAll(p.name+"[]");if(o){w(o);var i=p.options&&p.options.filter((function(e){return o.includes(e.value.toString())}));i&&E(i)}}else{var s=e.getAll(p.name+"[]");s&&w(s)}}}),[]),a.createElement(Z,{onClose:function(){return v(!open)},active:h,title:a.createElement("div",{onClick:function(){v(!h)},className:s("flex rounded-2xl border hover:cursor-pointer hover:border-accent bg-gray-600 px-2 py-1 items-center justify-between shrink-0 gap-2 text-xs text-white hover:bg-accent transition-colors",{"!bg-accent border-accent":_})},a.createElement("p",{className:"whitespace-nowrap"},p.label),a.createElement(c.HiChevronDown,null))},a.createElement("form",{className:"mt-2 flex max-h-[350px] min-w-[200px] max-w-[260px] flex-col gap-2 rounded-md border border-gray-300 bg-white shadow-lg "+(p.type&&"select"===p.type?"":"overflow-y-scroll"),onSubmit:function(e){e.preventDefault();var r=new URLSearchParams(window.location.search);if(r.set("page","1"),"date"===p.type){var a=y[0],o=y[1];r.set(p.name+"[from]",null!=a?a:t.format(new Date,"yyyy-MM-dd")),r.set(p.name+"[to]",null!=o?o:t.format(new Date,"yyyy-MM-dd"))}else"greaterThan"===p.type?(r.delete(p.name+"-GTE"),y.length>0&&r.set(p.name+"-GTE",y[0])):"scope"===p.type?(r.delete(""+p.name),y.length>0&&r.set("scope"+p.name,y[0])):(r.delete(p.name+"[]"),y.forEach((function(e){r.append(p.name+"[]",e)})));n.router.get(window.location.pathname+"?"+r.toString())}},a.createElement("div",{className:"flex flex-col items-start gap-1 p-4"},(!p.type||"options"===p.type)&&(null==(r=p.options)?void 0:r.map((function(e,t){return a.createElement("div",{className:"checkbox text-sm ",key:e.label+"-"+t},a.createElement("input",{type:"checkbox",name:p.name,id:e.label,value:e.value.toString(),checked:y.includes(e.value.toString()),onChange:N}),a.createElement("label",{className:"leading-tight",htmlFor:e.label},e.label))}))),"greaterThan"===p.type&&p.options&&a.createElement("label",{className:"mb-2 w-full"},a.createElement("div",{className:"text-sm"},"Greater than or equal to"),a.createElement("select",{name:p.name,id:p.label,value:y[0],onChange:S,className:"!p-2 text-sm w-full"},a.createElement("option",{value:""},"Select option"),null==(o=p.options)?void 0:o.map((function(e){return a.createElement("option",{key:e.value,value:e.value},e.label)})))),"scope"===p.type&&p.options&&a.createElement("label",{className:"mb-2 w-full"},a.createElement("select",{name:p.name,id:p.label,value:y[0],onChange:S,className:"!p-2 text-sm w-full"},a.createElement("option",{value:""},"Select option"),null==(i=p.options)?void 0:i.map((function(e){return a.createElement("option",{key:e.value,value:e.value},e.label)})))),"date"===p.type&&a.createElement("div",{className:"mb-2 flex flex-col gap-4 w-full"},a.createElement("label",{className:"text-xs w-full"},"From",a.createElement("input",{type:"date",name:p.name+"[from]",id:p.name+"[from]",onChange:T,value:null!=(l=y[0])?l:"",className:"!p-2 text-sm w-full"})),a.createElement("label",{className:"text-xs w-full"},"To",a.createElement("input",{type:"date",name:p.name+"[to]",id:p.name+"[to]",onChange:T,value:null!=(u=y[1])?u:"",className:"!p-2 text-sm w-full"}))),"select"===p.type&&p.options&&a.createElement("div",{className:"w-full"},a.createElement(d,{isMulti:!0,options:p.options,className:"basic-multi-select text-xs w-52 !transition-none",classNamePrefix:"select",onChange:function(e){E(e);var t=e.map((function(e){return e.value.toString()}));w(t.length>0?t:[])},components:{ClearIndicator:function(){return null}},value:b,theme:function(e){return k({},e,{colors:k({},e.colors,{primary25:"rgb(111, 199, 182)",primary:"rgb(111, 199, 182)"})})}})),"text"===p.type&&a.createElement("div",{className:"w-full"},a.createElement("input",{type:"text",name:p.name,placeholder:p.label,value:null!=(m=y[0])?m:"",onChange:function(e){var t=e.currentTarget.value;w(t?[t]:[])},className:"!p-2 text-sm w-full"}))),a.createElement("div",{className:"bg-gray-100 border-t border-gray-200 flex items-center gap-2 p-4 bottom-0 sticky"},a.createElement(U,{type:"button",className:"!min-w-[0px] flex-grow !px-2 text-sm !transition-none",onClick:function(){var e=new URLSearchParams(window.location.search);e.set("page","1"),"date"===p.type?(e.delete(p.name+"[from]"),e.delete(p.name+"[to]")):e.delete("greaterThan"===p.type?p.name+"-GTE":"scope"===p.type?"scope"+p.name:p.name+"[]"),n.router.get(window.location.pathname+"?"+e.toString())},small:!0},"Clear"),a.createElement(U,{type:"submit",status:"primary",className:"!min-w-[0px] flex-grow !px-2 text-sm !transition-none",small:!0},"Apply"))))}function te(e){var t=e.title,n=e.search,r=e.className,o=void 0===r?"":r,i=e.innerClassName,l=void 0===i?"":i,u=e.back,d=void 0===u||u,p=e.actions,f=void 0===p?[]:p,h=e.filterOptions,v=void 0===h?[]:h,g=e.focusSearchShortcut,y=void 0!==g&&g,w=e.children,x=a.useState(!1),b=x[0],E=x[1],_=a.useRef(null),N=a.useState(!1),k=N[0],T=N[1],S=[];a.Children.forEach(w,(function(e){a.isValidElement(e)&&e.type===te.Action&&S.push(e)})),a.useEffect((function(){var e=_.current;if(e){var t=function(){var t=e.querySelector(".active");if(t){var n=t.querySelector(".children");if(n){var r=t.getBoundingClientRect(),a=n.getBoundingClientRect(),o=e.getBoundingClientRect();n.style.visibility=a.left<=o.left-50||a.left>=o.right-50?"hidden":"visible",n.style.left=r.left+"px"}}},n=function(t){var n=e.getBoundingClientRect();T(t.clientX>n.left&&t.clientX<n.right&&t.clientY>n.top&&t.clientY<n.bottom)};return e.addEventListener("scroll",t),document.addEventListener("mousemove",n),function(){e.removeEventListener("scroll",t),document.removeEventListener("mousemove",n)}}}),[]),a.useEffect((function(){var e=function(e){var t;k&&(e.preventDefault(),null==(t=_.current)||t.scrollBy({left:e.deltaY,behavior:"auto"}))};return document.addEventListener("wheel",e,{passive:!1}),function(){document.removeEventListener("wheel",e)}}),[k]);var C=a.useState(!1),L=C[0],M=C[1],O=a.useCallback((function(){var e=_.current;if(e){var t=e.getBoundingClientRect();M(e.scrollWidth>t.width+11)}}),[_.current]);a.useEffect((function(){return O(),window.addEventListener("resize",O),function(){window.removeEventListener("resize",O)}}),[O]);var A=a.useMemo((function(){return f.filter((function(e){return!e.hidden}))}),[f]);return a.createElement("section",{className:s("col-span-full flex items-center gap-2 max-w-full rounded-lg bg-white p-2 shadow",o)},d&&a.createElement(Q,{back:d,className:"bg-primary-100 h-[60px] w-[60px] rounded"}),a.createElement("div",{className:s("w-full grid grid-cols-[auto_1fr_auto_auto] h-[60px] rounded bg-primary-100 p-3 gap-4",l)},a.createElement("button",{type:"button",disabled:!n,onClick:function(){return E(!0)},className:s("mr-auto flex items-center gap-4 transition-colors pr-6 pl-1 disabled:opacity-100 text-primary",{"hover:text-accent":n&&!b})},n&&a.createElement(X,{search:n,active:b,onActive:E,placeholder:"Search "+t+"...",focusSearchShortcut:y}),!b&&a.createElement("h1",{className:"text-base text-primary font-black"},t)),a.createElement("div",{className:"flex items-center ml-auto gap-2 h-full min-w-0 max-w-full"},v.length>0&&a.createElement(a.Fragment,null,a.createElement("button",{onClick:function(){m.router.get(""+window.location.pathname)},className:"p-1.5 hover:text-red-500"},a.createElement(c.HiXMark,{className:"w-5 h-5 stroke-[1.25]"})),L&&a.createElement(c.HiChevronLeft,{onClick:function(){var e;null==(e=_.current)||e.scrollBy({left:-100,behavior:"auto"}),O()},className:"w-5 h-5 text-gray-400 stroke-[1.25]"}),a.createElement("div",{ref:_,className:"flex items-center h-full w-full gap-3 overflow-x-scroll hide-scroll"},v.map((function(e){return a.createElement(ee,{key:e.name,filter:e})}))),L&&a.createElement(c.HiChevronRight,{onClick:function(){var e;null==(e=_.current)||e.scrollBy({left:100,behavior:"auto"}),O()},className:"w-5 h-5 text-gray-400 stroke-[1.25]"}))),A.length>0&&a.createElement("div",{className:"flex items-center gap-3 bg-primary-100"},v.length>0&&a.createElement("div",{className:"w-[1px] h-full bg-gray-300"}),a.createElement("nav",{className:"flex items-center gap-2"},A.map((function(e){return a.createElement($,Object.assign({key:e.title+"-"+e.as+"-"+e.href},e))})))),S&&a.createElement("div",{className:"flex items-center gap-3 bg-gray-100"},S)))}te.Action=function(e){return a.createElement("div",null,e.children)},exports.Button=U,exports.Card=H,exports.DateOfBirthField=function(e){var t=e.name,n=void 0===t?"dob":t,r=e.id,o=void 0===r?"dob":r,i=e.onChange,s=e.value,c=e.maxYear,u=void 0===c?0:c,d=e.showAge,m=void 0!==d&&d,p=e.isRequired,f=void 0===p||p,h=[].concat(Array.from(Array(31).keys())).map((function(e){return l.padStart(""+(e+1),2,"0")})),v=["January","February","March","April","May","June","July","August","September","October","November","December"],g=[].concat(Array.from(Array(12).keys())).map((function(e){return{title:v[e],value:l.padStart(""+(e+1),2,"0")}})),y=[].concat(Array.from(Array(100).keys())).map((function(e){return u?u-e:(new Date).getFullYear()-e}));function w(e){var t=e.currentTarget,n=t.name,r=t.value,a=n.includes("year")?r:b,o=n.includes("month")?r:E,s=n.includes("day")?r:_;i(a+"-"+o+"-"+s)}var x=s?s.split("-"):["","",""],b=x[0],E=x[1],_=x[2],N=b&&E&&_&&!isNaN(Date.parse(b+"-"+E+"-"+_)),k={backgroundPosition:"top 10px right 3px, center right 10px"},T={backgroundPosition:"right 0.5rem center",paddingRight:"1.5rem"};return a.createElement("span",{className:"flex flex-col gap-2"},a.createElement("span",{className:"flex w-full border border-gray-300 rounded-lg bg-white"},a.createElement("select",{name:n+"_day",id:o+"_day",value:_,className:"flex-grow focus:outline-none border-0 !mr-[3px] lg:pl-4 xl:pl-2",onChange:w,required:f,style:f?k:T},a.createElement("option",{value:""},"Day"),h.map((function(e){return a.createElement("option",{key:e,value:e},e)}))),a.createElement("select",{name:n+"_month",id:o+"_month",value:E,className:"flex-grow focus:outline-none border-0 !mr-[3px] lg:pl-4 xl:pl-2",onChange:w,required:f,style:f?k:T},a.createElement("option",{value:""},"Month"),g.map((function(e){return a.createElement("option",{key:e.value,value:e.value},e.title)}))),a.createElement("select",{name:n+"_year",id:o+"_year",value:b,className:"flex-grow focus:outline-none border-0 !mr-[3px] lg:pl-4 xl:pl-2",onChange:w,required:f,style:f?k:T},a.createElement("option",{value:""},"Year"),y.map((function(e){return a.createElement("option",{key:e,value:e},e)})))),m&&s&&N&&a.createElement("span",{className:"font-bold"},"Age: ",D(s)," years"))},exports.ErrorList=function(e){var t=e.heading,n=void 0===t?"There was an error with your submission.":t,r=e.errors,o=void 0===r?{}:r,i=e.renderKeys,s=void 0!==i&&i,l=e.className,c=void 0===l?"":l;return 0===Object.values(o).length?a.createElement(a.Fragment,null):a.createElement("aside",{className:c+" col-span-full"},a.createElement(H,{className:"border border-red-500 !bg-red-50"},a.createElement("h2",{className:"font-black text-red-500 mb-2"},n),a.createElement("ul",{className:"space-y-2 list-disc ml-4"},Object.entries(o).map((function(e){var t=e[0],n=e[1];return a.createElement("li",{className:"font-bold text-red-500",key:t},s&&a.createElement("strong",null,t,": "),n)})))))},exports.FormTester=function(e){var t=e.populatePurchaseOptions,n=void 0!==t&&t,r=A().form,o=a.useState([]),i=o[0],s=o[1],l=a.useState(!1),c=l[0],u=l[1];function d(){null==r||r.setData((function(e){return k({},e,{first_name:"TEST",last_name:"TEST",email:"dev@sual.co.nz",phone:"021 234 5678",mobile:"021 234 5678",dob:"1990-01-01",licence:"Other",licence_other:"Test",club_id:50,club_membership_number:"12345",street_address:{address:"123 Street Name",unit:"Level 1",suburb:"Suburb",city:"Auckland",post_code:"1234"},promo_code:"TEST",declaration:{had_incident:!0,incidents:[{description:"Lorem ipsum dolor sit amet.",month:"January",year:"2020"}],has_demerit_points:!0,demerit_points:"1-24",has_lost_licence:!0,lost_licence_details:"Lorem ipsum dolor sit amet.",was_refused_insurance:!0,refused_insurance_details:"Lorem ipsum dolor sit amet.",has_criminal_conviction:!0,criminal_conviction_details:"Lorem ipsum dolor sit amet.",has_vehicle_modifications:!0,vehicle_modifications_details:"Lorem ipsum dolor sit amet.",has_previous_insurer:!0,previous_insurer_details:"AA",previous_insurer_expires_at:"2020-01-01",additional_details:"I am a robot, beep boop. Please ignore this submission."},vehicles:[{make:"Tesla",model:"Cybertruck",year:"2023",registration:"ELMUSK",vehicle_type:"car",product:"star-enthusiast-prestige-everyday-plus",value:1e5,is_heavy:!1,usage:"Childrens car",storage_location:"Carport",has_financially_interested_party:!0,financially_interested_party_detail:"MTA",owned_duration:"Less than 12 months",main_driver:"TEST TEST",drivers:[{first_name:"X Æ",last_name:"A-12",dob:"2000-05-04",licence:"Other",licence_other:"None",relationship:"Child",key:"driver-test-key"}],key:"vehicle-test-key"}],purchase_options:n?[{premium_type:"annual",level_of_insurance_id:12,authorised_drivers:"TEST",excess_details:"TEST",terms:"TEST",description:"This is a test purchase option",premium:1e5,monthly_premium:8500,show_monthly:!0,fsl:100,sort_order:1,enhancements:[{name:"Test enhancement",premium:2500,disable_rounding:!1,description:"Test enhancement",auto_select:!0,key:"enhancement-test-key-1"},{name:"Test enhancement",premium:5e3,disable_rounding:!1,description:"Test enhancement",auto_select:!1,key:"enhancement-test-key-2"}],key:"purchase-option-test-key-annual"},{premium_type:"total-due",level_of_insurance_id:13,authorised_drivers:"TEST",excess_details:"TEST",terms:"TEST",description:"This is a test purchase option",premium:1e5,show_monthly:!1,fsl:100,sort_order:2,enhancements:[{name:"Test enhancement",premium:2500,disable_rounding:!1,description:"Test enhancement",auto_select:!0,key:"enhancement-test-key-3"},{name:"Test enhancement",premium:5e3,disable_rounding:!1,description:"Test enhancement",auto_select:!1,key:"enhancement-test-key-4"}],key:"purchase-option-test-key-total-due"}]:[]})}))}function m(e){if("Escape"===e.key)return s([]);s((function(t){return[].concat(t,[e.key])}))}return a.useEffect((function(){"debug"===i.join("")&&d()}),[i]),a.useEffect((function(){if("undefined"!=typeof window)return(window.location.href.includes("dev")||window.location.href.includes("localhost")||window.location.href.includes("test")||window.location.href.includes("local"))&&u(!0),window.addEventListener("keydown",(function(e){return m(e)})),function(){window.removeEventListener("keydown",(function(e){return m(e)}))}}),[]),c?a.createElement(U,{onClick:d,type:"button",status:"primary",className:"fixed bottom-4 right-4"},"Populate data"):a.createElement(a.Fragment,null)},exports.Modal=function(e){var t=e.children,n=e.isActive,o=e.onClose,s=e.title,l=e.width,c=void 0===l?"":l,u=e.className,d=void 0===u?"":u;return a.createElement(i.Transition.Root,{show:void 0!==n&&n,as:r.Fragment},a.createElement(i.Dialog,{as:"div",className:"fixed z-[110] inset-0 overflow-y-auto",onClose:o},a.createElement("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"},a.createElement(i.Transition.Child,{as:r.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0"},a.createElement(i.Dialog.Overlay,{className:"fixed inset-0 bg-gray-500/75 transition-opacity"})),a.createElement(i.Transition.Child,{as:r.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"},a.createElement("div",{className:d+" w-full align-start inline-block bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-7xl sm:p-6 "+c},a.createElement("div",{className:"flex gap-4 mb-4 text-primary "+(s?"border-b-2 border-primary pb-4":"")},s&&a.createElement("h3",{className:"font-black text-lg"},s),a.createElement("button",{type:"button",onClick:o,className:"ml-auto transition-all hover:opacity-50"},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})))),a.createElement("div",null,t))))))},exports.MoneyField=function(e){var t=e.value,n=e.onChange,r=e.name,o=void 0===r?"value":r,i=e.id,s=void 0===i?"value":i,l=e.className,c=void 0===l?"":l,u=e.required,d=void 0!==u&&u,m=w(void 0===t?0:t,0);return a.createElement("div",{className:c+" flex items-center gap-2 pl-4 rounded-md border border-gray-300 transition-all focus-within:border-accent focus-within:outline-none focus-within:ring focus-within:ring-accent focus-within:ring-opacity-50"},a.createElement("span",{className:"font-bold pr-2"},"$"),a.createElement("input",{type:"text",name:o,id:s,value:m,onChange:function(e){var t=0;e.currentTarget.value&&(t=x(e.currentTarget.value),isNaN(t)&&(t=0)),n(t)},className:"w-full !focus:outline-none !focus:ring-0 !focus:ring-transparent !focus:ring-opacity-0 !ring-0 !border-0 !transition-none !rounded-l-none",required:d}))},exports.PageHeader=te,exports.Pagination=function(e){var t=e.meta,r=e.className,o=e.showPerPageSelector,i=void 0!==o&&o,s=e.defaultValue,l=t.current_page,c=t.per_page,u=null!=s?s:c,d=Math.ceil(t.total/c),m=function(){if("undefined"!=typeof window){var e=new URLSearchParams(window.location.search);return e.set("page",String(l+1)),"?"+e.toString()}return""}(),p=function(){if("undefined"!=typeof window){var e=new URLSearchParams(window.location.search);return e.set("page",String(l-1)),"?"+e.toString()}return""}();return a.createElement("div",{className:""+(null!=r?r:"")},a.createElement("nav",{className:"font-bold flex justify-between items-center gap-6"},a.createElement(n.Link,{href:p,className:"flex items-center gap-2",disabled:1===l},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 19l-7-7m0 0l7-7m-7 7h18"})),"Prev"),a.createElement("div",{className:"flex gap-6 items-center"},a.createElement("p",null,"Page ",l," of ",d),i?a.createElement("select",{value:u,onChange:function(e){var t,n=new URLSearchParams(null==(t=window)?void 0:t.location.search);n.set("limit",e.currentTarget.value),n.set("page","1"),window.location.href="?"+n.toString()}},a.createElement("option",{value:"10"},"10 per page"),a.createElement("option",{value:"25"},"25 per page"),a.createElement("option",{value:"50"},"50 per page"),a.createElement("option",{value:"100"},"100 per page"),a.createElement("option",{value:"250"},"250 per page"),a.createElement("option",{value:"500"},"500 per page")):""),a.createElement(n.Link,{href:m,className:"flex items-center gap-2",disabled:l===d},"Next",a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14 5l7 7m0 0l-7 7m7-7H3"})))))},exports.QuoteRequestFormContext=O,exports.QuoteRequestFormProvider=function(e){var t=e.children,r=n.useForm(k({},M));return a.createElement(O.Provider,{value:{form:r,handleChange:function(e){var t=e.currentTarget.name,n=e.currentTarget.value;if("checkbox"!==e.currentTarget.type&&"radio"!==e.currentTarget.type||(n="1"===e.currentTarget.value),t.includes(".")){var a=t.split(".");return 2===a.length?r.setData((function(e){var t,r;return k({},e,((r={})[a[0]]=k({},e[a[0]],((t={})[a[1]]=n,t)),r))})):void 0}return r.setData((function(e){var r;return k({},e,((r={})[t]=n,r))}))},clear:function(){r.setData(k({},M))}}},t)},exports.QuoteRequestOptionsProvider=function(e){var t=e.children,n=a.useState();return a.createElement(j.Provider,{value:{options:n[0],setOptions:n[1]}},t)},exports.RegistrationSearchField=function(e){var t=e.name,n=void 0===t?"registration_search":t,r=e.initialRegistrationValue,o=e.onVehicleDataFound,i=e.apiUrl,l=void 0===i?"/api/rego-search":i,c=e.showOdometerReadingField,u=void 0!==c&&c,d=e.showConditionField,m=void 0!==d&&d,p=e.onChange,f=e.outerClassName,h=e.odoInputClassName,v=e.conditionSelectClassName,g=e.regoInputClassName,y=e.searchBtnClassName,w=a.useState(void 0===r?"":r),x=w[0],_=w[1],T=a.useState(""),S=T[0],C=T[1],M=a.useState("GOOD"),O=M[0],A=M[1],j=a.useState("idle"),R=j[0],P=j[1],D=L().addToast;function F(e){var t;e.currentTarget.name===n&&_((null==(t=e.currentTarget.value)?void 0:t.toUpperCase())||""),"odo_search"===e.currentTarget.name&&C(e.currentTarget.value),"condition_search"===e.currentTarget.name&&A(e.currentTarget.value),p&&p({registration:e.currentTarget.value.toUpperCase()})}function I(e){"Enter"===e.key&&G()}function G(){return U.apply(this,arguments)}function U(){return(U=N(E().mark((function e(){var t,n,r,a,i,s,c,u,d,m;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return P("processing"),t=new URLSearchParams({registration:x,odometerReading:S,condition:O}).toString(),e.next=5,fetch(l+"?"+t,{headers:{"Content-Type":"application/json"}});case 5:if((n=e.sent).ok){e.next=10;break}return D({message:"There was an error with the provided registration.",status:"error",timeout:3e3}),P("error"),e.abrupt("return");case 10:return e.next=12,n.json();case 12:if(a=(r=e.sent).data,r.ok&&a){e.next=19;break}return D({message:"Failed to find vehicle, please complete manually.",status:"error",timeout:3e3}),P("error"),e.abrupt("return");case 19:s=(i=a.data.vehicle).make,c=i.model,u=i["year-of-manufacture"],d=i["gross-vehicle-mass"]?parseInt(i["gross-vehicle-mass"].replaceAll(",","")):0,m=i["vehicle-type"],s&&c&&u&&m||(D({message:"We couldn't find all of your data, please complete manually.",status:"error",timeout:3e3}),P("error")),o(k({},a,{make:s||"",model:c||"",year:u||"",vehicle_type:m?b(m):"car",is_heavy:d&&d>3500||!1})),P("success");case 28:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return a.createElement("div",{className:"w-full flex flex-col"},a.createElement("div",{className:s(f,"w-full flex flex-wrap gap-3 bg-gray-100 rounded-md p-3")},u||m&&a.createElement("div",{className:"w-full grid grid-cols-2 gap-3"},u&&a.createElement("label",null,"Approx. km travelled",a.createElement("input",{onKeyDown:I,type:"number",name:"odo_search",id:"odo_search",value:S,onChange:F,className:s(h,"transition-all",{"pointer-events-none opacity-50":"processing"===R}),disabled:"processing"===R})),m&&a.createElement("label",null,"Vehicle condition",a.createElement("select",{name:"condition_search",id:"condition_search",value:O,onChange:F,className:s(v,"transition-all",{"pointer-events-none opacity-50":"processing"===R}),disabled:"processing"===R},J.map((function(e){return a.createElement("option",{key:e},e)}))))),a.createElement("input",{onKeyDown:I,placeholder:"Search for your rego",type:"text",name:n,id:n,value:x,onChange:F,className:s(g,"flex-grow transition-all",{"pointer-events-none opacity-50":"processing"===R}),disabled:"processing"===R}),a.createElement("button",{title:"Search",type:"button",onClick:G,disabled:"processing"===R,className:s(y,"bg-accent px-4 py-3 rounded-md transition-all")},a.createElement("span",{className:"sr-only"},"Search"),a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})))))},exports.SimplePagination=function(e){var t=e.meta,r=e.className,o=e.showPerPageSelector,i=void 0!==o&&o,s=e.defaultValue,l=t.current_page,c=t.per_page,u=null!=s?s:c,d=t.to-t.from+1===c,m=function(){if("undefined"!=typeof window){var e=new URLSearchParams(window.location.search);return e.set("page",String(l+1)),"?"+e.toString()}return""}(),p=function(){if("undefined"!=typeof window){var e=new URLSearchParams(window.location.search);return e.set("page",String(l-1)),"?"+e.toString()}return""}();return a.createElement("div",{className:""+(null!=r?r:"")},a.createElement("nav",{className:"font-bold flex justify-between items-center gap-6"},a.createElement(n.Link,{href:p,className:"flex items-center gap-2",disabled:1===l},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 19l-7-7m0 0l7-7m-7 7h18"})),"Prev"),a.createElement("div",{className:"flex gap-6 items-center"},a.createElement("p",null,"Page ",l),i?a.createElement("select",{value:u,onChange:function(e){var t,n=new URLSearchParams(null==(t=window)?void 0:t.location.search);n.set("limit",e.currentTarget.value),n.set("page","1"),window.location.href="?"+n.toString()}},a.createElement("option",{value:"10"},"10 per page"),a.createElement("option",{value:"25"},"25 per page"),a.createElement("option",{value:"50"},"50 per page"),a.createElement("option",{value:"100"},"100 per page"),a.createElement("option",{value:"250"},"250 per page"),a.createElement("option",{value:"500"},"500 per page")):""),a.createElement(n.Link,{href:m,className:"flex items-center gap-2",disabled:!d},"Next",a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14 5l7 7m0 0l-7 7m7-7H3"})))))},exports.Table=function(e){var t=e.children,n=T(e,B);return a.createElement("div",{className:"-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8 text-sm"},a.createElement("div",{className:"inline-block min-w-full py-2 align-middle md:px-6 lg:px-8"},a.createElement("div",{className:"overflow-hidden shadow ring-1 ring-gray-300 ring-opacity-5 md:rounded-lg"},a.createElement("table",Object.assign({},n,{className:"min-w-full divide-y divide-gray-300"}),t))))},exports.TableActions=function(e){var t=e.className;return a.createElement("div",{className:(void 0===t?"":t)+" flex gap-4 justify-end items-center"},e.children)},exports.TableBody=function(e){var t=e.children,n=e.className,r=T(e,V);return a.createElement("tbody",Object.assign({},r,{className:s(n,"divide-y divide-gray-200 bg-white")}),t)},exports.TableCell=function(e){var t=e.children,n=e.className,r=e.condensed,o=T(e,W);return a.createElement("td",Object.assign({},o,{className:s(n,"px-3 py-3 text-sm text-gray-500",{"w-0 whitespace-nowrap":r})}),t)},exports.TableHead=function(e){var t=e.children,n=e.className,r=T(e,Y);return a.createElement("thead",Object.assign({},r,{className:s(n,"px-3 py-4 text-sm text-white bg-gray-600")}),t)},exports.TableHeader=function(e){var t=e.children,r=e.className,o=void 0===r?"":r,i=e.sort,l=e.textAlign,c=void 0===l?"left":l,u=e.condensed,d=T(e,z),m=a.useState(""),p=m[0],f=m[1];a.useEffect((function(){if("undefined"!=typeof window&&i){var e,t=new URLSearchParams(window.location.search),n="asc";t.get("sort")&&(n=null!=(e=t.get("sort"))&&e.includes("asc")?"desc":"asc"),t.set("sort",i+" "+n),f("?"+t.toString())}}),[]);var h=("center"===c?"text-center justify-center":"right"===c&&"text-right justify-end")||"text-left justify-between";return a.createElement("th",Object.assign({},d,{className:s(o,"py-3.5 px-3 text-sm font-semibold text-left",{"w-0 whitespace-nowrap":u})}),a.createElement("div",{className:"flex items-center gap-3 "+h},t,i&&a.createElement(n.Link,{href:p},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 9l4-4 4 4m0 6l-4 4-4-4"})))))},exports.TableRow=function(e){var t=e.children,n=e.className,r=void 0===n?"":n,o=e.onClick,i=void 0===o?function(){}:o,l=T(e,K),c=r.includes("bg")?"":"bg-white even:bg-gray-50";return a.createElement("tr",Object.assign({},l,{className:s(r,c,"hover:bg-gray-100"),onClick:function(e){return i(e)}}),t)},exports.ToastItem=q,exports.ToastProvider=function(e){var t=e.children,n=r.useState([]),a=n[1];function i(e){a((function(t){return t.filter((function(t){return t._id!==e}))}))}return r.createElement(C.Provider,{value:{toasts:n[0],addToast:function(e){var t=e.timeout,n=void 0===t?4e3:t,r={message:e.message,status:e.status,timeout:n};r._id=o.v4(),a((function(e){return[].concat(e,[r])})),setTimeout((function(){i(r._id)}),n)},removeToast:i}},t)},exports.Toasts=function(){var e=L();return a.createElement("div",{className:"fixed bottom-4 right-4 z-[120] flex flex-col gap-6"},e.toasts.map((function(e){return a.createElement(q,Object.assign({},e,{key:e._id}))})))},exports.addGst=g,exports.autocomplete=function(e){return R.apply(this,arguments)},exports.calcMonthlyEnhancementPrice=F,exports.calcPurchaseOptionPricing=function(e){var t=e.option,n=e.selectedEnhancements,r=e.brokerFee,a=void 0===r?0:r,o=function(e){var t=e.option;return(t.monthly_premium||0)+(e.selectedEnhancements.reduce((function(e,n){var r,a=null==(r=t.enhancements)?void 0:r.find((function(e){return e.id===n}));if(!a)return e;var o=F(a);return e?e+o:o}),0)||0)}({option:t,selectedEnhancements:n}),i=function(e){var t=e.option,n=e.brokerFee,r=void 0===n?0:n;return(t.premium||0)+(t.fsl||0)+(e.selectedEnhancements.reduce((function(e,n){var r,a=null==(r=t.enhancements)?void 0:r.find((function(e){return e.id===n}));return a?(e||0)+(a.premium||0):e}),0)||0)+r}({option:t,selectedEnhancements:n,brokerFee:a});return{monthly:o,annually:i,monthlyWithGst:I(Math.round(g(o))),annuallyWithGst:I(Math.round(g(i)))}},exports.calculateAge=D,exports.createDate=function(e){var n=f(e);if(!n)return null;try{return t.parse(n,"dd/MM/yyyy HH:mm",new Date)}catch(t){return console.error("Error parsing date: "+(null==e?void 0:e.toString())),null}},exports.fixRoundingError=I,exports.formatDate=p,exports.formatDateForTable=function(e,t){return void 0===t&&(t=!0),t?f(e):p(e)},exports.formatDateNice=function(e,t){return void 0===t&&(t=!0),(t?f:p)(e,t?"MMM d, yyyy 'at' h:mma":"MMM d, yyyy")},exports.formatDateTime=f,exports.formatMoney=w,exports.formatNumber=x,exports.getAddressData=function(e){return P.apply(this,arguments)},exports.getGst=v,exports.gstCalc=function(e){var t=e;return"string"==typeof t&&(t=parseFloat(t.replace(/[^0-9.]/g,""))),{gst:v(t=h(t)),amountInclusive:g(t),amountExclusive:y(t)}},exports.initialData=M,exports.round=h,exports.sanitiseQuoteRequestFormData=function e(t){return Array.isArray(t)?t.map((function(t){return e(t)})):null===t?"":"object"==typeof t?Object.keys(t).reduce((function(n,r){return n[r]=e(t[r]),n}),{}):t},exports.sanitiseVehicleType=b,exports.subtractGst=y,exports.useAuth=function(){var e=n.usePage().props;return k({},e.auth,{can:function(t){return e.auth.permissions.includes(t)}})},exports.useClickOutside=S,exports.useFetch=function(e){var t=e.url,n=e.method,r=void 0===n?"GET":n,o=e.params,i=void 0===o?{}:o,s=e.headers,l=void 0===s?{}:s,c=G().props.access_token,u=t;if("GET"===r){var d=new URLSearchParams(i);u=u+"?"+d.toString()}return a.useMemo((function(){return N(E().mark((function e(){var t,n,a,o,s;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(u,{method:r,headers:k({"Content-Type":"application/json",Accept:"application/json",Authorization:c?"Bearer "+c:""},l),body:Object.keys(i).length>0&&"GET"!==r?JSON.stringify(i):null});case 2:return n=(t=e.sent).ok,e.next=6,t.text();case 6:o=a=e.sent;try{o=JSON.parse(a)}catch(e){}if(s="string"==typeof o?o:void 0,n){e.next=12;break}return e.abrupt("return",{ok:n,message:s});case 12:return e.abrupt("return",{ok:n,data:"string"!=typeof o?o:void 0,message:s});case 14:case"end":return e.stop()}}),e)})))}),[c,u,i,l,r])},exports.useInertiaOptions=function(e){var t=(void 0===e?{}:e).successMessage,n=void 0===t?"":t,r=L().addToast;return{onSuccess:function(){r({message:null!=n?n:"Your request was successful.",status:"success"})},onError:function(e){Object.values(e).forEach((function(e){r({message:e,status:"error"})}))}}},exports.useLocalStorage=function(e,t){var n=r.useState((function(){if("undefined"==typeof window)return t;try{var n=window.localStorage.getItem(e);return n?JSON.parse(n):t}catch(e){return console.log(e),t}})),a=n[0],o=n[1];return[a,function(t){try{var n=t instanceof Function?t(a):t;o(n),"undefined"!=typeof window&&window.localStorage.setItem(e,JSON.stringify(n))}catch(e){console.log(e)}}]},exports.useQuoteRequestForm=A,exports.useQuoteRequestOptions=function(){return a.useContext(j)},exports.useToast=L;
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("date-fns"),n=require("@inertiajs/react"),r=require("react"),a=e(r),o=require("uuid"),i=require("@headlessui/react"),s=e(require("classnames")),l=require("lodash"),c=require("react-icons/hi2"),u=require("react-tooltip"),d=e(require("react-select")),m=require("@inertiajs/core");function p(e,n){if(!e)return"";var r=n||"dd/MM/yyyy";if(e instanceof Date)return t.format(e,r);var a=e.substring(0,10).split("-").join("/").split(".").join("/"),o=t.parse(a,"dd/MM/yyyy",new Date);if("Invalid Date"!==o.toString())return t.format(o,r);var i=new Date(e);return"Invalid Date"!==i.toString()?t.format(i,r):""}function f(e,n){if(!e)return"";var r=n||"dd/MM/yyyy HH:mm";if(e instanceof Date)return t.format(e,r);var a=e.split(",").join("").substring(0,22).split("-").join("/").split(".").join("/"),o=["AM","PM"].includes(a.slice(-2).toUpperCase()),i=("dd/MM/yyyy "+(o?"hh":"HH")+":mm"+(3===a.split(":").length?":ss":"")+" "+(o?"a":"")).trim(),s=t.parse(a,i,new Date);if("Invalid Date"!==s.toString())return t.format(s,r);var l=new Date(e);return"Invalid Date"!==l.toString()?t.format(l,r):""}function h(e){return Number(Math.round(parseFloat(e+"e2"))+"e-2")}function v(e){return h(3*e/23)}function g(e){return h(1.15*e)}function y(e){return h(e-v(e))}function w(e,t){if(void 0===t&&(t=2),null==e)return"";var n=e;return"string"==typeof e&&(n=e.replace(/[^\d.-]/g,"")),Number(n).toLocaleString("en",{minimumFractionDigits:t,maximumFractionDigits:t})}function x(e){return parseFloat(e.replace(/[^0-9.]/g,""))}function b(e){var t;switch(e){case"Camper":case"Goods Van/Truck/Utility":case"Bus":case"Motor Caravan":case"Trailer/Caravan":case"TRAILER_CARAVAN":case"TRAILER_NOT_DESIGNED_FOR_HIGHWAY_USE":case"MOBILE_MACHINE":case"GOODS_VAN_TRUCK_UTILITY":case"BUS":case"MOTOR_CARAVAN":t="motorhome";break;case"Motorcycle":case"Moped":case"ATV":case"Agricultural Machine":case"MOTORCYCLE":case"MOPED":case"TRACTOR":case"AGRICULTURAL_MACHINE":case"HIGH_SPEED_AGRICULTURAL_VEHICLE":t="motorcycle";break;case"Passenger Car/Van":case"PASSENGER_CAR_VAN":case"SPECIAL_PURPOSE_VEHICLE":case"UNKNOWN":default:t="car"}return t}function E(){E=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",i=r.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var a=Object.create((t&&t.prototype instanceof d?t:d).prototype),o=new N(r||[]);return a._invoke=function(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var s=x(i,n);if(s){if(s===u)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=c(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===u)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}(e,n,o),a}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var u={};function d(){}function m(){}function p(){}var f={};s(f,a,(function(){return this}));var h=Object.getPrototypeOf,v=h&&h(h(k([])));v&&v!==t&&n.call(v,a)&&(f=v);var g=p.prototype=d.prototype=Object.create(f);function y(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){var r;this._invoke=function(a,o){function i(){return new t((function(r,i){!function r(a,o,i,s){var l=c(e[a],e,o);if("throw"!==l.type){var u=l.arg,d=u.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,i,s)}),(function(e){r("throw",e,i,s)})):t.resolve(d).then((function(e){u.value=e,i(u)}),(function(e){return r("throw",e,i,s)}))}s(l.arg)}(a,o,r,i)}))}return r=r?r.then(i,i):i()}}function x(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var r=c(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,u;var a=r.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function k(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return m.prototype=p,s(g,"constructor",p),s(p,"constructor",m),m.displayName=s(p,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,i,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},y(w.prototype),s(w.prototype,o,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(l(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},y(g),s(g,i,"Generator"),s(g,a,(function(){return this})),s(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=k,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(s&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),_(n),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;_(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:k(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),u}},e}function _(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function N(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){_(o,r,a,i,s,"next",e)}function s(e){_(o,r,a,i,s,"throw",e)}i(void 0)}))}}function k(){return(k=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)}function T(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(a[n]=e[n]);return a}function C(e,t){r.useEffect((function(){var n=function(n){e.current&&!e.current.contains(n.target)&&t(n)};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),function(){document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}}),[e,t])}var S=r.createContext({toasts:[],addToast:function(e){},removeToast:function(e){}}),L=function(){return r.useContext(S)},M={id:void 0,status:"new",source:"phone",reference:"",client_number:"",first_name:"",last_name:"",phone:"",mobile:"",email:"",licence:"",licence_other:"",promo_code:"",club_membership_number:"",length_of_insurance:"",dob:"",secondary_first_name:"",secondary_last_name:"",secondary_licence:"",secondary_licence_other:"",secondary_dob:"",club_id:void 0,street_address:{address:"",unit:"",suburb:"",city:"",post_code:""},declaration:{had_incident:void 0,incidents:[],has_demerit_points:void 0,demerit_points:"",has_lost_licence:void 0,lost_licence_details:"",was_refused_insurance:void 0,refused_insurance_details:"",has_criminal_conviction:void 0,criminal_conviction_details:"",has_vehicle_modifications:void 0,vehicle_modifications_details:"",has_previous_insurer:void 0,previous_insurer_details:"",previous_insurer_expires_at:"",additional_details:""},vehicles:[],purchase_options:[],theme:"",broker_fee:void 0,broker_id:void 0,broker_firm_id:void 0,agent_id:void 0,agent_firm_id:void 0,staff_member_id:void 0,sent_at:void 0,sold_at:void 0,referrer_id:void 0,referrer_category_id:void 0,pricing_expires_at:void 0,follow_up_at:void 0,is_follow_up_required:!0},O=a.createContext({clear:function(){return null}}),A=function(){return a.useContext(O)},j=a.createContext({setOptions:function(){}});function R(){return(R=N(E().mark((function e(t){var n,r,a;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=encodeURIComponent(t),e.next=4,fetch("https://api.addressfinder.io/api/nz/address/autocomplete/?key=XVAKN4Q9PREJD8CUTFBW&q="+n+"&format=json&strict=2");case 4:if((r=e.sent).ok){e.next=7;break}return e.abrupt("return",[]);case 7:return e.next=9,r.json();case 9:if(!(a=e.sent).completions){e.next=12;break}return e.abrupt("return",a.completions);case 12:return e.abrupt("return",[]);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function P(){return(P=N(E().mark((function e(t){var n;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,fetch("https://api.addressfinder.io/api/nz/address/metadata/?key=XVAKN4Q9PREJD8CUTFBW&pxid="+t.pxid+"&format=json");case 3:if((n=e.sent).ok){e.next=6;break}return e.abrupt("return",null);case 6:return e.next=8,n.json();case 8:return e.abrupt("return",e.sent);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function D(e){if(!e)return 0;try{var t=new Date,n=new Date(e),r=t.getFullYear()-n.getFullYear(),a=t.getMonth()-n.getMonth();return a<0||0===a&&t.getDate()<n.getDate()?r-1:r}catch(e){return console.error(e),0}}function F(e){if(!e.premium)return 0;var t=e.premium/100/12;return e.disable_rounding?Math.round(100*t):Math.round(100*Math.ceil(t))}function I(e){return e%100==1?e-1:e%100==99?e+1:e}function G(){return n.usePage()}function U(e){var t=e.className,r=e.href,o=e.target,i=e.onClick,s=e.type,l=e.children,c=e.status,u=void 0===c?"default":c,d=e.disabled,m=void 0!==d&&d,p=e.as,f=e.small,h=(null!=t?t:"")+" "+(void 0!==f&&f?"font-bold text-sm inline-flex items-center gap-3 justify-center text-white text-center px-3 py-1 rounded min-w-[80px] transition-all hover:brightness-110":"font-black inline-flex items-center gap-3 justify-center text-white text-center px-5 py-2 rounded-md min-w-[120px] transition-all hover:brightness-110")+" "+(("primary"===u?"bg-accent":"danger"===u&&"bg-red-500")||"warning"===u&&"bg-yellow-400"||"info"===u&&"bg-blue-400"||"bg-gray-600");return i?a.createElement("button",{className:h,type:null!=s?s:"button",onClick:function(e){return i(e)},disabled:m},l):s?a.createElement("button",{className:h,type:null!=s?s:"button",disabled:m},l):r?r.includes("http")||"_blank"===o||"a"===p?a.createElement("a",{href:r,target:null!=o?o:"_self",className:h},l):a.createElement(n.Link,{href:r,className:h},l):a.createElement("p",{className:"text-red-500 text-sm"},"[Invalid button]")}function H(e){var t=e.className;return a.createElement("div",{className:(null!=t?t:"")+" flex flex-col items-start bg-white rounded-md shadow-sm border border-gray-300 p-4 md:p-6"},e.children)}function q(e){var t=e._id,n=void 0===t?"":t,r=e.message,o=e.status,s=void 0===o?"default":o,l=L().removeToast;return a.createElement(i.Transition,{show:!0,appear:!0,enter:"transition-all duration-300",enterFrom:"opacity-0 translate-y-4",enterTo:"opacity-100 translate-y-0",leave:"transition-all duration-300",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 translate-y-2"},a.createElement("div",{className:"w-full min-w-[250px] p-4 shadow flex justify-between items-center font-black rounded-md not: "+(("success"===s?"bg-accent text-white":"error"===s&&"bg-red-500 text-white")||"warning"===s&&"bg-yellow-400 text-white"||"bg-white text-primary")},a.createElement("p",null,r),a.createElement("button",{className:"",onClick:function(){l(n)},title:"Close message"},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",className:"h-6 w-6"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})))))}var B=["children"],V=["children","className"],W=["children","className","condensed"],Y=["children","className"],z=["children","className","sort","textAlign","condensed"],K=["children","className","onClick"],J=["POOR","FAIR","AVERAGE","GOOD","VERY_GOOD","AS_NEW","NEW"];function Q(e){var t=e.back,r=e.className,o=a.useState("string"==typeof t?t:void 0),i=o[0],l=o[1],u=G().props.breadcrumbs;return a.useEffect((function(){if("undefined"!=typeof window){if(!u)return;if(t&&"boolean"==typeof t){var e=u.slice(u.length-2,u.length-1);if(e&&1===e.length){var n=e[0].url;n&&l(new URL(n).pathname)}}}}),[u]),a.createElement(n.Link,{href:i||"/",className:s(r,"flex items-center justify-center text-primary hover:text-accent transition-all")},a.createElement(c.HiArrowLeft,{className:"h-5 w-5 stroke-[1.25]"}))}function X(e){var t=e.search,r=e.active,o=e.onActive,i=e.placeholder,s=e.focusSearchShortcut,l=void 0!==s&&s,u=a.useState(""),d=u[0],m=u[1],p=a.useRef(null);function f(e,r){var a;if(null==e||e.preventDefault(),"string"==typeof t){var o=t;"/"!==o[0]&&(o="/"+o);var i=new URLSearchParams(null==(a=window)?void 0:a.location.search);i.set("search",null!=r?r:d),i.set("page","1"),n.router.get(o+"?"+i.toString())}}return a.useEffect((function(){if("undefined"!=typeof window){var e=new URLSearchParams(window.location.search).get("search");e&&(m(e),o(!0))}var t=function(e){l&&"/"===e.key&&(e.preventDefault(),o(!0)),"Escape"===e.key&&o(!1)};return window.addEventListener("keydown",t),function(){window.removeEventListener("keydown",t)}}),[l]),C(p,(function(){d||o(!1)})),a.createElement("div",{ref:p,className:""},!r&&a.createElement("button",{title:"Open Search Bar",type:"button",onClick:function(){return o(!0)},className:"flex items-center justify-center rounded-full hover:text-accent p-1 hover:bg-gray-100"},a.createElement(c.HiMagnifyingGlass,{className:"h-5 w-5 stroke-[1.25]"})),r&&a.createElement("form",{onSubmit:f,className:"group flex items-center gap-2 rounded-full bg-white pr-4 pl-1 shadow transition-all focus-within:outline-none focus-within:ring-1 focus-within:ring-accent"},a.createElement("input",{type:"text",name:"search",id:"search",value:d,onChange:function(e){return m(e.currentTarget.value||"")},className:"no-focus-shadow !focus:border-0 !border-0 !bg-transparent !shadow-none !ring-opacity-0 !transition-none placeholder:text-gray-400 !py-1.5 text-sm",autoFocus:!0,placeholder:i}),d&&a.createElement("button",{type:"button",title:"Clear Search",onClick:function(){m(""),f(void 0,"")}},a.createElement(c.HiXMark,{className:"h-5 w-5"})),a.createElement("button",{type:"submit"},a.createElement(c.HiMagnifyingGlass,{className:"h-5 w-5"}))))}function $(e){var t=e.title,r=e.href,o=e.as,i=void 0===o?"Link":o,s=e.target,l=void 0===s?"_self":s,c=e.type,d=e.onClick,m=void 0===d?function(){}:d,p=e.shortcutKey,f=e.backgroundColor,h=e.textColor,v=e.actions,g=((f?"bg-"+f:"bg-white")+" "+(h?"text-"+h:"")).trim()+" rounded-full font-bold px-4 py-1.5 text-sm whitespace-nowrap hover:bg-gray-100 hover:border-gray-400 transition-colors border border-gray-300",y="action-"+t,w=p?"Ctrl + "+p:void 0,x=a.useRef(null),b=v&&v.length>0,E="relative cursor-pointer "+g,_=a.useState(!1),N=_[0],k=_[1];return C(x,(function(){return k(!1)})),a.useEffect((function(){if("undefined"!=typeof window&&p){var e=function(e){var t=e.ctrlKey||e.metaKey,a=e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLSelectElement,o=e.target instanceof Element&&e.target.closest("form");!t||a||o||e.key!==p||(e.preventDefault(),"Link"===i&&r?n.router.get(r):"a"===i&&r?window.location.href=r:m())};return window.addEventListener("keydown",e),function(){window.removeEventListener("keydown",e)}}}),[p]),a.createElement(a.Fragment,null,w&&a.createElement(u.Tooltip,{id:y,className:"z-10"}),b?a.createElement("div",{ref:x,"data-tooltip-id":y,"data-tooltip-content":w,className:E,onClick:function(){k(!N)}},t,N&&a.createElement("div",{className:"absolute top-[120%] right-[-20%] z-10"},a.createElement("div",{className:"flex flex-col gap-2 bg-white rounded-lg shadow-xl p-3"},v&&v.map((function(e,t){return e.hidden?null:a.createElement($,{key:t,title:e.title,as:e.as,href:e.href,target:e.target,onClick:e.onClick,type:"button"})}))))):"Link"===i&&r?a.createElement(n.Link,{"data-tooltip-id":y,"data-tooltip-content":w,className:g,href:r,onClick:function(){return m()}},t):"a"===i&&r?a.createElement("a",{"data-tooltip-id":y,"data-tooltip-content":w,className:g,target:l,href:r,onClick:function(){return m()}},t):a.createElement("button",{"data-tooltip-id":y,"data-tooltip-content":w,className:g,type:c,onClick:function(){return m()}},t))}function Z(e){var t=e.onClose,n=e.active,r=e.title,o=e.children,i=a.useRef(null),s=a.useRef(null);return C(i,(function(){return t(!1)})),a.useEffect((function(){var e=null==i?void 0:i.current,t=s.current;if(null==e||e.classList.toggle("active",n),e&&t){var r=null==e?void 0:e.getBoundingClientRect();t.style.setProperty("left",(null==r?void 0:r.left)+"px")}}),[n,i.current,s.current]),a.createElement("div",{ref:i,className:"static inline-block"},r,n&&a.createElement("div",{ref:s,className:"absolute children z-10 flex flex-col"},o))}function ee(e){var r,o,i,l,u,m,p=e.filter,f=a.useState(!1),h=f[0],v=f[1],g=a.useState([]),y=g[0],w=g[1],x=a.useState([]),b=x[0],E=x[1],_=y.length>0;function N(e){var t=e.currentTarget,n=t.value;w(t.checked?function(e){return[].concat(e,[n])}:y.filter((function(e){return e!==n})))}function T(e){var n=e.currentTarget,r=n.name,a=n.value;return r.includes("from")?w([a]):r.includes("to")?w(0===y.length?[t.format(t.subYears(new Date,1),"yyyy-MM-dd"),a]:[y[0],a]):w([])}function C(e){var t=e.currentTarget.value;w(t?[t]:[])}return a.useEffect((function(){if("undefined"!=typeof window){var e=new URLSearchParams(window.location.search);if("date"===p.type){var t=e.get(p.name+"[from]"),n=e.get(p.name+"[to]");t&&n&&w([t,n])}else if("greaterThan"===p.type){var r=e.getAll(p.name+"-GTE");r&&w(r)}else if("scope"===p.type){var a=e.getAll("scope"+p.name);a&&w(a)}else if("select"===p.type){var o=e.getAll(p.name+"[]");if(o){w(o);var i=p.options&&p.options.filter((function(e){return o.includes(e.value.toString())}));i&&E(i)}}else{var s=e.getAll(p.name+"[]");s&&w(s)}}}),[]),a.createElement(Z,{onClose:function(){return v(!open)},active:h,title:a.createElement("div",{onClick:function(){v(!h)},className:s("flex rounded-2xl border hover:cursor-pointer hover:border-accent bg-gray-600 px-2 py-1 items-center justify-between shrink-0 gap-2 text-xs text-white hover:bg-accent transition-colors",{"!bg-accent border-accent":_})},a.createElement("p",{className:"whitespace-nowrap"},p.label),a.createElement(c.HiChevronDown,null))},a.createElement("form",{className:"mt-2 flex max-h-[350px] min-w-[200px] max-w-[260px] flex-col gap-2 rounded-md border border-gray-300 bg-white shadow-lg "+(p.type&&"select"===p.type?"":"overflow-y-scroll"),onSubmit:function(e){e.preventDefault();var r=new URLSearchParams(window.location.search);if(r.set("page","1"),"date"===p.type){var a=y[0],o=y[1];r.set(p.name+"[from]",null!=a?a:t.format(new Date,"yyyy-MM-dd")),r.set(p.name+"[to]",null!=o?o:t.format(new Date,"yyyy-MM-dd"))}else"greaterThan"===p.type?(r.delete(p.name+"-GTE"),y.length>0&&r.set(p.name+"-GTE",y[0])):"scope"===p.type?(r.delete(""+p.name),y.length>0&&r.set("scope"+p.name,y[0])):(r.delete(p.name+"[]"),y.forEach((function(e){r.append(p.name+"[]",e)})));n.router.get(window.location.pathname+"?"+r.toString())}},a.createElement("div",{className:"flex flex-col items-start gap-1 p-4"},(!p.type||"options"===p.type)&&(null==(r=p.options)?void 0:r.map((function(e,t){return a.createElement("div",{className:"checkbox text-sm ",key:e.label+"-"+t},a.createElement("input",{type:"checkbox",name:p.name,id:e.label,value:e.value.toString(),checked:y.includes(e.value.toString()),onChange:N}),a.createElement("label",{className:"leading-tight",htmlFor:e.label},e.label))}))),"greaterThan"===p.type&&p.options&&a.createElement("label",{className:"mb-2 w-full"},a.createElement("div",{className:"text-sm"},"Greater than or equal to"),a.createElement("select",{name:p.name,id:p.label,value:y[0],onChange:C,className:"!p-2 text-sm w-full"},a.createElement("option",{value:""},"Select option"),null==(o=p.options)?void 0:o.map((function(e){return a.createElement("option",{key:e.value,value:e.value},e.label)})))),"scope"===p.type&&p.options&&a.createElement("label",{className:"mb-2 w-full"},a.createElement("select",{name:p.name,id:p.label,value:y[0],onChange:C,className:"!p-2 text-sm w-full"},a.createElement("option",{value:""},"Select option"),null==(i=p.options)?void 0:i.map((function(e){return a.createElement("option",{key:e.value,value:e.value},e.label)})))),"date"===p.type&&a.createElement("div",{className:"mb-2 flex flex-col gap-4 w-full"},a.createElement("label",{className:"text-xs w-full"},"From",a.createElement("input",{type:"date",name:p.name+"[from]",id:p.name+"[from]",onChange:T,value:null!=(l=y[0])?l:"",className:"!p-2 text-sm w-full"})),a.createElement("label",{className:"text-xs w-full"},"To",a.createElement("input",{type:"date",name:p.name+"[to]",id:p.name+"[to]",onChange:T,value:null!=(u=y[1])?u:"",className:"!p-2 text-sm w-full"}))),"select"===p.type&&p.options&&a.createElement("div",{className:"w-full"},a.createElement(d,{isMulti:!0,options:p.options,className:"basic-multi-select text-xs w-52 !transition-none",classNamePrefix:"select",onChange:function(e){E(e);var t=e.map((function(e){return e.value.toString()}));w(t.length>0?t:[])},components:{ClearIndicator:function(){return null}},value:b,theme:function(e){return k({},e,{colors:k({},e.colors,{primary25:"rgb(111, 199, 182)",primary:"rgb(111, 199, 182)"})})}})),"text"===p.type&&a.createElement("div",{className:"w-full"},a.createElement("input",{type:"text",name:p.name,placeholder:p.label,value:null!=(m=y[0])?m:"",onChange:function(e){var t=e.currentTarget.value;w(t?[t]:[])},className:"!p-2 text-sm w-full"}))),a.createElement("div",{className:"bg-gray-100 border-t border-gray-200 flex items-center gap-2 p-4 bottom-0 sticky"},a.createElement(U,{type:"button",className:"!min-w-[0px] flex-grow !px-2 text-sm !transition-none",onClick:function(){var e=new URLSearchParams(window.location.search);e.set("page","1"),"date"===p.type?(e.delete(p.name+"[from]"),e.delete(p.name+"[to]")):e.delete("greaterThan"===p.type?p.name+"-GTE":"scope"===p.type?"scope"+p.name:p.name+"[]"),n.router.get(window.location.pathname+"?"+e.toString())},small:!0},"Clear"),a.createElement(U,{type:"submit",status:"primary",className:"!min-w-[0px] flex-grow !px-2 text-sm !transition-none",small:!0},"Apply"))))}function te(e){var t=e.title,n=e.search,r=e.className,o=void 0===r?"":r,i=e.innerClassName,l=void 0===i?"":i,u=e.back,d=void 0===u||u,p=e.actions,f=void 0===p?[]:p,h=e.filterOptions,v=void 0===h?[]:h,g=e.focusSearchShortcut,y=void 0!==g&&g,w=e.children,x=a.useState(!1),b=x[0],E=x[1],_=a.useRef(null),N=a.useState(!1),k=N[0],T=N[1],C=[];a.Children.forEach(w,(function(e){a.isValidElement(e)&&e.type===te.Action&&C.push(e)})),a.useEffect((function(){var e=_.current;if(e){var t=function(){var t=e.querySelector(".active");if(t){var n=t.querySelector(".children");if(n){var r=t.getBoundingClientRect(),a=n.getBoundingClientRect(),o=e.getBoundingClientRect();n.style.visibility=a.left<=o.left-50||a.left>=o.right-50?"hidden":"visible",n.style.left=r.left+"px"}}},n=function(t){var n=e.getBoundingClientRect();T(t.clientX>n.left&&t.clientX<n.right&&t.clientY>n.top&&t.clientY<n.bottom)};return e.addEventListener("scroll",t),document.addEventListener("mousemove",n),function(){e.removeEventListener("scroll",t),document.removeEventListener("mousemove",n)}}}),[]),a.useEffect((function(){var e=function(e){var t;k&&(e.preventDefault(),null==(t=_.current)||t.scrollBy({left:e.deltaY,behavior:"auto"}))};return document.addEventListener("wheel",e,{passive:!1}),function(){document.removeEventListener("wheel",e)}}),[k]);var S=a.useState(!1),L=S[0],M=S[1],O=a.useCallback((function(){var e=_.current;if(e){var t=e.getBoundingClientRect();M(e.scrollWidth>t.width+11)}}),[_.current]);a.useEffect((function(){return O(),window.addEventListener("resize",O),function(){window.removeEventListener("resize",O)}}),[O]);var A=a.useMemo((function(){return f.filter((function(e){return!e.hidden}))}),[f]);return a.createElement("section",{className:s("col-span-full flex items-center gap-2 max-w-full rounded-lg bg-white p-2 shadow",o)},d&&a.createElement(Q,{back:d,className:"bg-primary-100 h-[60px] w-[60px] rounded"}),a.createElement("div",{className:s("w-full grid grid-cols-[auto_1fr_auto_auto] h-[60px] rounded bg-primary-100 p-3 gap-4",l)},a.createElement("button",{type:"button",disabled:!n,onClick:function(){return E(!0)},className:s("mr-auto flex items-center gap-4 transition-colors pr-6 pl-1 disabled:opacity-100 text-primary",{"hover:text-accent":n&&!b})},n&&a.createElement(X,{search:n,active:b,onActive:E,placeholder:"Search "+t+"...",focusSearchShortcut:y}),!b&&a.createElement("h1",{className:"text-base text-primary font-black"},t)),a.createElement("div",{className:"flex items-center ml-auto gap-2 h-full min-w-0 max-w-full"},v.length>0&&a.createElement(a.Fragment,null,a.createElement("button",{onClick:function(){m.router.get(""+window.location.pathname)},className:"p-1.5 hover:text-red-500"},a.createElement(c.HiXMark,{className:"w-5 h-5 stroke-[1.25]"})),L&&a.createElement(c.HiChevronLeft,{onClick:function(){var e;null==(e=_.current)||e.scrollBy({left:-100,behavior:"auto"}),O()},className:"w-5 h-5 text-gray-400 stroke-[1.25]"}),a.createElement("div",{ref:_,className:"flex items-center h-full w-full gap-3 overflow-x-scroll hide-scroll"},v.map((function(e){return a.createElement(ee,{key:e.name,filter:e})}))),L&&a.createElement(c.HiChevronRight,{onClick:function(){var e;null==(e=_.current)||e.scrollBy({left:100,behavior:"auto"}),O()},className:"w-5 h-5 text-gray-400 stroke-[1.25]"}))),A.length>0&&a.createElement("div",{className:"flex items-center gap-3 bg-primary-100"},v.length>0&&a.createElement("div",{className:"w-[1px] h-full bg-gray-300"}),a.createElement("nav",{className:"flex items-center gap-2"},A.map((function(e){return a.createElement($,Object.assign({key:e.title+"-"+e.as+"-"+e.href},e))})))),C&&a.createElement("div",{className:"flex items-center gap-3 bg-gray-100"},C)))}te.Action=function(e){return a.createElement("div",null,e.children)},exports.Button=U,exports.Card=H,exports.DateOfBirthField=function(e){var t=e.name,n=void 0===t?"dob":t,r=e.id,o=void 0===r?"dob":r,i=e.onChange,s=e.value,c=e.maxYear,u=void 0===c?0:c,d=e.showAge,m=void 0!==d&&d,p=e.isRequired,f=void 0===p||p,h=[].concat(Array.from(Array(31).keys())).map((function(e){return l.padStart(""+(e+1),2,"0")})),v=["January","February","March","April","May","June","July","August","September","October","November","December"],g=[].concat(Array.from(Array(12).keys())).map((function(e){return{title:v[e],value:l.padStart(""+(e+1),2,"0")}})),y=[].concat(Array.from(Array(100).keys())).map((function(e){return u?u-e:(new Date).getFullYear()-e}));function w(e){var t=e.currentTarget,n=t.name,r=t.value,a=n.includes("year")?r:b,o=n.includes("month")?r:E,s=n.includes("day")?r:_;i(a+"-"+o+"-"+s)}var x=s?s.split("-"):["","",""],b=x[0],E=x[1],_=x[2],N=b&&E&&_&&!isNaN(Date.parse(b+"-"+E+"-"+_)),k={backgroundPosition:"top 10px right 3px, center right 10px"},T={backgroundPosition:"right 0.5rem center",paddingRight:"1.5rem"};return a.createElement("span",{className:"flex flex-col gap-2"},a.createElement("span",{className:"flex w-full border border-gray-300 rounded-lg bg-white"},a.createElement("select",{name:n+"_day",id:o+"_day",value:_,className:"flex-grow focus:outline-none border-0 !mr-[3px] lg:pl-4 xl:pl-2",onChange:w,required:f,style:f?k:T},a.createElement("option",{value:""},"Day"),h.map((function(e){return a.createElement("option",{key:e,value:e},e)}))),a.createElement("select",{name:n+"_month",id:o+"_month",value:E,className:"flex-grow focus:outline-none border-0 !mr-[3px] lg:pl-4 xl:pl-2",onChange:w,required:f,style:f?k:T},a.createElement("option",{value:""},"Month"),g.map((function(e){return a.createElement("option",{key:e.value,value:e.value},e.title)}))),a.createElement("select",{name:n+"_year",id:o+"_year",value:b,className:"flex-grow focus:outline-none border-0 !mr-[3px] lg:pl-4 xl:pl-2",onChange:w,required:f,style:f?k:T},a.createElement("option",{value:""},"Year"),y.map((function(e){return a.createElement("option",{key:e,value:e},e)})))),m&&s&&N&&a.createElement("span",{className:"font-bold"},"Age: ",D(s)," years"))},exports.ErrorList=function(e){var t=e.heading,n=void 0===t?"There was an error with your submission.":t,r=e.errors,o=void 0===r?{}:r,i=e.renderKeys,s=void 0!==i&&i,l=e.className,c=void 0===l?"":l;return 0===Object.values(o).length?a.createElement(a.Fragment,null):a.createElement("aside",{className:c+" col-span-full"},a.createElement(H,{className:"border border-red-500 !bg-red-50"},a.createElement("h2",{className:"font-black text-red-500 mb-2"},n),a.createElement("ul",{className:"space-y-2 list-disc ml-4"},Object.entries(o).map((function(e){var t=e[0],n=e[1];return a.createElement("li",{className:"font-bold text-red-500",key:t},s&&a.createElement("strong",null,t,": "),n)})))))},exports.FormTester=function(e){var t=e.populatePurchaseOptions,n=void 0!==t&&t,r=A().form,o=a.useState([]),i=o[0],s=o[1],l=a.useState(!1),c=l[0],u=l[1];function d(){null==r||r.setData((function(e){return k({},e,{first_name:"TEST",last_name:"TEST",email:"dev@sual.co.nz",phone:"021 234 5678",mobile:"021 234 5678",dob:"1990-01-01",licence:"Other",licence_other:"Test",club_id:50,club_membership_number:"12345",street_address:{address:"123 Street Name",unit:"Level 1",suburb:"Suburb",city:"Auckland",post_code:"1234"},promo_code:"TEST",declaration:{had_incident:!0,incidents:[{description:"Lorem ipsum dolor sit amet.",month:"January",year:"2020"}],has_demerit_points:!0,demerit_points:"1-24",has_lost_licence:!0,lost_licence_details:"Lorem ipsum dolor sit amet.",was_refused_insurance:!0,refused_insurance_details:"Lorem ipsum dolor sit amet.",has_criminal_conviction:!0,criminal_conviction_details:"Lorem ipsum dolor sit amet.",has_vehicle_modifications:!0,vehicle_modifications_details:"Lorem ipsum dolor sit amet.",has_previous_insurer:!0,previous_insurer_details:"AA",previous_insurer_expires_at:"2020-01-01",additional_details:"I am a robot, beep boop. Please ignore this submission."},vehicles:[{make:"Tesla",model:"Cybertruck",year:"2023",registration:"ELMUSK",vehicle_type:"car",product:"star-enthusiast-prestige-everyday-plus",value:1e5,is_heavy:!1,usage:"Childrens car",storage_location:"Carport",has_financially_interested_party:!0,financially_interested_party_detail:"MTA",owned_duration:"Less than 12 months",main_driver:"TEST TEST",drivers:[{first_name:"X Æ",last_name:"A-12",dob:"2000-05-04",licence:"Other",licence_other:"None",relationship:"Child",key:"driver-test-key"}],key:"vehicle-test-key"}],purchase_options:n?[{premium_type:"annual",level_of_insurance_id:12,authorised_drivers:"TEST",excess_details:"TEST",terms:"TEST",description:"This is a test purchase option",premium:1e5,monthly_premium:8500,show_monthly:!0,fsl:100,sort_order:1,enhancements:[{name:"Test enhancement",premium:2500,disable_rounding:!1,description:"Test enhancement",auto_select:!0,key:"enhancement-test-key-1"},{name:"Test enhancement",premium:5e3,disable_rounding:!1,description:"Test enhancement",auto_select:!1,key:"enhancement-test-key-2"}],key:"purchase-option-test-key-annual"},{premium_type:"total-due",level_of_insurance_id:13,authorised_drivers:"TEST",excess_details:"TEST",terms:"TEST",description:"This is a test purchase option",premium:1e5,show_monthly:!1,fsl:100,sort_order:2,enhancements:[{name:"Test enhancement",premium:2500,disable_rounding:!1,description:"Test enhancement",auto_select:!0,key:"enhancement-test-key-3"},{name:"Test enhancement",premium:5e3,disable_rounding:!1,description:"Test enhancement",auto_select:!1,key:"enhancement-test-key-4"}],key:"purchase-option-test-key-total-due"}]:[]})}))}function m(e){if("Escape"===e.key)return s([]);s((function(t){return[].concat(t,[e.key])}))}return a.useEffect((function(){"debug"===i.join("")&&d()}),[i]),a.useEffect((function(){if("undefined"!=typeof window)return(window.location.href.includes("dev")||window.location.href.includes("localhost")||window.location.href.includes("test")||window.location.href.includes("local"))&&u(!0),window.addEventListener("keydown",(function(e){return m(e)})),function(){window.removeEventListener("keydown",(function(e){return m(e)}))}}),[]),c?a.createElement(U,{onClick:d,type:"button",status:"primary",className:"fixed bottom-4 right-4"},"Populate data"):a.createElement(a.Fragment,null)},exports.Modal=function(e){var t=e.children,n=e.isActive,o=e.onClose,s=e.title,l=e.width,c=void 0===l?"":l,u=e.className,d=void 0===u?"":u;return a.createElement(i.Transition.Root,{show:void 0!==n&&n,as:r.Fragment},a.createElement(i.Dialog,{as:"div",className:"fixed z-[110] inset-0 overflow-y-auto",onClose:o},a.createElement("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"},a.createElement(i.Transition.Child,{as:r.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0"},a.createElement(i.Dialog.Overlay,{className:"fixed inset-0 bg-gray-500/75 transition-opacity"})),a.createElement(i.Transition.Child,{as:r.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"},a.createElement("div",{className:d+" w-full align-start inline-block bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-7xl sm:p-6 "+c},a.createElement("div",{className:"flex gap-4 mb-4 text-primary "+(s?"border-b-2 border-primary pb-4":"")},s&&a.createElement("h3",{className:"font-black text-lg"},s),a.createElement("button",{type:"button",onClick:o,className:"ml-auto transition-all hover:opacity-50"},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})))),a.createElement("div",null,t))))))},exports.MoneyField=function(e){var t=e.value,n=e.onChange,r=e.name,o=void 0===r?"value":r,i=e.id,s=void 0===i?"value":i,l=e.className,c=void 0===l?"":l,u=e.required,d=void 0!==u&&u,m=w(void 0===t?0:t,0);return a.createElement("div",{className:c+" flex items-center gap-2 pl-4 rounded-md border border-gray-300 transition-all focus-within:border-accent focus-within:outline-none focus-within:ring focus-within:ring-accent focus-within:ring-opacity-50"},a.createElement("span",{className:"font-bold pr-2"},"$"),a.createElement("input",{type:"text",name:o,id:s,value:m,onChange:function(e){var t=0;e.currentTarget.value&&(t=x(e.currentTarget.value),isNaN(t)&&(t=0)),n(t)},className:"w-full !focus:outline-none !focus:ring-0 !focus:ring-transparent !focus:ring-opacity-0 !ring-0 !border-0 !transition-none !rounded-l-none",required:d}))},exports.PageHeader=te,exports.Pagination=function(e){var t=e.meta,r=e.className,o=e.showPerPageSelector,i=void 0!==o&&o,s=e.defaultValue,l=t.current_page,c=t.per_page,u=null!=s?s:c,d=Math.ceil(t.total/c),m=function(){if("undefined"!=typeof window){var e=new URLSearchParams(window.location.search);return e.set("page",String(l+1)),"?"+e.toString()}return""}(),p=function(){if("undefined"!=typeof window){var e=new URLSearchParams(window.location.search);return e.set("page",String(l-1)),"?"+e.toString()}return""}();return a.createElement("div",{className:""+(null!=r?r:"")},a.createElement("nav",{className:"font-bold flex justify-between items-center gap-6"},a.createElement(n.Link,{href:p,className:"flex items-center gap-2",disabled:1===l},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 19l-7-7m0 0l7-7m-7 7h18"})),"Prev"),a.createElement("div",{className:"flex gap-6 items-center"},a.createElement("p",null,"Page ",l," of ",d),i?a.createElement("select",{value:u,onChange:function(e){var t,n=new URLSearchParams(null==(t=window)?void 0:t.location.search);n.set("limit",e.currentTarget.value),n.set("page","1"),window.location.href="?"+n.toString()}},a.createElement("option",{value:"10"},"10 per page"),a.createElement("option",{value:"25"},"25 per page"),a.createElement("option",{value:"50"},"50 per page"),a.createElement("option",{value:"100"},"100 per page"),a.createElement("option",{value:"250"},"250 per page"),a.createElement("option",{value:"500"},"500 per page")):""),a.createElement(n.Link,{href:m,className:"flex items-center gap-2",disabled:l===d},"Next",a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14 5l7 7m0 0l-7 7m7-7H3"})))))},exports.QuoteRequestFormContext=O,exports.QuoteRequestFormProvider=function(e){var t=e.children,r=n.useForm(k({},M));return a.createElement(O.Provider,{value:{form:r,handleChange:function(e){var t=e.currentTarget.name,n=e.currentTarget.value;if("checkbox"!==e.currentTarget.type&&"radio"!==e.currentTarget.type||(n="1"===e.currentTarget.value),t.includes(".")){var a=t.split(".");return 2===a.length?r.setData((function(e){var t,r;return k({},e,((r={})[a[0]]=k({},e[a[0]],((t={})[a[1]]=n,t)),r))})):void 0}return r.setData((function(e){var r;return k({},e,((r={})[t]=n,r))}))},clear:function(){r.setData(k({},M))}}},t)},exports.QuoteRequestOptionsProvider=function(e){var t=e.children,n=a.useState();return a.createElement(j.Provider,{value:{options:n[0],setOptions:n[1]}},t)},exports.RegistrationSearchField=function(e){var t=e.name,n=void 0===t?"registration_search":t,r=e.initialRegistrationValue,o=e.onVehicleDataFound,i=e.apiUrl,l=void 0===i?"/api/rego-search":i,c=e.showOdometerReadingField,u=void 0!==c&&c,d=e.showConditionField,m=void 0!==d&&d,p=e.onChange,f=e.outerClassName,h=e.odoInputClassName,v=e.conditionSelectClassName,g=e.regoInputClassName,y=e.searchBtnClassName,w=a.useState(void 0===r?"":r),x=w[0],_=w[1],T=a.useState(""),C=T[0],S=T[1],M=a.useState("GOOD"),O=M[0],A=M[1],j=a.useState("idle"),R=j[0],P=j[1],D=L().addToast;function F(e){var t;e.currentTarget.name===n&&_((null==(t=e.currentTarget.value)?void 0:t.toUpperCase())||""),"odo_search"===e.currentTarget.name&&S(e.currentTarget.value),"condition_search"===e.currentTarget.name&&A(e.currentTarget.value),p&&p({registration:e.currentTarget.value.toUpperCase()})}function I(e){"Enter"===e.key&&G()}function G(){return U.apply(this,arguments)}function U(){return(U=N(E().mark((function e(){var t,n,r,a,i,s,c,u,d,m;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return P("processing"),t=new URLSearchParams({registration:x,odometerReading:C,condition:O}).toString(),e.next=5,fetch(l+"?"+t,{headers:{"Content-Type":"application/json"}});case 5:if((n=e.sent).ok){e.next=10;break}return D({message:"There was an error with the provided registration.",status:"error",timeout:3e3}),P("error"),e.abrupt("return");case 10:return e.next=12,n.json();case 12:if(a=(r=e.sent).data,r.ok&&a){e.next=19;break}return D({message:"Failed to find vehicle, please complete manually.",status:"error",timeout:3e3}),P("error"),e.abrupt("return");case 19:s=(i=a.data.vehicle).make,c=i.model,u=i["year-of-manufacture"],d=i["gross-vehicle-mass"]?parseInt(i["gross-vehicle-mass"].replaceAll(",","")):0,m=i["vehicle-type"],s&&c&&u&&m||(D({message:"We couldn't find all of your data, please complete manually.",status:"error",timeout:3e3}),P("error")),o(k({},a,{make:s||"",model:c||"",year:u||"",vehicle_type:m?b(m):"car",is_heavy:d&&d>3500||!1})),P("success");case 28:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return a.createElement("div",{className:"w-full flex flex-col"},a.createElement("div",{className:s(f,"w-full flex flex-wrap gap-3 bg-gray-100 rounded-md p-3")},u||m&&a.createElement("div",{className:"w-full grid grid-cols-2 gap-3"},u&&a.createElement("label",null,"Approx. km travelled",a.createElement("input",{onKeyDown:I,type:"number",name:"odo_search",id:"odo_search",value:C,onChange:F,className:s(h,"transition-all",{"pointer-events-none opacity-50":"processing"===R}),disabled:"processing"===R})),m&&a.createElement("label",null,"Vehicle condition",a.createElement("select",{name:"condition_search",id:"condition_search",value:O,onChange:F,className:s(v,"transition-all",{"pointer-events-none opacity-50":"processing"===R}),disabled:"processing"===R},J.map((function(e){return a.createElement("option",{key:e},e)}))))),a.createElement("input",{onKeyDown:I,placeholder:"Search for your rego",type:"text",name:n,id:n,value:x,onChange:F,className:s(g,"flex-grow transition-all",{"pointer-events-none opacity-50":"processing"===R}),disabled:"processing"===R}),a.createElement("button",{title:"Search",type:"button",onClick:G,disabled:"processing"===R,className:s(y,"bg-accent px-4 py-3 rounded-md transition-all")},a.createElement("span",{className:"sr-only"},"Search"),a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})))))},exports.SimplePagination=function(e){var t=e.meta,r=e.className,o=e.showPerPageSelector,i=void 0!==o&&o,s=e.defaultValue,l=t.current_page,c=t.per_page,u=null!=s?s:c,d=t.to-t.from+1===c,m=function(){if("undefined"!=typeof window){var e=new URLSearchParams(window.location.search);return e.set("page",String(l+1)),"?"+e.toString()}return""}(),p=function(){if("undefined"!=typeof window){var e=new URLSearchParams(window.location.search);return e.set("page",String(l-1)),"?"+e.toString()}return""}();return a.createElement("div",{className:""+(null!=r?r:"")},a.createElement("nav",{className:"font-bold flex justify-between items-center gap-6"},a.createElement(n.Link,{href:p,className:"flex items-center gap-2",disabled:1===l},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 19l-7-7m0 0l7-7m-7 7h18"})),"Prev"),a.createElement("div",{className:"flex gap-6 items-center"},a.createElement("p",null,"Page ",l),i?a.createElement("select",{value:u,onChange:function(e){var t,n=new URLSearchParams(null==(t=window)?void 0:t.location.search);n.set("limit",e.currentTarget.value),n.set("page","1"),window.location.href="?"+n.toString()}},a.createElement("option",{value:"10"},"10 per page"),a.createElement("option",{value:"25"},"25 per page"),a.createElement("option",{value:"50"},"50 per page"),a.createElement("option",{value:"100"},"100 per page"),a.createElement("option",{value:"250"},"250 per page"),a.createElement("option",{value:"500"},"500 per page")):""),a.createElement(n.Link,{href:m,className:"flex items-center gap-2",disabled:!d},"Next",a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14 5l7 7m0 0l-7 7m7-7H3"})))))},exports.Table=function(e){var t=e.children,n=T(e,B);return a.createElement("div",{className:"-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8 text-sm"},a.createElement("div",{className:"inline-block min-w-full py-2 align-middle md:px-6 lg:px-8"},a.createElement("div",{className:"overflow-hidden shadow ring-1 ring-gray-300 ring-opacity-5 md:rounded-lg"},a.createElement("table",Object.assign({},n,{className:"min-w-full divide-y divide-gray-300"}),t))))},exports.TableActions=function(e){var t=e.className;return a.createElement("div",{className:(void 0===t?"":t)+" flex gap-4 justify-end items-center"},e.children)},exports.TableBody=function(e){var t=e.children,n=e.className,r=T(e,V);return a.createElement("tbody",Object.assign({},r,{className:s(n,"divide-y divide-gray-200 bg-white")}),t)},exports.TableCell=function(e){var t=e.children,n=e.className,r=e.condensed,o=T(e,W);return a.createElement("td",Object.assign({},o,{className:s(n,"px-3 py-3 text-sm text-gray-500",{"w-0 whitespace-nowrap":r})}),t)},exports.TableHead=function(e){var t=e.children,n=e.className,r=T(e,Y);return a.createElement("thead",Object.assign({},r,{className:s(n,"px-3 py-4 text-sm text-white bg-gray-600")}),t)},exports.TableHeader=function(e){var t=e.children,r=e.className,o=void 0===r?"":r,i=e.sort,l=e.textAlign,c=void 0===l?"left":l,u=e.condensed,d=T(e,z),m=a.useState(""),p=m[0],f=m[1];a.useEffect((function(){if("undefined"!=typeof window&&i){var e,t=new URLSearchParams(window.location.search),n="asc";t.get("sort")&&(n=null!=(e=t.get("sort"))&&e.includes("asc")?"desc":"asc"),t.set("sort",i+" "+n),f("?"+t.toString())}}),[]);var h=("center"===c?"text-center justify-center":"right"===c&&"text-right justify-end")||"text-left justify-between";return a.createElement("th",Object.assign({},d,{className:s(o,"py-3.5 px-3 text-sm font-semibold text-left",{"w-0 whitespace-nowrap":u})}),a.createElement("div",{className:"flex items-center gap-3 "+h},t,i&&a.createElement(n.Link,{href:p},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 9l4-4 4 4m0 6l-4 4-4-4"})))))},exports.TableRow=function(e){var t=e.children,n=e.className,r=void 0===n?"":n,o=e.onClick,i=void 0===o?function(){}:o,l=T(e,K),c=r.includes("bg")?"":"bg-white even:bg-gray-50";return a.createElement("tr",Object.assign({},l,{className:s(r,c,"hover:bg-gray-100"),onClick:function(e){return i(e)}}),t)},exports.ToastItem=q,exports.ToastProvider=function(e){var t=e.children,n=r.useState([]),a=n[1];function i(e){a((function(t){return t.filter((function(t){return t._id!==e}))}))}return r.createElement(S.Provider,{value:{toasts:n[0],addToast:function(e){var t=e.timeout,n=void 0===t?4e3:t,r={message:e.message,status:e.status,timeout:n};r._id=o.v4(),a((function(e){return[].concat(e,[r])})),setTimeout((function(){i(r._id)}),n)},removeToast:i}},t)},exports.Toasts=function(){var e=L();return a.createElement("div",{className:"fixed bottom-4 right-4 z-[120] flex flex-col gap-6"},e.toasts.map((function(e){return a.createElement(q,Object.assign({},e,{key:e._id}))})))},exports.addGst=g,exports.autocomplete=function(e){return R.apply(this,arguments)},exports.calcMonthlyEnhancementPrice=F,exports.calcPurchaseOptionPricing=function(e){var t=e.option,n=e.selectedEnhancements,r=e.brokerFee,a=void 0===r?0:r,o=function(e){var t=e.option;return(t.monthly_premium||0)+(e.selectedEnhancements.reduce((function(e,n){var r,a=null==(r=t.enhancements)?void 0:r.find((function(e){return e.id===n}));if(!a)return e;var o=F(a);return e?e+o:o}),0)||0)}({option:t,selectedEnhancements:n}),i=function(e){var t=e.option,n=e.brokerFee,r=void 0===n?0:n;return(t.premium||0)+(t.fsl||0)+(e.selectedEnhancements.reduce((function(e,n){var r,a=null==(r=t.enhancements)?void 0:r.find((function(e){return e.id===n}));return a?(e||0)+(a.premium||0):e}),0)||0)+r}({option:t,selectedEnhancements:n,brokerFee:a});return{monthly:o,annually:i,monthlyWithGst:I(Math.round(g(o))),annuallyWithGst:I(Math.round(g(i)))}},exports.calculateAge=D,exports.createDate=function(e){var n=f(e);if(!n)return null;try{return t.parse(n,"dd/MM/yyyy HH:mm",new Date)}catch(t){return console.error("Error parsing date: "+(null==e?void 0:e.toString())),null}},exports.fixRoundingError=I,exports.formatDate=p,exports.formatDateForTable=function(e,t){return void 0===t&&(t=!0),t?f(e):p(e)},exports.formatDateNice=function(e,t){return void 0===t&&(t=!0),(t?f:p)(e,t?"MMM d, yyyy 'at' h:mma":"MMM d, yyyy")},exports.formatDateTime=f,exports.formatMoney=w,exports.formatNumber=x,exports.getAddressData=function(e){return P.apply(this,arguments)},exports.getGst=v,exports.gstCalc=function(e){var t=e;return"string"==typeof t&&(t=parseFloat(t.replace(/[^0-9.]/g,""))),{gst:v(t=h(t)),amountInclusive:g(t),amountExclusive:y(t)}},exports.initialData=M,exports.round=h,exports.sanitiseQuoteRequestFormData=function e(t){return Array.isArray(t)?t.map((function(t){return e(t)})):null===t?"":"object"==typeof t?Object.keys(t).reduce((function(n,r){return n[r]=e(t[r]),n}),{}):t},exports.sanitiseVehicleType=b,exports.subtractGst=y,exports.useAuth=function(){var e=n.usePage().props;return k({},e.auth,{can:function(t){return e.auth.permissions.includes(t)}})},exports.useClickOutside=C,exports.useFetch=function(e){var t=e.url,n=e.method,r=void 0===n?"GET":n,o=e.params,i=void 0===o?{}:o,s=e.headers,l=void 0===s?{}:s,c=G().props.access_token,u=t;if("GET"===r){var d=new URLSearchParams(i);u=u+"?"+d.toString()}return a.useMemo((function(){return N(E().mark((function e(){var t,n,a,o,s;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(u,{method:r,headers:k({"Content-Type":"application/json",Accept:"application/json",Authorization:c?"Bearer "+c:""},l),body:Object.keys(i).length>0&&"GET"!==r?JSON.stringify(i):null});case 2:return n=(t=e.sent).ok,e.next=6,t.text();case 6:o=a=e.sent;try{o=JSON.parse(a)}catch(e){}if(s="string"==typeof o?o:void 0,n){e.next=12;break}return e.abrupt("return",{ok:n,message:s});case 12:return e.abrupt("return",{ok:n,data:"string"!=typeof o?o:void 0,message:s});case 14:case"end":return e.stop()}}),e)})))}),[c,u,i,l,r])},exports.useInertiaOptions=function(e){var t=(void 0===e?{}:e).successMessage,n=void 0===t?"":t,r=L().addToast;return{onSuccess:function(){r({message:null!=n?n:"Your request was successful.",status:"success"})},onError:function(e){Object.values(e).forEach((function(e){r({message:e,status:"error"})}))}}},exports.useLocalStorage=function(e,t){var n=r.useState((function(){if("undefined"==typeof window)return t;try{var n=window.localStorage.getItem(e);return n?JSON.parse(n):t}catch(e){return console.log(e),t}})),a=n[0],o=n[1];return[a,function(t){try{var n=t instanceof Function?t(a):t;o(n),"undefined"!=typeof window&&window.localStorage.setItem(e,JSON.stringify(n))}catch(e){console.log(e)}}]},exports.useQuoteRequestForm=A,exports.useQuoteRequestOptions=function(){return a.useContext(j)},exports.useToast=L;
2
2
  //# sourceMappingURL=sdk.cjs.production.min.js.map