@hashtagcms/admin-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @hashtagcms/admin-sdk
2
+
3
+ > Core Logic SDK for HashtagCMS Admin Panel
4
+
5
+ This package abstracts the non-UI logic from the admin panel, including:
6
+ - **API Fetching** (Axios wrapper)
7
+ - **Configuration** (Handling server-side config injection)
8
+ - **Storage** (Local storage management)
9
+ - **Utilities** (Clipboard, URL params, JSON validation)
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @hashtagcms/admin-sdk
15
+ ```
16
+
17
+ ## Documentation
18
+
19
+ See the [detailed documentation](./docs/README.md).
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ presets: [
3
+ ['@babel/preset-env', {targets: {node: 'current'}}]
4
+ ],
5
+ };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see index.js.LICENSE.txt */
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.HashtagCmsAdminSdk=t():e.HashtagCmsAdminSdk=t()}(this,()=>(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};e.r(t),e.d(t,{AdminConfig:()=>a,CopyToClipboard:()=>Mt,Fetcher:()=>Tt,IsJson:()=>Jt,PasteFromClipboard:()=>zt,Storage:()=>Pt,Utils:()=>qt,default:()=>Wt,queryBuilder:()=>It});var n={};function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,s(r.key),r)}}function s(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}e.r(n),e.d(n,{hasBrowserEnv:()=>ye,hasStandardBrowserEnv:()=>ge,hasStandardBrowserWebWorkerEnv:()=>we,navigator:()=>be,origin:()=>ve});var a=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.appConfig="undefined"!=typeof window&&window.Laravel&&window.Laravel.adminConfig||{}},t=[{key:"get",value:function(e,t){return this.appConfig[e]||t}},{key:"admin_path",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n="";if(null!==t&&"[object Object]"===Object.prototype.toString.call(t)){var r=[];Object.entries(t).forEach(function(e){var t=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,s,a=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(a.push(r.value),a.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,2),n=t[0],i=t[1];return r.push(n+"="+i)}),n="?"+r.join("&")}return this.get("base_path")+"/"+e+n}},{key:"admin_asset",value:function(e){return this.get("app_url")+"/"+this.get("theme_assets")+"/"+e}},{key:"get_media",value:function(e){return this.get("media_path")+"/"+e}}],t&&i(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();const c=new a;function u(e,t){return function(){return e.apply(t,arguments)}}const{toString:l}=Object.prototype,{getPrototypeOf:f}=Object,{iterator:d,toStringTag:p}=Symbol,h=(m=Object.create(null),e=>{const t=l.call(e);return m[t]||(m[t]=t.slice(8,-1).toLowerCase())});var m;const y=e=>(e=e.toLowerCase(),t=>h(t)===e),b=e=>t=>typeof t===e,{isArray:g}=Array,w=b("undefined");function v(e){return null!==e&&!w(e)&&null!==e.constructor&&!w(e.constructor)&&S(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const E=y("ArrayBuffer"),O=b("string"),S=b("function"),R=b("number"),T=e=>null!==e&&"object"==typeof e,j=e=>{if("object"!==h(e))return!1;const t=f(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||p in e||d in e)},A=y("Date"),C=y("File"),P=y("Blob"),x=y("FileList"),_=y("URLSearchParams"),[N,k,U,F]=["ReadableStream","Request","Response","Headers"].map(y);function L(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),g(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(v(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let s;for(r=0;r<i;r++)s=o[r],t.call(null,e[s],s,e)}}function B(e,t){if(v(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:e.g,I=e=>!w(e)&&e!==D,q=(M="undefined"!=typeof Uint8Array&&f(Uint8Array),e=>M&&e instanceof M);var M;const z=y("HTMLFormElement"),H=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),J=y("RegExp"),W=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};L(n,(n,o)=>{let i;!1!==(i=t(n,o,e))&&(r[o]=i||n)}),Object.defineProperties(e,r)},$=y("AsyncFunction"),K=(V="function"==typeof setImmediate,G=S(D.postMessage),V?setImmediate:G?(X=`axios@${Math.random()}`,Q=[],D.addEventListener("message",({source:e,data:t})=>{e===D&&t===X&&Q.length&&Q.shift()()},!1),e=>{Q.push(e),D.postMessage(X,"*")}):e=>setTimeout(e));var V,G,X,Q;const Y="undefined"!=typeof queueMicrotask?queueMicrotask.bind(D):"undefined"!=typeof process&&process.nextTick||K,Z={isArray:g,isArrayBuffer:E,isBuffer:v,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||S(e.append)&&("formdata"===(t=h(e))||"object"===t&&S(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&E(e.buffer),t},isString:O,isNumber:R,isBoolean:e=>!0===e||!1===e,isObject:T,isPlainObject:j,isEmptyObject:e=>{if(!T(e)||v(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:N,isRequest:k,isResponse:U,isHeaders:F,isUndefined:w,isDate:A,isFile:C,isBlob:P,isRegExp:J,isFunction:S,isStream:e=>T(e)&&S(e.pipe),isURLSearchParams:_,isTypedArray:q,isFileList:x,forEach:L,merge:function e(){const{caseless:t,skipUndefined:n}=I(this)&&this||{},r={},o=(o,i)=>{const s=t&&B(r,i)||i;j(r[s])&&j(o)?r[s]=e(r[s],o):j(o)?r[s]=e({},o):g(o)?r[s]=o.slice():n&&w(o)||(r[s]=o)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&L(arguments[e],o);return r},extend:(e,t,n,{allOwnKeys:r}={})=>(L(t,(t,r)=>{n&&S(t)?Object.defineProperty(e,r,{value:u(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let o,i,s;const a={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],r&&!r(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==n&&f(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:h,kindOfTest:y,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(g(e))return e;let t=e.length;if(!R(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[d]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:z,hasOwnProperty:H,hasOwnProp:H,reduceDescriptors:W,freezeMethods:e=>{W(e,(t,n)=>{if(S(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];S(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return g(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:B,global:D,isContextDefined:I,isSpecCompliantForm:function(e){return!!(e&&S(e.append)&&"FormData"===e[p]&&e[d])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(T(e)){if(t.indexOf(e)>=0)return;if(v(e))return e;if(!("toJSON"in e)){t[r]=e;const o=g(e)?[]:{};return L(e,(e,t)=>{const i=n(e,r+1);!w(i)&&(o[t]=i)}),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:$,isThenable:e=>e&&(T(e)||S(e))&&S(e.then)&&S(e.catch),setImmediate:K,asap:Y,isIterable:e=>null!=e&&S(e[d])};class ee extends Error{static from(e,t,n,r,o,i){const s=new ee(e.message,t||e.code,n,r,o);return s.cause=e,s.name=e.name,i&&Object.assign(s,i),s}constructor(e,t,n,r,o){super(e),this.name="AxiosError",this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Z.toJSONObject(this.config),code:this.code,status:this.status}}}ee.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",ee.ERR_BAD_OPTION="ERR_BAD_OPTION",ee.ECONNABORTED="ECONNABORTED",ee.ETIMEDOUT="ETIMEDOUT",ee.ERR_NETWORK="ERR_NETWORK",ee.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",ee.ERR_DEPRECATED="ERR_DEPRECATED",ee.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",ee.ERR_BAD_REQUEST="ERR_BAD_REQUEST",ee.ERR_CANCELED="ERR_CANCELED",ee.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",ee.ERR_INVALID_URL="ERR_INVALID_URL";const te=ee;function ne(e){return Z.isPlainObject(e)||Z.isArray(e)}function re(e){return Z.endsWith(e,"[]")?e.slice(0,-2):e}function oe(e,t,n){return e?e.concat(t).map(function(e,t){return e=re(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const ie=Z.toFlatObject(Z,{},null,function(e){return/^is[A-Z]/.test(e)}),se=function(e,t,n){if(!Z.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Z.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Z.isUndefined(t[e])})).metaTokens,o=n.visitor||u,i=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Z.isSpecCompliantForm(t);if(!Z.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(Z.isDate(e))return e.toISOString();if(Z.isBoolean(e))return e.toString();if(!a&&Z.isBlob(e))throw new te("Blob is not supported. Use a Buffer instead.");return Z.isArrayBuffer(e)||Z.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,n,o){let a=e;if(e&&!o&&"object"==typeof e)if(Z.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Z.isArray(e)&&function(e){return Z.isArray(e)&&!e.some(ne)}(e)||(Z.isFileList(e)||Z.endsWith(n,"[]"))&&(a=Z.toArray(e)))return n=re(n),a.forEach(function(e,r){!Z.isUndefined(e)&&null!==e&&t.append(!0===s?oe([n],r,i):null===s?n:n+"[]",c(e))}),!1;return!!ne(e)||(t.append(oe(o,n,i),c(e)),!1)}const l=[],f=Object.assign(ie,{defaultVisitor:u,convertValue:c,isVisitable:ne});if(!Z.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Z.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+r.join("."));l.push(n),Z.forEach(n,function(n,i){!0===(!(Z.isUndefined(n)||null===n)&&o.call(t,n,Z.isString(i)?i.trim():i,r,f))&&e(n,r?r.concat(i):[i])}),l.pop()}}(e),t};function ae(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function ce(e,t){this._pairs=[],e&&se(e,this,t)}const ue=ce.prototype;ue.append=function(e,t){this._pairs.push([e,t])},ue.toString=function(e){const t=e?function(t){return e.call(this,t,ae)}:ae;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};const le=ce;function fe(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function de(e,t,n){if(!t)return e;const r=n&&n.encode||fe,o=Z.isFunction(n)?{serialize:n}:n,i=o&&o.serialize;let s;if(s=i?i(t,o):Z.isURLSearchParams(t)?t.toString():new le(t,o).toString(r),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}const pe=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Z.forEach(this.handlers,function(t){null!==t&&e(t)})}},he={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},me={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:le,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},ye="undefined"!=typeof window&&"undefined"!=typeof document,be="object"==typeof navigator&&navigator||void 0,ge=ye&&(!be||["ReactNative","NativeScript","NS"].indexOf(be.product)<0),we="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ve=ye&&window.location.href||"http://localhost",Ee={...n,...me},Oe=function(e){function t(e,n,r,o){let i=e[o++];if("__proto__"===i)return!0;const s=Number.isFinite(+i),a=o>=e.length;return i=!i&&Z.isArray(r)?r.length:i,a?(Z.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!s):(r[i]&&Z.isObject(r[i])||(r[i]=[]),t(e,n,r[i],o)&&Z.isArray(r[i])&&(r[i]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let i;for(r=0;r<o;r++)i=n[r],t[i]=e[i];return t}(r[i])),!s)}if(Z.isFormData(e)&&Z.isFunction(e.entries)){const n={};return Z.forEachEntry(e,(e,r)=>{t(function(e){return Z.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null},Se={transitional:he,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=Z.isObject(e);if(o&&Z.isHTMLForm(e)&&(e=new FormData(e)),Z.isFormData(e))return r?JSON.stringify(Oe(e)):e;if(Z.isArrayBuffer(e)||Z.isBuffer(e)||Z.isStream(e)||Z.isFile(e)||Z.isBlob(e)||Z.isReadableStream(e))return e;if(Z.isArrayBufferView(e))return e.buffer;if(Z.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return se(e,new Ee.classes.URLSearchParams,{visitor:function(e,t,n,r){return Ee.isNode&&Z.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((i=Z.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return se(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e){if(Z.isString(e))try{return(0,JSON.parse)(e),Z.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Se.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Z.isResponse(e)||Z.isReadableStream(e))return e;if(e&&Z.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw te.from(e,te.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ee.classes.FormData,Blob:Ee.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Z.forEach(["delete","get","head","post","put","patch"],e=>{Se.headers[e]={}});const Re=Se,Te=Z.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),je=Symbol("internals");function Ae(e){return e&&String(e).trim().toLowerCase()}function Ce(e){return!1===e||null==e?e:Z.isArray(e)?e.map(Ce):String(e)}function Pe(e,t,n,r,o){return Z.isFunction(r)?r.call(this,t,n):(o&&(t=n),Z.isString(t)?Z.isString(r)?-1!==t.indexOf(r):Z.isRegExp(r)?r.test(t):void 0:void 0)}class xe{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=Ae(t);if(!o)throw new Error("header name must be a non-empty string");const i=Z.findKey(r,o);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||t]=Ce(e))}const i=(e,t)=>Z.forEach(e,(e,n)=>o(e,n,t));if(Z.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(Z.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&Te[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(Z.isObject(e)&&Z.isIterable(e)){let n,r,o={};for(const t of e){if(!Z.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[r=t[0]]=(n=o[r])?Z.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}i(o,t)}else null!=e&&o(t,e,n);return this}get(e,t){if(e=Ae(e)){const n=Z.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Z.isFunction(t))return t.call(this,e,n);if(Z.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Ae(e)){const n=Z.findKey(this,e);return!(!n||void 0===this[n]||t&&!Pe(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=Ae(e)){const o=Z.findKey(n,e);!o||t&&!Pe(0,n[o],o,t)||(delete n[o],r=!0)}}return Z.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!Pe(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return Z.forEach(this,(r,o)=>{const i=Z.findKey(n,o);if(i)return t[i]=Ce(r),void delete t[o];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(o):String(o).trim();s!==o&&delete t[o],t[s]=Ce(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Z.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Z.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[je]=this[je]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=Ae(e);t[r]||(function(e,t){const n=Z.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})})}(n,e),t[r]=!0)}return Z.isArray(e)?e.forEach(r):r(e),this}}xe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Z.reduceDescriptors(xe.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),Z.freezeMethods(xe);const _e=xe;function Ne(e,t){const n=this||Re,r=t||n,o=_e.from(r.headers);let i=r.data;return Z.forEach(e,function(e){i=e.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function ke(e){return!(!e||!e.__CANCEL__)}const Ue=class extends te{constructor(e,t,n){super(null==e?"canceled":e,te.ERR_CANCELED,t,n),this.name="CanceledError",this.__CANCEL__=!0}};function Fe(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new te("Request failed with status code "+n.status,[te.ERR_BAD_REQUEST,te.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}const Le=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,i=0,s=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=r[s];o||(o=c),n[i]=a,r[i]=c;let l=s,f=0;for(;l!==i;)f+=n[l++],l%=e;if(i=(i+1)%e,i===s&&(s=(s+1)%e),c-o<t)return;const d=u&&c-u;return d?Math.round(1e3*f/d):void 0}}(50,250);return function(e,t){let n,r,o=0,i=1e3/t;const s=(t,i=Date.now())=>{o=i,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-o;a>=i?s(e,t):(n=e,r||(r=setTimeout(()=>{r=null,s(n)},i-a)))},()=>n&&s(n)]}(n=>{const i=n.loaded,s=n.lengthComputable?n.total:void 0,a=i-r,c=o(a);r=i,e({loaded:i,total:s,progress:s?i/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&i<=s?(s-i)/c:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})},n)},Be=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},De=e=>(...t)=>Z.asap(()=>e(...t)),Ie=Ee.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Ee.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Ee.origin),Ee.navigator&&/(msie|trident)/i.test(Ee.navigator.userAgent)):()=>!0,qe=Ee.hasStandardBrowserEnv?{write(e,t,n,r,o,i,s){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];Z.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),Z.isString(r)&&a.push(`path=${r}`),Z.isString(o)&&a.push(`domain=${o}`),!0===i&&a.push("secure"),Z.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function Me(e,t,n){let r=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const ze=e=>e instanceof _e?{...e}:e;function He(e,t){t=t||{};const n={};function r(e,t,n,r){return Z.isPlainObject(e)&&Z.isPlainObject(t)?Z.merge.call({caseless:r},e,t):Z.isPlainObject(t)?Z.merge({},t):Z.isArray(t)?t.slice():t}function o(e,t,n,o){return Z.isUndefined(t)?Z.isUndefined(e)?void 0:r(void 0,e,0,o):r(e,t,0,o)}function i(e,t){if(!Z.isUndefined(t))return r(void 0,t)}function s(e,t){return Z.isUndefined(t)?Z.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,i){return i in t?r(n,o):i in e?r(void 0,n):void 0}const c={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,n)=>o(ze(e),ze(t),0,!0)};return Z.forEach(Object.keys({...e,...t}),function(r){const i=c[r]||o,s=i(e[r],t[r],r);Z.isUndefined(s)&&i!==a||(n[r]=s)}),n}const Je=e=>{const t=He({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:i,headers:s,auth:a}=t;if(t.headers=s=_e.from(s),t.url=de(Me(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Z.isFormData(n))if(Ee.hasStandardBrowserEnv||Ee.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(Z.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&s.set(e,n)})}if(Ee.hasStandardBrowserEnv&&(r&&Z.isFunction(r)&&(r=r(t)),r||!1!==r&&Ie(t.url))){const e=o&&i&&qe.read(i);e&&s.set(o,e)}return t},We="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=Je(e);let o=r.data;const i=_e.from(r.headers).normalize();let s,a,c,u,l,{responseType:f,onUploadProgress:d,onDownloadProgress:p}=r;function h(){u&&u(),l&&l(),r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let m=new XMLHttpRequest;function y(){if(!m)return;const r=_e.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());Fe(function(e){t(e),h()},function(e){n(e),h()},{data:f&&"text"!==f&&"json"!==f?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=y:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(y)},m.onabort=function(){m&&(n(new te("Request aborted",te.ECONNABORTED,e,m)),m=null)},m.onerror=function(t){const r=t&&t.message?t.message:"Network Error",o=new te(r,te.ERR_NETWORK,e,m);o.event=t||null,n(o),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const o=r.transitional||he;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new te(t,o.clarifyTimeoutError?te.ETIMEDOUT:te.ECONNABORTED,e,m)),m=null},void 0===o&&i.setContentType(null),"setRequestHeader"in m&&Z.forEach(i.toJSON(),function(e,t){m.setRequestHeader(t,e)}),Z.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),f&&"json"!==f&&(m.responseType=r.responseType),p&&([c,l]=Le(p,!0),m.addEventListener("progress",c)),d&&m.upload&&([a,u]=Le(d),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",u)),(r.cancelToken||r.signal)&&(s=t=>{m&&(n(!t||t.type?new Ue(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const b=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);b&&-1===Ee.protocols.indexOf(b)?n(new te("Unsupported protocol "+b+":",te.ERR_BAD_REQUEST,e)):m.send(o||null)})},$e=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const o=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;r.abort(t instanceof te?t:new Ue(t instanceof Error?t.message:t))}};let i=t&&setTimeout(()=>{i=null,o(new te(`timeout of ${t}ms exceeded`,te.ETIMEDOUT))},t);const s=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)}),e=null)};e.forEach(e=>e.addEventListener("abort",o));const{signal:a}=r;return a.unsubscribe=()=>Z.asap(s),a}},Ke=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,o=0;for(;o<n;)r=o+t,yield e.slice(o,r),o=r},Ve=(e,t,n,r)=>{const o=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*Ke(n,t)}(e,t);let i,s=0,a=e=>{i||(i=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await o.next();if(t)return a(),void e.close();let i=r.byteLength;if(n){let e=s+=i;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),o.return())},{highWaterMark:2})},{isFunction:Ge}=Z,Xe=(({Request:e,Response:t})=>({Request:e,Response:t}))(Z.global),{ReadableStream:Qe,TextEncoder:Ye}=Z.global,Ze=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},et=e=>{e=Z.merge.call({skipUndefined:!0},Xe,e);const{fetch:t,Request:n,Response:r}=e,o=t?Ge(t):"function"==typeof fetch,i=Ge(n),s=Ge(r);if(!o)return!1;const a=o&&Ge(Qe),c=o&&("function"==typeof Ye?(u=new Ye,e=>u.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var u;const l=i&&a&&Ze(()=>{let e=!1;const t=new n(Ee.origin,{body:new Qe,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),f=s&&a&&Ze(()=>Z.isReadableStream(new r("").body)),d={stream:f&&(e=>e.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new te(`Response type '${e}' is not supported`,te.ERR_NOT_SUPPORT,n)})});return async e=>{let{url:o,method:s,data:a,signal:u,cancelToken:p,timeout:h,onDownloadProgress:m,onUploadProgress:y,responseType:b,headers:g,withCredentials:w="same-origin",fetchOptions:v}=Je(e),E=t||fetch;b=b?(b+"").toLowerCase():"text";let O=$e([u,p&&p.toAbortSignal()],h),S=null;const R=O&&O.unsubscribe&&(()=>{O.unsubscribe()});let T;try{if(y&&l&&"get"!==s&&"head"!==s&&0!==(T=await(async(e,t)=>{const r=Z.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Z.isBlob(e))return e.size;if(Z.isSpecCompliantForm(e)){const t=new n(Ee.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Z.isArrayBufferView(e)||Z.isArrayBuffer(e)?e.byteLength:(Z.isURLSearchParams(e)&&(e+=""),Z.isString(e)?(await c(e)).byteLength:void 0)})(t):r})(g,a))){let e,t=new n(o,{method:"POST",body:a,duplex:"half"});if(Z.isFormData(a)&&(e=t.headers.get("content-type"))&&g.setContentType(e),t.body){const[e,n]=Be(T,Le(De(y)));a=Ve(t.body,65536,e,n)}}Z.isString(w)||(w=w?"include":"omit");const t=i&&"credentials"in n.prototype,u={...v,signal:O,method:s.toUpperCase(),headers:g.normalize().toJSON(),body:a,duplex:"half",credentials:t?w:void 0};S=i&&new n(o,u);let p=await(i?E(S,v):E(o,u));const h=f&&("stream"===b||"response"===b);if(f&&(m||h&&R)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=p[t]});const t=Z.toFiniteNumber(p.headers.get("content-length")),[n,o]=m&&Be(t,Le(De(m),!0))||[];p=new r(Ve(p.body,65536,n,()=>{o&&o(),R&&R()}),e)}b=b||"text";let j=await d[Z.findKey(d,b)||"text"](p,e);return!h&&R&&R(),await new Promise((t,n)=>{Fe(t,n,{data:j,headers:_e.from(p.headers),status:p.status,statusText:p.statusText,config:e,request:S})})}catch(t){if(R&&R(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new te("Network Error",te.ERR_NETWORK,e,S),{cause:t.cause||t});throw te.from(t,t&&t.code,e,S)}}},tt=new Map,nt=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:o}=t,i=[r,o,n];let s,a,c=i.length,u=tt;for(;c--;)s=i[c],a=u.get(s),void 0===a&&u.set(s,a=c?new Map:et(t)),u=a;return a},rt=(nt(),{http:null,xhr:We,fetch:{get:nt}});Z.forEach(rt,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const ot=e=>`- ${e}`,it=e=>Z.isFunction(e)||null===e||!1===e,st=function(e,t){e=Z.isArray(e)?e:[e];const{length:n}=e;let r,o;const i={};for(let s=0;s<n;s++){let n;if(r=e[s],o=r,!it(r)&&(o=rt[(n=String(r)).toLowerCase()],void 0===o))throw new te(`Unknown adapter '${n}'`);if(o&&(Z.isFunction(o)||(o=o.get(t))))break;i[n||"#"+s]=o}if(!o){const e=Object.entries(i).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));let t=n?e.length>1?"since :\n"+e.map(ot).join("\n"):" "+ot(e[0]):"as no adapter specified";throw new te("There is no suitable adapter to dispatch the request "+t,"ERR_NOT_SUPPORT")}return o};function at(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ue(null,e)}function ct(e){return at(e),e.headers=_e.from(e.headers),e.data=Ne.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),st(e.adapter||Re.adapter,e)(e).then(function(t){return at(e),t.data=Ne.call(e,e.transformResponse,t),t.headers=_e.from(t.headers),t},function(t){return ke(t)||(at(e),t&&t.response&&(t.response.data=Ne.call(e,e.transformResponse,t.response),t.response.headers=_e.from(t.response.headers))),Promise.reject(t)})}const ut="1.13.4",lt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{lt[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const ft={};lt.transitional=function(e,t,n){function r(e,t){return"[Axios v"+ut+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,i)=>{if(!1===e)throw new te(r(o," has been removed"+(t?" in "+t:"")),te.ERR_DEPRECATED);return t&&!ft[o]&&(ft[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,i)}},lt.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};const dt={assertOptions:function(e,t,n){if("object"!=typeof e)throw new te("options must be an object",te.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],s=t[i];if(s){const t=e[i],n=void 0===t||s(t,i,e);if(!0!==n)throw new te("option "+i+" must be "+n,te.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new te("Unknown option "+i,te.ERR_BAD_OPTION)}},validators:lt},pt=dt.validators;class ht{constructor(e){this.defaults=e||{},this.interceptors={request:new pe,response:new pe}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=He(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&dt.assertOptions(n,{silentJSONParsing:pt.transitional(pt.boolean),forcedJSONParsing:pt.transitional(pt.boolean),clarifyTimeoutError:pt.transitional(pt.boolean)},!1),null!=r&&(Z.isFunction(r)?t.paramsSerializer={serialize:r}:dt.assertOptions(r,{encode:pt.function,serialize:pt.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),dt.assertOptions(t,{baseUrl:pt.spelling("baseURL"),withXsrfToken:pt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=o&&Z.merge(o.common,o[t.method]);o&&Z.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=_e.concat(i,o);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const c=[];let u;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,f=0;if(!a){const e=[ct.bind(this),void 0];for(e.unshift(...s),e.push(...c),l=e.length,u=Promise.resolve(t);f<l;)u=u.then(e[f++],e[f++]);return u}l=s.length;let d=t;for(;f<l;){const e=s[f++],t=s[f++];try{d=e(d)}catch(e){t.call(this,e);break}}try{u=ct.call(this,d)}catch(e){return Promise.reject(e)}for(f=0,l=c.length;f<l;)u=u.then(c[f++],c[f++]);return u}getUri(e){return de(Me((e=He(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}Z.forEach(["delete","get","head","options"],function(e){ht.prototype[e]=function(t,n){return this.request(He(n||{},{method:e,url:t,data:(n||{}).data}))}}),Z.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,o){return this.request(He(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}ht.prototype[e]=t(),ht.prototype[e+"Form"]=t(!0)});const mt=ht;class yt{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,o){n.reason||(n.reason=new Ue(e,r,o),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new yt(function(t){e=t}),cancel:e}}}const bt=yt,gt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(gt).forEach(([e,t])=>{gt[t]=e});const wt=gt,vt=function e(t){const n=new mt(t),r=u(mt.prototype.request,n);return Z.extend(r,mt.prototype,n,{allOwnKeys:!0}),Z.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(He(t,n))},r}(Re);vt.Axios=mt,vt.CanceledError=Ue,vt.CancelToken=bt,vt.isCancel=ke,vt.VERSION=ut,vt.toFormData=se,vt.AxiosError=te,vt.Cancel=vt.CanceledError,vt.all=function(e){return Promise.all(e)},vt.spread=function(e){return function(t){return e.apply(null,t)}},vt.isAxiosError=function(e){return Z.isObject(e)&&!0===e.isAxiosError},vt.mergeConfig=He,vt.AxiosHeaders=_e,vt.formToJSON=e=>Oe(Z.isHTMLForm(e)?new FormData(e):e),vt.getAdapter=st,vt.HttpStatusCode=wt,vt.default=vt;const Et=vt;function Ot(e){return Ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ot(e)}function St(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Rt(r.key),r)}}function Rt(e){var t=function(e){if("object"!=Ot(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=Ot(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Ot(t)?t:t+""}var Tt=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)},(t=[{key:"get",value:function(e,t){return Et.get(e,t)}},{key:"post",value:function(e,t,n){return Et.post(e,t,n)}},{key:"put",value:function(e,t,n){return Et.put(e,t,n)}},{key:"delete",value:function(e,t){return Et.delete(e,t)}}])&&St(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function jt(e){return jt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},jt(e)}function At(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Ct(r.key),r)}}function Ct(e){var t=function(e){if("object"!=jt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=jt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==jt(t)?t:t+""}var Pt=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.obj={},this.counter=1},(t=[{key:"nextCounter",value:function(){return this.counter++}},{key:"store",value:function(e,t){this.obj[e]=t}},{key:"fetch",value:function(e){return this.obj[e]}},{key:"clear",value:function(e){return delete this.obj[e]}}])&&At(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function xt(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof a?r:a,u=Object.create(c.prototype);return _t(u,"_invoke",function(n,r,o){var i,a,c,u=0,l=o||[],f=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,a=0,c=e,d.n=n,s}};function p(n,r){for(a=n,c=r,t=0;!f&&u&&!o&&t<l.length;t++){var o,i=l[t],p=d.p,h=i[2];n>3?(o=h===r)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=n<2&&p<i[1])?(a=0,d.v=r,d.n=i[1]):p<h&&(o=n<3||i[0]>r||r>h)&&(i[4]=n,i[5]=r,d.n=h,a=0))}if(o||n>1)return s;throw f=!0,r}return function(o,l,h){if(u>1)throw TypeError("Generator is already running");for(f&&1===l&&p(l,h),a=l,c=h;(t=a<2?e:c)||!f;){i||(a?a<3?(a>1&&(d.n=-1),p(a,c)):d.n=c:d.v=c);try{if(u=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(f=d.n<0)?c:n.call(r,d))!==s)break}catch(t){i=e,a=1,c=t}finally{u=1}}return{value:t,done:f}}}(n,o,i),!0),u}var s={};function a(){}function c(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(_t(t={},r,function(){return this}),t),f=u.prototype=a.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,_t(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return c.prototype=u,_t(f,"constructor",u),_t(u,"constructor",c),c.displayName="GeneratorFunction",_t(u,o,"GeneratorFunction"),_t(f),_t(f,o,"Generator"),_t(f,r,function(){return this}),_t(f,"toString",function(){return"[object Generator]"}),(xt=function(){return{w:i,m:d}})()}function _t(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}_t=function(e,t,n,r){function i(t,n){_t(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},_t(e,t,n,r)}function Nt(e,t,n,r,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,o)}function kt(e){return kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},kt(e)}function Ut(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ft(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Bt(r.key),r)}}function Lt(e,t,n){return t&&Ft(e.prototype,t),n&&Ft(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Bt(e){var t=function(e){if("object"!=kt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=kt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==kt(t)?t:t+""}var Dt="htcms_cps",It=function(){return Lt(function e(){Ut(this,e)},null,[{key:"cache",get:function(){return{}}},{key:"get",value:function(e,t){if(this.cache[e])return this.cache[e];for(var n=(void 0===t?"undefined"!=typeof window?window.location.search.substring(1):"":t).split("&"),r={},o=0;o<n.length;o++){var i=n[o].split("="),s=i[0],a=i[1];if(i.length>2&&(i.shift(),a=i.join("=")),r[s]=a,s===e){var c=decodeURIComponent(a);return this.cache[e]=c,c}}return null==e?r:""}},{key:"all",value:function(e){return this.get(null,e)}}])}(),qt=function(){return Lt(function e(){Ut(this,e)},[{key:"serializeFormArray",value:function(e){if("undefined"==typeof document)return[];var t,n,r=[];if("object"==kt(e="string"==typeof e?document.getElementById(e):e)&&e&&"FORM"===e.nodeName)for(var o=e.elements.length,i=0;i<o;i++)if((t=e.elements[i]).name&&!t.disabled&&"file"!==t.type&&"reset"!==t.type&&"submit"!==t.type&&"button"!==t.type)if("select-multiple"===t.type){n=e.elements[i].options.length;for(var s=0;s<n;s++)t.options[s].selected&&(r[r.length]={name:t.name,value:t.options[s].value})}else("checkbox"!==t.type&&"radio"!==t.type||t.checked)&&(r[r.length]={name:t.name,value:t.value});return r}}])}();function Mt(e){if("undefined"!=typeof navigator&&navigator.clipboard)navigator.clipboard.writeText(e);else if("undefined"!=typeof window){window.localStorage.setItem(Dt,e);var t=document.createElement("textarea");t.value=e,t.style.position="absolute",t.style.left="-99999px",t.style.top="-99999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}}function zt(){return Ht.apply(this,arguments)}function Ht(){var e;return e=xt().m(function e(){return xt().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,"undefined"!=typeof navigator){e.n=1;break}throw new Error("Navigator not available");case 1:return e.n=2,navigator.permissions.query({name:"clipboard-read"});case 2:if("denied"!==e.v.state){e.n=3;break}throw new Error("Not allowed to read clipboard.");case 3:return e.a(2,navigator.clipboard.read());case 4:return e.p=4,e.v,e.a(2,new Promise(function(e,t){"undefined"!=typeof window&&window.localStorage.getItem(Dt)?e(window.localStorage.getItem(Dt)):t(null)}))}},e,null,[[0,4]])}),Ht=function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function s(e){Nt(i,r,o,s,a,"next",e)}function a(e){Nt(i,r,o,s,a,"throw",e)}s(void 0)})},Ht.apply(this,arguments)}function Jt(e){try{JSON.parse(e)}catch(e){return!1}return!0}const Wt=c;return t})());
@@ -0,0 +1 @@
1
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
package/docs/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Admin SDK Documentation
2
+
3
+ ## Overview
4
+ The `@hashtagcms/admin-sdk` provides the core business logic, API helpers, and configuration management for the HashtagCMS Admin Panel. It is designed to be UI-agnostic, allowing it to be used in various JavaScript environments (Admin UI Kit, Node.js scripts, etc.).
5
+
6
+ ## Installation
7
+ ```bash
8
+ npm install @hashtagcms/admin-sdk
9
+ ```
10
+
11
+ ## Core Modules
12
+
13
+ ### 1. `AdminConfig`
14
+ Handles the configuration passed from the Laravel backend to the frontend.
15
+ ```javascript
16
+ import { AdminConfig } from '@hashtagcms/admin-sdk';
17
+ const config = new AdminConfig();
18
+ console.log(config.get('base_path'));
19
+ ```
20
+
21
+ ### 2. `Fetcher`
22
+ A wrapper around Axios for making API requests.
23
+ ```javascript
24
+ import { Fetcher } from '@hashtagcms/admin-sdk';
25
+ const api = new Fetcher();
26
+ api.get('/api/users').then(response => ...);
27
+ ```
28
+
29
+ ### 3. `Storage`
30
+ A simple wrapper for key-value storage (compatible with `secure-ls` logic).
31
+ ```javascript
32
+ import { Storage } from '@hashtagcms/admin-sdk';
33
+ const store = new Storage();
34
+ store.store('user_id', 123);
35
+ ```
36
+
37
+ ### 4. Utilities
38
+ Various helper functions.
39
+ ```javascript
40
+ import { queryBuilder, CopyToClipboard, IsJson } from '@hashtagcms/admin-sdk';
41
+
42
+ // Get URL param
43
+ const id = queryBuilder.get('id');
44
+
45
+ // Copy text
46
+ CopyToClipboard('Hello World');
47
+ ```
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@hashtagcms/admin-sdk",
3
+ "version": "1.0.0",
4
+ "description": "Core Logic SDK for HashtagCMS Admin Panel",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "jest",
8
+ "dev": "webpack --mode development --progress --color",
9
+ "prod": "webpack --mode production --progress --color",
10
+ "build": "npm run prod",
11
+ "watch": "webpack --mode development --watch --progress --color"
12
+ },
13
+ "jest": {
14
+ "testEnvironment": "jsdom"
15
+ },
16
+ "author": "HashtagCMS",
17
+ "license": "MIT",
18
+ "dependencies": {
19
+ "axios": "^1.8.0",
20
+ "secure-ls": "^2.0.0"
21
+ },
22
+ "devDependencies": {
23
+ "@babel/core": "^7.0.0",
24
+ "@babel/preset-env": "^7.29.0",
25
+ "babel-jest": "^29.7.0",
26
+ "babel-loader": "^9.0.0",
27
+ "jest": "^29.7.0",
28
+ "jest-environment-jsdom": "^29.7.0",
29
+ "webpack": "^5.0.0",
30
+ "webpack-cli": "^5.0.0"
31
+ }
32
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Admin Configuration Helper
3
+ * Handles application configuration data passed from the backend
4
+ */
5
+ export class AdminConfig {
6
+ constructor() {
7
+ this.appConfig = (typeof window !== 'undefined' && window.Laravel && window.Laravel.adminConfig) || {};
8
+ }
9
+
10
+ get(key, defaultVal) {
11
+ return this.appConfig[key] || defaultVal;
12
+ }
13
+
14
+ admin_path(path, params = null) {
15
+ let qParamStr = "";
16
+ if (
17
+ params !== null &&
18
+ Object.prototype.toString.call(params) === "[object Object]"
19
+ ) {
20
+ let qParam = [];
21
+ Object.entries(params).forEach(([key, value]) =>
22
+ qParam.push(key + "=" + value),
23
+ );
24
+ qParamStr = "?" + qParam.join("&");
25
+ }
26
+ return this.get("base_path") + "/" + path + qParamStr;
27
+ }
28
+
29
+ admin_asset(path) {
30
+ return this.get("app_url") + "/" + this.get("theme_assets") + "/" + path;
31
+ }
32
+
33
+ get_media(path) {
34
+ return this.get("media_path") + "/" + path;
35
+ }
36
+ }
37
+
38
+ const adminConfig = new AdminConfig();
39
+ export default adminConfig;
package/src/fetcher.js ADDED
@@ -0,0 +1,22 @@
1
+ import axios from "axios";
2
+
3
+ /**
4
+ * Fetcher Wrapper
5
+ */
6
+ export class Fetcher {
7
+ get(url, config) {
8
+ return axios.get(url, config);
9
+ }
10
+
11
+ post(url, data, config) {
12
+ return axios.post(url, data, config);
13
+ }
14
+
15
+ put(url, data, config) {
16
+ return axios.put(url, data, config);
17
+ }
18
+
19
+ delete(url, config) {
20
+ return axios.delete(url, config);
21
+ }
22
+ }
package/src/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export { AdminConfig } from './admin-config';
2
+ export { Fetcher } from './fetcher';
3
+ export { Storage } from './storage';
4
+ export { queryBuilder, Utils, CopyToClipboard, PasteFromClipboard, IsJson } from './utils';
5
+
6
+ // Default export if needed
7
+ import adminConfig from './admin-config';
8
+ export default adminConfig;
package/src/storage.js ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Simple In-Memory Storage Wrapper
3
+ * Intended to be compatible with secure-ls or other storage mechanisms
4
+ */
5
+ export class Storage {
6
+ constructor() {
7
+ this.obj = {};
8
+ this.counter = 1;
9
+ }
10
+
11
+ nextCounter() {
12
+ return this.counter++;
13
+ }
14
+
15
+ store(name, value) {
16
+ this.obj[name] = value;
17
+ }
18
+
19
+ fetch(name) {
20
+ return this.obj[name];
21
+ }
22
+
23
+ clear(name) {
24
+ return delete this.obj[name];
25
+ }
26
+ }
package/src/utils.js ADDED
@@ -0,0 +1,146 @@
1
+ const CLIPBOARD_KEY = "htcms_cps";
2
+
3
+ /**
4
+ * queryBuilder
5
+ * Get Param from query
6
+ */
7
+ export class queryBuilder {
8
+ static get cache() {
9
+ return {};
10
+ }
11
+
12
+ static get(param, custom) {
13
+ if (this.cache[param]) {
14
+ return this.cache[param];
15
+ }
16
+ let query =
17
+ typeof custom == "undefined"
18
+ ? (typeof window !== 'undefined' ? window.location.search.substring(1) : '')
19
+ : custom;
20
+ let query_arr = query.split("&");
21
+ let all = {};
22
+ for (let i = 0; i < query_arr.length; i++) {
23
+ let current = query_arr[i].split("=");
24
+ let key = current[0];
25
+ let value = current[1];
26
+ if (current.length > 2) {
27
+ current.shift();
28
+ value = current.join("=");
29
+ }
30
+ all[key] = value;
31
+
32
+ if (key === param) {
33
+ let val = decodeURIComponent(value);
34
+ this.cache[param] = val;
35
+ return val;
36
+ }
37
+ }
38
+ return param == null ? all : "";
39
+ }
40
+ static all(custom) {
41
+ return this.get(null, custom);
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Form Serialization Helper
47
+ */
48
+ export class Utils {
49
+ serializeFormArray(form) {
50
+ if (typeof document === 'undefined') return [];
51
+
52
+ form = typeof form == "string" ? document.getElementById(form) : form;
53
+ let field,
54
+ l,
55
+ s = [];
56
+ if (typeof form == "object" && form && form.nodeName === "FORM") {
57
+ let len = form.elements.length;
58
+ for (let i = 0; i < len; i++) {
59
+ field = form.elements[i];
60
+ if (
61
+ field.name &&
62
+ !field.disabled &&
63
+ field.type !== "file" &&
64
+ field.type !== "reset" &&
65
+ field.type !== "submit" &&
66
+ field.type !== "button"
67
+ ) {
68
+ if (field.type === "select-multiple") {
69
+ l = form.elements[i].options.length;
70
+ for (let j = 0; j < l; j++) {
71
+ if (field.options[j].selected)
72
+ s[s.length] = {
73
+ name: field.name,
74
+ value: field.options[j].value,
75
+ };
76
+ }
77
+ } else if (
78
+ (field.type !== "checkbox" && field.type !== "radio") ||
79
+ field.checked
80
+ ) {
81
+ s[s.length] = { name: field.name, value: field.value };
82
+ }
83
+ }
84
+ }
85
+ }
86
+ return s;
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Copy to clipboard
92
+ */
93
+ export function CopyToClipboard(text) {
94
+ if (typeof navigator !== 'undefined' && navigator.clipboard) {
95
+ navigator.clipboard.writeText(text);
96
+ } else if (typeof window !== 'undefined') {
97
+ window.localStorage.setItem(CLIPBOARD_KEY, text);
98
+ const el = document.createElement("textarea");
99
+ el.value = text;
100
+ el.style.position = "absolute";
101
+ el.style.left = "-99999px";
102
+ el.style.top = "-99999px";
103
+ document.body.appendChild(el);
104
+ el.select();
105
+ document.execCommand("copy");
106
+ document.body.removeChild(el);
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Paste from clipboard
112
+ */
113
+ export async function PasteFromClipboard() {
114
+ try {
115
+ if (typeof navigator === 'undefined') throw new Error("Navigator not available");
116
+
117
+ const permission = await navigator.permissions.query({
118
+ name: "clipboard-read",
119
+ });
120
+ if (permission.state === "denied") {
121
+ throw new Error("Not allowed to read clipboard.");
122
+ }
123
+ return navigator.clipboard.read();
124
+ } catch (error) {
125
+ return new Promise((resolve, reject) => {
126
+ if (typeof window !== 'undefined' && window.localStorage.getItem(CLIPBOARD_KEY)) {
127
+ let data = window.localStorage.getItem(CLIPBOARD_KEY);
128
+ resolve(data);
129
+ } else {
130
+ reject(null);
131
+ }
132
+ });
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Check if string is a json
138
+ */
139
+ export function IsJson(str) {
140
+ try {
141
+ JSON.parse(str);
142
+ } catch (e) {
143
+ return false;
144
+ }
145
+ return true;
146
+ }
@@ -0,0 +1,55 @@
1
+ import { AdminConfig } from '../src/admin-config';
2
+
3
+ describe('AdminConfig Class', () => {
4
+ let originalWindowLaravel;
5
+
6
+ beforeAll(() => {
7
+ originalWindowLaravel = window.Laravel;
8
+ window.Laravel = {
9
+ adminConfig: {
10
+ base_path: 'https://example.com/admin',
11
+ app_url: 'https://example.com',
12
+ theme_assets: 'assets/theme',
13
+ media_path: 'https://cdn.example.com',
14
+ custom_setting: 'foobar'
15
+ }
16
+ };
17
+ });
18
+
19
+ afterAll(() => {
20
+ window.Laravel = originalWindowLaravel;
21
+ });
22
+
23
+ it('retrieves config values from window.Laravel', () => {
24
+ const config = new AdminConfig();
25
+ expect(config.get('custom_setting')).toBe('foobar');
26
+ });
27
+
28
+ it('returns default value if key missing', () => {
29
+ const config = new AdminConfig();
30
+ expect(config.get('missing_key', 'default')).toBe('default');
31
+ });
32
+
33
+ it('constructs admin_path correctly', () => {
34
+ const config = new AdminConfig();
35
+
36
+ // No params
37
+ expect(config.admin_path('dashboard')).toBe('https://example.com/admin/dashboard');
38
+
39
+ // With params
40
+ expect(config.admin_path('users', { page: 1, sort: 'desc' }))
41
+ .toBe('https://example.com/admin/users?page=1&sort=desc');
42
+ });
43
+
44
+ it('constructs admin_asset paths correctly', () => {
45
+ const config = new AdminConfig();
46
+ expect(config.admin_asset('css/app.css'))
47
+ .toBe('https://example.com/assets/theme/css/app.css');
48
+ });
49
+
50
+ it('constructs media paths correctly', () => {
51
+ const config = new AdminConfig();
52
+ expect(config.get_media('images/logo.png'))
53
+ .toBe('https://cdn.example.com/images/logo.png');
54
+ });
55
+ });
@@ -0,0 +1,32 @@
1
+ import { Storage } from '../src/storage';
2
+
3
+ describe('Storage Class', () => {
4
+ let storage;
5
+
6
+ beforeEach(() => {
7
+ storage = new Storage();
8
+ });
9
+
10
+ it('stores and retrieves values', () => {
11
+ storage.store('key1', 'value1');
12
+ expect(storage.fetch('key1')).toBe('value1');
13
+ });
14
+
15
+ it('handles object values', () => {
16
+ const data = { id: 1, name: 'Test' };
17
+ storage.store('user', data);
18
+ expect(storage.fetch('user')).toEqual(data);
19
+ });
20
+
21
+ it('clears stored values', () => {
22
+ storage.store('temp', 123);
23
+ storage.clear('temp');
24
+ expect(storage.fetch('temp')).toBeUndefined();
25
+ });
26
+
27
+ it('manages counters', () => {
28
+ expect(storage.nextCounter()).toBe(1);
29
+ expect(storage.nextCounter()).toBe(2);
30
+ expect(storage.nextCounter()).toBe(3);
31
+ });
32
+ });
@@ -0,0 +1,106 @@
1
+ import { Utils, IsJson, CopyToClipboard, queryBuilder } from '../src/utils';
2
+
3
+ describe('Utils Class', () => {
4
+ let mockForm;
5
+
6
+ beforeEach(() => {
7
+ document.body.innerHTML = `
8
+ <form id="test-form">
9
+ <input type="text" name="username" value="johndoe">
10
+ <input type="email" name="email" value="john@example.com">
11
+ <input type="checkbox" name="subscribe" checked>
12
+ <input type="checkbox" name="terms">
13
+ <select name="role">
14
+ <option value="user" selected>User</option>
15
+ <option value="admin">Admin</option>
16
+ </select>
17
+ <select name="tags" multiple>
18
+ <option value="js" selected>JS</option>
19
+ <option value="php" selected>PHP</option>
20
+ <option value="python">Python</option>
21
+ </select>
22
+ <input type="submit" value="Submit">
23
+ <input type="button" value="Cancel">
24
+ </form>
25
+ `;
26
+ mockForm = document.getElementById('test-form');
27
+ });
28
+
29
+ it('serializeFormArray transforms form elements to array of objects', () => {
30
+ const utils = new Utils();
31
+ const result = utils.serializeFormArray(mockForm);
32
+
33
+ expect(result).toEqual(expect.arrayContaining([
34
+ { name: 'username', value: 'johndoe' },
35
+ { name: 'email', value: 'john@example.com' },
36
+ { name: 'subscribe', value: 'on' },
37
+ { name: 'role', value: 'user' },
38
+ { name: 'tags', value: 'js' },
39
+ { name: 'tags', value: 'php' }
40
+ ]));
41
+
42
+ // Unchecked checkbox should not be included
43
+ expect(result).not.toEqual(expect.arrayContaining([{ name: 'terms', value: 'on' }]));
44
+ });
45
+
46
+ it('serializeFormArray handles string ID input', () => {
47
+ const utils = new Utils();
48
+ const result = utils.serializeFormArray('test-form');
49
+ expect(result.length).toBeGreaterThan(0);
50
+ });
51
+
52
+ it('serializeFormArray returns empty array for invalid input', () => {
53
+ const utils = new Utils();
54
+ expect(utils.serializeFormArray(null)).toEqual([]);
55
+ expect(utils.serializeFormArray({})).toEqual([]);
56
+ });
57
+ });
58
+
59
+ describe('IsJson Helper', () => {
60
+ it('returns true for valid JSON string', () => {
61
+ expect(IsJson('{"key": "value"}')).toBe(true);
62
+ expect(IsJson('["item1", "item2"]')).toBe(true);
63
+ expect(IsJson('true')).toBe(true);
64
+ expect(IsJson('123')).toBe(true);
65
+ });
66
+
67
+ it('returns false for invalid JSON string', () => {
68
+ expect(IsJson('{key: "value"}')).toBe(false);
69
+ expect(IsJson('plain text')).toBe(false);
70
+ expect(IsJson(undefined)).toBe(false);
71
+ });
72
+ });
73
+
74
+ describe('queryBuilder Helper', () => {
75
+ beforeAll(() => {
76
+ Object.defineProperty(window, 'location', {
77
+ value: {
78
+ search: '?id=123&name=john&category=admin'
79
+ },
80
+ writable: true
81
+ });
82
+ });
83
+
84
+ it('parses current window location query params', () => {
85
+ const result = queryBuilder.all();
86
+ expect(result).toEqual({
87
+ id: '123',
88
+ name: 'john',
89
+ category: 'admin'
90
+ });
91
+ });
92
+
93
+ it('gets specific parameter', () => {
94
+ expect(queryBuilder.get('id')).toBe('123');
95
+ expect(queryBuilder.get('name')).toBe('john');
96
+ });
97
+
98
+ it('handles custom query string input', () => {
99
+ const customQuery = 'foo=bar&baz=qux';
100
+ expect(queryBuilder.get('foo', customQuery)).toBe('bar');
101
+ expect(queryBuilder.all(customQuery)).toEqual({
102
+ foo: 'bar',
103
+ baz: 'qux'
104
+ });
105
+ });
106
+ });
@@ -0,0 +1,29 @@
1
+ const path = require('path');
2
+
3
+ module.exports = {
4
+ entry: './src/index.js',
5
+ output: {
6
+ filename: 'index.js',
7
+ path: path.resolve(__dirname, 'dist'),
8
+ library: {
9
+ name: 'HashtagCmsAdminSdk',
10
+ type: 'umd',
11
+ },
12
+ globalObject: 'this',
13
+ clean: true
14
+ },
15
+ module: {
16
+ rules: [
17
+ {
18
+ test: /\.js$/,
19
+ exclude: /node_modules/,
20
+ use: {
21
+ loader: 'babel-loader',
22
+ options: {
23
+ presets: ['@babel/preset-env']
24
+ }
25
+ }
26
+ }
27
+ ]
28
+ }
29
+ };