Scripts/resources/[phone]/npwd/dist/html/8466.js
2024-12-29 20:49:12 +01:00

2 lines
7.6 KiB
JavaScript

/*! For license information please see 8466.js.LICENSE.txt */
"use strict";(self.webpackChunk_npwd_nui=self.webpackChunk_npwd_nui||[]).push([[8466,5472,7619],{48466:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),u=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),u(n(20612),t),u(n(33723),t),u(n(98398),t),u(n(7339),t),u(n(88327),t),u(n(38006),t)},7339:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.NuiContext=void 0;var r=n(53182);t.NuiContext=r.createContext(null)},33723:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.useNuiCallback=void 0;var r=n(53182),u=n(7339),o=n(38006),i=n(20612);t.useNuiCallback=function(e,t,n,c){var a=r.useContext(u.NuiContext),s=a.sendAbortable,l=a.callbackTimeout,f=r.useRef(),v=r.useRef(),d=r.useRef(o.eventNameFactory(e,t)),p=r.useRef(t),b=r.useRef(e),y=r.useState(!1),h=y[0],m=y[1],_=r.useState(!1),w=_[0],O=_[1],g=r.useState(!1),j=g[0],N=g[1],E=r.useState(null),k=E[0],C=E[1],P=r.useState(null),x=P[0],S=P[1],R=r.useCallback((function(e){j&&(v.current&&clearTimeout(v.current),h||(S(e),C(null),N(!1),null==n||n(e)))}),[n,h,j]),T=r.useCallback((function(e){v.current&&clearTimeout(v.current),C(e),S(null),N(!1),null==c||c(e)}),[c]);return i.useNuiEvent(b.current,p.current+"Success",R),i.useNuiEvent(b.current,p.current+"Error",T),[r.useCallback((function(e,t){N((function(n){if(!n){m(!1),O(!1),C(null),S(null),f.current=s(p.current,e),f.current.promise.catch((function(e){h||(T(e),O(!0),v.current=void 0,f.current=void 0)}));var r=t||{timeout:l},u=!1!==r.timeout&&(r.timeout||l);return u&&!w&&(clearTimeout(v.current),v.current=setTimeout((function(){m(!0),T(new Error('fivem-nui-react-lib: "'+d.current+'" event callback timed out after '+u+" milliseconds")),f.current&&f.current.abort(),v.current=void 0,f.current=void 0}),u)),!0}return n}))}),[]),{loading:j,response:x,error:k}]}},20612:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.useNuiEvent=void 0;var r=n(53182),u=n(38006);t.useNuiEvent=function(e,t,n){var o=r.useRef();r.useEffect((function(){o.current=n}),[n]),r.useEffect((function(){var n=u.eventNameFactory(e,t),r=function(e){if(o.current&&o.current.call){var t=e.data;o.current(t)}};return function(e,t,n){e.addEventListener(t,n)}(window,n,r),function(){return window.removeEventListener(n,r)}}),[e,t])}},98398:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.useNuiRequest=void 0;var r=n(53182),u=n(7339);t.useNuiRequest=function(e){var t=(void 0===e?{}:e).resource,n=r.useContext(u.NuiContext);if(!n)throw new Error("fivem-nui-react-lib: useNuiRequest must be used inside NuiProvider passing the `resource` prop");var o=n.send,i=n.sendAbortable;return r.useMemo((function(){return{send:function(e,n){return void 0===n&&(n={}),o(e,n,t)},sendAbortable:function(e,n){return void 0===n&&(n={}),i(e,n,t)}}}),[o,i,t])}},88327:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var u in t=arguments[n])Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u]);return e},r.apply(this,arguments)},u=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(u,o){function i(e){try{a(r.next(e))}catch(e){o(e)}}function c(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?u(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}a((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,u,o,i={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(u=2&o[0]?r.return:o[0]?r.throw||((u=r.return)&&u.call(r),0):r.next)&&!(u=u.call(r,o[1])).done)return u;switch(r=0,u&&(o=[2&o[0],u.value]),o[0]){case 0:case 1:u=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!((u=(u=i.trys).length>0&&u[u.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!u||o[1]>u[0]&&o[1]<u[3])){i.label=o[1];break}if(6===o[0]&&i.label<u[1]){i.label=u[1],u=o;break}if(u&&i.label<u[2]){i.label=u[2],i.ops.push(o);break}u[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=u=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.NuiProvider=void 0;var i=n(61250),c=n(53182),a=n(7339),s=n(38006);function l(e,t){var n=new AbortController,u=n.signal;return{abort:function(){return n.abort()},promise:fetch(e,r(r({},t),{signal:u}))}}function f(e,t,n){return["https://"+e+"/"+t,{method:"post",headers:{"Content-Type":"application/json; charset=UTF-8"},body:JSON.stringify(n)}]}t.NuiProvider=function(e){var t=e.resource,n=e.children,v=e.timeout,d=c.useRef(t||""),p=c.useRef(v||1e4),b=function(e){var t=e.data,n=t.app,r=t.method,u=t.data;n&&r&&window.dispatchEvent(new MessageEvent(s.eventNameFactory(n,r),{data:u}))};c.useEffect((function(){return window.addEventListener("message",b),function(){return window.removeEventListener("message",b)}}),[]);var y=c.useCallback((function(e,t,n){return void 0===t&&(t={}),u(void 0,void 0,void 0,(function(){return o(this,(function(r){return[2,fetch.apply(void 0,f(n||d.current,e,t))]}))}))}),[]),h=c.useCallback((function(e,t,n){return void 0===t&&(t={}),l.apply(void 0,f(n||d.current,e,t))}),[]);return i.jsx(a.NuiContext.Provider,r({value:{send:y,sendAbortable:h,resource:d.current,callbackTimeout:p.current}},{children:n}),void 0)}},38006:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.eventNameFactory=void 0,t.eventNameFactory=function(e,t){return e+":"+t}},52458:function(e){var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,u){for(var o,i,c=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),a=1;a<arguments.length;a++){for(var s in o=Object(arguments[a]))n.call(o,s)&&(c[s]=o[s]);if(t){i=t(o);for(var l=0;l<i.length;l++)r.call(o,i[l])&&(c[i[l]]=o[i[l]])}}return c}},95472:function(e,t,n){n(52458);var r=n(53182),u=60103;if(t.Fragment=60107,"function"==typeof Symbol&&Symbol.for){var o=Symbol.for;u=o("react.element"),t.Fragment=o("react.fragment")}var i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c=Object.prototype.hasOwnProperty,a={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,n){var r,o={},s=null,l=null;for(r in void 0!==n&&(s=""+n),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(l=t.ref),t)c.call(t,r)&&!a.hasOwnProperty(r)&&(o[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===o[r]&&(o[r]=t[r]);return{$$typeof:u,type:e,key:s,ref:l,props:o,_owner:i.current}}t.jsx=s,t.jsxs=s},61250:function(e,t,n){e.exports=n(95472)}}]);