From 1c984dd8d6e4f80ac5dc5e1374561514b9ef06af Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Tue, 6 Dec 2022 10:27:59 +0100 Subject: [PATCH 01/43] Add new action to infer a tabular resource schema --- ckanext/validation/logic.py | 38 +++++++++++++++++++++++++++ ckanext/validation/plugin/__init__.py | 4 +++ 2 files changed, 42 insertions(+) diff --git a/ckanext/validation/logic.py b/ckanext/validation/logic.py index 213e4648..dbf7a320 100644 --- a/ckanext/validation/logic.py +++ b/ckanext/validation/logic.py @@ -5,6 +5,7 @@ import json from sqlalchemy.orm.exc import NoResultFound +from frictionless import system, Resource import ckan.plugins as plugins import ckan.lib.uploader as uploader @@ -174,6 +175,43 @@ def resource_validation_show(context, data_dict): return _validation_dictize(validation) +def resource_table_schema_infer(context, data_dict): + ''' + Use frictionless framework to infer a resource schema + ''' + + t.check_access('resource_create', context, data_dict) + + if not data_dict.get(u'resource_id'): + raise t.ValidationError({u'resource_id': u'Missing value'}) + + store_schema = data_dict.get('store_schema', True) + + resource = t.get_action('resource_show')( + {}, {u'id': data_dict['resource_id']}) + + source = None + if resource.get('url_type') == 'upload': + upload = uploader.get_resource_uploader(resource) + if isinstance(upload, uploader.ResourceUpload): + source = upload.get_path(resource['id']) + + if not source: + source = resource['url'] + + with system.use_context(trusted=True): + # TODO: check for valid formats + fric_resource = Resource({'path': source, 'format': resource.get('format', 'csv').lower()}) + fric_resource.infer() + resource['schema'] = fric_resource.schema.to_json() + + # TODO: check for exception + if store_schema: + t.get_action('resource_update')( + context, resource) + + return {u'schema': fric_resource.schema.to_dict()} + def resource_validation_delete(context, data_dict): u''' diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index d648709e..b9153ff5 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -6,6 +6,7 @@ from werkzeug.datastructures import FileStorage as FlaskFileStorage import ckan.plugins as p +import ckan.lib.uploader as uploader import ckantoolkit as t from ckanext.validation import settings @@ -17,6 +18,7 @@ auth_resource_validation_delete, auth_resource_validation_run_batch, resource_create as custom_resource_create, resource_update as custom_resource_update, + resource_table_schema_infer ) from ckanext.validation.helpers import ( get_validation_badge, @@ -34,6 +36,7 @@ get_create_mode_from_config, get_update_mode_from_config, ) + from ckanext.validation.interfaces import IDataValidation from ckanext.validation import blueprints, cli @@ -89,6 +92,7 @@ def get_actions(self): u'resource_validation_run_batch': resource_validation_run_batch, u'resource_create': custom_resource_create, u'resource_update': custom_resource_update, + u'resource_table_schema_infer': resource_table_schema_infer } return new_actions From 154d529de123f095b714ad23da46de7b4855b288 Mon Sep 17 00:00:00 2001 From: "Edgar Z. Alvarenga" Date: Tue, 6 Dec 2022 15:32:39 +0100 Subject: [PATCH 02/43] Update ckanext/validation/logic.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adrià Mercader --- ckanext/validation/logic.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ckanext/validation/logic.py b/ckanext/validation/logic.py index dbf7a320..abe41d1e 100644 --- a/ckanext/validation/logic.py +++ b/ckanext/validation/logic.py @@ -182,8 +182,7 @@ def resource_table_schema_infer(context, data_dict): t.check_access('resource_create', context, data_dict) - if not data_dict.get(u'resource_id'): - raise t.ValidationError({u'resource_id': u'Missing value'}) + toolkit.get_or_bust(data_dict, 'resource_id') store_schema = data_dict.get('store_schema', True) From 3b1773cfcfd45d9a9ab9f272cf86e4a2884e461f Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Tue, 6 Dec 2022 15:39:28 +0100 Subject: [PATCH 03/43] Remove coverage report --- .github/workflows/test.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1b0bf37..71593d04 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -58,9 +58,10 @@ jobs: run: | ckan -c test.ini db init - name: Run tests - run: pytest --ckan-ini=test.ini --cov=ckanext.validation --cov-report=xml --cov-append --disable-warnings ckanext/validation/tests -vv + # run: pytest --ckan-ini=test.ini --cov=ckanext.validation --cov-report=xml --cov-append --disable-warnings ckanext/validation/tests -vv + run: pytest --ckan-ini=test.ini --disable-warnings ckanext/validation/tests -vv - - name: Upload coverage report to codecov - uses: codecov/codecov-action@v1 - with: - file: ./coverage.xml + #- name: Upload coverage report to codecov + # uses: codecov/codecov-action@v1 + # with: + # file: ./coverage.xml From 670d8963861985e84b6003517325fed9dcd46fe6 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Tue, 6 Dec 2022 15:50:06 +0100 Subject: [PATCH 04/43] correct toolkit imported name --- ckanext/validation/logic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/validation/logic.py b/ckanext/validation/logic.py index abe41d1e..50a82762 100644 --- a/ckanext/validation/logic.py +++ b/ckanext/validation/logic.py @@ -182,7 +182,7 @@ def resource_table_schema_infer(context, data_dict): t.check_access('resource_create', context, data_dict) - toolkit.get_or_bust(data_dict, 'resource_id') + t.get_or_bust(data_dict, 'resource_id') store_schema = data_dict.get('store_schema', True) From 1dd1a8ae44b14a08fff7d6c58582ad3e8c67d3cc Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Fri, 9 Dec 2022 23:50:16 +0100 Subject: [PATCH 05/43] use new action endpoint with upload widget to create a resource --- ckanext/validation/logic.py | 78 ++++++++++++++++ ckanext/validation/plugin/__init__.py | 11 +-- .../package/snippets/resource_form.html | 89 +++++++++++++++++++ .../form_snippets/resource_schema.html | 2 +- .../webassets/css/ckan-uploader.css | 1 + .../validation/webassets/js/ckan-uploader.js | 3 + .../webassets/js/module-ckan-uploader.js | 40 +++++++++ .../webassets/js/module-resource-schema.js | 2 +- ckanext/validation/webassets/webassets.yml | 14 +++ 9 files changed, 233 insertions(+), 7 deletions(-) create mode 100644 ckanext/validation/templates/package/snippets/resource_form.html create mode 100644 ckanext/validation/webassets/css/ckan-uploader.css create mode 100644 ckanext/validation/webassets/js/ckan-uploader.js create mode 100644 ckanext/validation/webassets/js/module-ckan-uploader.js diff --git a/ckanext/validation/logic.py b/ckanext/validation/logic.py index 50a82762..bac2d720 100644 --- a/ckanext/validation/logic.py +++ b/ckanext/validation/logic.py @@ -456,6 +456,84 @@ def _validation_dictize(validation): return out +def resource_create_with_schema(context, data_dict): + '''Appends a new resource to a datasets list of resources. + ''' + + model = context['model'] + + package_id = t.get_or_bust(data_dict, 'package_id') + if not data_dict.get('url'): + data_dict['url'] = '' + + pkg_dict = t.get_action('package_show')( + dict(context, return_type='dict'), + {'id': package_id}) + + t.check_access('resource_create', context, data_dict) + + for plugin in plugins.PluginImplementations(plugins.IResourceController): + plugin.before_create(context, data_dict) + + if 'resources' not in pkg_dict: + pkg_dict['resources'] = [] + + upload = uploader.get_resource_uploader(data_dict) + + if 'mimetype' not in data_dict: + if hasattr(upload, 'mimetype'): + data_dict['mimetype'] = upload.mimetype + + if 'size' not in data_dict: + if hasattr(upload, 'filesize'): + data_dict['size'] = upload.filesize + + pkg_dict['resources'].append(data_dict) + + try: + context['defer_commit'] = True + context['use_cache'] = False + t.get_action('package_update')(context, pkg_dict) + context.pop('defer_commit') + except t.ValidationError as e: + try: + raise t.ValidationError(e.error_dict['resources'][-1]) + except (KeyError, IndexError): + raise t.ValidationError(e.error_dict) + + # Get out resource_id resource from model as it will not appear in + # package_show until after commit + resource_id = context['package'].resources[-1].id + upload.upload(resource_id, + uploader.get_max_resource_size()) + + model.repo.commit() + + update_resource = t.get_action('resource_table_schema_infer')( + context, {'resource_id': resource_id, 'store_schema': True} + ) + + # Run package show again to get out actual last_resource + updated_pkg_dict = t.get_action('package_show')( + context, {'id': package_id}) + resource = updated_pkg_dict['resources'][-1] + + # Add the default views to the new resource + t.get_action('resource_create_default_resource_views')( + {'model': context['model'], + 'user': context['user'], + 'ignore_auth': True + }, + {'resource': resource, + 'package': updated_pkg_dict + }) + + for plugin in plugins.PluginImplementations(plugins.IResourceController): + plugin.after_create(context, resource) + + return resource + + @t.chained_action def resource_create(up_func, context, data_dict): diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index b9153ff5..ec61cc4e 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -18,7 +18,8 @@ auth_resource_validation_delete, auth_resource_validation_run_batch, resource_create as custom_resource_create, resource_update as custom_resource_update, - resource_table_schema_infer + resource_table_schema_infer, + resource_create_with_schema ) from ckanext.validation.helpers import ( get_validation_badge, @@ -92,7 +93,8 @@ def get_actions(self): u'resource_validation_run_batch': resource_validation_run_batch, u'resource_create': custom_resource_create, u'resource_update': custom_resource_update, - u'resource_table_schema_infer': resource_table_schema_infer + u'resource_table_schema_infer': resource_table_schema_infer, + u'resource_create_with_schema': resource_create_with_schema } return new_actions @@ -141,13 +143,12 @@ def _process_schema_fields(self, data_dict): schema_upload = data_dict.pop(u'schema_upload', None) schema_url = data_dict.pop(u'schema_url', None) schema_json = data_dict.pop(u'schema_json', None) - if isinstance(schema_upload, ALLOWED_UPLOAD_TYPES): + if isinstance(schema_upload, ALLOWED_UPLOAD_TYPES) and schema_upload.content_length > 0: uploaded_file = _get_underlying_file(schema_upload) data_dict[u'schema'] = uploaded_file.read() if isinstance(data_dict["schema"], (bytes, bytearray)): data_dict["schema"] = data_dict["schema"].decode() - elif schema_url: - + elif schema_url != '' and schema_url != None: if (not isinstance(schema_url, str) or not schema_url.lower()[:4] == u'http'): raise t.ValidationError({u'schema_url': 'Must be a valid URL'}) diff --git a/ckanext/validation/templates/package/snippets/resource_form.html b/ckanext/validation/templates/package/snippets/resource_form.html new file mode 100644 index 00000000..8593303c --- /dev/null +++ b/ckanext/validation/templates/package/snippets/resource_form.html @@ -0,0 +1,89 @@ +{% import 'macros/form.html' as form %} + +{% set data = data or {} %} +{% set errors = errors or {} %} +{% set action = form_action or h.url_for(dataset_type ~ '_resource.new', id=pkg_name) %} +{% asset 'ckanext-validation/ckan-uploader-js' %} +{% asset 'ckanext-validation/ckan-uploader-css' %} + +
+ + {% block stages %} + {# An empty stages variable will not show the stages #} + {% if stage %} + {{ h.snippet('package/snippets/stages.html', stages=stage, pkg_name=pkg_name) }} + {% endif %} + {% endblock %} + + {% block errors %}{{ form.errors(error_summary) }}{% endblock %} + + +
+ +
+
+ {% block basic_fields %} + {% block basic_fields_url %} + {% endblock %} + + {% block basic_fields_name %} + {{ form.input('name', id='field-name', label=_('Name'), placeholder=_('eg. January 2011 Gold Prices'), value=data.name, error=errors.name, classes=['control-full']) }} + {% endblock %} + + {% block basic_fields_description %} + {{ form.markdown('description', id='field-description', label=_('Description'), placeholder=_('Some useful notes about the data'), value=data.description, error=errors.description) }} + {% endblock %} + + {% block basic_fields_format %} + {% set format_attrs = {'data-module': 'autocomplete', 'data-module-source': '/api/2/util/resource/format_autocomplete?incomplete=?'} %} + {% call form.input('format', id='field-format', label=_('Format'), placeholder=_('eg. CSV, XML or JSON'), value=data.format, error=errors.format, classes=['control-medium'], attrs=format_attrs) %} + + + {{ _('This will be guessed automatically. Leave blank if you wish') }} + + {% endcall %} + {% endblock %} + {% endblock basic_fields %} + + {% block metadata_fields %} + {% if include_metadata %} + {# TODO: Where do these come from, they don't exist in /package/new_package_form.html #} + {# {{ form.select('resource_type', id='field-type', label=_('Resource Type'), options=[{'value': 'empty', 'text': _('Select a type…')}], selected="empty", error=errors.type) }} #} + + {{ form.input('last_modified', id='field-last-modified', label=_('Last Modified'), placeholder=_('eg. 2012-06-05'), value=data.last_modified, error=errors.last_modified, classes=[]) }} + + {{ form.input('size', id='field-size', label=_('File Size'), placeholder=_('eg. 1024'), value=data.size, error=errors.size, classes=[]) }} + + {{ form.input('mimetype', id='field-mimetype', label=_('MIME Type'), placeholder=_('eg. application/json'), value=data.mimetype, error=errors.mimetype, classes=[]) }} + + {{ form.input('mimetype_inner', id='field-mimetype-inner', label=_('MIME Type'), placeholder=_('eg. application/json'), value=data.mimetype_inner, error=errors.mimetype_inner, classes=[]) }} + {% endif %} + {% endblock %} + +
+ {% block delete_button %} + {% if data.id %} + {% if h.check_access('resource_delete', {'id': data.id}) %} + {% block delete_button_text %}{{ _('Delete') }}{% endblock %} + {% endif %} + {% endif %} + {% endblock %} + {% if stage %} + {% block previous_button %} + + {% endblock %} + {% endif %} + {% block again_button %} + + {% endblock %} + {% if stage %} + {% block save_button %} + + {% endblock %} + {% else %} + {% block add_button %} + + {% endblock %} + {% endif %} +
+
diff --git a/ckanext/validation/templates/scheming/form_snippets/resource_schema.html b/ckanext/validation/templates/scheming/form_snippets/resource_schema.html index cf4f03cc..40f90928 100644 --- a/ckanext/validation/templates/scheming/form_snippets/resource_schema.html +++ b/ckanext/validation/templates/scheming/form_snippets/resource_schema.html @@ -1,7 +1,7 @@ {% import 'macros/form.html' as form %} {% set value = data[field.field_name] %} - {% set is_url = value and value[4:]|lower == 'http' %} + {% set is_url = value.__class__ == "" and value[4:]|lower == 'http' %} {% set is_json = not is_url and value %}
e.removeEventListener(t,n,r)}function O(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function mt(e){return Array.from(e.childNodes)}function yt(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function xe(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function bt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let M;function z(e){M=e}function Et(){if(!M)throw new Error("Function called outside component initialization");return M}function Ne(){const e=Et();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=bt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const I=[],oe=[],W=[],Ce=[],wt=Promise.resolve();let ie=!1;function _t(){ie||(ie=!0,wt.then(Pe))}function ae(e){W.push(e)}const ce=new Set;let v=0;function Pe(){const e=M;do{for(;v{K.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Rt(e){e&&e.c()}function ke(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||ae(()=>{const i=e.$$.on_mount.map(U).filter(Re);e.$$.on_destroy?e.$$.on_destroy.push(...i):H(i),e.$$.on_mount=[]}),o.forEach(ae)}function De(e,t){const n=e.$$;n.fragment!==null&&(H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function At(e,t){e.$$.dirty[0]===-1&&(I.push(e),_t(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=b.length?b[0]:y;return a.ctx&&s(a.ctx[d],a.ctx[d]=p)&&(!a.skip_bound&&a.bound[d]&&a.bound[d](p),l&&At(e,d)),y}):[],a.update(),l=!0,H(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const d=mt(t.target);a.fragment&&a.fragment.l(d),d.forEach(S)}else a.fragment&&a.fragment.c();t.intro&&Fe(e.$$.fragment),ke(e,t.target,t.anchor,t.customElement),Pe()}z(f)}class Ue{$destroy(){De(this,1),this.$destroy=g}$on(t,n){if(!Re(n))return g;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!pt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Vn="";function je(e,t){return function(){return e.apply(t,arguments)}}const{toString:Le}=Object.prototype,{getPrototypeOf:ue}=Object,le=(e=>t=>{const n=Le.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),T=e=>(e=e.toLowerCase(),t=>le(t)===e),X=e=>t=>typeof t===e,{isArray:j}=Array,$=X("undefined");function Tt(e){return e!==null&&!$(e)&&e.constructor!==null&&!$(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const He=T("ArrayBuffer");function xt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&He(e.buffer),t}const Nt=X("string"),B=X("function"),Me=X("number"),fe=e=>e!==null&&typeof e=="object",Ct=e=>e===!0||e===!1,G=e=>{if(le(e)!=="object")return!1;const t=ue(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Pt=T("Date"),Ft=T("File"),kt=T("Blob"),Dt=T("FileList"),Bt=e=>fe(e)&&B(e.pipe),Ut=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||Le.call(e)===t||B(e.toString)&&e.toString()===t)},jt=T("URLSearchParams"),Lt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function J(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),j(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Ie=typeof self>"u"?typeof global>"u"?globalThis:global:self,$e=e=>!$(e)&&e!==Ie;function de(){const{caseless:e}=$e(this)&&this||{},t={},n=(r,s)=>{const o=e&&ze(t,s)||s;G(t[o])&&G(r)?t[o]=de(t[o],r):G(r)?t[o]=de({},r):j(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(J(t,(s,o)=>{n&&B(s)?e[o]=je(s,n):e[o]=s},{allOwnKeys:r}),e),Mt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),zt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},It=(e,t,n,r)=>{let s,o,i;const u={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!u[i]&&(t[i]=e[i],u[i]=!0);e=n!==!1&&ue(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},$t=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Jt=e=>{if(!e)return null;if(j(e))return e;let t=e.length;if(!Me(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},qt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ue(Uint8Array)),Vt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},Wt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},vt=T("HTMLFormElement"),Kt=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Je=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Xt=T("RegExp"),qe=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};J(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},c={isArray:j,isArrayBuffer:He,isBuffer:Tt,isFormData:Ut,isArrayBufferView:xt,isString:Nt,isNumber:Me,isBoolean:Ct,isObject:fe,isPlainObject:G,isUndefined:$,isDate:Pt,isFile:Ft,isBlob:kt,isRegExp:Xt,isFunction:B,isStream:Bt,isURLSearchParams:jt,isTypedArray:qt,isFileList:Dt,forEach:J,merge:de,extend:Ht,trim:Lt,stripBOM:Mt,inherits:zt,toFlatObject:It,kindOf:le,kindOfTest:T,endsWith:$t,toArray:Jt,forEachEntry:Vt,matchAll:Wt,isHTMLForm:vt,hasOwnProperty:Je,hasOwnProp:Je,reduceDescriptors:qe,freezeMethods:e=>{qe(e,(t,n)=>{if(B(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!B(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return j(e)?r(e):r(String(e).split(t)),n},toCamelCase:Kt,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:ze,global:Ie,isContextDefined:$e,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(fe(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=j(r)?[]:{};return J(r,(i,u)=>{const f=n(i,s+1);!$(f)&&(o[u]=f)}),t[s]=void 0,o}}return r};return n(e,0)}};function m(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}c.inherits(m,Error,{toJSON:function(){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:c.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ve=m.prototype,We={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{We[e]={value:e}}),Object.defineProperties(m,We),Object.defineProperty(Ve,"isAxiosError",{value:!0}),m.from=(e,t,n,r,s,o)=>{const i=Object.create(Ve);return c.toFlatObject(e,i,function(f){return f!==Error.prototype},u=>u!=="isAxiosError"),m.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var Gt=typeof self=="object"?self.FormData:window.FormData;const Qt=Gt;function pe(e){return c.isPlainObject(e)||c.isArray(e)}function ve(e){return c.endsWith(e,"[]")?e.slice(0,-2):e}function Ke(e,t,n){return e?e.concat(t).map(function(s,o){return s=ve(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function Yt(e){return c.isArray(e)&&!e.some(pe)}const Zt=c.toFlatObject(c,{},null,function(t){return/^is[A-Z]/.test(t)});function en(e){return e&&c.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function Q(e,t,n){if(!c.isObject(e))throw new TypeError("target must be an object");t=t||new(Qt||FormData),n=c.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,_){return!c.isUndefined(_[h])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,f=(n.Blob||typeof Blob<"u"&&Blob)&&en(t);if(!c.isFunction(s))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(c.isDate(p))return p.toISOString();if(!f&&c.isBlob(p))throw new m("Blob is not supported. Use a Buffer instead.");return c.isArrayBuffer(p)||c.isTypedArray(p)?f&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function l(p,h,_){let E=p;if(p&&!_&&typeof p=="object"){if(c.endsWith(h,"{}"))h=r?h:h.slice(0,-2),p=JSON.stringify(p);else if(c.isArray(p)&&Yt(p)||c.isFileList(p)||c.endsWith(h,"[]")&&(E=c.toArray(p)))return h=ve(h),E.forEach(function(P,Oe){!(c.isUndefined(P)||P===null)&&t.append(i===!0?Ke([h],Oe,o):i===null?h:h+"[]",a(P))}),!1}return pe(p)?!0:(t.append(Ke(_,h,o),a(p)),!1)}const d=[],y=Object.assign(Zt,{defaultVisitor:l,convertValue:a,isVisitable:pe});function b(p,h){if(!c.isUndefined(p)){if(d.indexOf(p)!==-1)throw Error("Circular reference detected in "+h.join("."));d.push(p),c.forEach(p,function(E,N){(!(c.isUndefined(E)||E===null)&&s.call(t,E,c.isString(N)?N.trim():N,h,y))===!0&&b(E,h?h.concat(N):[N])}),d.pop()}}if(!c.isObject(e))throw new TypeError("data must be an object");return b(e),t}function Xe(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function he(e,t){this._pairs=[],e&&Q(e,this,t)}const Ge=he.prototype;Ge.append=function(t,n){this._pairs.push([t,n])},Ge.toString=function(t){const n=t?function(r){return t.call(this,r,Xe)}:Xe;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function tn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Qe(e,t,n){if(!t)return e;const r=n&&n.encode||tn,s=n&&n.serialize;let o;if(s?o=s(t,n):o=c.isURLSearchParams(t)?t.toString():new he(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class nn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){c.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ye=nn,Ze={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},rn=typeof URLSearchParams<"u"?URLSearchParams:he,sn=FormData,on=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),an=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),R={isBrowser:!0,classes:{URLSearchParams:rn,FormData:sn,Blob},isStandardBrowserEnv:on,isStandardBrowserWebWorkerEnv:an,protocols:["http","https","file","blob","url","data"]};function cn(e,t){return Q(e,new R.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return R.isNode&&c.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function un(e){return c.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function ln(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&c.isArray(s)?s.length:i,f?(c.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!u):((!s[i]||!c.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&c.isArray(s[i])&&(s[i]=ln(s[i])),!u)}if(c.isFormData(e)&&c.isFunction(e.entries)){const n={};return c.forEachEntry(e,(r,s)=>{t(un(r),s,n,0)}),n}return null}const fn={"Content-Type":void 0};function dn(e,t,n){if(c.isString(e))try{return(t||JSON.parse)(e),c.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Y={transitional:Ze,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=c.isObject(t);if(o&&c.isHTMLForm(t)&&(t=new FormData(t)),c.isFormData(t))return s&&s?JSON.stringify(et(t)):t;if(c.isArrayBuffer(t)||c.isBuffer(t)||c.isStream(t)||c.isFile(t)||c.isBlob(t))return t;if(c.isArrayBufferView(t))return t.buffer;if(c.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return cn(t,this.formSerializer).toString();if((u=c.isFileList(t))||r.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return Q(u?{"files[]":t}:t,f&&new f,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),dn(t)):t}],transformResponse:[function(t){const n=this.transitional||Y.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&c.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(u){if(i)throw u.name==="SyntaxError"?m.from(u,m.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:R.classes.FormData,Blob:R.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};c.forEach(["delete","get","head"],function(t){Y.headers[t]={}}),c.forEach(["post","put","patch"],function(t){Y.headers[t]=c.merge(fn)});const me=Y,pn=c.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"]),hn=e=>{const t={};let n,r,s;return e&&e.split(` +`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&pn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},tt=Symbol("internals");function q(e){return e&&String(e).trim().toLowerCase()}function Z(e){return e===!1||e==null?e:c.isArray(e)?e.map(Z):String(e)}function mn(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}function yn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function nt(e,t,n,r){if(c.isFunction(r))return r.call(this,t,n);if(!!c.isString(t)){if(c.isString(r))return t.indexOf(r)!==-1;if(c.isRegExp(r))return r.test(t)}}function bn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function En(e,t){const n=c.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class ee{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(u,f,a){const l=q(f);if(!l)throw new Error("header name must be a non-empty string");const d=c.findKey(s,l);(!d||s[d]===void 0||a===!0||a===void 0&&s[d]!==!1)&&(s[d||f]=Z(u))}const i=(u,f)=>c.forEach(u,(a,l)=>o(a,l,f));return c.isPlainObject(t)||t instanceof this.constructor?i(t,n):c.isString(t)&&(t=t.trim())&&!yn(t)?i(hn(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=q(t),t){const r=c.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return mn(s);if(c.isFunction(n))return n.call(this,s,r);if(c.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=q(t),t){const r=c.findKey(this,t);return!!(r&&(!n||nt(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=q(i),i){const u=c.findKey(r,i);u&&(!n||nt(r,r[u],u,n))&&(delete r[u],s=!0)}}return c.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return c.forEach(this,(s,o)=>{const i=c.findKey(r,o);if(i){n[i]=Z(s),delete n[o];return}const u=t?bn(o):String(o).trim();u!==o&&delete n[o],n[u]=Z(s),r[u]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return c.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&c.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[tt]=this[tt]={accessors:{}}).accessors,s=this.prototype;function o(i){const u=q(i);r[u]||(En(s,i),r[u]=!0)}return c.isArray(t)?t.forEach(o):o(t),this}}ee.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),c.freezeMethods(ee.prototype),c.freezeMethods(ee);const x=ee;function ye(e,t){const n=this||me,r=t||n,s=x.from(r.headers);let o=r.data;return c.forEach(e,function(u){o=u.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function rt(e){return!!(e&&e.__CANCEL__)}function V(e,t,n){m.call(this,e==null?"canceled":e,m.ERR_CANCELED,t,n),this.name="CanceledError"}c.inherits(V,m,{__CANCEL__:!0});const wn=null;function _n(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new m("Request failed with status code "+n.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const On=R.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,u){const f=[];f.push(n+"="+encodeURIComponent(r)),c.isNumber(s)&&f.push("expires="+new Date(s).toGMTString()),c.isString(o)&&f.push("path="+o),c.isString(i)&&f.push("domain="+i),u===!0&&f.push("secure"),document.cookie=f.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function gn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Sn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function st(e,t){return e&&!gn(t)?Sn(e,t):t}const Rn=R.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const u=c.isString(i)?s(i):i;return u.protocol===r.protocol&&u.host===r.host}}():function(){return function(){return!0}}();function An(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Tn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(f){const a=Date.now(),l=r[o];i||(i=a),n[s]=f,r[s]=a;let d=o,y=0;for(;d!==s;)y+=n[d++],d=d%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,u=o-n,f=r(u),a=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:u,rate:f||void 0,estimated:f&&i&&a?(i-o)/f:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const te={http:wn,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=x.from(e.headers).normalize(),i=e.responseType;let u;function f(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}c.isFormData(s)&&(R.isStandardBrowserEnv||R.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const b=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(b+":"+p))}const l=st(e.baseURL,e.url);a.open(e.method.toUpperCase(),Qe(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function d(){if(!a)return;const b=x.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),h={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:b,config:e,request:a};_n(function(E){n(E),f()},function(E){r(E),f()},h),a=null}if("onloadend"in a?a.onloadend=d:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(d)},a.onabort=function(){!a||(r(new m("Request aborted",m.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new m("Network Error",m.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const h=e.transitional||Ze;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new m(p,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,a)),a=null},R.isStandardBrowserEnv){const b=(e.withCredentials||Rn(l))&&e.xsrfCookieName&&On.read(e.xsrfCookieName);b&&o.set(e.xsrfHeaderName,b)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&c.forEach(o.toJSON(),function(p,h){a.setRequestHeader(h,p)}),c.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",ot(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",ot(e.onUploadProgress)),(e.cancelToken||e.signal)&&(u=b=>{!a||(r(!b||b.type?new V(null,e,a):b),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u)));const y=An(l);if(y&&R.protocols.indexOf(y)===-1){r(new m("Unsupported protocol "+y+":",m.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};c.forEach(te,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const xn={getAdapter:e=>{e=c.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof x?e.toJSON():e;function L(e,t){t=t||{};const n={};function r(a,l,d){return c.isPlainObject(a)&&c.isPlainObject(l)?c.merge.call({caseless:d},a,l):c.isPlainObject(l)?c.merge({},l):c.isArray(l)?l.slice():l}function s(a,l,d){if(c.isUndefined(l)){if(!c.isUndefined(a))return r(void 0,a,d)}else return r(a,l,d)}function o(a,l){if(!c.isUndefined(l))return r(void 0,l)}function i(a,l){if(c.isUndefined(l)){if(!c.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function u(a,l,d){if(d in t)return r(a,l);if(d in e)return r(void 0,a)}const f={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:u,headers:(a,l)=>s(at(a),at(l),!0)};return c.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const d=f[l]||s,y=d(e[l],t[l],l);c.isUndefined(y)&&d!==u||(n[l]=y)}),n}const ct="1.2.1",Ee={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ee[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const ut={};Ee.transitional=function(t,n,r){function s(o,i){return"[Axios v"+ct+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,u)=>{if(t===!1)throw new m(s(i," has been removed"+(n?" in "+n:"")),m.ERR_DEPRECATED);return n&&!ut[i]&&(ut[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,u):!0}};function Nn(e,t,n){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const u=e[o],f=u===void 0||i(u,o,e);if(f!==!0)throw new m("option "+o+" must be "+f,m.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new m("Unknown option "+o,m.ERR_BAD_OPTION)}}const we={assertOptions:Nn,validators:Ee},C=we.validators;class ne{constructor(t){this.defaults=t,this.interceptors={request:new Ye,response:new Ye}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=L(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&we.assertOptions(r,{silentJSONParsing:C.transitional(C.boolean),forcedJSONParsing:C.transitional(C.boolean),clarifyTimeoutError:C.transitional(C.boolean)},!1),s!==void 0&&we.assertOptions(s,{encode:C.function,serialize:C.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&c.merge(o.common,o[n.method]),i&&c.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=x.concat(i,o);const u=[];let f=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(f=f&&h.synchronous,u.unshift(h.fulfilled,h.rejected))});const a=[];this.interceptors.response.forEach(function(h){a.push(h.fulfilled,h.rejected)});let l,d=0,y;if(!f){const p=[it.bind(this),void 0];for(p.unshift.apply(p,u),p.push.apply(p,a),y=p.length,l=Promise.resolve(n);d{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(u=>{r.subscribe(u),o=u}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,u){r.reason||(r.reason=new V(o,i,u),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new _e(function(s){t=s}),cancel:t}}}const Cn=_e;function Pn(e){return function(n){return e.apply(null,n)}}function Fn(e){return c.isObject(e)&&e.isAxiosError===!0}function lt(e){const t=new re(e),n=je(re.prototype.request,t);return c.extend(n,re.prototype,t,{allOwnKeys:!0}),c.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return lt(L(e,s))},n}const w=lt(me);w.Axios=re,w.CanceledError=V,w.CancelToken=Cn,w.isCancel=rt,w.VERSION=ct,w.toFormData=Q,w.AxiosError=m,w.Cancel=w.CanceledError,w.all=function(t){return Promise.all(t)},w.spread=Pn,w.isAxiosError=Fn,w.mergeConfig=L,w.AxiosHeaders=x,w.formToJSON=e=>et(c.isHTMLForm(e)?new FormData(e):e),w.default=w;const kn=w,Zn="";function Dn(e){let t,n,r,s,o,i=`${e[1]}%`;function u(d,y){return d[3]?Un:jn}let f=u(e),a=f(e),l=e[4]&&dt();return{c(){t=k("div"),n=k("div"),a.c(),r=se(),l&&l.c(),s=se(),o=k("div"),O(n,"class","z-20"),O(o,"id","percentage-bar"),O(o,"class","ease-in duration-300 z-10 absolute top-0 left-0 bottom-0 bg-blue-800"),xe(o,"width",i),O(t,"id","percentage"),O(t,"class","w-full h-full text-center align-middle flex justify-center")},m(d,y){A(d,t,y),F(t,n),a.m(n,null),F(n,r),l&&l.m(n,null),F(t,s),F(t,o)},p(d,y){f===(f=u(d))&&a?a.p(d,y):(a.d(1),a=f(d),a&&(a.c(),a.m(n,r))),d[4]?l||(l=dt(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),y&2&&i!==(i=`${d[1]}%`)&&xe(o,"width",i)},d(d){d&&S(t),a.d(),l&&l.d()}}}function Bn(e){let t;return{c(){t=D("Select a file to upload")},m(n,r){A(n,t,r)},p:g,d(n){n&&S(t)}}}function Un(e){let t;return{c(){t=D("Waiting for data schema detection...")},m(n,r){A(n,t,r)},p:g,d(n){n&&S(t)}}}function jn(e){let t,n=!e[4]&&ft(e);return{c(){n&&n.c(),t=ht()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[4]?n&&(n.d(1),n=null):n?n.p(r,s):(n=ft(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&S(t)}}}function ft(e){let t,n;return{c(){t=D(e[1]),n=D("%")},m(r,s){A(r,t,s),A(r,n,s)},p(r,s){s&2&&yt(t,r[1])},d(r){r&&S(t),r&&S(n)}}}function dt(e){let t;return{c(){t=D("File uploaded")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Ln(e){let t,n,r,s,o,i;function u(l,d){return!l[2]&&!l[3]&&!l[4]?Bn:Dn}let f=u(e),a=f(e);return{c(){t=k("div"),n=k("div"),a.c(),r=se(),s=k("input"),O(n,"id","label"),O(n,"class","w-full h-full relative text-sky-100 place-content-center justify-center flex"),O(s,"id","fileUpload"),O(s,"type","file"),O(s,"class","svelte-1t8uy1e"),O(t,"id","fileUploadWidget"),O(t,"class","border-solid border-2 rounded border-sky-900 bg-sky-500 flex h-8 svelte-1t8uy1e")},m(l,d){A(l,t,d),F(t,n),a.m(n,null),F(t,r),F(t,s),o||(i=[Te(s,"change",e[8]),Te(s,"change",e[5])],o=!0)},p(l,[d]){f===(f=u(l))&&a?a.p(l,d):(a.d(1),a=f(l),a&&(a.c(),a.m(n,null)))},i:g,o:g,d(l){l&&S(t),a.d(),o=!1,H(i)}}}function Hn(e,t,n){let r,{upload_url:s}=t,{dataset_id:o}=t,i=0,u=!1,f=!1,a=!1,l=Ne();async function d(h,_){try{const E={onUploadProgress:P=>{const{loaded:Oe,total:qn}=P,ge=Math.floor(Oe*100/qn);ge<=100&&(_(ge),ge==100&&(n(2,u=!1),n(3,f=!0)))}},{data:N}=await kn.post(s+"/api/3/action/resource_create_with_schema",h,E);return N}catch(E){console.log("ERROR",E.message)}}function y(h){n(1,i=h)}async function b(h){try{const _=h.target.files[0],E=new FormData;E.append("upload",_),E.append("package_id",o),n(2,u=!0);let P={data:await d(E,y)};l("fileUploaded",P),n(3,f=!1),n(4,a=!0)}catch(_){console.log("ERROR",_),y(0)}}function p(){r=this.files,n(0,r)}return e.$$set=h=>{"upload_url"in h&&n(6,s=h.upload_url),"dataset_id"in h&&n(7,o=h.dataset_id)},[r,i,u,f,a,b,s,o,p]}class Mn extends Ue{constructor(t){super(),Be(this,t,Hn,Ln,Ae,{upload_url:6,dataset_id:7})}}function zn(e){let t,n,r;return n=new Mn({props:{upload_url:e[0],dataset_id:e[1]}}),n.$on("fileUploaded",e[3]),{c(){t=k("main"),Rt(n.$$.fragment),O(t,"class","tailwind")},m(s,o){A(s,t,o),ke(n,t,null),e[4](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),n.$set(i)},i(s){r||(Fe(n.$$.fragment,s),r=!0)},o(s){St(n.$$.fragment,s),r=!1},d(s){s&&S(t),De(n),e[4](null)}}}function In(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t;Ne();let o;function i(f){console.log(f),o.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:f.detail.data.result}))}function u(f){oe[f?"unshift":"push"](()=>{o=f,n(2,o)})}return e.$$set=f=>{"upload_url"in f&&n(0,r=f.upload_url),"dataset_id"in f&&n(1,s=f.dataset_id)},[r,s,o,i,u]}class $n extends Ue{constructor(t){super(),Be(this,t,In,zn,Ae,{upload_url:0,dataset_id:1})}}function Jn(e,t="",n=""){new $n({target:document.getElementById(e),props:{upload_url:t,dataset_id:n}})}return Jn}); diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js new file mode 100644 index 00000000..5e26d070 --- /dev/null +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -0,0 +1,40 @@ +"use strict"; + +ckan.module('ckan-uploader', function (jQuery) { + return { + options: { + upload_url: '', + dataset_id: '' + }, + afterUpload: (evt) => { + let resource = evt.detail + // Set name + let field_name = document.getElementById('field-name') + let url_parts = resource.url.split('/') + let resource_name = url_parts[url_parts.length - 1] + field_name.value = resource_name + + // Set mime type + let resource_type = document.getElementById('field-format') + jQuery('#field-format').select2("val", resource.format) + resource_type.value = resource.format + + // Set schema + let json_schema_field = document.getElementById('field-schema-json') + json_schema_field.value = JSON.stringify(resource.schema, null, 2) + let json_button = document.getElementById('open-json-button') + json_button.dispatchEvent(new Event('click')) + + // Set the form action to save the created resource + let resource_form = document.getElementById('resource-edit') + let current_action = resource_form.action + let lastIndexNew = current_action.lastIndexOf('new') + + resource_form.action = current_action.slice(0, lastIndexNew) + `${resource.id}/edit` + }, + initialize: function() { + CkanUploader('ckan_uploader', this.options.upload_url, this.options.dataset_id) + document.getElementById('ckan_uploader').addEventListener('fileUploaded', this.afterUpload) + } + } +}); diff --git a/ckanext/validation/webassets/js/module-resource-schema.js b/ckanext/validation/webassets/js/module-resource-schema.js index 2400b2e4..c7edfaca 100644 --- a/ckanext/validation/webassets/js/module-resource-schema.js +++ b/ckanext/validation/webassets/js/module-resource-schema.js @@ -81,7 +81,7 @@ ckan.module('resource-schema', function($) { $('.controls', this.buttons_div).append(this.button_url); // Button to set the field to be a JSON text - this.button_json = $('' + + this.button_json = $('' + '' + this._('JSON') + '') .prop('title', this._('Enter manually a Table Schema JSON object')) diff --git a/ckanext/validation/webassets/webassets.yml b/ckanext/validation/webassets/webassets.yml index a18bd9a0..e9c57885 100644 --- a/ckanext/validation/webassets/webassets.yml +++ b/ckanext/validation/webassets/webassets.yml @@ -44,4 +44,18 @@ report-css: contents: - vendor/frictionless-components/frictionless-components.min.css +ckan-uploader-js: + output: ckanext-validation/ckan-uploader.js + contents: + - js/ckan-uploader.js + - js/module-ckan-uploader.js + extra: + preload: + - base/main + + +ckan-uploader-css: + output: ckanext-validation/ckan-uploader.css + contents: + - css/ckan-uploader.css From 0f452637c3b871687c8983e76a67dcbf54082615 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Sat, 10 Dec 2022 19:21:12 +0100 Subject: [PATCH 06/43] remove default resource upload file field --- ckanext/validation/examples/ckan_default_schema.json | 5 ----- .../validation/templates/package/snippets/resource_form.html | 1 + ckanext/validation/webassets/js/module-ckan-uploader.js | 4 ++++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ckanext/validation/examples/ckan_default_schema.json b/ckanext/validation/examples/ckan_default_schema.json index 58b968ed..2c640118 100644 --- a/ckanext/validation/examples/ckan_default_schema.json +++ b/ckanext/validation/examples/ckan_default_schema.json @@ -83,11 +83,6 @@ } ], "resource_fields": [ - { - "field_name": "url", - "label": "URL", - "preset": "resource_url_upload" - }, { "field_name": "name", "label": "Name", diff --git a/ckanext/validation/templates/package/snippets/resource_form.html b/ckanext/validation/templates/package/snippets/resource_form.html index 8593303c..e0944f27 100644 --- a/ckanext/validation/templates/package/snippets/resource_form.html +++ b/ckanext/validation/templates/package/snippets/resource_form.html @@ -22,6 +22,7 @@
+ {% block basic_fields %} {% block basic_fields_url %} {% endblock %} diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js index 5e26d070..77704314 100644 --- a/ckanext/validation/webassets/js/module-ckan-uploader.js +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -30,6 +30,10 @@ ckan.module('ckan-uploader', function (jQuery) { let current_action = resource_form.action let lastIndexNew = current_action.lastIndexOf('new') + // Set URL + let url_field = document.getElementById('resource-url') + url_field.value = resource.url + resource_form.action = current_action.slice(0, lastIndexNew) + `${resource.id}/edit` }, initialize: function() { From 124a0f79b944e5d16d5b12b50b9e39e34ba0d8b8 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Mon, 12 Dec 2022 19:37:13 +0100 Subject: [PATCH 07/43] Update widget and logic to replace already existing resource files --- ckanext/validation/logic.py | 122 ++++++++++++++++++ ckanext/validation/plugin/__init__.py | 6 +- .../package/snippets/resource_form.html | 3 +- .../webassets/css/ckan-uploader.css | 2 +- .../validation/webassets/js/ckan-uploader.js | 6 +- .../webassets/js/module-ckan-uploader.js | 26 ++-- 6 files changed, 144 insertions(+), 21 deletions(-) diff --git a/ckanext/validation/logic.py b/ckanext/validation/logic.py index bac2d720..963a889f 100644 --- a/ckanext/validation/logic.py +++ b/ckanext/validation/logic.py @@ -493,6 +493,7 @@ def resource_create_with_schema(context, data_dict): try: context['defer_commit'] = True context['use_cache'] = False + pkg_dict['state'] = 'active' t.get_action('package_update')(context, pkg_dict) context.pop('defer_commit') except t.ValidationError as e: @@ -640,6 +641,127 @@ def resource_create(up_func, context, data_dict): return resource +def resource_update_with_schema(context, data_dict): + '''Update a resource. + + This is duplicate of the CKAN core resource_update action, with just the + addition of a synchronous data validation step. + + This is of course not ideal but it's the only way right now to hook + reliably into the creation process without overcomplicating things. + Hopefully future versions of CKAN will incorporate more flexible hook + points that will allow a better approach. + + ''' + + model = context['model'] + id = t.get_or_bust(data_dict, "id") + + if not data_dict.get('url'): + data_dict['url'] = '' + + resource = model.Resource.get(id) + context["resource"] = resource + old_resource_format = resource.format + + if not resource: + log.debug('Could not find resource %s', id) + raise t.ObjectNotFound(t._('Resource was not found.')) + + t.check_access('resource_update', context, data_dict) + del context["resource"] + + package_id = resource.package.id + pkg_dict = t.get_action('package_show')(dict(context, return_type='dict'), + {'id': package_id}) + + for n, p in enumerate(pkg_dict['resources']): + if p['id'] == id: + break + else: + log.error('Could not find resource %s after all', id) + raise t.ObjectNotFound(t._('Resource was not found.')) + + # Persist the datastore_active extra if already present and not provided + if ('datastore_active' in resource.extras and + 'datastore_active' not in data_dict): + data_dict['datastore_active'] = resource.extras['datastore_active'] + + for plugin in plugins.PluginImplementations(plugins.IResourceController): + plugin.before_update(context, pkg_dict['resources'][n], data_dict) + + upload = uploader.get_resource_uploader(data_dict) + + if 'mimetype' not in data_dict: + if hasattr(upload, 'mimetype'): + data_dict['mimetype'] = upload.mimetype + + if 'size' not in data_dict and 'url_type' in data_dict: + if hasattr(upload, 'filesize'): + data_dict['size'] = upload.filesize + + pkg_dict['resources'][n] = data_dict + + try: + context['defer_commit'] = True + context['use_cache'] = False + updated_pkg_dict = t.get_action('package_update')(context, pkg_dict) + context.pop('defer_commit') + except t.ValidationError as e: + try: + raise t.ValidationError(e.error_dict['resources'][-1]) + except (KeyError, IndexError): + raise t.ValidationError(e.error_dict) + + upload.upload(id, uploader.get_max_resource_size()) + + update_resource = t.get_action('resource_table_schema_infer')( + context, {'resource_id': resource.id, 'store_schema': True} + ) + + # Run package show again to get out actual last_resource + updated_pkg_dict = t.get_action('package_show')( + context, {'id': package_id}) + resource = updated_pkg_dict['resources'][-1] + + # Custom code starts + + run_validation = True + for plugin in plugins.PluginImplementations(IDataValidation): + if not plugin.can_validate(context, data_dict): + log.debug('Skipping validation for resource {}'.format(id)) + run_validation = False + + if run_validation: + run_validation = not data_dict.pop('_skip_next_validation', None) + + if run_validation: + is_local_upload = ( + hasattr(upload, 'filename') and + upload.filename is not None and + isinstance(upload, uploader.ResourceUpload)) + _run_sync_validation( + id, local_upload=is_local_upload, new_resource=False) + + # Custom code ends + + model.repo.commit() + + resource = t.get_action('resource_show')(context, {'id': id}) + + if old_resource_format != resource['format']: + t.get_action('resource_create_default_resource_views')( + {'model': context['model'], 'user': context['user'], + 'ignore_auth': True}, + {'package': updated_pkg_dict, + 'resource': resource}) + + for plugin in plugins.PluginImplementations(plugins.IResourceController): + plugin.after_update(context, resource) + + return resource + + @t.chained_action def resource_update(up_func, context, data_dict): diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index ec61cc4e..fdf6c982 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -19,7 +19,8 @@ resource_create as custom_resource_create, resource_update as custom_resource_update, resource_table_schema_infer, - resource_create_with_schema + resource_create_with_schema, + resource_update_with_schema, ) from ckanext.validation.helpers import ( get_validation_badge, @@ -94,7 +95,8 @@ def get_actions(self): u'resource_create': custom_resource_create, u'resource_update': custom_resource_update, u'resource_table_schema_infer': resource_table_schema_infer, - u'resource_create_with_schema': resource_create_with_schema + u'resource_create_with_schema': resource_create_with_schema, + u'resource_update_with_schema': resource_update_with_schema } return new_actions diff --git a/ckanext/validation/templates/package/snippets/resource_form.html b/ckanext/validation/templates/package/snippets/resource_form.html index e0944f27..9129189e 100644 --- a/ckanext/validation/templates/package/snippets/resource_form.html +++ b/ckanext/validation/templates/package/snippets/resource_form.html @@ -20,9 +20,8 @@
-
+
- {% block basic_fields %} {% block basic_fields_url %} {% endblock %} diff --git a/ckanext/validation/webassets/css/ckan-uploader.css b/ckanext/validation/webassets/css/ckan-uploader.css index e66e6224..fdd8635a 100644 --- a/ckanext/validation/webassets/css/ckan-uploader.css +++ b/ckanext/validation/webassets/css/ckan-uploader.css @@ -1 +1 @@ -.tailwind *,.tailwind :before,.tailwind :after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}.tailwind :before,.tailwind :after{--tw-content: ""}.tailwind html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal}.tailwind body{margin:0;line-height:inherit}.tailwind hr{height:0;color:inherit;border-top-width:1px}.tailwind abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6{font-size:inherit;font-weight:inherit}.tailwind a{color:inherit;text-decoration:inherit}.tailwind b,.tailwind strong{font-weight:bolder}.tailwind code,.tailwind kbd,.tailwind samp,.tailwind pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}.tailwind small{font-size:80%}.tailwind sub,.tailwind sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.tailwind sub{bottom:-.25em}.tailwind sup{top:-.5em}.tailwind table{text-indent:0;border-color:inherit;border-collapse:collapse}.tailwind button,.tailwind input,.tailwind optgroup,.tailwind select,.tailwind textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}.tailwind button,.tailwind select{text-transform:none}.tailwind button,.tailwind [type=button],.tailwind [type=reset],.tailwind [type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}.tailwind :-moz-focusring{outline:auto}.tailwind :-moz-ui-invalid{box-shadow:none}.tailwind progress{vertical-align:baseline}.tailwind ::-webkit-inner-spin-button,.tailwind ::-webkit-outer-spin-button{height:auto}.tailwind [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.tailwind ::-webkit-search-decoration{-webkit-appearance:none}.tailwind ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.tailwind summary{display:list-item}.tailwind blockquote,.tailwind dl,.tailwind dd,.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6,.tailwind hr,.tailwind figure,.tailwind p,.tailwind pre{margin:0}.tailwind fieldset{margin:0;padding:0}.tailwind legend{padding:0}.tailwind ol,.tailwind ul,.tailwind menu{list-style:none;margin:0;padding:0}.tailwind textarea{resize:vertical}.tailwind input::-moz-placeholder,.tailwind textarea::-moz-placeholder{opacity:1;color:#9ca3af}.tailwind input::placeholder,.tailwind textarea::placeholder{opacity:1;color:#9ca3af}.tailwind button,.tailwind [role=button]{cursor:pointer}.tailwind :disabled{cursor:default}.tailwind img,.tailwind svg,.tailwind video,.tailwind canvas,.tailwind audio,.tailwind iframe,.tailwind embed,.tailwind object{display:block;vertical-align:middle}.tailwind img,.tailwind video{max-width:100%;height:auto}.tailwind [hidden]{display:none}.tailwind *,.tailwind :before,.tailwind :after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind ::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind .absolute{position:absolute}.tailwind .relative{position:relative}.tailwind .top-0{top:0px}.tailwind .left-0{left:0px}.tailwind .bottom-0{bottom:0px}.tailwind .z-20{z-index:20}.tailwind .z-10{z-index:10}.tailwind .flex{display:flex}.tailwind .h-8{height:2rem}.tailwind .h-full{height:100%}.tailwind .w-full{width:100%}.tailwind .place-content-center{place-content:center}.tailwind .justify-center{justify-content:center}.tailwind .rounded{border-radius:.25rem}.tailwind .border-2{border-width:2px}.tailwind .border-solid{border-style:solid}.tailwind .border-sky-900{--tw-border-opacity: 1;border-color:rgb(12 74 110 / var(--tw-border-opacity))}.tailwind .bg-sky-500{--tw-bg-opacity: 1;background-color:rgb(14 165 233 / var(--tw-bg-opacity))}.tailwind .bg-blue-800{--tw-bg-opacity: 1;background-color:rgb(30 64 175 / var(--tw-bg-opacity))}.tailwind .text-center{text-align:center}.tailwind .align-middle{vertical-align:middle}.tailwind .text-sky-100{--tw-text-opacity: 1;color:rgb(224 242 254 / var(--tw-text-opacity))}.tailwind .duration-300{transition-duration:.3s}.tailwind .ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}#fileUploadWidget.svelte-1t8uy1e{position:relative;display:flex;max-width:300px}#fileUpload.svelte-1t8uy1e{position:absolute;width:100%;height:100%;top:0;left:0;opacity:0} +.tailwind *,.tailwind :before,.tailwind :after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}.tailwind :before,.tailwind :after{--tw-content: ""}.tailwind html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal}.tailwind body{margin:0;line-height:inherit}.tailwind hr{height:0;color:inherit;border-top-width:1px}.tailwind abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6{font-size:inherit;font-weight:inherit}.tailwind a{color:inherit;text-decoration:inherit}.tailwind b,.tailwind strong{font-weight:bolder}.tailwind code,.tailwind kbd,.tailwind samp,.tailwind pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}.tailwind small{font-size:80%}.tailwind sub,.tailwind sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.tailwind sub{bottom:-.25em}.tailwind sup{top:-.5em}.tailwind table{text-indent:0;border-color:inherit;border-collapse:collapse}.tailwind button,.tailwind input,.tailwind optgroup,.tailwind select,.tailwind textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}.tailwind button,.tailwind select{text-transform:none}.tailwind button,.tailwind [type=button],.tailwind [type=reset],.tailwind [type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}.tailwind :-moz-focusring{outline:auto}.tailwind :-moz-ui-invalid{box-shadow:none}.tailwind progress{vertical-align:baseline}.tailwind ::-webkit-inner-spin-button,.tailwind ::-webkit-outer-spin-button{height:auto}.tailwind [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.tailwind ::-webkit-search-decoration{-webkit-appearance:none}.tailwind ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.tailwind summary{display:list-item}.tailwind blockquote,.tailwind dl,.tailwind dd,.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6,.tailwind hr,.tailwind figure,.tailwind p,.tailwind pre{margin:0}.tailwind fieldset{margin:0;padding:0}.tailwind legend{padding:0}.tailwind ol,.tailwind ul,.tailwind menu{list-style:none;margin:0;padding:0}.tailwind textarea{resize:vertical}.tailwind input::-moz-placeholder,.tailwind textarea::-moz-placeholder{opacity:1;color:#9ca3af}.tailwind input::placeholder,.tailwind textarea::placeholder{opacity:1;color:#9ca3af}.tailwind button,.tailwind [role=button]{cursor:pointer}.tailwind :disabled{cursor:default}.tailwind img,.tailwind svg,.tailwind video,.tailwind canvas,.tailwind audio,.tailwind iframe,.tailwind embed,.tailwind object{display:block;vertical-align:middle}.tailwind img,.tailwind video{max-width:100%;height:auto}.tailwind [hidden]{display:none}.tailwind *,.tailwind :before,.tailwind :after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind ::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind .absolute{position:absolute}.tailwind .relative{position:relative}.tailwind .top-0{top:0px}.tailwind .left-0{left:0px}.tailwind .bottom-0{bottom:0px}.tailwind .z-20{z-index:20}.tailwind .z-10{z-index:10}.tailwind .flex{display:flex}.tailwind .hidden{display:none}.tailwind .h-8{height:2rem}.tailwind .h-full{height:100%}.tailwind .w-full{width:100%}.tailwind .place-content-center{place-content:center}.tailwind .justify-center{justify-content:center}.tailwind .rounded{border-radius:.25rem}.tailwind .border-2{border-width:2px}.tailwind .border-solid{border-style:solid}.tailwind .border-sky-900{--tw-border-opacity: 1;border-color:rgb(12 74 110 / var(--tw-border-opacity))}.tailwind .bg-sky-500{--tw-bg-opacity: 1;background-color:rgb(14 165 233 / var(--tw-bg-opacity))}.tailwind .bg-blue-800{--tw-bg-opacity: 1;background-color:rgb(30 64 175 / var(--tw-bg-opacity))}.tailwind .pt-4{padding-top:1rem}.tailwind .text-center{text-align:center}.tailwind .align-middle{vertical-align:middle}.tailwind .text-sky-100{--tw-text-opacity: 1;color:rgb(224 242 254 / var(--tw-text-opacity))}.tailwind .duration-300{transition-duration:.3s}.tailwind .ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}#fileUploadWidget.svelte-11h4gxn{position:relative;display:flex;max-width:400px}#fileUpload.svelte-11h4gxn{position:absolute;width:100%;height:100%;top:0;left:0;opacity:0} diff --git a/ckanext/validation/webassets/js/ckan-uploader.js b/ckanext/validation/webassets/js/ckan-uploader.js index 7be1f7e5..c556c7b3 100644 --- a/ckanext/validation/webassets/js/ckan-uploader.js +++ b/ckanext/validation/webassets/js/ckan-uploader.js @@ -1,3 +1,3 @@ -(function(g,U){typeof exports=="object"&&typeof module<"u"?module.exports=U():typeof define=="function"&&define.amd?define(U):(g=typeof globalThis<"u"?globalThis:g||self,g.CkanUploader=U())})(this,function(){"use strict";function g(){}function U(e){return e()}function Se(){return Object.create(null)}function H(e){e.forEach(U)}function Re(e){return typeof e=="function"}function Ae(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function pt(e){return Object.keys(e).length===0}function F(e,t){e.appendChild(t)}function A(e,t,n){e.insertBefore(t,n||null)}function S(e){e.parentNode&&e.parentNode.removeChild(e)}function k(e){return document.createElement(e)}function D(e){return document.createTextNode(e)}function se(){return D(" ")}function ht(){return D("")}function Te(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function O(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function mt(e){return Array.from(e.childNodes)}function yt(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function xe(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function bt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let M;function z(e){M=e}function Et(){if(!M)throw new Error("Function called outside component initialization");return M}function Ne(){const e=Et();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=bt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const I=[],oe=[],W=[],Ce=[],wt=Promise.resolve();let ie=!1;function _t(){ie||(ie=!0,wt.then(Pe))}function ae(e){W.push(e)}const ce=new Set;let v=0;function Pe(){const e=M;do{for(;v{K.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Rt(e){e&&e.c()}function ke(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||ae(()=>{const i=e.$$.on_mount.map(U).filter(Re);e.$$.on_destroy?e.$$.on_destroy.push(...i):H(i),e.$$.on_mount=[]}),o.forEach(ae)}function De(e,t){const n=e.$$;n.fragment!==null&&(H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function At(e,t){e.$$.dirty[0]===-1&&(I.push(e),_t(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=b.length?b[0]:y;return a.ctx&&s(a.ctx[d],a.ctx[d]=p)&&(!a.skip_bound&&a.bound[d]&&a.bound[d](p),l&&At(e,d)),y}):[],a.update(),l=!0,H(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const d=mt(t.target);a.fragment&&a.fragment.l(d),d.forEach(S)}else a.fragment&&a.fragment.c();t.intro&&Fe(e.$$.fragment),ke(e,t.target,t.anchor,t.customElement),Pe()}z(f)}class Ue{$destroy(){De(this,1),this.$destroy=g}$on(t,n){if(!Re(n))return g;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!pt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Vn="";function je(e,t){return function(){return e.apply(t,arguments)}}const{toString:Le}=Object.prototype,{getPrototypeOf:ue}=Object,le=(e=>t=>{const n=Le.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),T=e=>(e=e.toLowerCase(),t=>le(t)===e),X=e=>t=>typeof t===e,{isArray:j}=Array,$=X("undefined");function Tt(e){return e!==null&&!$(e)&&e.constructor!==null&&!$(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const He=T("ArrayBuffer");function xt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&He(e.buffer),t}const Nt=X("string"),B=X("function"),Me=X("number"),fe=e=>e!==null&&typeof e=="object",Ct=e=>e===!0||e===!1,G=e=>{if(le(e)!=="object")return!1;const t=ue(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Pt=T("Date"),Ft=T("File"),kt=T("Blob"),Dt=T("FileList"),Bt=e=>fe(e)&&B(e.pipe),Ut=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||Le.call(e)===t||B(e.toString)&&e.toString()===t)},jt=T("URLSearchParams"),Lt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function J(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),j(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Ie=typeof self>"u"?typeof global>"u"?globalThis:global:self,$e=e=>!$(e)&&e!==Ie;function de(){const{caseless:e}=$e(this)&&this||{},t={},n=(r,s)=>{const o=e&&ze(t,s)||s;G(t[o])&&G(r)?t[o]=de(t[o],r):G(r)?t[o]=de({},r):j(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(J(t,(s,o)=>{n&&B(s)?e[o]=je(s,n):e[o]=s},{allOwnKeys:r}),e),Mt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),zt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},It=(e,t,n,r)=>{let s,o,i;const u={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!u[i]&&(t[i]=e[i],u[i]=!0);e=n!==!1&&ue(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},$t=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Jt=e=>{if(!e)return null;if(j(e))return e;let t=e.length;if(!Me(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},qt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ue(Uint8Array)),Vt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},Wt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},vt=T("HTMLFormElement"),Kt=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Je=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Xt=T("RegExp"),qe=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};J(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},c={isArray:j,isArrayBuffer:He,isBuffer:Tt,isFormData:Ut,isArrayBufferView:xt,isString:Nt,isNumber:Me,isBoolean:Ct,isObject:fe,isPlainObject:G,isUndefined:$,isDate:Pt,isFile:Ft,isBlob:kt,isRegExp:Xt,isFunction:B,isStream:Bt,isURLSearchParams:jt,isTypedArray:qt,isFileList:Dt,forEach:J,merge:de,extend:Ht,trim:Lt,stripBOM:Mt,inherits:zt,toFlatObject:It,kindOf:le,kindOfTest:T,endsWith:$t,toArray:Jt,forEachEntry:Vt,matchAll:Wt,isHTMLForm:vt,hasOwnProperty:Je,hasOwnProp:Je,reduceDescriptors:qe,freezeMethods:e=>{qe(e,(t,n)=>{if(B(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!B(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return j(e)?r(e):r(String(e).split(t)),n},toCamelCase:Kt,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:ze,global:Ie,isContextDefined:$e,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(fe(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=j(r)?[]:{};return J(r,(i,u)=>{const f=n(i,s+1);!$(f)&&(o[u]=f)}),t[s]=void 0,o}}return r};return n(e,0)}};function m(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}c.inherits(m,Error,{toJSON:function(){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:c.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ve=m.prototype,We={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{We[e]={value:e}}),Object.defineProperties(m,We),Object.defineProperty(Ve,"isAxiosError",{value:!0}),m.from=(e,t,n,r,s,o)=>{const i=Object.create(Ve);return c.toFlatObject(e,i,function(f){return f!==Error.prototype},u=>u!=="isAxiosError"),m.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var Gt=typeof self=="object"?self.FormData:window.FormData;const Qt=Gt;function pe(e){return c.isPlainObject(e)||c.isArray(e)}function ve(e){return c.endsWith(e,"[]")?e.slice(0,-2):e}function Ke(e,t,n){return e?e.concat(t).map(function(s,o){return s=ve(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function Yt(e){return c.isArray(e)&&!e.some(pe)}const Zt=c.toFlatObject(c,{},null,function(t){return/^is[A-Z]/.test(t)});function en(e){return e&&c.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function Q(e,t,n){if(!c.isObject(e))throw new TypeError("target must be an object");t=t||new(Qt||FormData),n=c.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,_){return!c.isUndefined(_[h])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,f=(n.Blob||typeof Blob<"u"&&Blob)&&en(t);if(!c.isFunction(s))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(c.isDate(p))return p.toISOString();if(!f&&c.isBlob(p))throw new m("Blob is not supported. Use a Buffer instead.");return c.isArrayBuffer(p)||c.isTypedArray(p)?f&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function l(p,h,_){let E=p;if(p&&!_&&typeof p=="object"){if(c.endsWith(h,"{}"))h=r?h:h.slice(0,-2),p=JSON.stringify(p);else if(c.isArray(p)&&Yt(p)||c.isFileList(p)||c.endsWith(h,"[]")&&(E=c.toArray(p)))return h=ve(h),E.forEach(function(P,Oe){!(c.isUndefined(P)||P===null)&&t.append(i===!0?Ke([h],Oe,o):i===null?h:h+"[]",a(P))}),!1}return pe(p)?!0:(t.append(Ke(_,h,o),a(p)),!1)}const d=[],y=Object.assign(Zt,{defaultVisitor:l,convertValue:a,isVisitable:pe});function b(p,h){if(!c.isUndefined(p)){if(d.indexOf(p)!==-1)throw Error("Circular reference detected in "+h.join("."));d.push(p),c.forEach(p,function(E,N){(!(c.isUndefined(E)||E===null)&&s.call(t,E,c.isString(N)?N.trim():N,h,y))===!0&&b(E,h?h.concat(N):[N])}),d.pop()}}if(!c.isObject(e))throw new TypeError("data must be an object");return b(e),t}function Xe(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function he(e,t){this._pairs=[],e&&Q(e,this,t)}const Ge=he.prototype;Ge.append=function(t,n){this._pairs.push([t,n])},Ge.toString=function(t){const n=t?function(r){return t.call(this,r,Xe)}:Xe;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function tn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Qe(e,t,n){if(!t)return e;const r=n&&n.encode||tn,s=n&&n.serialize;let o;if(s?o=s(t,n):o=c.isURLSearchParams(t)?t.toString():new he(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class nn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){c.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ye=nn,Ze={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},rn=typeof URLSearchParams<"u"?URLSearchParams:he,sn=FormData,on=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),an=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),R={isBrowser:!0,classes:{URLSearchParams:rn,FormData:sn,Blob},isStandardBrowserEnv:on,isStandardBrowserWebWorkerEnv:an,protocols:["http","https","file","blob","url","data"]};function cn(e,t){return Q(e,new R.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return R.isNode&&c.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function un(e){return c.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function ln(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&c.isArray(s)?s.length:i,f?(c.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!u):((!s[i]||!c.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&c.isArray(s[i])&&(s[i]=ln(s[i])),!u)}if(c.isFormData(e)&&c.isFunction(e.entries)){const n={};return c.forEachEntry(e,(r,s)=>{t(un(r),s,n,0)}),n}return null}const fn={"Content-Type":void 0};function dn(e,t,n){if(c.isString(e))try{return(t||JSON.parse)(e),c.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Y={transitional:Ze,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=c.isObject(t);if(o&&c.isHTMLForm(t)&&(t=new FormData(t)),c.isFormData(t))return s&&s?JSON.stringify(et(t)):t;if(c.isArrayBuffer(t)||c.isBuffer(t)||c.isStream(t)||c.isFile(t)||c.isBlob(t))return t;if(c.isArrayBufferView(t))return t.buffer;if(c.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return cn(t,this.formSerializer).toString();if((u=c.isFileList(t))||r.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return Q(u?{"files[]":t}:t,f&&new f,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),dn(t)):t}],transformResponse:[function(t){const n=this.transitional||Y.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&c.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(u){if(i)throw u.name==="SyntaxError"?m.from(u,m.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:R.classes.FormData,Blob:R.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};c.forEach(["delete","get","head"],function(t){Y.headers[t]={}}),c.forEach(["post","put","patch"],function(t){Y.headers[t]=c.merge(fn)});const me=Y,pn=c.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"]),hn=e=>{const t={};let n,r,s;return e&&e.split(` -`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&pn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},tt=Symbol("internals");function q(e){return e&&String(e).trim().toLowerCase()}function Z(e){return e===!1||e==null?e:c.isArray(e)?e.map(Z):String(e)}function mn(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}function yn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function nt(e,t,n,r){if(c.isFunction(r))return r.call(this,t,n);if(!!c.isString(t)){if(c.isString(r))return t.indexOf(r)!==-1;if(c.isRegExp(r))return r.test(t)}}function bn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function En(e,t){const n=c.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class ee{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(u,f,a){const l=q(f);if(!l)throw new Error("header name must be a non-empty string");const d=c.findKey(s,l);(!d||s[d]===void 0||a===!0||a===void 0&&s[d]!==!1)&&(s[d||f]=Z(u))}const i=(u,f)=>c.forEach(u,(a,l)=>o(a,l,f));return c.isPlainObject(t)||t instanceof this.constructor?i(t,n):c.isString(t)&&(t=t.trim())&&!yn(t)?i(hn(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=q(t),t){const r=c.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return mn(s);if(c.isFunction(n))return n.call(this,s,r);if(c.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=q(t),t){const r=c.findKey(this,t);return!!(r&&(!n||nt(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=q(i),i){const u=c.findKey(r,i);u&&(!n||nt(r,r[u],u,n))&&(delete r[u],s=!0)}}return c.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return c.forEach(this,(s,o)=>{const i=c.findKey(r,o);if(i){n[i]=Z(s),delete n[o];return}const u=t?bn(o):String(o).trim();u!==o&&delete n[o],n[u]=Z(s),r[u]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return c.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&c.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[tt]=this[tt]={accessors:{}}).accessors,s=this.prototype;function o(i){const u=q(i);r[u]||(En(s,i),r[u]=!0)}return c.isArray(t)?t.forEach(o):o(t),this}}ee.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),c.freezeMethods(ee.prototype),c.freezeMethods(ee);const x=ee;function ye(e,t){const n=this||me,r=t||n,s=x.from(r.headers);let o=r.data;return c.forEach(e,function(u){o=u.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function rt(e){return!!(e&&e.__CANCEL__)}function V(e,t,n){m.call(this,e==null?"canceled":e,m.ERR_CANCELED,t,n),this.name="CanceledError"}c.inherits(V,m,{__CANCEL__:!0});const wn=null;function _n(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new m("Request failed with status code "+n.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const On=R.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,u){const f=[];f.push(n+"="+encodeURIComponent(r)),c.isNumber(s)&&f.push("expires="+new Date(s).toGMTString()),c.isString(o)&&f.push("path="+o),c.isString(i)&&f.push("domain="+i),u===!0&&f.push("secure"),document.cookie=f.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function gn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Sn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function st(e,t){return e&&!gn(t)?Sn(e,t):t}const Rn=R.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const u=c.isString(i)?s(i):i;return u.protocol===r.protocol&&u.host===r.host}}():function(){return function(){return!0}}();function An(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Tn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(f){const a=Date.now(),l=r[o];i||(i=a),n[s]=f,r[s]=a;let d=o,y=0;for(;d!==s;)y+=n[d++],d=d%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,u=o-n,f=r(u),a=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:u,rate:f||void 0,estimated:f&&i&&a?(i-o)/f:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const te={http:wn,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=x.from(e.headers).normalize(),i=e.responseType;let u;function f(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}c.isFormData(s)&&(R.isStandardBrowserEnv||R.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const b=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(b+":"+p))}const l=st(e.baseURL,e.url);a.open(e.method.toUpperCase(),Qe(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function d(){if(!a)return;const b=x.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),h={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:b,config:e,request:a};_n(function(E){n(E),f()},function(E){r(E),f()},h),a=null}if("onloadend"in a?a.onloadend=d:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(d)},a.onabort=function(){!a||(r(new m("Request aborted",m.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new m("Network Error",m.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const h=e.transitional||Ze;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new m(p,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,a)),a=null},R.isStandardBrowserEnv){const b=(e.withCredentials||Rn(l))&&e.xsrfCookieName&&On.read(e.xsrfCookieName);b&&o.set(e.xsrfHeaderName,b)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&c.forEach(o.toJSON(),function(p,h){a.setRequestHeader(h,p)}),c.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",ot(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",ot(e.onUploadProgress)),(e.cancelToken||e.signal)&&(u=b=>{!a||(r(!b||b.type?new V(null,e,a):b),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u)));const y=An(l);if(y&&R.protocols.indexOf(y)===-1){r(new m("Unsupported protocol "+y+":",m.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};c.forEach(te,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const xn={getAdapter:e=>{e=c.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof x?e.toJSON():e;function L(e,t){t=t||{};const n={};function r(a,l,d){return c.isPlainObject(a)&&c.isPlainObject(l)?c.merge.call({caseless:d},a,l):c.isPlainObject(l)?c.merge({},l):c.isArray(l)?l.slice():l}function s(a,l,d){if(c.isUndefined(l)){if(!c.isUndefined(a))return r(void 0,a,d)}else return r(a,l,d)}function o(a,l){if(!c.isUndefined(l))return r(void 0,l)}function i(a,l){if(c.isUndefined(l)){if(!c.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function u(a,l,d){if(d in t)return r(a,l);if(d in e)return r(void 0,a)}const f={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:u,headers:(a,l)=>s(at(a),at(l),!0)};return c.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const d=f[l]||s,y=d(e[l],t[l],l);c.isUndefined(y)&&d!==u||(n[l]=y)}),n}const ct="1.2.1",Ee={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ee[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const ut={};Ee.transitional=function(t,n,r){function s(o,i){return"[Axios v"+ct+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,u)=>{if(t===!1)throw new m(s(i," has been removed"+(n?" in "+n:"")),m.ERR_DEPRECATED);return n&&!ut[i]&&(ut[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,u):!0}};function Nn(e,t,n){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const u=e[o],f=u===void 0||i(u,o,e);if(f!==!0)throw new m("option "+o+" must be "+f,m.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new m("Unknown option "+o,m.ERR_BAD_OPTION)}}const we={assertOptions:Nn,validators:Ee},C=we.validators;class ne{constructor(t){this.defaults=t,this.interceptors={request:new Ye,response:new Ye}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=L(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&we.assertOptions(r,{silentJSONParsing:C.transitional(C.boolean),forcedJSONParsing:C.transitional(C.boolean),clarifyTimeoutError:C.transitional(C.boolean)},!1),s!==void 0&&we.assertOptions(s,{encode:C.function,serialize:C.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&c.merge(o.common,o[n.method]),i&&c.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=x.concat(i,o);const u=[];let f=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(f=f&&h.synchronous,u.unshift(h.fulfilled,h.rejected))});const a=[];this.interceptors.response.forEach(function(h){a.push(h.fulfilled,h.rejected)});let l,d=0,y;if(!f){const p=[it.bind(this),void 0];for(p.unshift.apply(p,u),p.push.apply(p,a),y=p.length,l=Promise.resolve(n);d{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(u=>{r.subscribe(u),o=u}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,u){r.reason||(r.reason=new V(o,i,u),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new _e(function(s){t=s}),cancel:t}}}const Cn=_e;function Pn(e){return function(n){return e.apply(null,n)}}function Fn(e){return c.isObject(e)&&e.isAxiosError===!0}function lt(e){const t=new re(e),n=je(re.prototype.request,t);return c.extend(n,re.prototype,t,{allOwnKeys:!0}),c.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return lt(L(e,s))},n}const w=lt(me);w.Axios=re,w.CanceledError=V,w.CancelToken=Cn,w.isCancel=rt,w.VERSION=ct,w.toFormData=Q,w.AxiosError=m,w.Cancel=w.CanceledError,w.all=function(t){return Promise.all(t)},w.spread=Pn,w.isAxiosError=Fn,w.mergeConfig=L,w.AxiosHeaders=x,w.formToJSON=e=>et(c.isHTMLForm(e)?new FormData(e):e),w.default=w;const kn=w,Zn="";function Dn(e){let t,n,r,s,o,i=`${e[1]}%`;function u(d,y){return d[3]?Un:jn}let f=u(e),a=f(e),l=e[4]&&dt();return{c(){t=k("div"),n=k("div"),a.c(),r=se(),l&&l.c(),s=se(),o=k("div"),O(n,"class","z-20"),O(o,"id","percentage-bar"),O(o,"class","ease-in duration-300 z-10 absolute top-0 left-0 bottom-0 bg-blue-800"),xe(o,"width",i),O(t,"id","percentage"),O(t,"class","w-full h-full text-center align-middle flex justify-center")},m(d,y){A(d,t,y),F(t,n),a.m(n,null),F(n,r),l&&l.m(n,null),F(t,s),F(t,o)},p(d,y){f===(f=u(d))&&a?a.p(d,y):(a.d(1),a=f(d),a&&(a.c(),a.m(n,r))),d[4]?l||(l=dt(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),y&2&&i!==(i=`${d[1]}%`)&&xe(o,"width",i)},d(d){d&&S(t),a.d(),l&&l.d()}}}function Bn(e){let t;return{c(){t=D("Select a file to upload")},m(n,r){A(n,t,r)},p:g,d(n){n&&S(t)}}}function Un(e){let t;return{c(){t=D("Waiting for data schema detection...")},m(n,r){A(n,t,r)},p:g,d(n){n&&S(t)}}}function jn(e){let t,n=!e[4]&&ft(e);return{c(){n&&n.c(),t=ht()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[4]?n&&(n.d(1),n=null):n?n.p(r,s):(n=ft(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&S(t)}}}function ft(e){let t,n;return{c(){t=D(e[1]),n=D("%")},m(r,s){A(r,t,s),A(r,n,s)},p(r,s){s&2&&yt(t,r[1])},d(r){r&&S(t),r&&S(n)}}}function dt(e){let t;return{c(){t=D("File uploaded")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Ln(e){let t,n,r,s,o,i;function u(l,d){return!l[2]&&!l[3]&&!l[4]?Bn:Dn}let f=u(e),a=f(e);return{c(){t=k("div"),n=k("div"),a.c(),r=se(),s=k("input"),O(n,"id","label"),O(n,"class","w-full h-full relative text-sky-100 place-content-center justify-center flex"),O(s,"id","fileUpload"),O(s,"type","file"),O(s,"class","svelte-1t8uy1e"),O(t,"id","fileUploadWidget"),O(t,"class","border-solid border-2 rounded border-sky-900 bg-sky-500 flex h-8 svelte-1t8uy1e")},m(l,d){A(l,t,d),F(t,n),a.m(n,null),F(t,r),F(t,s),o||(i=[Te(s,"change",e[8]),Te(s,"change",e[5])],o=!0)},p(l,[d]){f===(f=u(l))&&a?a.p(l,d):(a.d(1),a=f(l),a&&(a.c(),a.m(n,null)))},i:g,o:g,d(l){l&&S(t),a.d(),o=!1,H(i)}}}function Hn(e,t,n){let r,{upload_url:s}=t,{dataset_id:o}=t,i=0,u=!1,f=!1,a=!1,l=Ne();async function d(h,_){try{const E={onUploadProgress:P=>{const{loaded:Oe,total:qn}=P,ge=Math.floor(Oe*100/qn);ge<=100&&(_(ge),ge==100&&(n(2,u=!1),n(3,f=!0)))}},{data:N}=await kn.post(s+"/api/3/action/resource_create_with_schema",h,E);return N}catch(E){console.log("ERROR",E.message)}}function y(h){n(1,i=h)}async function b(h){try{const _=h.target.files[0],E=new FormData;E.append("upload",_),E.append("package_id",o),n(2,u=!0);let P={data:await d(E,y)};l("fileUploaded",P),n(3,f=!1),n(4,a=!0)}catch(_){console.log("ERROR",_),y(0)}}function p(){r=this.files,n(0,r)}return e.$$set=h=>{"upload_url"in h&&n(6,s=h.upload_url),"dataset_id"in h&&n(7,o=h.dataset_id)},[r,i,u,f,a,b,s,o,p]}class Mn extends Ue{constructor(t){super(),Be(this,t,Hn,Ln,Ae,{upload_url:6,dataset_id:7})}}function zn(e){let t,n,r;return n=new Mn({props:{upload_url:e[0],dataset_id:e[1]}}),n.$on("fileUploaded",e[3]),{c(){t=k("main"),Rt(n.$$.fragment),O(t,"class","tailwind")},m(s,o){A(s,t,o),ke(n,t,null),e[4](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),n.$set(i)},i(s){r||(Fe(n.$$.fragment,s),r=!0)},o(s){St(n.$$.fragment,s),r=!1},d(s){s&&S(t),De(n),e[4](null)}}}function In(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t;Ne();let o;function i(f){console.log(f),o.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:f.detail.data.result}))}function u(f){oe[f?"unshift":"push"](()=>{o=f,n(2,o)})}return e.$$set=f=>{"upload_url"in f&&n(0,r=f.upload_url),"dataset_id"in f&&n(1,s=f.dataset_id)},[r,s,o,i,u]}class $n extends Ue{constructor(t){super(),Be(this,t,In,zn,Ae,{upload_url:0,dataset_id:1})}}function Jn(e,t="",n=""){new $n({target:document.getElementById(e),props:{upload_url:t,dataset_id:n}})}return Jn}); +(function(x,I){typeof exports=="object"&&typeof module<"u"?module.exports=I():typeof define=="function"&&define.amd?define(I):(x=typeof globalThis<"u"?globalThis:x||self,x.CkanUploader=I())})(this,function(){"use strict";function x(){}function I(e){return e()}function ke(){return Object.create(null)}function v(e){e.forEach(I)}function Fe(e){return typeof e=="function"}function De(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function St(e){return Object.keys(e).length===0}function T(e,t){e.appendChild(t)}function A(e,t,n){e.insertBefore(t,n||null)}function R(e){e.parentNode&&e.parentNode.removeChild(e)}function N(e){return document.createElement(e)}function F(e){return document.createTextNode(e)}function j(){return F(" ")}function Ue(){return F("")}function Z(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function E(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function gt(e){return Array.from(e.childNodes)}function Be(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function $(e,t){e.value=t==null?"":t}function je(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function Rt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let V;function W(e){V=e}function At(){if(!V)throw new Error("Function called outside component initialization");return V}function Le(){const e=At();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=Rt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const K=[],pe=[],ee=[],He=[],Tt=Promise.resolve();let he=!1;function Nt(){he||(he=!0,Tt.then(Me))}function me(e){ee.push(e)}const _e=new Set;let te=0;function Me(){const e=V;do{for(;te{ne.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function kt(e){e&&e.c()}function Ie(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||me(()=>{const i=e.$$.on_mount.map(I).filter(Fe);e.$$.on_destroy?e.$$.on_destroy.push(...i):v(i),e.$$.on_mount=[]}),o.forEach(me)}function Je(e,t){const n=e.$$;n.fragment!==null&&(v(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Ft(e,t){e.$$.dirty[0]===-1&&(K.push(e),Nt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=h.length?h[0]:y;return a.ctx&&s(a.ctx[l],a.ctx[l]=p)&&(!a.skip_bound&&a.bound[l]&&a.bound[l](p),f&&Ft(e,l)),y}):[],a.update(),f=!0,v(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const l=gt(t.target);a.fragment&&a.fragment.l(l),l.forEach(R)}else a.fragment&&a.fragment.c();t.intro&&ze(e.$$.fragment),Ie(e,t.target,t.anchor,t.customElement),Me()}W(d)}class ve{$destroy(){Je(this,1),this.$destroy=x}$on(t,n){if(!Fe(n))return x;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!St(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const tr="";function Ve(e,t){return function(){return e.apply(t,arguments)}}const{toString:We}=Object.prototype,{getPrototypeOf:ye}=Object,be=(e=>t=>{const n=We.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),D=e=>(e=e.toLowerCase(),t=>be(t)===e),re=e=>t=>typeof t===e,{isArray:J}=Array,X=re("undefined");function Dt(e){return e!==null&&!X(e)&&e.constructor!==null&&!X(e.constructor)&&z(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ke=D("ArrayBuffer");function Ut(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ke(e.buffer),t}const Bt=re("string"),z=re("function"),Xe=re("number"),Ee=e=>e!==null&&typeof e=="object",jt=e=>e===!0||e===!1,se=e=>{if(be(e)!=="object")return!1;const t=ye(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Lt=D("Date"),Ht=D("File"),Mt=D("Blob"),zt=D("FileList"),It=e=>Ee(e)&&z(e.pipe),Jt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||We.call(e)===t||z(e.toString)&&e.toString()===t)},qt=D("URLSearchParams"),vt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function G(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),J(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Qe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ye=e=>!X(e)&&e!==Qe;function we(){const{caseless:e}=Ye(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ge(t,s)||s;se(t[o])&&se(r)?t[o]=we(t[o],r):se(r)?t[o]=we({},r):J(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(G(t,(s,o)=>{n&&z(s)?e[o]=Ve(s,n):e[o]=s},{allOwnKeys:r}),e),Wt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Kt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Xt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&ye(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Gt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Qt=e=>{if(!e)return null;if(J(e))return e;let t=e.length;if(!Xe(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Yt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ye(Uint8Array)),Zt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},$t=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},en=D("HTMLFormElement"),tn=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ze=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),nn=D("RegExp"),$e=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};G(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},u={isArray:J,isArrayBuffer:Ke,isBuffer:Dt,isFormData:Jt,isArrayBufferView:Ut,isString:Bt,isNumber:Xe,isBoolean:jt,isObject:Ee,isPlainObject:se,isUndefined:X,isDate:Lt,isFile:Ht,isBlob:Mt,isRegExp:nn,isFunction:z,isStream:It,isURLSearchParams:qt,isTypedArray:Yt,isFileList:zt,forEach:G,merge:we,extend:Vt,trim:vt,stripBOM:Wt,inherits:Kt,toFlatObject:Xt,kindOf:be,kindOfTest:D,endsWith:Gt,toArray:Qt,forEachEntry:Zt,matchAll:$t,isHTMLForm:en,hasOwnProperty:Ze,hasOwnProp:Ze,reduceDescriptors:$e,freezeMethods:e=>{$e(e,(t,n)=>{if(z(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!z(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return J(e)?r(e):r(String(e).split(t)),n},toCamelCase:tn,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ge,global:Qe,isContextDefined:Ye,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(Ee(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=J(r)?[]:{};return G(r,(i,c)=>{const d=n(i,s+1);!X(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function b(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}u.inherits(b,Error,{toJSON:function(){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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const et=b.prototype,tt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{tt[e]={value:e}}),Object.defineProperties(b,tt),Object.defineProperty(et,"isAxiosError",{value:!0}),b.from=(e,t,n,r,s,o)=>{const i=Object.create(et);return u.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),b.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var rn=typeof self=="object"?self.FormData:window.FormData;const sn=rn;function Oe(e){return u.isPlainObject(e)||u.isArray(e)}function nt(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function rt(e,t,n){return e?e.concat(t).map(function(s,o){return s=nt(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function on(e){return u.isArray(e)&&!e.some(Oe)}const an=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function un(e){return e&&u.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function oe(e,t,n){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new(sn||FormData),n=u.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(_,w){return!u.isUndefined(w[_])});const r=n.metaTokens,s=n.visitor||f,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&un(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(u.isDate(p))return p.toISOString();if(!d&&u.isBlob(p))throw new b("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(p)||u.isTypedArray(p)?d&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function f(p,_,w){let S=p;if(p&&!w&&typeof p=="object"){if(u.endsWith(_,"{}"))_=r?_:_.slice(0,-2),p=JSON.stringify(p);else if(u.isArray(p)&&on(p)||u.isFileList(p)||u.endsWith(_,"[]")&&(S=u.toArray(p)))return _=nt(_),S.forEach(function(B,H){!(u.isUndefined(B)||B===null)&&t.append(i===!0?rt([_],H,o):i===null?_:_+"[]",a(B))}),!1}return Oe(p)?!0:(t.append(rt(w,_,o),a(p)),!1)}const l=[],y=Object.assign(an,{defaultVisitor:f,convertValue:a,isVisitable:Oe});function h(p,_){if(!u.isUndefined(p)){if(l.indexOf(p)!==-1)throw Error("Circular reference detected in "+_.join("."));l.push(p),u.forEach(p,function(S,P){(!(u.isUndefined(S)||S===null)&&s.call(t,S,u.isString(P)?P.trim():P,_,y))===!0&&h(S,_?_.concat(P):[P])}),l.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return h(e),t}function st(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Se(e,t){this._pairs=[],e&&oe(e,this,t)}const ot=Se.prototype;ot.append=function(t,n){this._pairs.push([t,n])},ot.toString=function(t){const n=t?function(r){return t.call(this,r,st)}:st;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function cn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function it(e,t,n){if(!t)return e;const r=n&&n.encode||cn,s=n&&n.serialize;let o;if(s?o=s(t,n):o=u.isURLSearchParams(t)?t.toString():new Se(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class ln{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){u.forEach(this.handlers,function(r){r!==null&&t(r)})}}const at=ln,ut={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},fn=typeof URLSearchParams<"u"?URLSearchParams:Se,dn=FormData,pn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),hn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),k={isBrowser:!0,classes:{URLSearchParams:fn,FormData:dn,Blob},isStandardBrowserEnv:pn,isStandardBrowserWebWorkerEnv:hn,protocols:["http","https","file","blob","url","data"]};function mn(e,t){return oe(e,new k.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return k.isNode&&u.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function _n(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function yn(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&u.isArray(s)?s.length:i,d?(u.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!u.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&u.isArray(s[i])&&(s[i]=yn(s[i])),!c)}if(u.isFormData(e)&&u.isFunction(e.entries)){const n={};return u.forEachEntry(e,(r,s)=>{t(_n(r),s,n,0)}),n}return null}const bn={"Content-Type":void 0};function En(e,t,n){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const ie={transitional:ut,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=u.isObject(t);if(o&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(ct(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return mn(t,this.formSerializer).toString();if((c=u.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return oe(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),En(t)):t}],transformResponse:[function(t){const n=this.transitional||ie.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&u.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?b.from(c,b.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:k.classes.FormData,Blob:k.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};u.forEach(["delete","get","head"],function(t){ie.headers[t]={}}),u.forEach(["post","put","patch"],function(t){ie.headers[t]=u.merge(bn)});const ge=ie,wn=u.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"]),On=e=>{const t={};let n,r,s;return e&&e.split(` +`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&wn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},lt=Symbol("internals");function Q(e){return e&&String(e).trim().toLowerCase()}function ae(e){return e===!1||e==null?e:u.isArray(e)?e.map(ae):String(e)}function Sn(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}function gn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ft(e,t,n,r){if(u.isFunction(r))return r.call(this,t,n);if(!!u.isString(t)){if(u.isString(r))return t.indexOf(r)!==-1;if(u.isRegExp(r))return r.test(t)}}function Rn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function An(e,t){const n=u.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class ue{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,a){const f=Q(d);if(!f)throw new Error("header name must be a non-empty string");const l=u.findKey(s,f);(!l||s[l]===void 0||a===!0||a===void 0&&s[l]!==!1)&&(s[l||d]=ae(c))}const i=(c,d)=>u.forEach(c,(a,f)=>o(a,f,d));return u.isPlainObject(t)||t instanceof this.constructor?i(t,n):u.isString(t)&&(t=t.trim())&&!gn(t)?i(On(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=Q(t),t){const r=u.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Sn(s);if(u.isFunction(n))return n.call(this,s,r);if(u.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Q(t),t){const r=u.findKey(this,t);return!!(r&&(!n||ft(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=Q(i),i){const c=u.findKey(r,i);c&&(!n||ft(r,r[c],c,n))&&(delete r[c],s=!0)}}return u.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return u.forEach(this,(s,o)=>{const i=u.findKey(r,o);if(i){n[i]=ae(s),delete n[o];return}const c=t?Rn(o):String(o).trim();c!==o&&delete n[o],n[c]=ae(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return u.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&u.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[lt]=this[lt]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=Q(i);r[c]||(An(s,i),r[c]=!0)}return u.isArray(t)?t.forEach(o):o(t),this}}ue.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(ue.prototype),u.freezeMethods(ue);const U=ue;function Re(e,t){const n=this||ge,r=t||n,s=U.from(r.headers);let o=r.data;return u.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function dt(e){return!!(e&&e.__CANCEL__)}function Y(e,t,n){b.call(this,e==null?"canceled":e,b.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(Y,b,{__CANCEL__:!0});const Tn=null;function Nn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new b("Request failed with status code "+n.status,[b.ERR_BAD_REQUEST,b.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Cn=k.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const d=[];d.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),u.isString(o)&&d.push("path="+o),u.isString(i)&&d.push("domain="+i),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Pn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function xn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function pt(e,t){return e&&!Pn(t)?xn(e,t):t}const kn=k.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=u.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function Fn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Dn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),f=r[o];i||(i=a),n[s]=d,r[s]=a;let l=o,y=0;for(;l!==s;)y+=n[l++],l=l%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,d=r(c),a=o<=i;n=o;const f={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};f[t?"download":"upload"]=!0,e(f)}}const ce={http:Tn,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=U.from(e.headers).normalize(),i=e.responseType;let c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(k.isStandardBrowserEnv||k.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const h=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(h+":"+p))}const f=pt(e.baseURL,e.url);a.open(e.method.toUpperCase(),it(f,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function l(){if(!a)return;const h=U.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),_={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:h,config:e,request:a};Nn(function(S){n(S),d()},function(S){r(S),d()},_),a=null}if("onloadend"in a?a.onloadend=l:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(l)},a.onabort=function(){!a||(r(new b("Request aborted",b.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new b("Network Error",b.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const _=e.transitional||ut;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new b(p,_.clarifyTimeoutError?b.ETIMEDOUT:b.ECONNABORTED,e,a)),a=null},k.isStandardBrowserEnv){const h=(e.withCredentials||kn(f))&&e.xsrfCookieName&&Cn.read(e.xsrfCookieName);h&&o.set(e.xsrfHeaderName,h)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&u.forEach(o.toJSON(),function(p,_){a.setRequestHeader(_,p)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",ht(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",ht(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=h=>{!a||(r(!h||h.type?new Y(null,e,a):h),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const y=Fn(f);if(y&&k.protocols.indexOf(y)===-1){r(new b("Unsupported protocol "+y+":",b.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(ce,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Un={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof U?e.toJSON():e;function q(e,t){t=t||{};const n={};function r(a,f,l){return u.isPlainObject(a)&&u.isPlainObject(f)?u.merge.call({caseless:l},a,f):u.isPlainObject(f)?u.merge({},f):u.isArray(f)?f.slice():f}function s(a,f,l){if(u.isUndefined(f)){if(!u.isUndefined(a))return r(void 0,a,l)}else return r(a,f,l)}function o(a,f){if(!u.isUndefined(f))return r(void 0,f)}function i(a,f){if(u.isUndefined(f)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,f)}function c(a,f,l){if(l in t)return r(a,f);if(l in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(a,f)=>s(_t(a),_t(f),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(f){const l=d[f]||s,y=l(e[f],t[f],f);u.isUndefined(y)&&l!==c||(n[f]=y)}),n}const yt="1.2.1",Te={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Te[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const bt={};Te.transitional=function(t,n,r){function s(o,i){return"[Axios v"+yt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new b(s(i," has been removed"+(n?" in "+n:"")),b.ERR_DEPRECATED);return n&&!bt[i]&&(bt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Bn(e,t,n){if(typeof e!="object")throw new b("options must be an object",b.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new b("option "+o+" must be "+d,b.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new b("Unknown option "+o,b.ERR_BAD_OPTION)}}const Ne={assertOptions:Bn,validators:Te},L=Ne.validators;class le{constructor(t){this.defaults=t,this.interceptors={request:new at,response:new at}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=q(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Ne.assertOptions(r,{silentJSONParsing:L.transitional(L.boolean),forcedJSONParsing:L.transitional(L.boolean),clarifyTimeoutError:L.transitional(L.boolean)},!1),s!==void 0&&Ne.assertOptions(s,{encode:L.function,serialize:L.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&u.merge(o.common,o[n.method]),i&&u.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=U.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(_){typeof _.runWhen=="function"&&_.runWhen(n)===!1||(d=d&&_.synchronous,c.unshift(_.fulfilled,_.rejected))});const a=[];this.interceptors.response.forEach(function(_){a.push(_.fulfilled,_.rejected)});let f,l=0,y;if(!d){const p=[mt.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,a),y=p.length,f=Promise.resolve(n);l{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new Y(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Ce(function(s){t=s}),cancel:t}}}const jn=Ce;function Ln(e){return function(n){return e.apply(null,n)}}function Hn(e){return u.isObject(e)&&e.isAxiosError===!0}function Et(e){const t=new fe(e),n=Ve(fe.prototype.request,t);return u.extend(n,fe.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Et(q(e,s))},n}const O=Et(ge);O.Axios=fe,O.CanceledError=Y,O.CancelToken=jn,O.isCancel=dt,O.VERSION=yt,O.toFormData=oe,O.AxiosError=b,O.Cancel=O.CanceledError,O.all=function(t){return Promise.all(t)},O.spread=Ln,O.isAxiosError=Hn,O.mergeConfig=q,O.AxiosHeaders=U,O.formToJSON=e=>ct(u.isHTMLForm(e)?new FormData(e):e),O.default=O;const Mn=O,cr="";function zn(e){let t,n,r,s,o,i=`${e[3]}%`;function c(l,y){return l[5]?Jn:qn}let d=c(e),a=d(e),f=e[6]&&Ot();return{c(){t=N("div"),n=N("div"),a.c(),r=j(),f&&f.c(),s=j(),o=N("div"),E(n,"class","z-20"),E(o,"id","percentage-bar"),E(o,"class","ease-in duration-300 z-10 absolute top-0 left-0 bottom-0 bg-blue-800"),je(o,"width",i),E(t,"id","percentage"),E(t,"class","w-full h-full text-center align-middle flex justify-center")},m(l,y){A(l,t,y),T(t,n),a.m(n,null),T(n,r),f&&f.m(n,null),T(t,s),T(t,o)},p(l,y){d===(d=c(l))&&a?a.p(l,y):(a.d(1),a=d(l),a&&(a.c(),a.m(n,r))),l[6]?f||(f=Ot(),f.c(),f.m(n,null)):f&&(f.d(1),f=null),y&8&&i!==(i=`${l[3]}%`)&&je(o,"width",i)},d(l){l&&R(t),a.d(),f&&f.d()}}}function In(e){let t;function n(o,i){return o[1]?Vn:vn}let r=n(e),s=r(e);return{c(){s.c(),t=Ue()},m(o,i){s.m(o,i),A(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&R(t)}}}function Jn(e){let t;return{c(){t=F("Waiting for data schema detection...")},m(n,r){A(n,t,r)},p:x,d(n){n&&R(t)}}}function qn(e){let t,n=!e[6]&&wt(e);return{c(){n&&n.c(),t=Ue()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[6]?n&&(n.d(1),n=null):n?n.p(r,s):(n=wt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&R(t)}}}function wt(e){let t,n;return{c(){t=F(e[3]),n=F("%")},m(r,s){A(r,t,s),A(r,n,s)},p(r,s){s&8&&Be(t,r[3])},d(r){r&&R(t),r&&R(n)}}}function Ot(e){let t;return{c(){t=F("File uploaded")},m(n,r){A(n,t,r)},d(n){n&&R(t)}}}function vn(e){let t;return{c(){t=F("Select a file to upload")},m(n,r){A(n,t,r)},d(n){n&&R(t)}}}function Vn(e){let t;return{c(){t=F("Select a file to replace the current one")},m(n,r){A(n,t,r)},d(n){n&&R(t)}}}function Wn(e){let t,n,r,s,o,i,c,d,a,f,l,y,h,p,_,w,S,P;function B(m,g){return!m[4]&&!m[5]&&!m[6]?In:zn}let H=B(e),C=H(e);return{c(){t=F(e[1]),n=j(),r=N("div"),s=N("div"),C.c(),o=j(),i=N("input"),c=j(),d=N("input"),f=j(),l=N("input"),y=j(),h=N("div"),p=N("label"),p.textContent="URL",_=j(),w=N("input"),E(s,"id","label"),E(s,"class","w-full h-full relative text-sky-100 place-content-center justify-center flex"),E(i,"type","hidden"),E(i,"name","url_type"),E(d,"type","hidden"),E(d,"name","clear_upload"),d.value=a=e[1]!=""?"true":"",E(l,"id","fileUpload"),E(l,"type","file"),E(l,"class","svelte-11h4gxn"),E(r,"id","fileUploadWidget"),E(r,"class","border-solid border-2 rounded border-sky-900 bg-sky-500 flex h-8 svelte-11h4gxn"),E(p,"for","field_url"),E(w,"id","field_url"),E(w,"class","form-control"),E(w,"type","text"),E(w,"name","url"),E(h,"class","controls pt-4")},m(m,g){A(m,t,g),A(m,n,g),A(m,r,g),T(r,s),C.m(s,null),T(r,o),T(r,i),$(i,e[7]),T(r,c),T(r,d),T(r,f),T(r,l),A(m,y,g),A(m,h,g),T(h,p),T(h,_),T(h,w),$(w,e[0]),S||(P=[Z(i,"input",e[12]),Z(l,"change",e[13]),Z(l,"change",e[8]),Z(w,"input",e[14])],S=!0)},p(m,[g]){g&2&&Be(t,m[1]),H===(H=B(m))&&C?C.p(m,g):(C.d(1),C=H(m),C&&(C.c(),C.m(s,null))),g&128&&$(i,m[7]),g&2&&a!==(a=m[1]!=""?"true":"")&&(d.value=a),g&1&&w.value!==m[0]&&$(w,m[0])},i:x,o:x,d(m){m&&R(t),m&&R(n),m&&R(r),C.d(),m&&R(y),m&&R(h),S=!1,v(P)}}}function Kn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:c}=t,d,a=0,f=!1,l=!1,y=!1,h="",p=Le(),_=i?"update":"create";async function w(m,g){try{const M={onUploadProgress:Pe=>{const{loaded:$n,total:er}=Pe,xe=Math.floor($n*100/er);xe<=100&&(g(xe),xe==100&&(n(4,f=!1),n(5,l=!0)))}},{data:de}=await Mn.post(`${r}/api/3/action/resource_${_}_with_schema`,m,M);return de}catch(M){console.log("ERROR",M.message)}}function S(m){n(3,a=m)}async function P(m){try{const g=m.target.files[0],M=new FormData;M.append("upload",g),M.append("package_id",s),i&&M.append("id",o),n(4,f=!0);let de=await w(M,S),Pe={data:de};n(0,c=de.result.url),n(7,h="upload"),p("fileUploaded",Pe),n(5,l=!1),n(6,y=!0)}catch(g){console.log("ERROR",g),S(0)}}function B(){h=this.value,n(7,h)}function H(){d=this.files,n(2,d)}function C(){c=this.value,n(0,c)}return e.$$set=m=>{"upload_url"in m&&n(9,r=m.upload_url),"dataset_id"in m&&n(10,s=m.dataset_id),"resource_id"in m&&n(11,o=m.resource_id),"update"in m&&n(1,i=m.update),"current_url"in m&&n(0,c=m.current_url)},[c,i,d,a,f,l,y,h,P,r,s,o,B,H,C]}class Xn extends ve{constructor(t){super(),qe(this,t,Kn,Wn,De,{upload_url:9,dataset_id:10,resource_id:11,update:1,current_url:0})}}function Gn(e){let t,n,r;return n=new Xn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4]}}),n.$on("fileUploaded",e[6]),{c(){t=N("main"),kt(n.$$.fragment),E(t,"class","tailwind")},m(s,o){A(s,t,o),Ie(n,t,null),e[7](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),n.$set(i)},i(s){r||(ze(n.$$.fragment,s),r=!0)},o(s){xt(n.$$.fragment,s),r=!1},d(s){s&&R(t),Je(n),e[7](null)}}}function Qn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:c}=t;Le();let d;function a(l){d.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:l.detail.data.result}))}function f(l){pe[l?"unshift":"push"](()=>{d=l,n(5,d)})}return e.$$set=l=>{"upload_url"in l&&n(0,r=l.upload_url),"dataset_id"in l&&n(1,s=l.dataset_id),"resource_id"in l&&n(2,o=l.resource_id),"update"in l&&n(3,i=l.update),"current_url"in l&&n(4,c=l.current_url)},[r,s,o,i,c,d,a,f]}class Yn extends ve{constructor(t){super(),qe(this,t,Qn,Gn,De,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4})}}function Zn(e,t="",n="",r="",s="",o=""){new Yn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,current_url:s,update:o}})}return Zn}); diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js index 77704314..05d37e38 100644 --- a/ckanext/validation/webassets/js/module-ckan-uploader.js +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -4,9 +4,12 @@ ckan.module('ckan-uploader', function (jQuery) { return { options: { upload_url: '', - dataset_id: '' + dataset_id: '', + resource_id: '', + current_url: false, + update: false }, - afterUpload: (evt) => { + afterUpload: (resource_id) => (evt) => { let resource = evt.detail // Set name let field_name = document.getElementById('field-name') @@ -26,19 +29,16 @@ ckan.module('ckan-uploader', function (jQuery) { json_button.dispatchEvent(new Event('click')) // Set the form action to save the created resource - let resource_form = document.getElementById('resource-edit') - let current_action = resource_form.action - let lastIndexNew = current_action.lastIndexOf('new') - - // Set URL - let url_field = document.getElementById('resource-url') - url_field.value = resource.url - - resource_form.action = current_action.slice(0, lastIndexNew) + `${resource.id}/edit` + if (resource_id == '' && resource_id == true) { + let resource_form = document.getElementById('resource-edit') + let current_action = resource_form.action + let lastIndexNew = current_action.lastIndexOf('new') + resource_form.action = current_action.slice(0, lastIndexNew) + `${resource.id}/edit` + } }, initialize: function() { - CkanUploader('ckan_uploader', this.options.upload_url, this.options.dataset_id) - document.getElementById('ckan_uploader').addEventListener('fileUploaded', this.afterUpload) + CkanUploader('ckan_uploader', this.options.upload_url, this.options.dataset_id, (this.options.resource_id != true)?this.options.resource_id:'', (this.options.current_url != true)?this.options.current_url:'', (this.options.update != true)?this.options.update:'') + document.getElementById('ckan_uploader').addEventListener('fileUploaded', this.afterUpload(this.options.resource_id)) } } }); From f2af7924bba25721d40304398093f1807cfd84a9 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Tue, 13 Dec 2022 11:07:06 +0100 Subject: [PATCH 08/43] Pass the url_type parameter to the ckan-uploader component --- .../templates/package/snippets/resource_form.html | 2 +- ckanext/validation/webassets/css/ckan-uploader.css | 2 +- ckanext/validation/webassets/js/ckan-uploader.js | 6 +++--- .../validation/webassets/js/module-ckan-uploader.js | 11 +++++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ckanext/validation/templates/package/snippets/resource_form.html b/ckanext/validation/templates/package/snippets/resource_form.html index 9129189e..3c4abb18 100644 --- a/ckanext/validation/templates/package/snippets/resource_form.html +++ b/ckanext/validation/templates/package/snippets/resource_form.html @@ -20,7 +20,7 @@
-
+
{% block basic_fields %} {% block basic_fields_url %} diff --git a/ckanext/validation/webassets/css/ckan-uploader.css b/ckanext/validation/webassets/css/ckan-uploader.css index fdd8635a..7c9ff18a 100644 --- a/ckanext/validation/webassets/css/ckan-uploader.css +++ b/ckanext/validation/webassets/css/ckan-uploader.css @@ -1 +1 @@ -.tailwind *,.tailwind :before,.tailwind :after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}.tailwind :before,.tailwind :after{--tw-content: ""}.tailwind html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal}.tailwind body{margin:0;line-height:inherit}.tailwind hr{height:0;color:inherit;border-top-width:1px}.tailwind abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6{font-size:inherit;font-weight:inherit}.tailwind a{color:inherit;text-decoration:inherit}.tailwind b,.tailwind strong{font-weight:bolder}.tailwind code,.tailwind kbd,.tailwind samp,.tailwind pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}.tailwind small{font-size:80%}.tailwind sub,.tailwind sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.tailwind sub{bottom:-.25em}.tailwind sup{top:-.5em}.tailwind table{text-indent:0;border-color:inherit;border-collapse:collapse}.tailwind button,.tailwind input,.tailwind optgroup,.tailwind select,.tailwind textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}.tailwind button,.tailwind select{text-transform:none}.tailwind button,.tailwind [type=button],.tailwind [type=reset],.tailwind [type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}.tailwind :-moz-focusring{outline:auto}.tailwind :-moz-ui-invalid{box-shadow:none}.tailwind progress{vertical-align:baseline}.tailwind ::-webkit-inner-spin-button,.tailwind ::-webkit-outer-spin-button{height:auto}.tailwind [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.tailwind ::-webkit-search-decoration{-webkit-appearance:none}.tailwind ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.tailwind summary{display:list-item}.tailwind blockquote,.tailwind dl,.tailwind dd,.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6,.tailwind hr,.tailwind figure,.tailwind p,.tailwind pre{margin:0}.tailwind fieldset{margin:0;padding:0}.tailwind legend{padding:0}.tailwind ol,.tailwind ul,.tailwind menu{list-style:none;margin:0;padding:0}.tailwind textarea{resize:vertical}.tailwind input::-moz-placeholder,.tailwind textarea::-moz-placeholder{opacity:1;color:#9ca3af}.tailwind input::placeholder,.tailwind textarea::placeholder{opacity:1;color:#9ca3af}.tailwind button,.tailwind [role=button]{cursor:pointer}.tailwind :disabled{cursor:default}.tailwind img,.tailwind svg,.tailwind video,.tailwind canvas,.tailwind audio,.tailwind iframe,.tailwind embed,.tailwind object{display:block;vertical-align:middle}.tailwind img,.tailwind video{max-width:100%;height:auto}.tailwind [hidden]{display:none}.tailwind *,.tailwind :before,.tailwind :after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind ::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind .absolute{position:absolute}.tailwind .relative{position:relative}.tailwind .top-0{top:0px}.tailwind .left-0{left:0px}.tailwind .bottom-0{bottom:0px}.tailwind .z-20{z-index:20}.tailwind .z-10{z-index:10}.tailwind .flex{display:flex}.tailwind .hidden{display:none}.tailwind .h-8{height:2rem}.tailwind .h-full{height:100%}.tailwind .w-full{width:100%}.tailwind .place-content-center{place-content:center}.tailwind .justify-center{justify-content:center}.tailwind .rounded{border-radius:.25rem}.tailwind .border-2{border-width:2px}.tailwind .border-solid{border-style:solid}.tailwind .border-sky-900{--tw-border-opacity: 1;border-color:rgb(12 74 110 / var(--tw-border-opacity))}.tailwind .bg-sky-500{--tw-bg-opacity: 1;background-color:rgb(14 165 233 / var(--tw-bg-opacity))}.tailwind .bg-blue-800{--tw-bg-opacity: 1;background-color:rgb(30 64 175 / var(--tw-bg-opacity))}.tailwind .pt-4{padding-top:1rem}.tailwind .text-center{text-align:center}.tailwind .align-middle{vertical-align:middle}.tailwind .text-sky-100{--tw-text-opacity: 1;color:rgb(224 242 254 / var(--tw-text-opacity))}.tailwind .duration-300{transition-duration:.3s}.tailwind .ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}#fileUploadWidget.svelte-11h4gxn{position:relative;display:flex;max-width:400px}#fileUpload.svelte-11h4gxn{position:absolute;width:100%;height:100%;top:0;left:0;opacity:0} +.tailwind *,.tailwind :before,.tailwind :after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}.tailwind :before,.tailwind :after{--tw-content: ""}.tailwind html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal}.tailwind body{margin:0;line-height:inherit}.tailwind hr{height:0;color:inherit;border-top-width:1px}.tailwind abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6{font-size:inherit;font-weight:inherit}.tailwind a{color:inherit;text-decoration:inherit}.tailwind b,.tailwind strong{font-weight:bolder}.tailwind code,.tailwind kbd,.tailwind samp,.tailwind pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}.tailwind small{font-size:80%}.tailwind sub,.tailwind sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.tailwind sub{bottom:-.25em}.tailwind sup{top:-.5em}.tailwind table{text-indent:0;border-color:inherit;border-collapse:collapse}.tailwind button,.tailwind input,.tailwind optgroup,.tailwind select,.tailwind textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}.tailwind button,.tailwind select{text-transform:none}.tailwind button,.tailwind [type=button],.tailwind [type=reset],.tailwind [type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}.tailwind :-moz-focusring{outline:auto}.tailwind :-moz-ui-invalid{box-shadow:none}.tailwind progress{vertical-align:baseline}.tailwind ::-webkit-inner-spin-button,.tailwind ::-webkit-outer-spin-button{height:auto}.tailwind [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.tailwind ::-webkit-search-decoration{-webkit-appearance:none}.tailwind ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.tailwind summary{display:list-item}.tailwind blockquote,.tailwind dl,.tailwind dd,.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6,.tailwind hr,.tailwind figure,.tailwind p,.tailwind pre{margin:0}.tailwind fieldset{margin:0;padding:0}.tailwind legend{padding:0}.tailwind ol,.tailwind ul,.tailwind menu{list-style:none;margin:0;padding:0}.tailwind textarea{resize:vertical}.tailwind input::-moz-placeholder,.tailwind textarea::-moz-placeholder{opacity:1;color:#9ca3af}.tailwind input::placeholder,.tailwind textarea::placeholder{opacity:1;color:#9ca3af}.tailwind button,.tailwind [role=button]{cursor:pointer}.tailwind :disabled{cursor:default}.tailwind img,.tailwind svg,.tailwind video,.tailwind canvas,.tailwind audio,.tailwind iframe,.tailwind embed,.tailwind object{display:block;vertical-align:middle}.tailwind img,.tailwind video{max-width:100%;height:auto}.tailwind [hidden]{display:none}.tailwind *,.tailwind :before,.tailwind :after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind ::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind .absolute{position:absolute}.tailwind .relative{position:relative}.tailwind .top-0{top:0px}.tailwind .left-0{left:0px}.tailwind .bottom-0{bottom:0px}.tailwind .z-20{z-index:20}.tailwind .z-10{z-index:10}.tailwind .flex{display:flex}.tailwind .h-8{height:2rem}.tailwind .h-full{height:100%}.tailwind .w-full{width:100%}.tailwind .place-content-center{place-content:center}.tailwind .justify-center{justify-content:center}.tailwind .rounded{border-radius:.25rem}.tailwind .border-2{border-width:2px}.tailwind .border-solid{border-style:solid}.tailwind .border-sky-900{--tw-border-opacity: 1;border-color:rgb(12 74 110 / var(--tw-border-opacity))}.tailwind .bg-sky-500{--tw-bg-opacity: 1;background-color:rgb(14 165 233 / var(--tw-bg-opacity))}.tailwind .bg-blue-800{--tw-bg-opacity: 1;background-color:rgb(30 64 175 / var(--tw-bg-opacity))}.tailwind .pt-4{padding-top:1rem}.tailwind .text-center{text-align:center}.tailwind .align-middle{vertical-align:middle}.tailwind .text-sky-100{--tw-text-opacity: 1;color:rgb(224 242 254 / var(--tw-text-opacity))}.tailwind .duration-300{transition-duration:.3s}.tailwind .ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}#fileUploadWidget.svelte-11h4gxn{position:relative;display:flex;max-width:400px}#fileUpload.svelte-11h4gxn{position:absolute;width:100%;height:100%;top:0;left:0;opacity:0} diff --git a/ckanext/validation/webassets/js/ckan-uploader.js b/ckanext/validation/webassets/js/ckan-uploader.js index c556c7b3..9e90eee0 100644 --- a/ckanext/validation/webassets/js/ckan-uploader.js +++ b/ckanext/validation/webassets/js/ckan-uploader.js @@ -1,3 +1,3 @@ -(function(x,I){typeof exports=="object"&&typeof module<"u"?module.exports=I():typeof define=="function"&&define.amd?define(I):(x=typeof globalThis<"u"?globalThis:x||self,x.CkanUploader=I())})(this,function(){"use strict";function x(){}function I(e){return e()}function ke(){return Object.create(null)}function v(e){e.forEach(I)}function Fe(e){return typeof e=="function"}function De(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function St(e){return Object.keys(e).length===0}function T(e,t){e.appendChild(t)}function A(e,t,n){e.insertBefore(t,n||null)}function R(e){e.parentNode&&e.parentNode.removeChild(e)}function N(e){return document.createElement(e)}function F(e){return document.createTextNode(e)}function j(){return F(" ")}function Ue(){return F("")}function Z(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function E(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function gt(e){return Array.from(e.childNodes)}function Be(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function $(e,t){e.value=t==null?"":t}function je(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function Rt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let V;function W(e){V=e}function At(){if(!V)throw new Error("Function called outside component initialization");return V}function Le(){const e=At();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=Rt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const K=[],pe=[],ee=[],He=[],Tt=Promise.resolve();let he=!1;function Nt(){he||(he=!0,Tt.then(Me))}function me(e){ee.push(e)}const _e=new Set;let te=0;function Me(){const e=V;do{for(;te{ne.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function kt(e){e&&e.c()}function Ie(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||me(()=>{const i=e.$$.on_mount.map(I).filter(Fe);e.$$.on_destroy?e.$$.on_destroy.push(...i):v(i),e.$$.on_mount=[]}),o.forEach(me)}function Je(e,t){const n=e.$$;n.fragment!==null&&(v(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Ft(e,t){e.$$.dirty[0]===-1&&(K.push(e),Nt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=h.length?h[0]:y;return a.ctx&&s(a.ctx[l],a.ctx[l]=p)&&(!a.skip_bound&&a.bound[l]&&a.bound[l](p),f&&Ft(e,l)),y}):[],a.update(),f=!0,v(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const l=gt(t.target);a.fragment&&a.fragment.l(l),l.forEach(R)}else a.fragment&&a.fragment.c();t.intro&&ze(e.$$.fragment),Ie(e,t.target,t.anchor,t.customElement),Me()}W(d)}class ve{$destroy(){Je(this,1),this.$destroy=x}$on(t,n){if(!Fe(n))return x;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!St(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const tr="";function Ve(e,t){return function(){return e.apply(t,arguments)}}const{toString:We}=Object.prototype,{getPrototypeOf:ye}=Object,be=(e=>t=>{const n=We.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),D=e=>(e=e.toLowerCase(),t=>be(t)===e),re=e=>t=>typeof t===e,{isArray:J}=Array,X=re("undefined");function Dt(e){return e!==null&&!X(e)&&e.constructor!==null&&!X(e.constructor)&&z(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ke=D("ArrayBuffer");function Ut(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ke(e.buffer),t}const Bt=re("string"),z=re("function"),Xe=re("number"),Ee=e=>e!==null&&typeof e=="object",jt=e=>e===!0||e===!1,se=e=>{if(be(e)!=="object")return!1;const t=ye(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Lt=D("Date"),Ht=D("File"),Mt=D("Blob"),zt=D("FileList"),It=e=>Ee(e)&&z(e.pipe),Jt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||We.call(e)===t||z(e.toString)&&e.toString()===t)},qt=D("URLSearchParams"),vt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function G(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),J(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Qe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ye=e=>!X(e)&&e!==Qe;function we(){const{caseless:e}=Ye(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ge(t,s)||s;se(t[o])&&se(r)?t[o]=we(t[o],r):se(r)?t[o]=we({},r):J(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(G(t,(s,o)=>{n&&z(s)?e[o]=Ve(s,n):e[o]=s},{allOwnKeys:r}),e),Wt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Kt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Xt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&ye(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Gt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Qt=e=>{if(!e)return null;if(J(e))return e;let t=e.length;if(!Xe(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Yt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ye(Uint8Array)),Zt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},$t=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},en=D("HTMLFormElement"),tn=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ze=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),nn=D("RegExp"),$e=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};G(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},u={isArray:J,isArrayBuffer:Ke,isBuffer:Dt,isFormData:Jt,isArrayBufferView:Ut,isString:Bt,isNumber:Xe,isBoolean:jt,isObject:Ee,isPlainObject:se,isUndefined:X,isDate:Lt,isFile:Ht,isBlob:Mt,isRegExp:nn,isFunction:z,isStream:It,isURLSearchParams:qt,isTypedArray:Yt,isFileList:zt,forEach:G,merge:we,extend:Vt,trim:vt,stripBOM:Wt,inherits:Kt,toFlatObject:Xt,kindOf:be,kindOfTest:D,endsWith:Gt,toArray:Qt,forEachEntry:Zt,matchAll:$t,isHTMLForm:en,hasOwnProperty:Ze,hasOwnProp:Ze,reduceDescriptors:$e,freezeMethods:e=>{$e(e,(t,n)=>{if(z(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!z(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return J(e)?r(e):r(String(e).split(t)),n},toCamelCase:tn,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ge,global:Qe,isContextDefined:Ye,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(Ee(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=J(r)?[]:{};return G(r,(i,c)=>{const d=n(i,s+1);!X(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function b(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}u.inherits(b,Error,{toJSON:function(){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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const et=b.prototype,tt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{tt[e]={value:e}}),Object.defineProperties(b,tt),Object.defineProperty(et,"isAxiosError",{value:!0}),b.from=(e,t,n,r,s,o)=>{const i=Object.create(et);return u.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),b.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var rn=typeof self=="object"?self.FormData:window.FormData;const sn=rn;function Oe(e){return u.isPlainObject(e)||u.isArray(e)}function nt(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function rt(e,t,n){return e?e.concat(t).map(function(s,o){return s=nt(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function on(e){return u.isArray(e)&&!e.some(Oe)}const an=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function un(e){return e&&u.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function oe(e,t,n){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new(sn||FormData),n=u.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(_,w){return!u.isUndefined(w[_])});const r=n.metaTokens,s=n.visitor||f,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&un(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(u.isDate(p))return p.toISOString();if(!d&&u.isBlob(p))throw new b("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(p)||u.isTypedArray(p)?d&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function f(p,_,w){let S=p;if(p&&!w&&typeof p=="object"){if(u.endsWith(_,"{}"))_=r?_:_.slice(0,-2),p=JSON.stringify(p);else if(u.isArray(p)&&on(p)||u.isFileList(p)||u.endsWith(_,"[]")&&(S=u.toArray(p)))return _=nt(_),S.forEach(function(B,H){!(u.isUndefined(B)||B===null)&&t.append(i===!0?rt([_],H,o):i===null?_:_+"[]",a(B))}),!1}return Oe(p)?!0:(t.append(rt(w,_,o),a(p)),!1)}const l=[],y=Object.assign(an,{defaultVisitor:f,convertValue:a,isVisitable:Oe});function h(p,_){if(!u.isUndefined(p)){if(l.indexOf(p)!==-1)throw Error("Circular reference detected in "+_.join("."));l.push(p),u.forEach(p,function(S,P){(!(u.isUndefined(S)||S===null)&&s.call(t,S,u.isString(P)?P.trim():P,_,y))===!0&&h(S,_?_.concat(P):[P])}),l.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return h(e),t}function st(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Se(e,t){this._pairs=[],e&&oe(e,this,t)}const ot=Se.prototype;ot.append=function(t,n){this._pairs.push([t,n])},ot.toString=function(t){const n=t?function(r){return t.call(this,r,st)}:st;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function cn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function it(e,t,n){if(!t)return e;const r=n&&n.encode||cn,s=n&&n.serialize;let o;if(s?o=s(t,n):o=u.isURLSearchParams(t)?t.toString():new Se(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class ln{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){u.forEach(this.handlers,function(r){r!==null&&t(r)})}}const at=ln,ut={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},fn=typeof URLSearchParams<"u"?URLSearchParams:Se,dn=FormData,pn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),hn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),k={isBrowser:!0,classes:{URLSearchParams:fn,FormData:dn,Blob},isStandardBrowserEnv:pn,isStandardBrowserWebWorkerEnv:hn,protocols:["http","https","file","blob","url","data"]};function mn(e,t){return oe(e,new k.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return k.isNode&&u.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function _n(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function yn(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&u.isArray(s)?s.length:i,d?(u.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!u.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&u.isArray(s[i])&&(s[i]=yn(s[i])),!c)}if(u.isFormData(e)&&u.isFunction(e.entries)){const n={};return u.forEachEntry(e,(r,s)=>{t(_n(r),s,n,0)}),n}return null}const bn={"Content-Type":void 0};function En(e,t,n){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const ie={transitional:ut,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=u.isObject(t);if(o&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(ct(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return mn(t,this.formSerializer).toString();if((c=u.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return oe(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),En(t)):t}],transformResponse:[function(t){const n=this.transitional||ie.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&u.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?b.from(c,b.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:k.classes.FormData,Blob:k.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};u.forEach(["delete","get","head"],function(t){ie.headers[t]={}}),u.forEach(["post","put","patch"],function(t){ie.headers[t]=u.merge(bn)});const ge=ie,wn=u.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"]),On=e=>{const t={};let n,r,s;return e&&e.split(` -`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&wn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},lt=Symbol("internals");function Q(e){return e&&String(e).trim().toLowerCase()}function ae(e){return e===!1||e==null?e:u.isArray(e)?e.map(ae):String(e)}function Sn(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}function gn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ft(e,t,n,r){if(u.isFunction(r))return r.call(this,t,n);if(!!u.isString(t)){if(u.isString(r))return t.indexOf(r)!==-1;if(u.isRegExp(r))return r.test(t)}}function Rn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function An(e,t){const n=u.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class ue{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,a){const f=Q(d);if(!f)throw new Error("header name must be a non-empty string");const l=u.findKey(s,f);(!l||s[l]===void 0||a===!0||a===void 0&&s[l]!==!1)&&(s[l||d]=ae(c))}const i=(c,d)=>u.forEach(c,(a,f)=>o(a,f,d));return u.isPlainObject(t)||t instanceof this.constructor?i(t,n):u.isString(t)&&(t=t.trim())&&!gn(t)?i(On(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=Q(t),t){const r=u.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Sn(s);if(u.isFunction(n))return n.call(this,s,r);if(u.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Q(t),t){const r=u.findKey(this,t);return!!(r&&(!n||ft(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=Q(i),i){const c=u.findKey(r,i);c&&(!n||ft(r,r[c],c,n))&&(delete r[c],s=!0)}}return u.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return u.forEach(this,(s,o)=>{const i=u.findKey(r,o);if(i){n[i]=ae(s),delete n[o];return}const c=t?Rn(o):String(o).trim();c!==o&&delete n[o],n[c]=ae(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return u.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&u.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[lt]=this[lt]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=Q(i);r[c]||(An(s,i),r[c]=!0)}return u.isArray(t)?t.forEach(o):o(t),this}}ue.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(ue.prototype),u.freezeMethods(ue);const U=ue;function Re(e,t){const n=this||ge,r=t||n,s=U.from(r.headers);let o=r.data;return u.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function dt(e){return!!(e&&e.__CANCEL__)}function Y(e,t,n){b.call(this,e==null?"canceled":e,b.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(Y,b,{__CANCEL__:!0});const Tn=null;function Nn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new b("Request failed with status code "+n.status,[b.ERR_BAD_REQUEST,b.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Cn=k.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const d=[];d.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),u.isString(o)&&d.push("path="+o),u.isString(i)&&d.push("domain="+i),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Pn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function xn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function pt(e,t){return e&&!Pn(t)?xn(e,t):t}const kn=k.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=u.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function Fn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Dn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),f=r[o];i||(i=a),n[s]=d,r[s]=a;let l=o,y=0;for(;l!==s;)y+=n[l++],l=l%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,d=r(c),a=o<=i;n=o;const f={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};f[t?"download":"upload"]=!0,e(f)}}const ce={http:Tn,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=U.from(e.headers).normalize(),i=e.responseType;let c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(k.isStandardBrowserEnv||k.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const h=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(h+":"+p))}const f=pt(e.baseURL,e.url);a.open(e.method.toUpperCase(),it(f,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function l(){if(!a)return;const h=U.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),_={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:h,config:e,request:a};Nn(function(S){n(S),d()},function(S){r(S),d()},_),a=null}if("onloadend"in a?a.onloadend=l:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(l)},a.onabort=function(){!a||(r(new b("Request aborted",b.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new b("Network Error",b.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const _=e.transitional||ut;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new b(p,_.clarifyTimeoutError?b.ETIMEDOUT:b.ECONNABORTED,e,a)),a=null},k.isStandardBrowserEnv){const h=(e.withCredentials||kn(f))&&e.xsrfCookieName&&Cn.read(e.xsrfCookieName);h&&o.set(e.xsrfHeaderName,h)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&u.forEach(o.toJSON(),function(p,_){a.setRequestHeader(_,p)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",ht(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",ht(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=h=>{!a||(r(!h||h.type?new Y(null,e,a):h),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const y=Fn(f);if(y&&k.protocols.indexOf(y)===-1){r(new b("Unsupported protocol "+y+":",b.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(ce,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Un={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof U?e.toJSON():e;function q(e,t){t=t||{};const n={};function r(a,f,l){return u.isPlainObject(a)&&u.isPlainObject(f)?u.merge.call({caseless:l},a,f):u.isPlainObject(f)?u.merge({},f):u.isArray(f)?f.slice():f}function s(a,f,l){if(u.isUndefined(f)){if(!u.isUndefined(a))return r(void 0,a,l)}else return r(a,f,l)}function o(a,f){if(!u.isUndefined(f))return r(void 0,f)}function i(a,f){if(u.isUndefined(f)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,f)}function c(a,f,l){if(l in t)return r(a,f);if(l in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(a,f)=>s(_t(a),_t(f),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(f){const l=d[f]||s,y=l(e[f],t[f],f);u.isUndefined(y)&&l!==c||(n[f]=y)}),n}const yt="1.2.1",Te={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Te[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const bt={};Te.transitional=function(t,n,r){function s(o,i){return"[Axios v"+yt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new b(s(i," has been removed"+(n?" in "+n:"")),b.ERR_DEPRECATED);return n&&!bt[i]&&(bt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Bn(e,t,n){if(typeof e!="object")throw new b("options must be an object",b.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new b("option "+o+" must be "+d,b.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new b("Unknown option "+o,b.ERR_BAD_OPTION)}}const Ne={assertOptions:Bn,validators:Te},L=Ne.validators;class le{constructor(t){this.defaults=t,this.interceptors={request:new at,response:new at}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=q(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Ne.assertOptions(r,{silentJSONParsing:L.transitional(L.boolean),forcedJSONParsing:L.transitional(L.boolean),clarifyTimeoutError:L.transitional(L.boolean)},!1),s!==void 0&&Ne.assertOptions(s,{encode:L.function,serialize:L.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&u.merge(o.common,o[n.method]),i&&u.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=U.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(_){typeof _.runWhen=="function"&&_.runWhen(n)===!1||(d=d&&_.synchronous,c.unshift(_.fulfilled,_.rejected))});const a=[];this.interceptors.response.forEach(function(_){a.push(_.fulfilled,_.rejected)});let f,l=0,y;if(!d){const p=[mt.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,a),y=p.length,f=Promise.resolve(n);l{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new Y(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Ce(function(s){t=s}),cancel:t}}}const jn=Ce;function Ln(e){return function(n){return e.apply(null,n)}}function Hn(e){return u.isObject(e)&&e.isAxiosError===!0}function Et(e){const t=new fe(e),n=Ve(fe.prototype.request,t);return u.extend(n,fe.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Et(q(e,s))},n}const O=Et(ge);O.Axios=fe,O.CanceledError=Y,O.CancelToken=jn,O.isCancel=dt,O.VERSION=yt,O.toFormData=oe,O.AxiosError=b,O.Cancel=O.CanceledError,O.all=function(t){return Promise.all(t)},O.spread=Ln,O.isAxiosError=Hn,O.mergeConfig=q,O.AxiosHeaders=U,O.formToJSON=e=>ct(u.isHTMLForm(e)?new FormData(e):e),O.default=O;const Mn=O,cr="";function zn(e){let t,n,r,s,o,i=`${e[3]}%`;function c(l,y){return l[5]?Jn:qn}let d=c(e),a=d(e),f=e[6]&&Ot();return{c(){t=N("div"),n=N("div"),a.c(),r=j(),f&&f.c(),s=j(),o=N("div"),E(n,"class","z-20"),E(o,"id","percentage-bar"),E(o,"class","ease-in duration-300 z-10 absolute top-0 left-0 bottom-0 bg-blue-800"),je(o,"width",i),E(t,"id","percentage"),E(t,"class","w-full h-full text-center align-middle flex justify-center")},m(l,y){A(l,t,y),T(t,n),a.m(n,null),T(n,r),f&&f.m(n,null),T(t,s),T(t,o)},p(l,y){d===(d=c(l))&&a?a.p(l,y):(a.d(1),a=d(l),a&&(a.c(),a.m(n,r))),l[6]?f||(f=Ot(),f.c(),f.m(n,null)):f&&(f.d(1),f=null),y&8&&i!==(i=`${l[3]}%`)&&je(o,"width",i)},d(l){l&&R(t),a.d(),f&&f.d()}}}function In(e){let t;function n(o,i){return o[1]?Vn:vn}let r=n(e),s=r(e);return{c(){s.c(),t=Ue()},m(o,i){s.m(o,i),A(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&R(t)}}}function Jn(e){let t;return{c(){t=F("Waiting for data schema detection...")},m(n,r){A(n,t,r)},p:x,d(n){n&&R(t)}}}function qn(e){let t,n=!e[6]&&wt(e);return{c(){n&&n.c(),t=Ue()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[6]?n&&(n.d(1),n=null):n?n.p(r,s):(n=wt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&R(t)}}}function wt(e){let t,n;return{c(){t=F(e[3]),n=F("%")},m(r,s){A(r,t,s),A(r,n,s)},p(r,s){s&8&&Be(t,r[3])},d(r){r&&R(t),r&&R(n)}}}function Ot(e){let t;return{c(){t=F("File uploaded")},m(n,r){A(n,t,r)},d(n){n&&R(t)}}}function vn(e){let t;return{c(){t=F("Select a file to upload")},m(n,r){A(n,t,r)},d(n){n&&R(t)}}}function Vn(e){let t;return{c(){t=F("Select a file to replace the current one")},m(n,r){A(n,t,r)},d(n){n&&R(t)}}}function Wn(e){let t,n,r,s,o,i,c,d,a,f,l,y,h,p,_,w,S,P;function B(m,g){return!m[4]&&!m[5]&&!m[6]?In:zn}let H=B(e),C=H(e);return{c(){t=F(e[1]),n=j(),r=N("div"),s=N("div"),C.c(),o=j(),i=N("input"),c=j(),d=N("input"),f=j(),l=N("input"),y=j(),h=N("div"),p=N("label"),p.textContent="URL",_=j(),w=N("input"),E(s,"id","label"),E(s,"class","w-full h-full relative text-sky-100 place-content-center justify-center flex"),E(i,"type","hidden"),E(i,"name","url_type"),E(d,"type","hidden"),E(d,"name","clear_upload"),d.value=a=e[1]!=""?"true":"",E(l,"id","fileUpload"),E(l,"type","file"),E(l,"class","svelte-11h4gxn"),E(r,"id","fileUploadWidget"),E(r,"class","border-solid border-2 rounded border-sky-900 bg-sky-500 flex h-8 svelte-11h4gxn"),E(p,"for","field_url"),E(w,"id","field_url"),E(w,"class","form-control"),E(w,"type","text"),E(w,"name","url"),E(h,"class","controls pt-4")},m(m,g){A(m,t,g),A(m,n,g),A(m,r,g),T(r,s),C.m(s,null),T(r,o),T(r,i),$(i,e[7]),T(r,c),T(r,d),T(r,f),T(r,l),A(m,y,g),A(m,h,g),T(h,p),T(h,_),T(h,w),$(w,e[0]),S||(P=[Z(i,"input",e[12]),Z(l,"change",e[13]),Z(l,"change",e[8]),Z(w,"input",e[14])],S=!0)},p(m,[g]){g&2&&Be(t,m[1]),H===(H=B(m))&&C?C.p(m,g):(C.d(1),C=H(m),C&&(C.c(),C.m(s,null))),g&128&&$(i,m[7]),g&2&&a!==(a=m[1]!=""?"true":"")&&(d.value=a),g&1&&w.value!==m[0]&&$(w,m[0])},i:x,o:x,d(m){m&&R(t),m&&R(n),m&&R(r),C.d(),m&&R(y),m&&R(h),S=!1,v(P)}}}function Kn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:c}=t,d,a=0,f=!1,l=!1,y=!1,h="",p=Le(),_=i?"update":"create";async function w(m,g){try{const M={onUploadProgress:Pe=>{const{loaded:$n,total:er}=Pe,xe=Math.floor($n*100/er);xe<=100&&(g(xe),xe==100&&(n(4,f=!1),n(5,l=!0)))}},{data:de}=await Mn.post(`${r}/api/3/action/resource_${_}_with_schema`,m,M);return de}catch(M){console.log("ERROR",M.message)}}function S(m){n(3,a=m)}async function P(m){try{const g=m.target.files[0],M=new FormData;M.append("upload",g),M.append("package_id",s),i&&M.append("id",o),n(4,f=!0);let de=await w(M,S),Pe={data:de};n(0,c=de.result.url),n(7,h="upload"),p("fileUploaded",Pe),n(5,l=!1),n(6,y=!0)}catch(g){console.log("ERROR",g),S(0)}}function B(){h=this.value,n(7,h)}function H(){d=this.files,n(2,d)}function C(){c=this.value,n(0,c)}return e.$$set=m=>{"upload_url"in m&&n(9,r=m.upload_url),"dataset_id"in m&&n(10,s=m.dataset_id),"resource_id"in m&&n(11,o=m.resource_id),"update"in m&&n(1,i=m.update),"current_url"in m&&n(0,c=m.current_url)},[c,i,d,a,f,l,y,h,P,r,s,o,B,H,C]}class Xn extends ve{constructor(t){super(),qe(this,t,Kn,Wn,De,{upload_url:9,dataset_id:10,resource_id:11,update:1,current_url:0})}}function Gn(e){let t,n,r;return n=new Xn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4]}}),n.$on("fileUploaded",e[6]),{c(){t=N("main"),kt(n.$$.fragment),E(t,"class","tailwind")},m(s,o){A(s,t,o),Ie(n,t,null),e[7](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),n.$set(i)},i(s){r||(ze(n.$$.fragment,s),r=!0)},o(s){xt(n.$$.fragment,s),r=!1},d(s){s&&R(t),Je(n),e[7](null)}}}function Qn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:c}=t;Le();let d;function a(l){d.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:l.detail.data.result}))}function f(l){pe[l?"unshift":"push"](()=>{d=l,n(5,d)})}return e.$$set=l=>{"upload_url"in l&&n(0,r=l.upload_url),"dataset_id"in l&&n(1,s=l.dataset_id),"resource_id"in l&&n(2,o=l.resource_id),"update"in l&&n(3,i=l.update),"current_url"in l&&n(4,c=l.current_url)},[r,s,o,i,c,d,a,f]}class Yn extends ve{constructor(t){super(),qe(this,t,Qn,Gn,De,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4})}}function Zn(e,t="",n="",r="",s="",o=""){new Yn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,current_url:s,update:o}})}return Zn}); +(function(A,j){typeof exports=="object"&&typeof module<"u"?module.exports=j():typeof define=="function"&&define.amd?define(j):(A=typeof globalThis<"u"?globalThis:A||self,A.CkanUploader=j())})(this,function(){"use strict";function A(){}function j(e){return e()}function Pe(){return Object.create(null)}function z(e){e.forEach(j)}function ke(e){return typeof e=="function"}function Fe(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function Ot(e){return Object.keys(e).length===0}function T(e,t){e.appendChild(t)}function S(e,t,n){e.insertBefore(t,n||null)}function O(e){e.parentNode&&e.parentNode.removeChild(e)}function N(e){return document.createElement(e)}function F(e){return document.createTextNode(e)}function I(){return F(" ")}function ce(){return F("")}function le(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function b(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function St(e){return Array.from(e.childNodes)}function gt(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function De(e,t){e.value=t==null?"":t}function Ue(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function Rt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function At(){if(!J)throw new Error("Function called outside component initialization");return J}function Be(){const e=At();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=Rt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const V=[],fe=[],Q=[],je=[],Tt=Promise.resolve();let de=!1;function Nt(){de||(de=!0,Tt.then(Le))}function pe(e){Q.push(e)}const he=new Set;let Y=0;function Le(){const e=J;do{for(;Y{Z.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function kt(e){e&&e.c()}function Me(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||pe(()=>{const i=e.$$.on_mount.map(j).filter(ke);e.$$.on_destroy?e.$$.on_destroy.push(...i):z(i),e.$$.on_mount=[]}),o.forEach(pe)}function ze(e,t){const n=e.$$;n.fragment!==null&&(z(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Ft(e,t){e.$$.dirty[0]===-1&&(V.push(e),Nt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=m.length?m[0]:h;return a.ctx&&s(a.ctx[f],a.ctx[f]=p)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](p),l&&Ft(e,f)),h}):[],a.update(),l=!0,z(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=St(t.target);a.fragment&&a.fragment.l(f),f.forEach(O)}else a.fragment&&a.fragment.c();t.intro&&He(e.$$.fragment),Me(e,t.target,t.anchor,t.customElement),Le()}q(d)}class Je{$destroy(){ze(this,1),this.$destroy=A}$on(t,n){if(!ke(n))return A;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!Ot(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const tr="";function qe(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ve}=Object.prototype,{getPrototypeOf:me}=Object,_e=(e=>t=>{const n=Ve.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),P=e=>(e=e.toLowerCase(),t=>_e(t)===e),$=e=>t=>typeof t===e,{isArray:L}=Array,W=$("undefined");function Dt(e){return e!==null&&!W(e)&&e.constructor!==null&&!W(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const We=P("ArrayBuffer");function Ut(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&We(e.buffer),t}const Bt=$("string"),B=$("function"),Ke=$("number"),ye=e=>e!==null&&typeof e=="object",jt=e=>e===!0||e===!1,ee=e=>{if(_e(e)!=="object")return!1;const t=me(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Lt=P("Date"),Ht=P("File"),Mt=P("Blob"),zt=P("FileList"),It=e=>ye(e)&&B(e.pipe),Jt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||Ve.call(e)===t||B(e.toString)&&e.toString()===t)},qt=P("URLSearchParams"),Vt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function K(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),L(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Xe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ge=e=>!W(e)&&e!==Xe;function be(){const{caseless:e}=Ge(this)&&this||{},t={},n=(r,s)=>{const o=e&&ve(t,s)||s;ee(t[o])&&ee(r)?t[o]=be(t[o],r):ee(r)?t[o]=be({},r):L(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(K(t,(s,o)=>{n&&B(s)?e[o]=qe(s,n):e[o]=s},{allOwnKeys:r}),e),Kt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),vt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Xt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&me(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Gt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Qt=e=>{if(!e)return null;if(L(e))return e;let t=e.length;if(!Ke(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Yt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&me(Uint8Array)),Zt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},$t=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},en=P("HTMLFormElement"),tn=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Qe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),nn=P("RegExp"),Ye=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};K(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},u={isArray:L,isArrayBuffer:We,isBuffer:Dt,isFormData:Jt,isArrayBufferView:Ut,isString:Bt,isNumber:Ke,isBoolean:jt,isObject:ye,isPlainObject:ee,isUndefined:W,isDate:Lt,isFile:Ht,isBlob:Mt,isRegExp:nn,isFunction:B,isStream:It,isURLSearchParams:qt,isTypedArray:Yt,isFileList:zt,forEach:K,merge:be,extend:Wt,trim:Vt,stripBOM:Kt,inherits:vt,toFlatObject:Xt,kindOf:_e,kindOfTest:P,endsWith:Gt,toArray:Qt,forEachEntry:Zt,matchAll:$t,isHTMLForm:en,hasOwnProperty:Qe,hasOwnProp:Qe,reduceDescriptors:Ye,freezeMethods:e=>{Ye(e,(t,n)=>{if(B(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!B(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return L(e)?r(e):r(String(e).split(t)),n},toCamelCase:tn,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:ve,global:Xe,isContextDefined:Ge,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(ye(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=L(r)?[]:{};return K(r,(i,c)=>{const d=n(i,s+1);!W(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function y(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}u.inherits(y,Error,{toJSON:function(){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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ze=y.prototype,$e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{$e[e]={value:e}}),Object.defineProperties(y,$e),Object.defineProperty(Ze,"isAxiosError",{value:!0}),y.from=(e,t,n,r,s,o)=>{const i=Object.create(Ze);return u.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),y.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var rn=typeof self=="object"?self.FormData:window.FormData;const sn=rn;function Ee(e){return u.isPlainObject(e)||u.isArray(e)}function et(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,n){return e?e.concat(t).map(function(s,o){return s=et(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function on(e){return u.isArray(e)&&!e.some(Ee)}const an=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function un(e){return e&&u.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function te(e,t,n){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new(sn||FormData),n=u.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(_,R){return!u.isUndefined(R[_])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&un(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(u.isDate(p))return p.toISOString();if(!d&&u.isBlob(p))throw new y("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(p)||u.isTypedArray(p)?d&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function l(p,_,R){let g=p;if(p&&!R&&typeof p=="object"){if(u.endsWith(_,"{}"))_=r?_:_.slice(0,-2),p=JSON.stringify(p);else if(u.isArray(p)&&on(p)||u.isFileList(p)||u.endsWith(_,"[]")&&(g=u.toArray(p)))return _=et(_),g.forEach(function(M,Ne){!(u.isUndefined(M)||M===null)&&t.append(i===!0?tt([_],Ne,o):i===null?_:_+"[]",a(M))}),!1}return Ee(p)?!0:(t.append(tt(R,_,o),a(p)),!1)}const f=[],h=Object.assign(an,{defaultVisitor:l,convertValue:a,isVisitable:Ee});function m(p,_){if(!u.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+_.join("."));f.push(p),u.forEach(p,function(g,U){(!(u.isUndefined(g)||g===null)&&s.call(t,g,u.isString(U)?U.trim():U,_,h))===!0&&m(g,_?_.concat(U):[U])}),f.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return m(e),t}function nt(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function we(e,t){this._pairs=[],e&&te(e,this,t)}const rt=we.prototype;rt.append=function(t,n){this._pairs.push([t,n])},rt.toString=function(t){const n=t?function(r){return t.call(this,r,nt)}:nt;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function cn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function st(e,t,n){if(!t)return e;const r=n&&n.encode||cn,s=n&&n.serialize;let o;if(s?o=s(t,n):o=u.isURLSearchParams(t)?t.toString():new we(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class ln{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){u.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ot=ln,it={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},fn=typeof URLSearchParams<"u"?URLSearchParams:we,dn=FormData,pn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),hn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),C={isBrowser:!0,classes:{URLSearchParams:fn,FormData:dn,Blob},isStandardBrowserEnv:pn,isStandardBrowserWebWorkerEnv:hn,protocols:["http","https","file","blob","url","data"]};function mn(e,t){return te(e,new C.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return C.isNode&&u.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function _n(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function yn(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&u.isArray(s)?s.length:i,d?(u.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!u.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&u.isArray(s[i])&&(s[i]=yn(s[i])),!c)}if(u.isFormData(e)&&u.isFunction(e.entries)){const n={};return u.forEachEntry(e,(r,s)=>{t(_n(r),s,n,0)}),n}return null}const bn={"Content-Type":void 0};function En(e,t,n){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const ne={transitional:it,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=u.isObject(t);if(o&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(at(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return mn(t,this.formSerializer).toString();if((c=u.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return te(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),En(t)):t}],transformResponse:[function(t){const n=this.transitional||ne.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&u.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};u.forEach(["delete","get","head"],function(t){ne.headers[t]={}}),u.forEach(["post","put","patch"],function(t){ne.headers[t]=u.merge(bn)});const Oe=ne,wn=u.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"]),On=e=>{const t={};let n,r,s;return e&&e.split(` +`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&wn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ut=Symbol("internals");function v(e){return e&&String(e).trim().toLowerCase()}function re(e){return e===!1||e==null?e:u.isArray(e)?e.map(re):String(e)}function Sn(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}function gn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ct(e,t,n,r){if(u.isFunction(r))return r.call(this,t,n);if(!!u.isString(t)){if(u.isString(r))return t.indexOf(r)!==-1;if(u.isRegExp(r))return r.test(t)}}function Rn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function An(e,t){const n=u.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class se{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,a){const l=v(d);if(!l)throw new Error("header name must be a non-empty string");const f=u.findKey(s,l);(!f||s[f]===void 0||a===!0||a===void 0&&s[f]!==!1)&&(s[f||d]=re(c))}const i=(c,d)=>u.forEach(c,(a,l)=>o(a,l,d));return u.isPlainObject(t)||t instanceof this.constructor?i(t,n):u.isString(t)&&(t=t.trim())&&!gn(t)?i(On(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=v(t),t){const r=u.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Sn(s);if(u.isFunction(n))return n.call(this,s,r);if(u.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=v(t),t){const r=u.findKey(this,t);return!!(r&&(!n||ct(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=v(i),i){const c=u.findKey(r,i);c&&(!n||ct(r,r[c],c,n))&&(delete r[c],s=!0)}}return u.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return u.forEach(this,(s,o)=>{const i=u.findKey(r,o);if(i){n[i]=re(s),delete n[o];return}const c=t?Rn(o):String(o).trim();c!==o&&delete n[o],n[c]=re(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return u.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&u.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ut]=this[ut]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=v(i);r[c]||(An(s,i),r[c]=!0)}return u.isArray(t)?t.forEach(o):o(t),this}}se.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(se.prototype),u.freezeMethods(se);const k=se;function Se(e,t){const n=this||Oe,r=t||n,s=k.from(r.headers);let o=r.data;return u.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function lt(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){y.call(this,e==null?"canceled":e,y.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(X,y,{__CANCEL__:!0});const Tn=null;function Nn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Cn=C.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const d=[];d.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),u.isString(o)&&d.push("path="+o),u.isString(i)&&d.push("domain="+i),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function xn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Pn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function ft(e,t){return e&&!xn(t)?Pn(e,t):t}const kn=C.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=u.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function Fn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Dn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),l=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,h=0;for(;f!==s;)h+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,d=r(c),a=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const oe={http:Tn,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=k.from(e.headers).normalize(),i=e.responseType;let c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(C.isStandardBrowserEnv||C.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const m=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(m+":"+p))}const l=ft(e.baseURL,e.url);a.open(e.method.toUpperCase(),st(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const m=k.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),_={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:m,config:e,request:a};Nn(function(g){n(g),d()},function(g){r(g),d()},_),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new y("Request aborted",y.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new y("Network Error",y.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const _=e.transitional||it;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new y(p,_.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,a)),a=null},C.isStandardBrowserEnv){const m=(e.withCredentials||kn(l))&&e.xsrfCookieName&&Cn.read(e.xsrfCookieName);m&&o.set(e.xsrfHeaderName,m)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&u.forEach(o.toJSON(),function(p,_){a.setRequestHeader(_,p)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",dt(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",dt(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=m=>{!a||(r(!m||m.type?new X(null,e,a):m),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const h=Fn(l);if(h&&C.protocols.indexOf(h)===-1){r(new y("Unsupported protocol "+h+":",y.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(oe,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Un={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof k?e.toJSON():e;function H(e,t){t=t||{};const n={};function r(a,l,f){return u.isPlainObject(a)&&u.isPlainObject(l)?u.merge.call({caseless:f},a,l):u.isPlainObject(l)?u.merge({},l):u.isArray(l)?l.slice():l}function s(a,l,f){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a,f)}else return r(a,l,f)}function o(a,l){if(!u.isUndefined(l))return r(void 0,l)}function i(a,l){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function c(a,l,f){if(f in t)return r(a,l);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(a,l)=>s(ht(a),ht(l),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const f=d[l]||s,h=f(e[l],t[l],l);u.isUndefined(h)&&f!==c||(n[l]=h)}),n}const mt="1.2.1",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _t={};Re.transitional=function(t,n,r){function s(o,i){return"[Axios v"+mt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new y(s(i," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!_t[i]&&(_t[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Bn(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new y("option "+o+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+o,y.ERR_BAD_OPTION)}}const Ae={assertOptions:Bn,validators:Re},D=Ae.validators;class ie{constructor(t){this.defaults=t,this.interceptors={request:new ot,response:new ot}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=H(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Ae.assertOptions(r,{silentJSONParsing:D.transitional(D.boolean),forcedJSONParsing:D.transitional(D.boolean),clarifyTimeoutError:D.transitional(D.boolean)},!1),s!==void 0&&Ae.assertOptions(s,{encode:D.function,serialize:D.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&u.merge(o.common,o[n.method]),i&&u.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=k.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(_){typeof _.runWhen=="function"&&_.runWhen(n)===!1||(d=d&&_.synchronous,c.unshift(_.fulfilled,_.rejected))});const a=[];this.interceptors.response.forEach(function(_){a.push(_.fulfilled,_.rejected)});let l,f=0,h;if(!d){const p=[pt.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,a),h=p.length,l=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new X(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Te(function(s){t=s}),cancel:t}}}const jn=Te;function Ln(e){return function(n){return e.apply(null,n)}}function Hn(e){return u.isObject(e)&&e.isAxiosError===!0}function yt(e){const t=new ae(e),n=qe(ae.prototype.request,t);return u.extend(n,ae.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yt(H(e,s))},n}const E=yt(Oe);E.Axios=ae,E.CanceledError=X,E.CancelToken=jn,E.isCancel=lt,E.VERSION=mt,E.toFormData=te,E.AxiosError=y,E.Cancel=E.CanceledError,E.all=function(t){return Promise.all(t)},E.spread=Ln,E.isAxiosError=Hn,E.mergeConfig=H,E.AxiosHeaders=k,E.formToJSON=e=>at(u.isHTMLForm(e)?new FormData(e):e),E.default=E;const Mn=E,cr="";function zn(e){let t,n,r,s,o,i=`${e[4]}%`;function c(f,h){return f[6]?Jn:qn}let d=c(e),a=d(e),l=e[7]&&Et();return{c(){t=N("div"),n=N("div"),a.c(),r=I(),l&&l.c(),s=I(),o=N("div"),b(n,"class","z-20"),b(o,"id","percentage-bar"),b(o,"class","ease-in duration-300 z-10 absolute top-0 left-0 bottom-0 bg-blue-800"),Ue(o,"width",i),b(t,"id","percentage"),b(t,"class","w-full h-full text-center align-middle flex justify-center")},m(f,h){S(f,t,h),T(t,n),a.m(n,null),T(n,r),l&&l.m(n,null),T(t,s),T(t,o)},p(f,h){d===(d=c(f))&&a?a.p(f,h):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[7]?l||(l=Et(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),h&16&&i!==(i=`${f[4]}%`)&&Ue(o,"width",i)},d(f){f&&O(t),a.d(),l&&l.d()}}}function In(e){let t;function n(o,i){return o[2]?Wn:Vn}let r=n(e),s=r(e);return{c(){s.c(),t=ce()},m(o,i){s.m(o,i),S(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&O(t)}}}function Jn(e){let t;return{c(){t=F("Waiting for data schema detection...")},m(n,r){S(n,t,r)},p:A,d(n){n&&O(t)}}}function qn(e){let t,n=!e[7]&&bt(e);return{c(){n&&n.c(),t=ce()},m(r,s){n&&n.m(r,s),S(r,t,s)},p(r,s){r[7]?n&&(n.d(1),n=null):n?n.p(r,s):(n=bt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&O(t)}}}function bt(e){let t,n;return{c(){t=F(e[4]),n=F("%")},m(r,s){S(r,t,s),S(r,n,s)},p(r,s){s&16&>(t,r[4])},d(r){r&&O(t),r&&O(n)}}}function Et(e){let t;return{c(){t=F("File uploaded")},m(n,r){S(n,t,r)},d(n){n&&O(t)}}}function Vn(e){let t;return{c(){t=F("Select a file to upload")},m(n,r){S(n,t,r)},d(n){n&&O(t)}}}function Wn(e){let t;return{c(){t=F("Select a file to replace the current one")},m(n,r){S(n,t,r)},d(n){n&&O(t)}}}function wt(e){let t,n,r,s,o,i;return{c(){t=N("div"),n=N("label"),n.textContent="URL",r=I(),s=N("input"),b(n,"for","field_url"),b(s,"id","field_url"),b(s,"class","form-control"),b(s,"type","text"),b(s,"name","url"),b(t,"class","controls pt-4")},m(c,d){S(c,t,d),T(t,n),T(t,r),T(t,s),De(s,e[0]),o||(i=le(s,"input",e[13]),o=!0)},p(c,d){d&1&&s.value!==c[0]&&De(s,c[0])},d(c){c&&O(t),o=!1,i()}}}function Kn(e){let t,n,r,s,o,i,c,d;function a(m,p){return!m[5]&&!m[6]&&!m[7]?In:zn}let l=a(e),f=l(e),h=e[1]!="upload"&&wt(e);return{c(){t=N("div"),n=N("div"),f.c(),r=I(),s=N("input"),o=I(),h&&h.c(),i=ce(),b(n,"id","label"),b(n,"class","w-full h-full relative text-sky-100 place-content-center justify-center flex"),b(s,"id","fileUpload"),b(s,"type","file"),b(s,"class","svelte-11h4gxn"),b(t,"id","fileUploadWidget"),b(t,"class","border-solid border-2 rounded border-sky-900 bg-sky-500 flex h-8 svelte-11h4gxn")},m(m,p){S(m,t,p),T(t,n),f.m(n,null),T(t,r),T(t,s),S(m,o,p),h&&h.m(m,p),S(m,i,p),c||(d=[le(s,"change",e[12]),le(s,"change",e[8])],c=!0)},p(m,[p]){l===(l=a(m))&&f?f.p(m,p):(f.d(1),f=l(m),f&&(f.c(),f.m(n,null))),m[1]!="upload"?h?h.p(m,p):(h=wt(m),h.c(),h.m(i.parentNode,i)):h&&(h.d(1),h=null)},i:A,o:A,d(m){m&&O(t),f.d(),m&&O(o),h&&h.d(m),m&&O(i),c=!1,z(d)}}}function vn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:c}=t,{url_type:d=""}=t,a,l=0,f=!1,h=!1,m=!1,p=Be(),_=i?"update":"create";async function R(w,G){try{const x={onUploadProgress:Ce=>{const{loaded:$n,total:er}=Ce,xe=Math.floor($n*100/er);xe<=100&&(G(xe),xe==100&&(n(5,f=!1),n(6,h=!0)))}},{data:ue}=await Mn.post(`${r}/api/3/action/resource_${_}_with_schema`,w,x);return ue}catch(x){console.log("ERROR",x.message)}}function g(w){n(4,l=w)}async function U(w){try{const G=w.target.files[0],x=new FormData;x.append("upload",G),x.append("package_id",s),i&&(x.append("id",o),x.append("clear_upload",!0),x.append("url_type",d)),n(5,f=!0);let ue=await R(x,g),Ce={data:ue};n(0,c=ue.result.url),n(1,d="upload"),p("fileUploaded",Ce),n(6,h=!1),n(7,m=!0)}catch(G){console.log("ERROR",G),g(0)}}function M(){a=this.files,n(3,a)}function Ne(){c=this.value,n(0,c)}return e.$$set=w=>{"upload_url"in w&&n(9,r=w.upload_url),"dataset_id"in w&&n(10,s=w.dataset_id),"resource_id"in w&&n(11,o=w.resource_id),"update"in w&&n(2,i=w.update),"current_url"in w&&n(0,c=w.current_url),"url_type"in w&&n(1,d=w.url_type)},[c,d,i,a,l,f,h,m,U,r,s,o,M,Ne]}class Xn extends Je{constructor(t){super(),Ie(this,t,vn,Kn,Fe,{upload_url:9,dataset_id:10,resource_id:11,update:2,current_url:0,url_type:1})}}function Gn(e){let t,n,r;return n=new Xn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=N("main"),kt(n.$$.fragment),b(t,"class","tailwind")},m(s,o){S(s,t,o),Me(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(He(n.$$.fragment,s),r=!0)},o(s){Pt(n.$$.fragment,s),r=!1},d(s){s&&O(t),ze(n),e[8](null)}}}function Qn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:c}=t,{url_type:d}=t;Be();let a;function l(h){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:h.detail.data.result}))}function f(h){fe[h?"unshift":"push"](()=>{a=h,n(6,a)})}return e.$$set=h=>{"upload_url"in h&&n(0,r=h.upload_url),"dataset_id"in h&&n(1,s=h.dataset_id),"resource_id"in h&&n(2,o=h.resource_id),"update"in h&&n(3,i=h.update),"current_url"in h&&n(4,c=h.current_url),"url_type"in h&&n(5,d=h.url_type)},[r,s,o,i,c,d,a,l,f]}class Yn extends Je{constructor(t){super(),Ie(this,t,Qn,Gn,Fe,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function Zn(e,t="",n="",r="",s="",o="",i=""){new Yn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return Zn}); diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js index 05d37e38..c9f87bc7 100644 --- a/ckanext/validation/webassets/js/module-ckan-uploader.js +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -6,6 +6,7 @@ ckan.module('ckan-uploader', function (jQuery) { upload_url: '', dataset_id: '', resource_id: '', + url_type: '', current_url: false, update: false }, @@ -29,7 +30,7 @@ ckan.module('ckan-uploader', function (jQuery) { json_button.dispatchEvent(new Event('click')) // Set the form action to save the created resource - if (resource_id == '' && resource_id == true) { + if (resource_id == '' || resource_id == true) { let resource_form = document.getElementById('resource-edit') let current_action = resource_form.action let lastIndexNew = current_action.lastIndexOf('new') @@ -37,7 +38,13 @@ ckan.module('ckan-uploader', function (jQuery) { } }, initialize: function() { - CkanUploader('ckan_uploader', this.options.upload_url, this.options.dataset_id, (this.options.resource_id != true)?this.options.resource_id:'', (this.options.current_url != true)?this.options.current_url:'', (this.options.update != true)?this.options.update:'') + CkanUploader('ckan_uploader', + this.options.upload_url, + this.options.dataset_id, + (this.options.resource_id != true)?this.options.resource_id:'', + (this.options.url_type != true)?this.options.url_type:'', + (this.options.current_url != true)?this.options.current_url:'', + (this.options.update != true)?this.options.update:'') document.getElementById('ckan_uploader').addEventListener('fileUploaded', this.afterUpload(this.options.resource_id)) } } From 52ca754826e9d5e7f8f06ea3109f7b64e9a9cd18 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Tue, 13 Dec 2022 21:56:36 +0100 Subject: [PATCH 09/43] get variables from resource form from hidden inputs --- .../examples/ckan_default_schema.json | 6 +++++ .../package/snippets/resource_form.html | 12 ++++++---- .../webassets/css/ckan-uploader.css | 2 +- .../validation/webassets/js/ckan-uploader.js | 6 ++--- .../webassets/js/module-ckan-uploader.js | 23 ++++++++++--------- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/ckanext/validation/examples/ckan_default_schema.json b/ckanext/validation/examples/ckan_default_schema.json index 2c640118..e55a9973 100644 --- a/ckanext/validation/examples/ckan_default_schema.json +++ b/ckanext/validation/examples/ckan_default_schema.json @@ -83,6 +83,12 @@ } ], "resource_fields": [ + { + "field_name": "url", + "label": "URL", + "preset": "resource_url_upload", + "form_snippet": "ckan_uploader.html" + }, { "field_name": "name", "label": "Name", diff --git a/ckanext/validation/templates/package/snippets/resource_form.html b/ckanext/validation/templates/package/snippets/resource_form.html index 3c4abb18..c89f0205 100644 --- a/ckanext/validation/templates/package/snippets/resource_form.html +++ b/ckanext/validation/templates/package/snippets/resource_form.html @@ -17,11 +17,6 @@ {% block errors %}{{ form.errors(error_summary) }}{% endblock %} - -
- -
-
{% block basic_fields %} {% block basic_fields_url %} {% endblock %} @@ -61,6 +56,13 @@ {% endblock %}
+ + + + + + + {% block delete_button %} {% if data.id %} {% if h.check_access('resource_delete', {'id': data.id}) %} diff --git a/ckanext/validation/webassets/css/ckan-uploader.css b/ckanext/validation/webassets/css/ckan-uploader.css index 7c9ff18a..28ed9299 100644 --- a/ckanext/validation/webassets/css/ckan-uploader.css +++ b/ckanext/validation/webassets/css/ckan-uploader.css @@ -1 +1 @@ -.tailwind *,.tailwind :before,.tailwind :after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}.tailwind :before,.tailwind :after{--tw-content: ""}.tailwind html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal}.tailwind body{margin:0;line-height:inherit}.tailwind hr{height:0;color:inherit;border-top-width:1px}.tailwind abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6{font-size:inherit;font-weight:inherit}.tailwind a{color:inherit;text-decoration:inherit}.tailwind b,.tailwind strong{font-weight:bolder}.tailwind code,.tailwind kbd,.tailwind samp,.tailwind pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}.tailwind small{font-size:80%}.tailwind sub,.tailwind sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.tailwind sub{bottom:-.25em}.tailwind sup{top:-.5em}.tailwind table{text-indent:0;border-color:inherit;border-collapse:collapse}.tailwind button,.tailwind input,.tailwind optgroup,.tailwind select,.tailwind textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}.tailwind button,.tailwind select{text-transform:none}.tailwind button,.tailwind [type=button],.tailwind [type=reset],.tailwind [type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}.tailwind :-moz-focusring{outline:auto}.tailwind :-moz-ui-invalid{box-shadow:none}.tailwind progress{vertical-align:baseline}.tailwind ::-webkit-inner-spin-button,.tailwind ::-webkit-outer-spin-button{height:auto}.tailwind [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.tailwind ::-webkit-search-decoration{-webkit-appearance:none}.tailwind ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.tailwind summary{display:list-item}.tailwind blockquote,.tailwind dl,.tailwind dd,.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6,.tailwind hr,.tailwind figure,.tailwind p,.tailwind pre{margin:0}.tailwind fieldset{margin:0;padding:0}.tailwind legend{padding:0}.tailwind ol,.tailwind ul,.tailwind menu{list-style:none;margin:0;padding:0}.tailwind textarea{resize:vertical}.tailwind input::-moz-placeholder,.tailwind textarea::-moz-placeholder{opacity:1;color:#9ca3af}.tailwind input::placeholder,.tailwind textarea::placeholder{opacity:1;color:#9ca3af}.tailwind button,.tailwind [role=button]{cursor:pointer}.tailwind :disabled{cursor:default}.tailwind img,.tailwind svg,.tailwind video,.tailwind canvas,.tailwind audio,.tailwind iframe,.tailwind embed,.tailwind object{display:block;vertical-align:middle}.tailwind img,.tailwind video{max-width:100%;height:auto}.tailwind [hidden]{display:none}.tailwind *,.tailwind :before,.tailwind :after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind ::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind .absolute{position:absolute}.tailwind .relative{position:relative}.tailwind .top-0{top:0px}.tailwind .left-0{left:0px}.tailwind .bottom-0{bottom:0px}.tailwind .z-20{z-index:20}.tailwind .z-10{z-index:10}.tailwind .flex{display:flex}.tailwind .h-8{height:2rem}.tailwind .h-full{height:100%}.tailwind .w-full{width:100%}.tailwind .place-content-center{place-content:center}.tailwind .justify-center{justify-content:center}.tailwind .rounded{border-radius:.25rem}.tailwind .border-2{border-width:2px}.tailwind .border-solid{border-style:solid}.tailwind .border-sky-900{--tw-border-opacity: 1;border-color:rgb(12 74 110 / var(--tw-border-opacity))}.tailwind .bg-sky-500{--tw-bg-opacity: 1;background-color:rgb(14 165 233 / var(--tw-bg-opacity))}.tailwind .bg-blue-800{--tw-bg-opacity: 1;background-color:rgb(30 64 175 / var(--tw-bg-opacity))}.tailwind .pt-4{padding-top:1rem}.tailwind .text-center{text-align:center}.tailwind .align-middle{vertical-align:middle}.tailwind .text-sky-100{--tw-text-opacity: 1;color:rgb(224 242 254 / var(--tw-text-opacity))}.tailwind .duration-300{transition-duration:.3s}.tailwind .ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}#fileUploadWidget.svelte-11h4gxn{position:relative;display:flex;max-width:400px}#fileUpload.svelte-11h4gxn{position:absolute;width:100%;height:100%;top:0;left:0;opacity:0} +.tailwind *,.tailwind :before,.tailwind :after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}.tailwind :before,.tailwind :after{--tw-content: ""}.tailwind html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal}.tailwind body{margin:0;line-height:inherit}.tailwind hr{height:0;color:inherit;border-top-width:1px}.tailwind abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6{font-size:inherit;font-weight:inherit}.tailwind a{color:inherit;text-decoration:inherit}.tailwind b,.tailwind strong{font-weight:bolder}.tailwind code,.tailwind kbd,.tailwind samp,.tailwind pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}.tailwind small{font-size:80%}.tailwind sub,.tailwind sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.tailwind sub{bottom:-.25em}.tailwind sup{top:-.5em}.tailwind table{text-indent:0;border-color:inherit;border-collapse:collapse}.tailwind button,.tailwind input,.tailwind optgroup,.tailwind select,.tailwind textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}.tailwind button,.tailwind select{text-transform:none}.tailwind button,.tailwind [type=button],.tailwind [type=reset],.tailwind [type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}.tailwind :-moz-focusring{outline:auto}.tailwind :-moz-ui-invalid{box-shadow:none}.tailwind progress{vertical-align:baseline}.tailwind ::-webkit-inner-spin-button,.tailwind ::-webkit-outer-spin-button{height:auto}.tailwind [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.tailwind ::-webkit-search-decoration{-webkit-appearance:none}.tailwind ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.tailwind summary{display:list-item}.tailwind blockquote,.tailwind dl,.tailwind dd,.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6,.tailwind hr,.tailwind figure,.tailwind p,.tailwind pre{margin:0}.tailwind fieldset{margin:0;padding:0}.tailwind legend{padding:0}.tailwind ol,.tailwind ul,.tailwind menu{list-style:none;margin:0;padding:0}.tailwind textarea{resize:vertical}.tailwind input::-moz-placeholder,.tailwind textarea::-moz-placeholder{opacity:1;color:#9ca3af}.tailwind input::placeholder,.tailwind textarea::placeholder{opacity:1;color:#9ca3af}.tailwind button,.tailwind [role=button]{cursor:pointer}.tailwind :disabled{cursor:default}.tailwind img,.tailwind svg,.tailwind video,.tailwind canvas,.tailwind audio,.tailwind iframe,.tailwind embed,.tailwind object{display:block;vertical-align:middle}.tailwind img,.tailwind video{max-width:100%;height:auto}.tailwind [hidden]{display:none}.tailwind *,.tailwind :before,.tailwind :after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind ::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind .absolute{position:absolute}.tailwind .relative{position:relative}.tailwind .top-0{top:0px}.tailwind .left-0{left:0px}.tailwind .bottom-0{bottom:0px}.tailwind .z-20{z-index:20}.tailwind .z-10{z-index:10}.tailwind .inline{display:inline}.tailwind .flex{display:flex}.tailwind .h-8{height:2rem}.tailwind .h-full{height:100%}.tailwind .w-full{width:100%}.tailwind .place-content-center{place-content:center}.tailwind .justify-center{justify-content:center}.tailwind .rounded{border-radius:.25rem}.tailwind .border-2{border-width:2px}.tailwind .border-solid{border-style:solid}.tailwind .border-sky-900{--tw-border-opacity: 1;border-color:rgb(12 74 110 / var(--tw-border-opacity))}.tailwind .bg-sky-500{--tw-bg-opacity: 1;background-color:rgb(14 165 233 / var(--tw-bg-opacity))}.tailwind .bg-blue-800{--tw-bg-opacity: 1;background-color:rgb(30 64 175 / var(--tw-bg-opacity))}.tailwind .pt-4{padding-top:1rem}.tailwind .text-center{text-align:center}.tailwind .align-middle{vertical-align:middle}.tailwind .text-sky-100{--tw-text-opacity: 1;color:rgb(224 242 254 / var(--tw-text-opacity))}.tailwind .duration-300{transition-duration:.3s}.tailwind .ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}#fileUploadWidget.svelte-11h4gxn{position:relative;display:flex;max-width:400px}#fileUpload.svelte-11h4gxn{position:absolute;width:100%;height:100%;top:0;left:0;opacity:0} diff --git a/ckanext/validation/webassets/js/ckan-uploader.js b/ckanext/validation/webassets/js/ckan-uploader.js index 9e90eee0..10f56808 100644 --- a/ckanext/validation/webassets/js/ckan-uploader.js +++ b/ckanext/validation/webassets/js/ckan-uploader.js @@ -1,3 +1,3 @@ -(function(A,j){typeof exports=="object"&&typeof module<"u"?module.exports=j():typeof define=="function"&&define.amd?define(j):(A=typeof globalThis<"u"?globalThis:A||self,A.CkanUploader=j())})(this,function(){"use strict";function A(){}function j(e){return e()}function Pe(){return Object.create(null)}function z(e){e.forEach(j)}function ke(e){return typeof e=="function"}function Fe(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function Ot(e){return Object.keys(e).length===0}function T(e,t){e.appendChild(t)}function S(e,t,n){e.insertBefore(t,n||null)}function O(e){e.parentNode&&e.parentNode.removeChild(e)}function N(e){return document.createElement(e)}function F(e){return document.createTextNode(e)}function I(){return F(" ")}function ce(){return F("")}function le(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function b(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function St(e){return Array.from(e.childNodes)}function gt(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function De(e,t){e.value=t==null?"":t}function Ue(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function Rt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function At(){if(!J)throw new Error("Function called outside component initialization");return J}function Be(){const e=At();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=Rt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const V=[],fe=[],Q=[],je=[],Tt=Promise.resolve();let de=!1;function Nt(){de||(de=!0,Tt.then(Le))}function pe(e){Q.push(e)}const he=new Set;let Y=0;function Le(){const e=J;do{for(;Y{Z.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function kt(e){e&&e.c()}function Me(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||pe(()=>{const i=e.$$.on_mount.map(j).filter(ke);e.$$.on_destroy?e.$$.on_destroy.push(...i):z(i),e.$$.on_mount=[]}),o.forEach(pe)}function ze(e,t){const n=e.$$;n.fragment!==null&&(z(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Ft(e,t){e.$$.dirty[0]===-1&&(V.push(e),Nt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=m.length?m[0]:h;return a.ctx&&s(a.ctx[f],a.ctx[f]=p)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](p),l&&Ft(e,f)),h}):[],a.update(),l=!0,z(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=St(t.target);a.fragment&&a.fragment.l(f),f.forEach(O)}else a.fragment&&a.fragment.c();t.intro&&He(e.$$.fragment),Me(e,t.target,t.anchor,t.customElement),Le()}q(d)}class Je{$destroy(){ze(this,1),this.$destroy=A}$on(t,n){if(!ke(n))return A;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!Ot(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const tr="";function qe(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ve}=Object.prototype,{getPrototypeOf:me}=Object,_e=(e=>t=>{const n=Ve.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),P=e=>(e=e.toLowerCase(),t=>_e(t)===e),$=e=>t=>typeof t===e,{isArray:L}=Array,W=$("undefined");function Dt(e){return e!==null&&!W(e)&&e.constructor!==null&&!W(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const We=P("ArrayBuffer");function Ut(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&We(e.buffer),t}const Bt=$("string"),B=$("function"),Ke=$("number"),ye=e=>e!==null&&typeof e=="object",jt=e=>e===!0||e===!1,ee=e=>{if(_e(e)!=="object")return!1;const t=me(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Lt=P("Date"),Ht=P("File"),Mt=P("Blob"),zt=P("FileList"),It=e=>ye(e)&&B(e.pipe),Jt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||Ve.call(e)===t||B(e.toString)&&e.toString()===t)},qt=P("URLSearchParams"),Vt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function K(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),L(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Xe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ge=e=>!W(e)&&e!==Xe;function be(){const{caseless:e}=Ge(this)&&this||{},t={},n=(r,s)=>{const o=e&&ve(t,s)||s;ee(t[o])&&ee(r)?t[o]=be(t[o],r):ee(r)?t[o]=be({},r):L(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(K(t,(s,o)=>{n&&B(s)?e[o]=qe(s,n):e[o]=s},{allOwnKeys:r}),e),Kt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),vt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Xt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&me(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Gt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Qt=e=>{if(!e)return null;if(L(e))return e;let t=e.length;if(!Ke(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Yt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&me(Uint8Array)),Zt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},$t=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},en=P("HTMLFormElement"),tn=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Qe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),nn=P("RegExp"),Ye=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};K(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},u={isArray:L,isArrayBuffer:We,isBuffer:Dt,isFormData:Jt,isArrayBufferView:Ut,isString:Bt,isNumber:Ke,isBoolean:jt,isObject:ye,isPlainObject:ee,isUndefined:W,isDate:Lt,isFile:Ht,isBlob:Mt,isRegExp:nn,isFunction:B,isStream:It,isURLSearchParams:qt,isTypedArray:Yt,isFileList:zt,forEach:K,merge:be,extend:Wt,trim:Vt,stripBOM:Kt,inherits:vt,toFlatObject:Xt,kindOf:_e,kindOfTest:P,endsWith:Gt,toArray:Qt,forEachEntry:Zt,matchAll:$t,isHTMLForm:en,hasOwnProperty:Qe,hasOwnProp:Qe,reduceDescriptors:Ye,freezeMethods:e=>{Ye(e,(t,n)=>{if(B(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!B(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return L(e)?r(e):r(String(e).split(t)),n},toCamelCase:tn,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:ve,global:Xe,isContextDefined:Ge,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(ye(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=L(r)?[]:{};return K(r,(i,c)=>{const d=n(i,s+1);!W(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function y(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}u.inherits(y,Error,{toJSON:function(){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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ze=y.prototype,$e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{$e[e]={value:e}}),Object.defineProperties(y,$e),Object.defineProperty(Ze,"isAxiosError",{value:!0}),y.from=(e,t,n,r,s,o)=>{const i=Object.create(Ze);return u.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),y.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var rn=typeof self=="object"?self.FormData:window.FormData;const sn=rn;function Ee(e){return u.isPlainObject(e)||u.isArray(e)}function et(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,n){return e?e.concat(t).map(function(s,o){return s=et(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function on(e){return u.isArray(e)&&!e.some(Ee)}const an=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function un(e){return e&&u.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function te(e,t,n){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new(sn||FormData),n=u.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(_,R){return!u.isUndefined(R[_])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&un(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(u.isDate(p))return p.toISOString();if(!d&&u.isBlob(p))throw new y("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(p)||u.isTypedArray(p)?d&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function l(p,_,R){let g=p;if(p&&!R&&typeof p=="object"){if(u.endsWith(_,"{}"))_=r?_:_.slice(0,-2),p=JSON.stringify(p);else if(u.isArray(p)&&on(p)||u.isFileList(p)||u.endsWith(_,"[]")&&(g=u.toArray(p)))return _=et(_),g.forEach(function(M,Ne){!(u.isUndefined(M)||M===null)&&t.append(i===!0?tt([_],Ne,o):i===null?_:_+"[]",a(M))}),!1}return Ee(p)?!0:(t.append(tt(R,_,o),a(p)),!1)}const f=[],h=Object.assign(an,{defaultVisitor:l,convertValue:a,isVisitable:Ee});function m(p,_){if(!u.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+_.join("."));f.push(p),u.forEach(p,function(g,U){(!(u.isUndefined(g)||g===null)&&s.call(t,g,u.isString(U)?U.trim():U,_,h))===!0&&m(g,_?_.concat(U):[U])}),f.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return m(e),t}function nt(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function we(e,t){this._pairs=[],e&&te(e,this,t)}const rt=we.prototype;rt.append=function(t,n){this._pairs.push([t,n])},rt.toString=function(t){const n=t?function(r){return t.call(this,r,nt)}:nt;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function cn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function st(e,t,n){if(!t)return e;const r=n&&n.encode||cn,s=n&&n.serialize;let o;if(s?o=s(t,n):o=u.isURLSearchParams(t)?t.toString():new we(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class ln{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){u.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ot=ln,it={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},fn=typeof URLSearchParams<"u"?URLSearchParams:we,dn=FormData,pn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),hn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),C={isBrowser:!0,classes:{URLSearchParams:fn,FormData:dn,Blob},isStandardBrowserEnv:pn,isStandardBrowserWebWorkerEnv:hn,protocols:["http","https","file","blob","url","data"]};function mn(e,t){return te(e,new C.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return C.isNode&&u.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function _n(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function yn(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&u.isArray(s)?s.length:i,d?(u.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!u.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&u.isArray(s[i])&&(s[i]=yn(s[i])),!c)}if(u.isFormData(e)&&u.isFunction(e.entries)){const n={};return u.forEachEntry(e,(r,s)=>{t(_n(r),s,n,0)}),n}return null}const bn={"Content-Type":void 0};function En(e,t,n){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const ne={transitional:it,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=u.isObject(t);if(o&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(at(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return mn(t,this.formSerializer).toString();if((c=u.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return te(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),En(t)):t}],transformResponse:[function(t){const n=this.transitional||ne.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&u.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};u.forEach(["delete","get","head"],function(t){ne.headers[t]={}}),u.forEach(["post","put","patch"],function(t){ne.headers[t]=u.merge(bn)});const Oe=ne,wn=u.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"]),On=e=>{const t={};let n,r,s;return e&&e.split(` -`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&wn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ut=Symbol("internals");function v(e){return e&&String(e).trim().toLowerCase()}function re(e){return e===!1||e==null?e:u.isArray(e)?e.map(re):String(e)}function Sn(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}function gn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ct(e,t,n,r){if(u.isFunction(r))return r.call(this,t,n);if(!!u.isString(t)){if(u.isString(r))return t.indexOf(r)!==-1;if(u.isRegExp(r))return r.test(t)}}function Rn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function An(e,t){const n=u.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class se{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,a){const l=v(d);if(!l)throw new Error("header name must be a non-empty string");const f=u.findKey(s,l);(!f||s[f]===void 0||a===!0||a===void 0&&s[f]!==!1)&&(s[f||d]=re(c))}const i=(c,d)=>u.forEach(c,(a,l)=>o(a,l,d));return u.isPlainObject(t)||t instanceof this.constructor?i(t,n):u.isString(t)&&(t=t.trim())&&!gn(t)?i(On(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=v(t),t){const r=u.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Sn(s);if(u.isFunction(n))return n.call(this,s,r);if(u.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=v(t),t){const r=u.findKey(this,t);return!!(r&&(!n||ct(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=v(i),i){const c=u.findKey(r,i);c&&(!n||ct(r,r[c],c,n))&&(delete r[c],s=!0)}}return u.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return u.forEach(this,(s,o)=>{const i=u.findKey(r,o);if(i){n[i]=re(s),delete n[o];return}const c=t?Rn(o):String(o).trim();c!==o&&delete n[o],n[c]=re(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return u.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&u.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ut]=this[ut]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=v(i);r[c]||(An(s,i),r[c]=!0)}return u.isArray(t)?t.forEach(o):o(t),this}}se.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(se.prototype),u.freezeMethods(se);const k=se;function Se(e,t){const n=this||Oe,r=t||n,s=k.from(r.headers);let o=r.data;return u.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function lt(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){y.call(this,e==null?"canceled":e,y.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(X,y,{__CANCEL__:!0});const Tn=null;function Nn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Cn=C.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const d=[];d.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),u.isString(o)&&d.push("path="+o),u.isString(i)&&d.push("domain="+i),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function xn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Pn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function ft(e,t){return e&&!xn(t)?Pn(e,t):t}const kn=C.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=u.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function Fn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Dn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),l=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,h=0;for(;f!==s;)h+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,d=r(c),a=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const oe={http:Tn,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=k.from(e.headers).normalize(),i=e.responseType;let c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(C.isStandardBrowserEnv||C.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const m=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(m+":"+p))}const l=ft(e.baseURL,e.url);a.open(e.method.toUpperCase(),st(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const m=k.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),_={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:m,config:e,request:a};Nn(function(g){n(g),d()},function(g){r(g),d()},_),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new y("Request aborted",y.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new y("Network Error",y.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const _=e.transitional||it;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new y(p,_.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,a)),a=null},C.isStandardBrowserEnv){const m=(e.withCredentials||kn(l))&&e.xsrfCookieName&&Cn.read(e.xsrfCookieName);m&&o.set(e.xsrfHeaderName,m)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&u.forEach(o.toJSON(),function(p,_){a.setRequestHeader(_,p)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",dt(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",dt(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=m=>{!a||(r(!m||m.type?new X(null,e,a):m),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const h=Fn(l);if(h&&C.protocols.indexOf(h)===-1){r(new y("Unsupported protocol "+h+":",y.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(oe,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Un={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof k?e.toJSON():e;function H(e,t){t=t||{};const n={};function r(a,l,f){return u.isPlainObject(a)&&u.isPlainObject(l)?u.merge.call({caseless:f},a,l):u.isPlainObject(l)?u.merge({},l):u.isArray(l)?l.slice():l}function s(a,l,f){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a,f)}else return r(a,l,f)}function o(a,l){if(!u.isUndefined(l))return r(void 0,l)}function i(a,l){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function c(a,l,f){if(f in t)return r(a,l);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(a,l)=>s(ht(a),ht(l),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const f=d[l]||s,h=f(e[l],t[l],l);u.isUndefined(h)&&f!==c||(n[l]=h)}),n}const mt="1.2.1",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _t={};Re.transitional=function(t,n,r){function s(o,i){return"[Axios v"+mt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new y(s(i," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!_t[i]&&(_t[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Bn(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new y("option "+o+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+o,y.ERR_BAD_OPTION)}}const Ae={assertOptions:Bn,validators:Re},D=Ae.validators;class ie{constructor(t){this.defaults=t,this.interceptors={request:new ot,response:new ot}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=H(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Ae.assertOptions(r,{silentJSONParsing:D.transitional(D.boolean),forcedJSONParsing:D.transitional(D.boolean),clarifyTimeoutError:D.transitional(D.boolean)},!1),s!==void 0&&Ae.assertOptions(s,{encode:D.function,serialize:D.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&u.merge(o.common,o[n.method]),i&&u.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=k.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(_){typeof _.runWhen=="function"&&_.runWhen(n)===!1||(d=d&&_.synchronous,c.unshift(_.fulfilled,_.rejected))});const a=[];this.interceptors.response.forEach(function(_){a.push(_.fulfilled,_.rejected)});let l,f=0,h;if(!d){const p=[pt.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,a),h=p.length,l=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new X(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Te(function(s){t=s}),cancel:t}}}const jn=Te;function Ln(e){return function(n){return e.apply(null,n)}}function Hn(e){return u.isObject(e)&&e.isAxiosError===!0}function yt(e){const t=new ae(e),n=qe(ae.prototype.request,t);return u.extend(n,ae.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yt(H(e,s))},n}const E=yt(Oe);E.Axios=ae,E.CanceledError=X,E.CancelToken=jn,E.isCancel=lt,E.VERSION=mt,E.toFormData=te,E.AxiosError=y,E.Cancel=E.CanceledError,E.all=function(t){return Promise.all(t)},E.spread=Ln,E.isAxiosError=Hn,E.mergeConfig=H,E.AxiosHeaders=k,E.formToJSON=e=>at(u.isHTMLForm(e)?new FormData(e):e),E.default=E;const Mn=E,cr="";function zn(e){let t,n,r,s,o,i=`${e[4]}%`;function c(f,h){return f[6]?Jn:qn}let d=c(e),a=d(e),l=e[7]&&Et();return{c(){t=N("div"),n=N("div"),a.c(),r=I(),l&&l.c(),s=I(),o=N("div"),b(n,"class","z-20"),b(o,"id","percentage-bar"),b(o,"class","ease-in duration-300 z-10 absolute top-0 left-0 bottom-0 bg-blue-800"),Ue(o,"width",i),b(t,"id","percentage"),b(t,"class","w-full h-full text-center align-middle flex justify-center")},m(f,h){S(f,t,h),T(t,n),a.m(n,null),T(n,r),l&&l.m(n,null),T(t,s),T(t,o)},p(f,h){d===(d=c(f))&&a?a.p(f,h):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[7]?l||(l=Et(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),h&16&&i!==(i=`${f[4]}%`)&&Ue(o,"width",i)},d(f){f&&O(t),a.d(),l&&l.d()}}}function In(e){let t;function n(o,i){return o[2]?Wn:Vn}let r=n(e),s=r(e);return{c(){s.c(),t=ce()},m(o,i){s.m(o,i),S(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&O(t)}}}function Jn(e){let t;return{c(){t=F("Waiting for data schema detection...")},m(n,r){S(n,t,r)},p:A,d(n){n&&O(t)}}}function qn(e){let t,n=!e[7]&&bt(e);return{c(){n&&n.c(),t=ce()},m(r,s){n&&n.m(r,s),S(r,t,s)},p(r,s){r[7]?n&&(n.d(1),n=null):n?n.p(r,s):(n=bt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&O(t)}}}function bt(e){let t,n;return{c(){t=F(e[4]),n=F("%")},m(r,s){S(r,t,s),S(r,n,s)},p(r,s){s&16&>(t,r[4])},d(r){r&&O(t),r&&O(n)}}}function Et(e){let t;return{c(){t=F("File uploaded")},m(n,r){S(n,t,r)},d(n){n&&O(t)}}}function Vn(e){let t;return{c(){t=F("Select a file to upload")},m(n,r){S(n,t,r)},d(n){n&&O(t)}}}function Wn(e){let t;return{c(){t=F("Select a file to replace the current one")},m(n,r){S(n,t,r)},d(n){n&&O(t)}}}function wt(e){let t,n,r,s,o,i;return{c(){t=N("div"),n=N("label"),n.textContent="URL",r=I(),s=N("input"),b(n,"for","field_url"),b(s,"id","field_url"),b(s,"class","form-control"),b(s,"type","text"),b(s,"name","url"),b(t,"class","controls pt-4")},m(c,d){S(c,t,d),T(t,n),T(t,r),T(t,s),De(s,e[0]),o||(i=le(s,"input",e[13]),o=!0)},p(c,d){d&1&&s.value!==c[0]&&De(s,c[0])},d(c){c&&O(t),o=!1,i()}}}function Kn(e){let t,n,r,s,o,i,c,d;function a(m,p){return!m[5]&&!m[6]&&!m[7]?In:zn}let l=a(e),f=l(e),h=e[1]!="upload"&&wt(e);return{c(){t=N("div"),n=N("div"),f.c(),r=I(),s=N("input"),o=I(),h&&h.c(),i=ce(),b(n,"id","label"),b(n,"class","w-full h-full relative text-sky-100 place-content-center justify-center flex"),b(s,"id","fileUpload"),b(s,"type","file"),b(s,"class","svelte-11h4gxn"),b(t,"id","fileUploadWidget"),b(t,"class","border-solid border-2 rounded border-sky-900 bg-sky-500 flex h-8 svelte-11h4gxn")},m(m,p){S(m,t,p),T(t,n),f.m(n,null),T(t,r),T(t,s),S(m,o,p),h&&h.m(m,p),S(m,i,p),c||(d=[le(s,"change",e[12]),le(s,"change",e[8])],c=!0)},p(m,[p]){l===(l=a(m))&&f?f.p(m,p):(f.d(1),f=l(m),f&&(f.c(),f.m(n,null))),m[1]!="upload"?h?h.p(m,p):(h=wt(m),h.c(),h.m(i.parentNode,i)):h&&(h.d(1),h=null)},i:A,o:A,d(m){m&&O(t),f.d(),m&&O(o),h&&h.d(m),m&&O(i),c=!1,z(d)}}}function vn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:c}=t,{url_type:d=""}=t,a,l=0,f=!1,h=!1,m=!1,p=Be(),_=i?"update":"create";async function R(w,G){try{const x={onUploadProgress:Ce=>{const{loaded:$n,total:er}=Ce,xe=Math.floor($n*100/er);xe<=100&&(G(xe),xe==100&&(n(5,f=!1),n(6,h=!0)))}},{data:ue}=await Mn.post(`${r}/api/3/action/resource_${_}_with_schema`,w,x);return ue}catch(x){console.log("ERROR",x.message)}}function g(w){n(4,l=w)}async function U(w){try{const G=w.target.files[0],x=new FormData;x.append("upload",G),x.append("package_id",s),i&&(x.append("id",o),x.append("clear_upload",!0),x.append("url_type",d)),n(5,f=!0);let ue=await R(x,g),Ce={data:ue};n(0,c=ue.result.url),n(1,d="upload"),p("fileUploaded",Ce),n(6,h=!1),n(7,m=!0)}catch(G){console.log("ERROR",G),g(0)}}function M(){a=this.files,n(3,a)}function Ne(){c=this.value,n(0,c)}return e.$$set=w=>{"upload_url"in w&&n(9,r=w.upload_url),"dataset_id"in w&&n(10,s=w.dataset_id),"resource_id"in w&&n(11,o=w.resource_id),"update"in w&&n(2,i=w.update),"current_url"in w&&n(0,c=w.current_url),"url_type"in w&&n(1,d=w.url_type)},[c,d,i,a,l,f,h,m,U,r,s,o,M,Ne]}class Xn extends Je{constructor(t){super(),Ie(this,t,vn,Kn,Fe,{upload_url:9,dataset_id:10,resource_id:11,update:2,current_url:0,url_type:1})}}function Gn(e){let t,n,r;return n=new Xn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=N("main"),kt(n.$$.fragment),b(t,"class","tailwind")},m(s,o){S(s,t,o),Me(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(He(n.$$.fragment,s),r=!0)},o(s){Pt(n.$$.fragment,s),r=!1},d(s){s&&O(t),ze(n),e[8](null)}}}function Qn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:c}=t,{url_type:d}=t;Be();let a;function l(h){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:h.detail.data.result}))}function f(h){fe[h?"unshift":"push"](()=>{a=h,n(6,a)})}return e.$$set=h=>{"upload_url"in h&&n(0,r=h.upload_url),"dataset_id"in h&&n(1,s=h.dataset_id),"resource_id"in h&&n(2,o=h.resource_id),"update"in h&&n(3,i=h.update),"current_url"in h&&n(4,c=h.current_url),"url_type"in h&&n(5,d=h.url_type)},[r,s,o,i,c,d,a,l,f]}class Yn extends Je{constructor(t){super(),Ie(this,t,Qn,Gn,Fe,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function Zn(e,t="",n="",r="",s="",o="",i=""){new Yn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return Zn}); +(function(A,j){typeof exports=="object"&&typeof module<"u"?module.exports=j():typeof define=="function"&&define.amd?define(j):(A=typeof globalThis<"u"?globalThis:A||self,A.CkanUploader=j())})(this,function(){"use strict";function A(){}function j(e){return e()}function Pe(){return Object.create(null)}function z(e){e.forEach(j)}function ke(e){return typeof e=="function"}function Fe(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function wt(e){return Object.keys(e).length===0}function T(e,t){e.appendChild(t)}function R(e,t,n){e.insertBefore(t,n||null)}function S(e){e.parentNode&&e.parentNode.removeChild(e)}function N(e){return document.createElement(e)}function F(e){return document.createTextNode(e)}function I(){return F(" ")}function De(){return F("")}function le(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function E(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Ot(e){return Array.from(e.childNodes)}function St(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Ue(e,t){e.value=t==null?"":t}function Q(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function gt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Rt(){if(!J)throw new Error("Function called outside component initialization");return J}function Be(){const e=Rt();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const i=gt(t,n,{cancelable:r});return s.slice().forEach(o=>{o.call(e,i)}),!i.defaultPrevented}return!0}}const V=[],fe=[],Y=[],je=[],At=Promise.resolve();let de=!1;function Tt(){de||(de=!0,At.then(Le))}function pe(e){Y.push(e)}const he=new Set;let Z=0;function Le(){const e=J;do{for(;Z{$.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Pt(e){e&&e.c()}function Me(e,t,n,r){const{fragment:s,after_update:i}=e.$$;s&&s.m(t,n),r||pe(()=>{const o=e.$$.on_mount.map(j).filter(ke);e.$$.on_destroy?e.$$.on_destroy.push(...o):z(o),e.$$.on_mount=[]}),i.forEach(pe)}function ze(e,t){const n=e.$$;n.fragment!==null&&(z(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function kt(e,t){e.$$.dirty[0]===-1&&(V.push(e),Tt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const d=_.length?_[0]:m;return a.ctx&&s(a.ctx[f],a.ctx[f]=d)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](d),l&&kt(e,f)),m}):[],a.update(),l=!0,z(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Ot(t.target);a.fragment&&a.fragment.l(f),f.forEach(S)}else a.fragment&&a.fragment.c();t.intro&&He(e.$$.fragment),Me(e,t.target,t.anchor,t.customElement),Le()}q(p)}class Je{$destroy(){ze(this,1),this.$destroy=A}$on(t,n){if(!ke(n))return A;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!wt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const er="";function qe(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ve}=Object.prototype,{getPrototypeOf:me}=Object,_e=(e=>t=>{const n=Ve.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),P=e=>(e=e.toLowerCase(),t=>_e(t)===e),ee=e=>t=>typeof t===e,{isArray:L}=Array,W=ee("undefined");function Ft(e){return e!==null&&!W(e)&&e.constructor!==null&&!W(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const We=P("ArrayBuffer");function Dt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&We(e.buffer),t}const Ut=ee("string"),B=ee("function"),Ke=ee("number"),ye=e=>e!==null&&typeof e=="object",Bt=e=>e===!0||e===!1,te=e=>{if(_e(e)!=="object")return!1;const t=me(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},jt=P("Date"),Lt=P("File"),Ht=P("Blob"),Mt=P("FileList"),zt=e=>ye(e)&&B(e.pipe),It=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||Ve.call(e)===t||B(e.toString)&&e.toString()===t)},Jt=P("URLSearchParams"),qt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function K(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),L(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Xe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ge=e=>!W(e)&&e!==Xe;function be(){const{caseless:e}=Ge(this)&&this||{},t={},n=(r,s)=>{const i=e&&ve(t,s)||s;te(t[i])&&te(r)?t[i]=be(t[i],r):te(r)?t[i]=be({},r):L(r)?t[i]=r.slice():t[i]=r};for(let r=0,s=arguments.length;r(K(t,(s,i)=>{n&&B(s)?e[i]=qe(s,n):e[i]=s},{allOwnKeys:r}),e),Wt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Kt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},vt=(e,t,n,r)=>{let s,i,o;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)o=s[i],(!r||r(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=n!==!1&&me(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Xt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Gt=e=>{if(!e)return null;if(L(e))return e;let t=e.length;if(!Ke(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Qt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&me(Uint8Array)),Yt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const i=s.value;t.call(e,i[0],i[1])}},Zt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},$t=P("HTMLFormElement"),en=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Qe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),tn=P("RegExp"),Ye=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};K(n,(s,i)=>{t(s,i,e)!==!1&&(r[i]=s)}),Object.defineProperties(e,r)},u={isArray:L,isArrayBuffer:We,isBuffer:Ft,isFormData:It,isArrayBufferView:Dt,isString:Ut,isNumber:Ke,isBoolean:Bt,isObject:ye,isPlainObject:te,isUndefined:W,isDate:jt,isFile:Lt,isBlob:Ht,isRegExp:tn,isFunction:B,isStream:zt,isURLSearchParams:Jt,isTypedArray:Qt,isFileList:Mt,forEach:K,merge:be,extend:Vt,trim:qt,stripBOM:Wt,inherits:Kt,toFlatObject:vt,kindOf:_e,kindOfTest:P,endsWith:Xt,toArray:Gt,forEachEntry:Yt,matchAll:Zt,isHTMLForm:$t,hasOwnProperty:Qe,hasOwnProp:Qe,reduceDescriptors:Ye,freezeMethods:e=>{Ye(e,(t,n)=>{if(B(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!B(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(i=>{n[i]=!0})};return L(e)?r(e):r(String(e).split(t)),n},toCamelCase:en,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:ve,global:Xe,isContextDefined:Ge,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(ye(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const i=L(r)?[]:{};return K(r,(o,c)=>{const p=n(o,s+1);!W(p)&&(i[c]=p)}),t[s]=void 0,i}}return r};return n(e,0)}};function y(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}u.inherits(y,Error,{toJSON:function(){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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ze=y.prototype,$e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{$e[e]={value:e}}),Object.defineProperties(y,$e),Object.defineProperty(Ze,"isAxiosError",{value:!0}),y.from=(e,t,n,r,s,i)=>{const o=Object.create(Ze);return u.toFlatObject(e,o,function(p){return p!==Error.prototype},c=>c!=="isAxiosError"),y.call(o,e.message,t,n,r,s),o.cause=e,o.name=e.name,i&&Object.assign(o,i),o};var nn=typeof self=="object"?self.FormData:window.FormData;const rn=nn;function Ee(e){return u.isPlainObject(e)||u.isArray(e)}function et(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,n){return e?e.concat(t).map(function(s,i){return s=et(s),!n&&i?"["+s+"]":s}).join(n?".":""):t}function sn(e){return u.isArray(e)&&!e.some(Ee)}const on=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function an(e){return e&&u.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function ne(e,t,n){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new(rn||FormData),n=u.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,b){return!u.isUndefined(b[h])});const r=n.metaTokens,s=n.visitor||l,i=n.dots,o=n.indexes,p=(n.Blob||typeof Blob<"u"&&Blob)&&an(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function a(d){if(d===null)return"";if(u.isDate(d))return d.toISOString();if(!p&&u.isBlob(d))throw new y("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(d)||u.isTypedArray(d)?p&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function l(d,h,b){let g=d;if(d&&!b&&typeof d=="object"){if(u.endsWith(h,"{}"))h=r?h:h.slice(0,-2),d=JSON.stringify(d);else if(u.isArray(d)&&sn(d)||u.isFileList(d)||u.endsWith(h,"[]")&&(g=u.toArray(d)))return h=et(h),g.forEach(function(M,Ne){!(u.isUndefined(M)||M===null)&&t.append(o===!0?tt([h],Ne,i):o===null?h:h+"[]",a(M))}),!1}return Ee(d)?!0:(t.append(tt(b,h,i),a(d)),!1)}const f=[],m=Object.assign(on,{defaultVisitor:l,convertValue:a,isVisitable:Ee});function _(d,h){if(!u.isUndefined(d)){if(f.indexOf(d)!==-1)throw Error("Circular reference detected in "+h.join("."));f.push(d),u.forEach(d,function(g,U){(!(u.isUndefined(g)||g===null)&&s.call(t,g,u.isString(U)?U.trim():U,h,m))===!0&&_(g,h?h.concat(U):[U])}),f.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return _(e),t}function nt(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function we(e,t){this._pairs=[],e&&ne(e,this,t)}const rt=we.prototype;rt.append=function(t,n){this._pairs.push([t,n])},rt.toString=function(t){const n=t?function(r){return t.call(this,r,nt)}:nt;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function un(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function st(e,t,n){if(!t)return e;const r=n&&n.encode||un,s=n&&n.serialize;let i;if(s?i=s(t,n):i=u.isURLSearchParams(t)?t.toString():new we(t,n).toString(r),i){const o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class cn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){u.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ot=cn,it={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ln=typeof URLSearchParams<"u"?URLSearchParams:we,fn=FormData,dn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),pn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),x={isBrowser:!0,classes:{URLSearchParams:ln,FormData:fn,Blob},isStandardBrowserEnv:dn,isStandardBrowserWebWorkerEnv:pn,protocols:["http","https","file","blob","url","data"]};function hn(e,t){return ne(e,new x.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,i){return x.isNode&&u.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function mn(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function _n(e){const t={},n=Object.keys(e);let r;const s=n.length;let i;for(r=0;r=n.length;return o=!o&&u.isArray(s)?s.length:o,p?(u.hasOwnProp(s,o)?s[o]=[s[o],r]:s[o]=r,!c):((!s[o]||!u.isObject(s[o]))&&(s[o]=[]),t(n,r,s[o],i)&&u.isArray(s[o])&&(s[o]=_n(s[o])),!c)}if(u.isFormData(e)&&u.isFunction(e.entries)){const n={};return u.forEachEntry(e,(r,s)=>{t(mn(r),s,n,0)}),n}return null}const yn={"Content-Type":void 0};function bn(e,t,n){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const re={transitional:it,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,i=u.isObject(t);if(i&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(at(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return hn(t,this.formSerializer).toString();if((c=u.isFileList(t))||r.indexOf("multipart/form-data")>-1){const p=this.env&&this.env.FormData;return ne(c?{"files[]":t}:t,p&&new p,this.formSerializer)}}return i||s?(n.setContentType("application/json",!1),bn(t)):t}],transformResponse:[function(t){const n=this.transitional||re.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&u.isString(t)&&(r&&!this.responseType||s)){const o=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(o)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:x.classes.FormData,Blob:x.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};u.forEach(["delete","get","head"],function(t){re.headers[t]={}}),u.forEach(["post","put","patch"],function(t){re.headers[t]=u.merge(yn)});const Oe=re,En=u.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"]),wn=e=>{const t={};let n,r,s;return e&&e.split(` +`).forEach(function(o){s=o.indexOf(":"),n=o.substring(0,s).trim().toLowerCase(),r=o.substring(s+1).trim(),!(!n||t[n]&&En[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ut=Symbol("internals");function v(e){return e&&String(e).trim().toLowerCase()}function se(e){return e===!1||e==null?e:u.isArray(e)?e.map(se):String(e)}function On(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}function Sn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ct(e,t,n,r){if(u.isFunction(r))return r.call(this,t,n);if(!!u.isString(t)){if(u.isString(r))return t.indexOf(r)!==-1;if(u.isRegExp(r))return r.test(t)}}function gn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Rn(e,t){const n=u.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,i,o){return this[r].call(this,t,s,i,o)},configurable:!0})})}class oe{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function i(c,p,a){const l=v(p);if(!l)throw new Error("header name must be a non-empty string");const f=u.findKey(s,l);(!f||s[f]===void 0||a===!0||a===void 0&&s[f]!==!1)&&(s[f||p]=se(c))}const o=(c,p)=>u.forEach(c,(a,l)=>i(a,l,p));return u.isPlainObject(t)||t instanceof this.constructor?o(t,n):u.isString(t)&&(t=t.trim())&&!Sn(t)?o(wn(t),n):t!=null&&i(n,t,r),this}get(t,n){if(t=v(t),t){const r=u.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return On(s);if(u.isFunction(n))return n.call(this,s,r);if(u.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=v(t),t){const r=u.findKey(this,t);return!!(r&&(!n||ct(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function i(o){if(o=v(o),o){const c=u.findKey(r,o);c&&(!n||ct(r,r[c],c,n))&&(delete r[c],s=!0)}}return u.isArray(t)?t.forEach(i):i(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return u.forEach(this,(s,i)=>{const o=u.findKey(r,i);if(o){n[o]=se(s),delete n[i];return}const c=t?gn(i):String(i).trim();c!==i&&delete n[i],n[c]=se(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return u.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&u.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ut]=this[ut]={accessors:{}}).accessors,s=this.prototype;function i(o){const c=v(o);r[c]||(Rn(s,o),r[c]=!0)}return u.isArray(t)?t.forEach(i):i(t),this}}oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(oe.prototype),u.freezeMethods(oe);const k=oe;function Se(e,t){const n=this||Oe,r=t||n,s=k.from(r.headers);let i=r.data;return u.forEach(e,function(c){i=c.call(n,i,s.normalize(),t?t.status:void 0)}),s.normalize(),i}function lt(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){y.call(this,e==null?"canceled":e,y.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(X,y,{__CANCEL__:!0});const An=null;function Tn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Nn=x.isStandardBrowserEnv?function(){return{write:function(n,r,s,i,o,c){const p=[];p.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&p.push("expires="+new Date(s).toGMTString()),u.isString(i)&&p.push("path="+i),u.isString(o)&&p.push("domain="+o),c===!0&&p.push("secure"),document.cookie=p.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function xn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Cn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function ft(e,t){return e&&!xn(t)?Cn(e,t):t}const Pn=x.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(i){let o=i;return t&&(n.setAttribute("href",o),o=n.href),n.setAttribute("href",o),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(o){const c=u.isString(o)?s(o):o;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function kn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Fn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,i=0,o;return t=t!==void 0?t:1e3,function(p){const a=Date.now(),l=r[i];o||(o=a),n[s]=p,r[s]=a;let f=i,m=0;for(;f!==s;)m+=n[f++],f=f%e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),a-o{const i=s.loaded,o=s.lengthComputable?s.total:void 0,c=i-n,p=r(c),a=i<=o;n=i;const l={loaded:i,total:o,progress:o?i/o:void 0,bytes:c,rate:p||void 0,estimated:p&&o&&a?(o-i)/p:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const ie={http:An,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const i=k.from(e.headers).normalize(),o=e.responseType;let c;function p(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(x.isStandardBrowserEnv||x.isStandardBrowserWebWorkerEnv)&&i.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const _=e.auth.username||"",d=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(_+":"+d))}const l=ft(e.baseURL,e.url);a.open(e.method.toUpperCase(),st(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const _=k.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),h={data:!o||o==="text"||o==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:_,config:e,request:a};Tn(function(g){n(g),p()},function(g){r(g),p()},h),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new y("Request aborted",y.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new y("Network Error",y.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let d=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const h=e.transitional||it;e.timeoutErrorMessage&&(d=e.timeoutErrorMessage),r(new y(d,h.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,a)),a=null},x.isStandardBrowserEnv){const _=(e.withCredentials||Pn(l))&&e.xsrfCookieName&&Nn.read(e.xsrfCookieName);_&&i.set(e.xsrfHeaderName,_)}s===void 0&&i.setContentType(null),"setRequestHeader"in a&&u.forEach(i.toJSON(),function(d,h){a.setRequestHeader(h,d)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),o&&o!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",dt(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",dt(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=_=>{!a||(r(!_||_.type?new X(null,e,a):_),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const m=kn(l);if(m&&x.protocols.indexOf(m)===-1){r(new y("Unsupported protocol "+m+":",y.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(ie,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Dn={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof k?e.toJSON():e;function H(e,t){t=t||{};const n={};function r(a,l,f){return u.isPlainObject(a)&&u.isPlainObject(l)?u.merge.call({caseless:f},a,l):u.isPlainObject(l)?u.merge({},l):u.isArray(l)?l.slice():l}function s(a,l,f){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a,f)}else return r(a,l,f)}function i(a,l){if(!u.isUndefined(l))return r(void 0,l)}function o(a,l){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function c(a,l,f){if(f in t)return r(a,l);if(f in e)return r(void 0,a)}const p={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(a,l)=>s(ht(a),ht(l),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const f=p[l]||s,m=f(e[l],t[l],l);u.isUndefined(m)&&f!==c||(n[l]=m)}),n}const mt="1.2.1",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _t={};Re.transitional=function(t,n,r){function s(i,o){return"[Axios v"+mt+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,c)=>{if(t===!1)throw new y(s(o," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!_t[o]&&(_t[o]=!0,console.warn(s(o," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,o,c):!0}};function Un(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const i=r[s],o=t[i];if(o){const c=e[i],p=c===void 0||o(c,i,e);if(p!==!0)throw new y("option "+i+" must be "+p,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+i,y.ERR_BAD_OPTION)}}const Ae={assertOptions:Un,validators:Re},D=Ae.validators;class ae{constructor(t){this.defaults=t,this.interceptors={request:new ot,response:new ot}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=H(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:i}=n;r!==void 0&&Ae.assertOptions(r,{silentJSONParsing:D.transitional(D.boolean),forcedJSONParsing:D.transitional(D.boolean),clarifyTimeoutError:D.transitional(D.boolean)},!1),s!==void 0&&Ae.assertOptions(s,{encode:D.function,serialize:D.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o;o=i&&u.merge(i.common,i[n.method]),o&&u.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),n.headers=k.concat(o,i);const c=[];let p=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(p=p&&h.synchronous,c.unshift(h.fulfilled,h.rejected))});const a=[];this.interceptors.response.forEach(function(h){a.push(h.fulfilled,h.rejected)});let l,f=0,m;if(!p){const d=[pt.bind(this),void 0];for(d.unshift.apply(d,c),d.push.apply(d,a),m=d.length,l=Promise.resolve(n);f{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(c=>{r.subscribe(c),i=c}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},t(function(i,o,c){r.reason||(r.reason=new X(i,o,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Te(function(s){t=s}),cancel:t}}}const Bn=Te;function jn(e){return function(n){return e.apply(null,n)}}function Ln(e){return u.isObject(e)&&e.isAxiosError===!0}function yt(e){const t=new ue(e),n=qe(ue.prototype.request,t);return u.extend(n,ue.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yt(H(e,s))},n}const w=yt(Oe);w.Axios=ue,w.CanceledError=X,w.CancelToken=Bn,w.isCancel=lt,w.VERSION=mt,w.toFormData=ne,w.AxiosError=y,w.Cancel=w.CanceledError,w.all=function(t){return Promise.all(t)},w.spread=jn,w.isAxiosError=Ln,w.mergeConfig=H,w.AxiosHeaders=k,w.formToJSON=e=>at(u.isHTMLForm(e)?new FormData(e):e),w.default=w;const Hn=w,ur="";function Mn(e){let t,n,r,s,i,o=`${e[4]}%`;function c(f,m){return f[6]?In:Jn}let p=c(e),a=p(e),l=e[7]&&Et();return{c(){t=N("div"),n=N("div"),a.c(),r=I(),l&&l.c(),s=I(),i=N("div"),E(n,"class","z-20"),E(i,"id","percentage-bar"),E(i,"class","ease-in duration-300 z-10 absolute top-0 left-0 bottom-0 bg-blue-800"),Q(i,"width",o),E(t,"id","percentage"),E(t,"class","w-full h-full text-center align-middle flex justify-center")},m(f,m){R(f,t,m),T(t,n),a.m(n,null),T(n,r),l&&l.m(n,null),T(t,s),T(t,i)},p(f,m){p===(p=c(f))&&a?a.p(f,m):(a.d(1),a=p(f),a&&(a.c(),a.m(n,r))),f[7]?l||(l=Et(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),m&16&&o!==(o=`${f[4]}%`)&&Q(i,"width",o)},d(f){f&&S(t),a.d(),l&&l.d()}}}function zn(e){let t;function n(i,o){return i[2]?Vn:qn}let r=n(e),s=r(e);return{c(){s.c(),t=De()},m(i,o){s.m(i,o),R(i,t,o)},p(i,o){r!==(r=n(i))&&(s.d(1),s=r(i),s&&(s.c(),s.m(t.parentNode,t)))},d(i){s.d(i),i&&S(t)}}}function In(e){let t;return{c(){t=F("Waiting for data schema detection...")},m(n,r){R(n,t,r)},p:A,d(n){n&&S(t)}}}function Jn(e){let t,n=!e[7]&&bt(e);return{c(){n&&n.c(),t=De()},m(r,s){n&&n.m(r,s),R(r,t,s)},p(r,s){r[7]?n&&(n.d(1),n=null):n?n.p(r,s):(n=bt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&S(t)}}}function bt(e){let t,n;return{c(){t=F(e[4]),n=F("%")},m(r,s){R(r,t,s),R(r,n,s)},p(r,s){s&16&&St(t,r[4])},d(r){r&&S(t),r&&S(n)}}}function Et(e){let t;return{c(){t=F("File uploaded")},m(n,r){R(n,t,r)},d(n){n&&S(t)}}}function qn(e){let t;return{c(){t=F("Select a file to upload")},m(n,r){R(n,t,r)},d(n){n&&S(t)}}}function Vn(e){let t;return{c(){t=F("Select a file to replace the current one")},m(n,r){R(n,t,r)},d(n){n&&S(t)}}}function Wn(e){let t,n,r,s,i,o,c,p,a,l,f;function m(h,b){return!h[5]&&!h[6]&&!h[7]?zn:Mn}let _=m(e),d=_(e);return{c(){t=N("div"),n=N("div"),d.c(),r=I(),s=N("input"),i=I(),o=N("div"),c=N("label"),c.textContent="URL",p=I(),a=N("input"),E(n,"id","label"),E(n,"class","w-full h-full relative text-sky-100 place-content-center justify-center flex"),E(s,"id","fileUpload"),E(s,"type","file"),E(s,"class","svelte-11h4gxn"),E(t,"id","fileUploadWidget"),E(t,"class","border-solid border-2 rounded border-sky-900 bg-sky-500 flex h-8 svelte-11h4gxn"),E(c,"for","field_url"),E(a,"id","field_url"),E(a,"styleclass","form-control"),E(a,"type","text"),E(a,"name","url"),Q(o,"display",e[1]!="upload"?"inline":"none"),E(o,"class","controls pt-4")},m(h,b){R(h,t,b),T(t,n),d.m(n,null),T(t,r),T(t,s),R(h,i,b),R(h,o,b),T(o,c),T(o,p),T(o,a),Ue(a,e[0]),l||(f=[le(s,"change",e[12]),le(s,"change",e[8]),le(a,"input",e[13])],l=!0)},p(h,[b]){_===(_=m(h))&&d?d.p(h,b):(d.d(1),d=_(h),d&&(d.c(),d.m(n,null))),b&1&&a.value!==h[0]&&Ue(a,h[0]),b&2&&Q(o,"display",h[1]!="upload"?"inline":"none")},i:A,o:A,d(h){h&&S(t),d.d(),h&&S(i),h&&S(o),l=!1,z(f)}}}function Kn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:i}=t,{update:o=""}=t,{current_url:c}=t,{url_type:p=""}=t,a,l=0,f=!1,m=!1,_=!1,d=Be(),h=o?"update":"create";async function b(O,G){try{const C={onUploadProgress:xe=>{const{loaded:Zn,total:$n}=xe,Ce=Math.floor(Zn*100/$n);Ce<=100&&(G(Ce),Ce==100&&(n(5,f=!1),n(6,m=!0)))}},{data:ce}=await Hn.post(`${r}/api/3/action/resource_${h}_with_schema`,O,C);return ce}catch(C){console.log("ERROR",C.message)}}function g(O){n(4,l=O)}async function U(O){try{const G=O.target.files[0],C=new FormData;C.append("upload",G),C.append("package_id",s),o&&(C.append("id",i),C.append("clear_upload",!0),C.append("url_type",p)),n(5,f=!0);let ce=await b(C,g),xe={data:ce};n(0,c=ce.result.url),n(1,p="upload"),d("fileUploaded",xe),n(6,m=!1),n(7,_=!0)}catch(G){console.log("ERROR",G),g(0)}}function M(){a=this.files,n(3,a)}function Ne(){c=this.value,n(0,c)}return e.$$set=O=>{"upload_url"in O&&n(9,r=O.upload_url),"dataset_id"in O&&n(10,s=O.dataset_id),"resource_id"in O&&n(11,i=O.resource_id),"update"in O&&n(2,o=O.update),"current_url"in O&&n(0,c=O.current_url),"url_type"in O&&n(1,p=O.url_type)},[c,p,o,a,l,f,m,_,U,r,s,i,M,Ne]}class vn extends Je{constructor(t){super(),Ie(this,t,Kn,Wn,Fe,{upload_url:9,dataset_id:10,resource_id:11,update:2,current_url:0,url_type:1})}}function Xn(e){let t,n,r;return n=new vn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=N("main"),Pt(n.$$.fragment),E(t,"class","tailwind")},m(s,i){R(s,t,i),Me(n,t,null),e[8](t),r=!0},p(s,[i]){const o={};i&1&&(o.upload_url=s[0]),i&2&&(o.dataset_id=s[1]),i&4&&(o.resource_id=s[2]),i&8&&(o.update=s[3]),i&16&&(o.current_url=s[4]),i&32&&(o.url_type=s[5]),n.$set(o)},i(s){r||(He(n.$$.fragment,s),r=!0)},o(s){Ct(n.$$.fragment,s),r=!1},d(s){s&&S(t),ze(n),e[8](null)}}}function Gn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:i}=t,{update:o}=t,{current_url:c}=t,{url_type:p}=t;Be();let a;function l(m){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:m.detail.data.result}))}function f(m){fe[m?"unshift":"push"](()=>{a=m,n(6,a)})}return e.$$set=m=>{"upload_url"in m&&n(0,r=m.upload_url),"dataset_id"in m&&n(1,s=m.dataset_id),"resource_id"in m&&n(2,i=m.resource_id),"update"in m&&n(3,o=m.update),"current_url"in m&&n(4,c=m.current_url),"url_type"in m&&n(5,p=m.url_type)},[r,s,i,o,c,p,a,l,f]}class Qn extends Je{constructor(t){super(),Ie(this,t,Gn,Xn,Fe,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function Yn(e,t="",n="",r="",s="",i="",o=""){new Qn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:i,update:o}})}return Yn}); diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js index c9f87bc7..8da9fd4d 100644 --- a/ckanext/validation/webassets/js/module-ckan-uploader.js +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -4,11 +4,6 @@ ckan.module('ckan-uploader', function (jQuery) { return { options: { upload_url: '', - dataset_id: '', - resource_id: '', - url_type: '', - current_url: false, - update: false }, afterUpload: (resource_id) => (evt) => { let resource = evt.detail @@ -38,14 +33,20 @@ ckan.module('ckan-uploader', function (jQuery) { } }, initialize: function() { + let resource_id = document.getElementById('resource_id').value + let dataset_id = document.getElementById('dataset_id').value + let current_url = document.getElementById('current_url').value + let url_type = document.getElementById('url_type').value + let update = document.getElementById('update').value + CkanUploader('ckan_uploader', this.options.upload_url, - this.options.dataset_id, - (this.options.resource_id != true)?this.options.resource_id:'', - (this.options.url_type != true)?this.options.url_type:'', - (this.options.current_url != true)?this.options.current_url:'', - (this.options.update != true)?this.options.update:'') - document.getElementById('ckan_uploader').addEventListener('fileUploaded', this.afterUpload(this.options.resource_id)) + dataset_id, + resource_id, + url_type, + current_url, + update) + document.getElementById('ckan_uploader').addEventListener('fileUploaded', this.afterUpload(resource_id)) } } }); From e8b5b42ddd2cd6f26a363c51e1fb181f73080011 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Tue, 13 Dec 2022 21:57:39 +0100 Subject: [PATCH 10/43] add ckan_uploader snippet --- .../templates/scheming/form_snippets/ckan_uploader.html | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html diff --git a/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html new file mode 100644 index 00000000..f8e91836 --- /dev/null +++ b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html @@ -0,0 +1,6 @@ + +
+ +
+
+ From 6c167a645c468cb770ab80494fc54ffed949da78 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Wed, 14 Dec 2022 16:30:55 +0100 Subject: [PATCH 11/43] Update logic to add another resource after saving one --- .../scheming/form_snippets/ckan_uploader.html | 2 +- .../webassets/css/ckan-uploader.css | 2 +- .../validation/webassets/js/ckan-uploader.js | 6 ++-- .../webassets/js/module-ckan-uploader.js | 36 +++++++++++++++++-- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html index f8e91836..b601c591 100644 --- a/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html +++ b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html @@ -1,5 +1,5 @@ -
+
diff --git a/ckanext/validation/webassets/css/ckan-uploader.css b/ckanext/validation/webassets/css/ckan-uploader.css index 28ed9299..3c838dcc 100644 --- a/ckanext/validation/webassets/css/ckan-uploader.css +++ b/ckanext/validation/webassets/css/ckan-uploader.css @@ -1 +1 @@ -.tailwind *,.tailwind :before,.tailwind :after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}.tailwind :before,.tailwind :after{--tw-content: ""}.tailwind html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal}.tailwind body{margin:0;line-height:inherit}.tailwind hr{height:0;color:inherit;border-top-width:1px}.tailwind abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6{font-size:inherit;font-weight:inherit}.tailwind a{color:inherit;text-decoration:inherit}.tailwind b,.tailwind strong{font-weight:bolder}.tailwind code,.tailwind kbd,.tailwind samp,.tailwind pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}.tailwind small{font-size:80%}.tailwind sub,.tailwind sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.tailwind sub{bottom:-.25em}.tailwind sup{top:-.5em}.tailwind table{text-indent:0;border-color:inherit;border-collapse:collapse}.tailwind button,.tailwind input,.tailwind optgroup,.tailwind select,.tailwind textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}.tailwind button,.tailwind select{text-transform:none}.tailwind button,.tailwind [type=button],.tailwind [type=reset],.tailwind [type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}.tailwind :-moz-focusring{outline:auto}.tailwind :-moz-ui-invalid{box-shadow:none}.tailwind progress{vertical-align:baseline}.tailwind ::-webkit-inner-spin-button,.tailwind ::-webkit-outer-spin-button{height:auto}.tailwind [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.tailwind ::-webkit-search-decoration{-webkit-appearance:none}.tailwind ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.tailwind summary{display:list-item}.tailwind blockquote,.tailwind dl,.tailwind dd,.tailwind h1,.tailwind h2,.tailwind h3,.tailwind h4,.tailwind h5,.tailwind h6,.tailwind hr,.tailwind figure,.tailwind p,.tailwind pre{margin:0}.tailwind fieldset{margin:0;padding:0}.tailwind legend{padding:0}.tailwind ol,.tailwind ul,.tailwind menu{list-style:none;margin:0;padding:0}.tailwind textarea{resize:vertical}.tailwind input::-moz-placeholder,.tailwind textarea::-moz-placeholder{opacity:1;color:#9ca3af}.tailwind input::placeholder,.tailwind textarea::placeholder{opacity:1;color:#9ca3af}.tailwind button,.tailwind [role=button]{cursor:pointer}.tailwind :disabled{cursor:default}.tailwind img,.tailwind svg,.tailwind video,.tailwind canvas,.tailwind audio,.tailwind iframe,.tailwind embed,.tailwind object{display:block;vertical-align:middle}.tailwind img,.tailwind video{max-width:100%;height:auto}.tailwind [hidden]{display:none}.tailwind *,.tailwind :before,.tailwind :after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind ::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.tailwind .absolute{position:absolute}.tailwind .relative{position:relative}.tailwind .top-0{top:0px}.tailwind .left-0{left:0px}.tailwind .bottom-0{bottom:0px}.tailwind .z-20{z-index:20}.tailwind .z-10{z-index:10}.tailwind .inline{display:inline}.tailwind .flex{display:flex}.tailwind .h-8{height:2rem}.tailwind .h-full{height:100%}.tailwind .w-full{width:100%}.tailwind .place-content-center{place-content:center}.tailwind .justify-center{justify-content:center}.tailwind .rounded{border-radius:.25rem}.tailwind .border-2{border-width:2px}.tailwind .border-solid{border-style:solid}.tailwind .border-sky-900{--tw-border-opacity: 1;border-color:rgb(12 74 110 / var(--tw-border-opacity))}.tailwind .bg-sky-500{--tw-bg-opacity: 1;background-color:rgb(14 165 233 / var(--tw-bg-opacity))}.tailwind .bg-blue-800{--tw-bg-opacity: 1;background-color:rgb(30 64 175 / var(--tw-bg-opacity))}.tailwind .pt-4{padding-top:1rem}.tailwind .text-center{text-align:center}.tailwind .align-middle{vertical-align:middle}.tailwind .text-sky-100{--tw-text-opacity: 1;color:rgb(224 242 254 / var(--tw-text-opacity))}.tailwind .duration-300{transition-duration:.3s}.tailwind .ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}#fileUploadWidget.svelte-11h4gxn{position:relative;display:flex;max-width:400px}#fileUpload.svelte-11h4gxn{position:absolute;width:100%;height:100%;top:0;left:0;opacity:0} +#fileUploadWidget.svelte-1urn4xa.svelte-1urn4xa{position:relative;display:flex;max-width:400px;border:2px solid #0c4a6e;border-radius:4px;background-color:#0284c7;margin-bottom:10px}#fileUploadWidget.svelte-1urn4xa #widget-label.svelte-1urn4xa{width:100%;height:100%;color:#fff;justify-content:center;display:flex}#percentage.svelte-1urn4xa.svelte-1urn4xa{width:100%;height:100%;align:middle;justify-content:center;display:flex;position:relative}.percentage-text.svelte-1urn4xa.svelte-1urn4xa{z-index:20}#percentage-bar.svelte-1urn4xa.svelte-1urn4xa{z-index:10;position:absolute;top:0;left:0;bottom:0;background-color:#1e3a8a;transition:width .3s;transition-timing-function:ease-in}#fileUpload.svelte-1urn4xa.svelte-1urn4xa{position:absolute;width:100%;height:100%;top:0;left:0;opacity:0} diff --git a/ckanext/validation/webassets/js/ckan-uploader.js b/ckanext/validation/webassets/js/ckan-uploader.js index 10f56808..a2444951 100644 --- a/ckanext/validation/webassets/js/ckan-uploader.js +++ b/ckanext/validation/webassets/js/ckan-uploader.js @@ -1,3 +1,3 @@ -(function(A,j){typeof exports=="object"&&typeof module<"u"?module.exports=j():typeof define=="function"&&define.amd?define(j):(A=typeof globalThis<"u"?globalThis:A||self,A.CkanUploader=j())})(this,function(){"use strict";function A(){}function j(e){return e()}function Pe(){return Object.create(null)}function z(e){e.forEach(j)}function ke(e){return typeof e=="function"}function Fe(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function wt(e){return Object.keys(e).length===0}function T(e,t){e.appendChild(t)}function R(e,t,n){e.insertBefore(t,n||null)}function S(e){e.parentNode&&e.parentNode.removeChild(e)}function N(e){return document.createElement(e)}function F(e){return document.createTextNode(e)}function I(){return F(" ")}function De(){return F("")}function le(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function E(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Ot(e){return Array.from(e.childNodes)}function St(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Ue(e,t){e.value=t==null?"":t}function Q(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function gt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Rt(){if(!J)throw new Error("Function called outside component initialization");return J}function Be(){const e=Rt();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const i=gt(t,n,{cancelable:r});return s.slice().forEach(o=>{o.call(e,i)}),!i.defaultPrevented}return!0}}const V=[],fe=[],Y=[],je=[],At=Promise.resolve();let de=!1;function Tt(){de||(de=!0,At.then(Le))}function pe(e){Y.push(e)}const he=new Set;let Z=0;function Le(){const e=J;do{for(;Z{$.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Pt(e){e&&e.c()}function Me(e,t,n,r){const{fragment:s,after_update:i}=e.$$;s&&s.m(t,n),r||pe(()=>{const o=e.$$.on_mount.map(j).filter(ke);e.$$.on_destroy?e.$$.on_destroy.push(...o):z(o),e.$$.on_mount=[]}),i.forEach(pe)}function ze(e,t){const n=e.$$;n.fragment!==null&&(z(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function kt(e,t){e.$$.dirty[0]===-1&&(V.push(e),Tt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const d=_.length?_[0]:m;return a.ctx&&s(a.ctx[f],a.ctx[f]=d)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](d),l&&kt(e,f)),m}):[],a.update(),l=!0,z(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Ot(t.target);a.fragment&&a.fragment.l(f),f.forEach(S)}else a.fragment&&a.fragment.c();t.intro&&He(e.$$.fragment),Me(e,t.target,t.anchor,t.customElement),Le()}q(p)}class Je{$destroy(){ze(this,1),this.$destroy=A}$on(t,n){if(!ke(n))return A;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!wt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const er="";function qe(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ve}=Object.prototype,{getPrototypeOf:me}=Object,_e=(e=>t=>{const n=Ve.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),P=e=>(e=e.toLowerCase(),t=>_e(t)===e),ee=e=>t=>typeof t===e,{isArray:L}=Array,W=ee("undefined");function Ft(e){return e!==null&&!W(e)&&e.constructor!==null&&!W(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const We=P("ArrayBuffer");function Dt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&We(e.buffer),t}const Ut=ee("string"),B=ee("function"),Ke=ee("number"),ye=e=>e!==null&&typeof e=="object",Bt=e=>e===!0||e===!1,te=e=>{if(_e(e)!=="object")return!1;const t=me(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},jt=P("Date"),Lt=P("File"),Ht=P("Blob"),Mt=P("FileList"),zt=e=>ye(e)&&B(e.pipe),It=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||Ve.call(e)===t||B(e.toString)&&e.toString()===t)},Jt=P("URLSearchParams"),qt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function K(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),L(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Xe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ge=e=>!W(e)&&e!==Xe;function be(){const{caseless:e}=Ge(this)&&this||{},t={},n=(r,s)=>{const i=e&&ve(t,s)||s;te(t[i])&&te(r)?t[i]=be(t[i],r):te(r)?t[i]=be({},r):L(r)?t[i]=r.slice():t[i]=r};for(let r=0,s=arguments.length;r(K(t,(s,i)=>{n&&B(s)?e[i]=qe(s,n):e[i]=s},{allOwnKeys:r}),e),Wt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Kt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},vt=(e,t,n,r)=>{let s,i,o;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)o=s[i],(!r||r(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=n!==!1&&me(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Xt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Gt=e=>{if(!e)return null;if(L(e))return e;let t=e.length;if(!Ke(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Qt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&me(Uint8Array)),Yt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const i=s.value;t.call(e,i[0],i[1])}},Zt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},$t=P("HTMLFormElement"),en=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Qe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),tn=P("RegExp"),Ye=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};K(n,(s,i)=>{t(s,i,e)!==!1&&(r[i]=s)}),Object.defineProperties(e,r)},u={isArray:L,isArrayBuffer:We,isBuffer:Ft,isFormData:It,isArrayBufferView:Dt,isString:Ut,isNumber:Ke,isBoolean:Bt,isObject:ye,isPlainObject:te,isUndefined:W,isDate:jt,isFile:Lt,isBlob:Ht,isRegExp:tn,isFunction:B,isStream:zt,isURLSearchParams:Jt,isTypedArray:Qt,isFileList:Mt,forEach:K,merge:be,extend:Vt,trim:qt,stripBOM:Wt,inherits:Kt,toFlatObject:vt,kindOf:_e,kindOfTest:P,endsWith:Xt,toArray:Gt,forEachEntry:Yt,matchAll:Zt,isHTMLForm:$t,hasOwnProperty:Qe,hasOwnProp:Qe,reduceDescriptors:Ye,freezeMethods:e=>{Ye(e,(t,n)=>{if(B(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!B(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(i=>{n[i]=!0})};return L(e)?r(e):r(String(e).split(t)),n},toCamelCase:en,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:ve,global:Xe,isContextDefined:Ge,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(ye(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const i=L(r)?[]:{};return K(r,(o,c)=>{const p=n(o,s+1);!W(p)&&(i[c]=p)}),t[s]=void 0,i}}return r};return n(e,0)}};function y(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}u.inherits(y,Error,{toJSON:function(){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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ze=y.prototype,$e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{$e[e]={value:e}}),Object.defineProperties(y,$e),Object.defineProperty(Ze,"isAxiosError",{value:!0}),y.from=(e,t,n,r,s,i)=>{const o=Object.create(Ze);return u.toFlatObject(e,o,function(p){return p!==Error.prototype},c=>c!=="isAxiosError"),y.call(o,e.message,t,n,r,s),o.cause=e,o.name=e.name,i&&Object.assign(o,i),o};var nn=typeof self=="object"?self.FormData:window.FormData;const rn=nn;function Ee(e){return u.isPlainObject(e)||u.isArray(e)}function et(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,n){return e?e.concat(t).map(function(s,i){return s=et(s),!n&&i?"["+s+"]":s}).join(n?".":""):t}function sn(e){return u.isArray(e)&&!e.some(Ee)}const on=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function an(e){return e&&u.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function ne(e,t,n){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new(rn||FormData),n=u.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,b){return!u.isUndefined(b[h])});const r=n.metaTokens,s=n.visitor||l,i=n.dots,o=n.indexes,p=(n.Blob||typeof Blob<"u"&&Blob)&&an(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function a(d){if(d===null)return"";if(u.isDate(d))return d.toISOString();if(!p&&u.isBlob(d))throw new y("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(d)||u.isTypedArray(d)?p&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function l(d,h,b){let g=d;if(d&&!b&&typeof d=="object"){if(u.endsWith(h,"{}"))h=r?h:h.slice(0,-2),d=JSON.stringify(d);else if(u.isArray(d)&&sn(d)||u.isFileList(d)||u.endsWith(h,"[]")&&(g=u.toArray(d)))return h=et(h),g.forEach(function(M,Ne){!(u.isUndefined(M)||M===null)&&t.append(o===!0?tt([h],Ne,i):o===null?h:h+"[]",a(M))}),!1}return Ee(d)?!0:(t.append(tt(b,h,i),a(d)),!1)}const f=[],m=Object.assign(on,{defaultVisitor:l,convertValue:a,isVisitable:Ee});function _(d,h){if(!u.isUndefined(d)){if(f.indexOf(d)!==-1)throw Error("Circular reference detected in "+h.join("."));f.push(d),u.forEach(d,function(g,U){(!(u.isUndefined(g)||g===null)&&s.call(t,g,u.isString(U)?U.trim():U,h,m))===!0&&_(g,h?h.concat(U):[U])}),f.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return _(e),t}function nt(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function we(e,t){this._pairs=[],e&&ne(e,this,t)}const rt=we.prototype;rt.append=function(t,n){this._pairs.push([t,n])},rt.toString=function(t){const n=t?function(r){return t.call(this,r,nt)}:nt;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function un(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function st(e,t,n){if(!t)return e;const r=n&&n.encode||un,s=n&&n.serialize;let i;if(s?i=s(t,n):i=u.isURLSearchParams(t)?t.toString():new we(t,n).toString(r),i){const o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class cn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){u.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ot=cn,it={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ln=typeof URLSearchParams<"u"?URLSearchParams:we,fn=FormData,dn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),pn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),x={isBrowser:!0,classes:{URLSearchParams:ln,FormData:fn,Blob},isStandardBrowserEnv:dn,isStandardBrowserWebWorkerEnv:pn,protocols:["http","https","file","blob","url","data"]};function hn(e,t){return ne(e,new x.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,i){return x.isNode&&u.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function mn(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function _n(e){const t={},n=Object.keys(e);let r;const s=n.length;let i;for(r=0;r=n.length;return o=!o&&u.isArray(s)?s.length:o,p?(u.hasOwnProp(s,o)?s[o]=[s[o],r]:s[o]=r,!c):((!s[o]||!u.isObject(s[o]))&&(s[o]=[]),t(n,r,s[o],i)&&u.isArray(s[o])&&(s[o]=_n(s[o])),!c)}if(u.isFormData(e)&&u.isFunction(e.entries)){const n={};return u.forEachEntry(e,(r,s)=>{t(mn(r),s,n,0)}),n}return null}const yn={"Content-Type":void 0};function bn(e,t,n){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const re={transitional:it,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,i=u.isObject(t);if(i&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(at(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return hn(t,this.formSerializer).toString();if((c=u.isFileList(t))||r.indexOf("multipart/form-data")>-1){const p=this.env&&this.env.FormData;return ne(c?{"files[]":t}:t,p&&new p,this.formSerializer)}}return i||s?(n.setContentType("application/json",!1),bn(t)):t}],transformResponse:[function(t){const n=this.transitional||re.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&u.isString(t)&&(r&&!this.responseType||s)){const o=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(o)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:x.classes.FormData,Blob:x.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};u.forEach(["delete","get","head"],function(t){re.headers[t]={}}),u.forEach(["post","put","patch"],function(t){re.headers[t]=u.merge(yn)});const Oe=re,En=u.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"]),wn=e=>{const t={};let n,r,s;return e&&e.split(` -`).forEach(function(o){s=o.indexOf(":"),n=o.substring(0,s).trim().toLowerCase(),r=o.substring(s+1).trim(),!(!n||t[n]&&En[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ut=Symbol("internals");function v(e){return e&&String(e).trim().toLowerCase()}function se(e){return e===!1||e==null?e:u.isArray(e)?e.map(se):String(e)}function On(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}function Sn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ct(e,t,n,r){if(u.isFunction(r))return r.call(this,t,n);if(!!u.isString(t)){if(u.isString(r))return t.indexOf(r)!==-1;if(u.isRegExp(r))return r.test(t)}}function gn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Rn(e,t){const n=u.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,i,o){return this[r].call(this,t,s,i,o)},configurable:!0})})}class oe{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function i(c,p,a){const l=v(p);if(!l)throw new Error("header name must be a non-empty string");const f=u.findKey(s,l);(!f||s[f]===void 0||a===!0||a===void 0&&s[f]!==!1)&&(s[f||p]=se(c))}const o=(c,p)=>u.forEach(c,(a,l)=>i(a,l,p));return u.isPlainObject(t)||t instanceof this.constructor?o(t,n):u.isString(t)&&(t=t.trim())&&!Sn(t)?o(wn(t),n):t!=null&&i(n,t,r),this}get(t,n){if(t=v(t),t){const r=u.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return On(s);if(u.isFunction(n))return n.call(this,s,r);if(u.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=v(t),t){const r=u.findKey(this,t);return!!(r&&(!n||ct(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function i(o){if(o=v(o),o){const c=u.findKey(r,o);c&&(!n||ct(r,r[c],c,n))&&(delete r[c],s=!0)}}return u.isArray(t)?t.forEach(i):i(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return u.forEach(this,(s,i)=>{const o=u.findKey(r,i);if(o){n[o]=se(s),delete n[i];return}const c=t?gn(i):String(i).trim();c!==i&&delete n[i],n[c]=se(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return u.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&u.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ut]=this[ut]={accessors:{}}).accessors,s=this.prototype;function i(o){const c=v(o);r[c]||(Rn(s,o),r[c]=!0)}return u.isArray(t)?t.forEach(i):i(t),this}}oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(oe.prototype),u.freezeMethods(oe);const k=oe;function Se(e,t){const n=this||Oe,r=t||n,s=k.from(r.headers);let i=r.data;return u.forEach(e,function(c){i=c.call(n,i,s.normalize(),t?t.status:void 0)}),s.normalize(),i}function lt(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){y.call(this,e==null?"canceled":e,y.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(X,y,{__CANCEL__:!0});const An=null;function Tn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Nn=x.isStandardBrowserEnv?function(){return{write:function(n,r,s,i,o,c){const p=[];p.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&p.push("expires="+new Date(s).toGMTString()),u.isString(i)&&p.push("path="+i),u.isString(o)&&p.push("domain="+o),c===!0&&p.push("secure"),document.cookie=p.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function xn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Cn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function ft(e,t){return e&&!xn(t)?Cn(e,t):t}const Pn=x.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(i){let o=i;return t&&(n.setAttribute("href",o),o=n.href),n.setAttribute("href",o),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(o){const c=u.isString(o)?s(o):o;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function kn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Fn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,i=0,o;return t=t!==void 0?t:1e3,function(p){const a=Date.now(),l=r[i];o||(o=a),n[s]=p,r[s]=a;let f=i,m=0;for(;f!==s;)m+=n[f++],f=f%e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),a-o{const i=s.loaded,o=s.lengthComputable?s.total:void 0,c=i-n,p=r(c),a=i<=o;n=i;const l={loaded:i,total:o,progress:o?i/o:void 0,bytes:c,rate:p||void 0,estimated:p&&o&&a?(o-i)/p:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const ie={http:An,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const i=k.from(e.headers).normalize(),o=e.responseType;let c;function p(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(x.isStandardBrowserEnv||x.isStandardBrowserWebWorkerEnv)&&i.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const _=e.auth.username||"",d=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(_+":"+d))}const l=ft(e.baseURL,e.url);a.open(e.method.toUpperCase(),st(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const _=k.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),h={data:!o||o==="text"||o==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:_,config:e,request:a};Tn(function(g){n(g),p()},function(g){r(g),p()},h),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new y("Request aborted",y.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new y("Network Error",y.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let d=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const h=e.transitional||it;e.timeoutErrorMessage&&(d=e.timeoutErrorMessage),r(new y(d,h.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,a)),a=null},x.isStandardBrowserEnv){const _=(e.withCredentials||Pn(l))&&e.xsrfCookieName&&Nn.read(e.xsrfCookieName);_&&i.set(e.xsrfHeaderName,_)}s===void 0&&i.setContentType(null),"setRequestHeader"in a&&u.forEach(i.toJSON(),function(d,h){a.setRequestHeader(h,d)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),o&&o!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",dt(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",dt(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=_=>{!a||(r(!_||_.type?new X(null,e,a):_),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const m=kn(l);if(m&&x.protocols.indexOf(m)===-1){r(new y("Unsupported protocol "+m+":",y.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(ie,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Dn={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof k?e.toJSON():e;function H(e,t){t=t||{};const n={};function r(a,l,f){return u.isPlainObject(a)&&u.isPlainObject(l)?u.merge.call({caseless:f},a,l):u.isPlainObject(l)?u.merge({},l):u.isArray(l)?l.slice():l}function s(a,l,f){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a,f)}else return r(a,l,f)}function i(a,l){if(!u.isUndefined(l))return r(void 0,l)}function o(a,l){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function c(a,l,f){if(f in t)return r(a,l);if(f in e)return r(void 0,a)}const p={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(a,l)=>s(ht(a),ht(l),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const f=p[l]||s,m=f(e[l],t[l],l);u.isUndefined(m)&&f!==c||(n[l]=m)}),n}const mt="1.2.1",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _t={};Re.transitional=function(t,n,r){function s(i,o){return"[Axios v"+mt+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,c)=>{if(t===!1)throw new y(s(o," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!_t[o]&&(_t[o]=!0,console.warn(s(o," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,o,c):!0}};function Un(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const i=r[s],o=t[i];if(o){const c=e[i],p=c===void 0||o(c,i,e);if(p!==!0)throw new y("option "+i+" must be "+p,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+i,y.ERR_BAD_OPTION)}}const Ae={assertOptions:Un,validators:Re},D=Ae.validators;class ae{constructor(t){this.defaults=t,this.interceptors={request:new ot,response:new ot}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=H(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:i}=n;r!==void 0&&Ae.assertOptions(r,{silentJSONParsing:D.transitional(D.boolean),forcedJSONParsing:D.transitional(D.boolean),clarifyTimeoutError:D.transitional(D.boolean)},!1),s!==void 0&&Ae.assertOptions(s,{encode:D.function,serialize:D.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o;o=i&&u.merge(i.common,i[n.method]),o&&u.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),n.headers=k.concat(o,i);const c=[];let p=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(p=p&&h.synchronous,c.unshift(h.fulfilled,h.rejected))});const a=[];this.interceptors.response.forEach(function(h){a.push(h.fulfilled,h.rejected)});let l,f=0,m;if(!p){const d=[pt.bind(this),void 0];for(d.unshift.apply(d,c),d.push.apply(d,a),m=d.length,l=Promise.resolve(n);f{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(c=>{r.subscribe(c),i=c}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},t(function(i,o,c){r.reason||(r.reason=new X(i,o,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Te(function(s){t=s}),cancel:t}}}const Bn=Te;function jn(e){return function(n){return e.apply(null,n)}}function Ln(e){return u.isObject(e)&&e.isAxiosError===!0}function yt(e){const t=new ue(e),n=qe(ue.prototype.request,t);return u.extend(n,ue.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yt(H(e,s))},n}const w=yt(Oe);w.Axios=ue,w.CanceledError=X,w.CancelToken=Bn,w.isCancel=lt,w.VERSION=mt,w.toFormData=ne,w.AxiosError=y,w.Cancel=w.CanceledError,w.all=function(t){return Promise.all(t)},w.spread=jn,w.isAxiosError=Ln,w.mergeConfig=H,w.AxiosHeaders=k,w.formToJSON=e=>at(u.isHTMLForm(e)?new FormData(e):e),w.default=w;const Hn=w,ur="";function Mn(e){let t,n,r,s,i,o=`${e[4]}%`;function c(f,m){return f[6]?In:Jn}let p=c(e),a=p(e),l=e[7]&&Et();return{c(){t=N("div"),n=N("div"),a.c(),r=I(),l&&l.c(),s=I(),i=N("div"),E(n,"class","z-20"),E(i,"id","percentage-bar"),E(i,"class","ease-in duration-300 z-10 absolute top-0 left-0 bottom-0 bg-blue-800"),Q(i,"width",o),E(t,"id","percentage"),E(t,"class","w-full h-full text-center align-middle flex justify-center")},m(f,m){R(f,t,m),T(t,n),a.m(n,null),T(n,r),l&&l.m(n,null),T(t,s),T(t,i)},p(f,m){p===(p=c(f))&&a?a.p(f,m):(a.d(1),a=p(f),a&&(a.c(),a.m(n,r))),f[7]?l||(l=Et(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),m&16&&o!==(o=`${f[4]}%`)&&Q(i,"width",o)},d(f){f&&S(t),a.d(),l&&l.d()}}}function zn(e){let t;function n(i,o){return i[2]?Vn:qn}let r=n(e),s=r(e);return{c(){s.c(),t=De()},m(i,o){s.m(i,o),R(i,t,o)},p(i,o){r!==(r=n(i))&&(s.d(1),s=r(i),s&&(s.c(),s.m(t.parentNode,t)))},d(i){s.d(i),i&&S(t)}}}function In(e){let t;return{c(){t=F("Waiting for data schema detection...")},m(n,r){R(n,t,r)},p:A,d(n){n&&S(t)}}}function Jn(e){let t,n=!e[7]&&bt(e);return{c(){n&&n.c(),t=De()},m(r,s){n&&n.m(r,s),R(r,t,s)},p(r,s){r[7]?n&&(n.d(1),n=null):n?n.p(r,s):(n=bt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&S(t)}}}function bt(e){let t,n;return{c(){t=F(e[4]),n=F("%")},m(r,s){R(r,t,s),R(r,n,s)},p(r,s){s&16&&St(t,r[4])},d(r){r&&S(t),r&&S(n)}}}function Et(e){let t;return{c(){t=F("File uploaded")},m(n,r){R(n,t,r)},d(n){n&&S(t)}}}function qn(e){let t;return{c(){t=F("Select a file to upload")},m(n,r){R(n,t,r)},d(n){n&&S(t)}}}function Vn(e){let t;return{c(){t=F("Select a file to replace the current one")},m(n,r){R(n,t,r)},d(n){n&&S(t)}}}function Wn(e){let t,n,r,s,i,o,c,p,a,l,f;function m(h,b){return!h[5]&&!h[6]&&!h[7]?zn:Mn}let _=m(e),d=_(e);return{c(){t=N("div"),n=N("div"),d.c(),r=I(),s=N("input"),i=I(),o=N("div"),c=N("label"),c.textContent="URL",p=I(),a=N("input"),E(n,"id","label"),E(n,"class","w-full h-full relative text-sky-100 place-content-center justify-center flex"),E(s,"id","fileUpload"),E(s,"type","file"),E(s,"class","svelte-11h4gxn"),E(t,"id","fileUploadWidget"),E(t,"class","border-solid border-2 rounded border-sky-900 bg-sky-500 flex h-8 svelte-11h4gxn"),E(c,"for","field_url"),E(a,"id","field_url"),E(a,"styleclass","form-control"),E(a,"type","text"),E(a,"name","url"),Q(o,"display",e[1]!="upload"?"inline":"none"),E(o,"class","controls pt-4")},m(h,b){R(h,t,b),T(t,n),d.m(n,null),T(t,r),T(t,s),R(h,i,b),R(h,o,b),T(o,c),T(o,p),T(o,a),Ue(a,e[0]),l||(f=[le(s,"change",e[12]),le(s,"change",e[8]),le(a,"input",e[13])],l=!0)},p(h,[b]){_===(_=m(h))&&d?d.p(h,b):(d.d(1),d=_(h),d&&(d.c(),d.m(n,null))),b&1&&a.value!==h[0]&&Ue(a,h[0]),b&2&&Q(o,"display",h[1]!="upload"?"inline":"none")},i:A,o:A,d(h){h&&S(t),d.d(),h&&S(i),h&&S(o),l=!1,z(f)}}}function Kn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:i}=t,{update:o=""}=t,{current_url:c}=t,{url_type:p=""}=t,a,l=0,f=!1,m=!1,_=!1,d=Be(),h=o?"update":"create";async function b(O,G){try{const C={onUploadProgress:xe=>{const{loaded:Zn,total:$n}=xe,Ce=Math.floor(Zn*100/$n);Ce<=100&&(G(Ce),Ce==100&&(n(5,f=!1),n(6,m=!0)))}},{data:ce}=await Hn.post(`${r}/api/3/action/resource_${h}_with_schema`,O,C);return ce}catch(C){console.log("ERROR",C.message)}}function g(O){n(4,l=O)}async function U(O){try{const G=O.target.files[0],C=new FormData;C.append("upload",G),C.append("package_id",s),o&&(C.append("id",i),C.append("clear_upload",!0),C.append("url_type",p)),n(5,f=!0);let ce=await b(C,g),xe={data:ce};n(0,c=ce.result.url),n(1,p="upload"),d("fileUploaded",xe),n(6,m=!1),n(7,_=!0)}catch(G){console.log("ERROR",G),g(0)}}function M(){a=this.files,n(3,a)}function Ne(){c=this.value,n(0,c)}return e.$$set=O=>{"upload_url"in O&&n(9,r=O.upload_url),"dataset_id"in O&&n(10,s=O.dataset_id),"resource_id"in O&&n(11,i=O.resource_id),"update"in O&&n(2,o=O.update),"current_url"in O&&n(0,c=O.current_url),"url_type"in O&&n(1,p=O.url_type)},[c,p,o,a,l,f,m,_,U,r,s,i,M,Ne]}class vn extends Je{constructor(t){super(),Ie(this,t,Kn,Wn,Fe,{upload_url:9,dataset_id:10,resource_id:11,update:2,current_url:0,url_type:1})}}function Xn(e){let t,n,r;return n=new vn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=N("main"),Pt(n.$$.fragment),E(t,"class","tailwind")},m(s,i){R(s,t,i),Me(n,t,null),e[8](t),r=!0},p(s,[i]){const o={};i&1&&(o.upload_url=s[0]),i&2&&(o.dataset_id=s[1]),i&4&&(o.resource_id=s[2]),i&8&&(o.update=s[3]),i&16&&(o.current_url=s[4]),i&32&&(o.url_type=s[5]),n.$set(o)},i(s){r||(He(n.$$.fragment,s),r=!0)},o(s){Ct(n.$$.fragment,s),r=!1},d(s){s&&S(t),ze(n),e[8](null)}}}function Gn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:i}=t,{update:o}=t,{current_url:c}=t,{url_type:p}=t;Be();let a;function l(m){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:m.detail.data.result}))}function f(m){fe[m?"unshift":"push"](()=>{a=m,n(6,a)})}return e.$$set=m=>{"upload_url"in m&&n(0,r=m.upload_url),"dataset_id"in m&&n(1,s=m.dataset_id),"resource_id"in m&&n(2,i=m.resource_id),"update"in m&&n(3,o=m.update),"current_url"in m&&n(4,c=m.current_url),"url_type"in m&&n(5,p=m.url_type)},[r,s,i,o,c,p,a,l,f]}class Qn extends Je{constructor(t){super(),Ie(this,t,Gn,Xn,Fe,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function Yn(e,t="",n="",r="",s="",i="",o=""){new Qn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:i,update:o}})}return Yn}); +(function(x,L){typeof exports=="object"&&typeof module<"u"?module.exports=L():typeof define=="function"&&define.amd?define(L):(x=typeof globalThis<"u"?globalThis:x||self,x.CkanUploader=L())})(this,function(){"use strict";function x(){}function L(e){return e()}function Pe(){return Object.create(null)}function I(e){e.forEach(L)}function ke(e){return typeof e=="function"}function Fe(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function wt(e){return Object.keys(e).length===0}function R(e,t){e.appendChild(t)}function N(e,t,n){e.insertBefore(t,n||null)}function A(e){e.parentNode&&e.parentNode.removeChild(e)}function T(e){return document.createElement(e)}function D(e){return document.createTextNode(e)}function z(){return D(" ")}function De(){return D("")}function le(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function w(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Ot(e){return Array.from(e.childNodes)}function St(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Ue(e,t){e.value=t==null?"":t}function Q(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function gt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Rt(){if(!J)throw new Error("Function called outside component initialization");return J}function Be(){const e=Rt();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=gt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const v=[],fe=[],Y=[],Le=[],At=Promise.resolve();let de=!1;function Tt(){de||(de=!0,At.then(je))}function pe(e){Y.push(e)}const he=new Set;let Z=0;function je(){const e=J;do{for(;Z{$.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Pt(e){e&&e.c()}function Me(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||pe(()=>{const i=e.$$.on_mount.map(L).filter(ke);e.$$.on_destroy?e.$$.on_destroy.push(...i):I(i),e.$$.on_mount=[]}),o.forEach(pe)}function Ie(e,t){const n=e.$$;n.fragment!==null&&(I(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function kt(e,t){e.$$.dirty[0]===-1&&(v.push(e),Tt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=_.length?_[0]:h;return a.ctx&&s(a.ctx[f],a.ctx[f]=p)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](p),l&&kt(e,f)),h}):[],a.update(),l=!0,I(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Ot(t.target);a.fragment&&a.fragment.l(f),f.forEach(A)}else a.fragment&&a.fragment.c();t.intro&&He(e.$$.fragment),Me(e,t.target,t.anchor,t.customElement),je()}q(d)}class Je{$destroy(){Ie(this,1),this.$destroy=x}$on(t,n){if(!ke(n))return x;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!wt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function qe(e,t){return function(){return e.apply(t,arguments)}}const{toString:ve}=Object.prototype,{getPrototypeOf:me}=Object,_e=(e=>t=>{const n=ve.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),k=e=>(e=e.toLowerCase(),t=>_e(t)===e),ee=e=>t=>typeof t===e,{isArray:j}=Array,V=ee("undefined");function Ft(e){return e!==null&&!V(e)&&e.constructor!==null&&!V(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ve=k("ArrayBuffer");function Dt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ve(e.buffer),t}const Ut=ee("string"),B=ee("function"),We=ee("number"),ye=e=>e!==null&&typeof e=="object",Bt=e=>e===!0||e===!1,te=e=>{if(_e(e)!=="object")return!1;const t=me(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Lt=k("Date"),jt=k("File"),Ht=k("Blob"),Mt=k("FileList"),It=e=>ye(e)&&B(e.pipe),zt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||ve.call(e)===t||B(e.toString)&&e.toString()===t)},Jt=k("URLSearchParams"),qt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function W(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),j(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Xe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ge=e=>!V(e)&&e!==Xe;function be(){const{caseless:e}=Ge(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ke(t,s)||s;te(t[o])&&te(r)?t[o]=be(t[o],r):te(r)?t[o]=be({},r):j(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(W(t,(s,o)=>{n&&B(s)?e[o]=qe(s,n):e[o]=s},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Wt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Kt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&me(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Xt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Gt=e=>{if(!e)return null;if(j(e))return e;let t=e.length;if(!We(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Qt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&me(Uint8Array)),Yt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},Zt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},$t=k("HTMLFormElement"),en=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Qe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),tn=k("RegExp"),Ye=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};W(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},u={isArray:j,isArrayBuffer:Ve,isBuffer:Ft,isFormData:zt,isArrayBufferView:Dt,isString:Ut,isNumber:We,isBoolean:Bt,isObject:ye,isPlainObject:te,isUndefined:V,isDate:Lt,isFile:jt,isBlob:Ht,isRegExp:tn,isFunction:B,isStream:It,isURLSearchParams:Jt,isTypedArray:Qt,isFileList:Mt,forEach:W,merge:be,extend:vt,trim:qt,stripBOM:Vt,inherits:Wt,toFlatObject:Kt,kindOf:_e,kindOfTest:k,endsWith:Xt,toArray:Gt,forEachEntry:Yt,matchAll:Zt,isHTMLForm:$t,hasOwnProperty:Qe,hasOwnProp:Qe,reduceDescriptors:Ye,freezeMethods:e=>{Ye(e,(t,n)=>{if(B(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!B(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return j(e)?r(e):r(String(e).split(t)),n},toCamelCase:en,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ke,global:Xe,isContextDefined:Ge,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(ye(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=j(r)?[]:{};return W(r,(i,c)=>{const d=n(i,s+1);!V(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function y(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}u.inherits(y,Error,{toJSON:function(){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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ze=y.prototype,$e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{$e[e]={value:e}}),Object.defineProperties(y,$e),Object.defineProperty(Ze,"isAxiosError",{value:!0}),y.from=(e,t,n,r,s,o)=>{const i=Object.create(Ze);return u.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),y.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var nn=typeof self=="object"?self.FormData:window.FormData;const rn=nn;function Ee(e){return u.isPlainObject(e)||u.isArray(e)}function et(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,n){return e?e.concat(t).map(function(s,o){return s=et(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function sn(e){return u.isArray(e)&&!e.some(Ee)}const on=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function an(e){return e&&u.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function ne(e,t,n){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new(rn||FormData),n=u.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,E){return!u.isUndefined(E[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&an(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(u.isDate(p))return p.toISOString();if(!d&&u.isBlob(p))throw new y("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(p)||u.isTypedArray(p)?d&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function l(p,m,E){let b=p;if(p&&!E&&typeof p=="object"){if(u.endsWith(m,"{}"))m=r?m:m.slice(0,-2),p=JSON.stringify(p);else if(u.isArray(p)&&sn(p)||u.isFileList(p)||u.endsWith(m,"[]")&&(b=u.toArray(p)))return m=et(m),b.forEach(function(M,Ne){!(u.isUndefined(M)||M===null)&&t.append(i===!0?tt([m],Ne,o):i===null?m:m+"[]",a(M))}),!1}return Ee(p)?!0:(t.append(tt(E,m,o),a(p)),!1)}const f=[],h=Object.assign(on,{defaultVisitor:l,convertValue:a,isVisitable:Ee});function _(p,m){if(!u.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(p),u.forEach(p,function(b,g){(!(u.isUndefined(b)||b===null)&&s.call(t,b,u.isString(g)?g.trim():g,m,h))===!0&&_(b,m?m.concat(g):[g])}),f.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return _(e),t}function nt(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function we(e,t){this._pairs=[],e&&ne(e,this,t)}const rt=we.prototype;rt.append=function(t,n){this._pairs.push([t,n])},rt.toString=function(t){const n=t?function(r){return t.call(this,r,nt)}:nt;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function un(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function st(e,t,n){if(!t)return e;const r=n&&n.encode||un,s=n&&n.serialize;let o;if(s?o=s(t,n):o=u.isURLSearchParams(t)?t.toString():new we(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class cn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){u.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ot=cn,it={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ln=typeof URLSearchParams<"u"?URLSearchParams:we,fn=FormData,dn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),pn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),C={isBrowser:!0,classes:{URLSearchParams:ln,FormData:fn,Blob},isStandardBrowserEnv:dn,isStandardBrowserWebWorkerEnv:pn,protocols:["http","https","file","blob","url","data"]};function hn(e,t){return ne(e,new C.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return C.isNode&&u.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function mn(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function _n(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&u.isArray(s)?s.length:i,d?(u.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!u.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&u.isArray(s[i])&&(s[i]=_n(s[i])),!c)}if(u.isFormData(e)&&u.isFunction(e.entries)){const n={};return u.forEachEntry(e,(r,s)=>{t(mn(r),s,n,0)}),n}return null}const yn={"Content-Type":void 0};function bn(e,t,n){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const re={transitional:it,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=u.isObject(t);if(o&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(at(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return hn(t,this.formSerializer).toString();if((c=u.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return ne(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),bn(t)):t}],transformResponse:[function(t){const n=this.transitional||re.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&u.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};u.forEach(["delete","get","head"],function(t){re.headers[t]={}}),u.forEach(["post","put","patch"],function(t){re.headers[t]=u.merge(yn)});const Oe=re,En=u.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"]),wn=e=>{const t={};let n,r,s;return e&&e.split(` +`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&En[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ut=Symbol("internals");function K(e){return e&&String(e).trim().toLowerCase()}function se(e){return e===!1||e==null?e:u.isArray(e)?e.map(se):String(e)}function On(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}function Sn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ct(e,t,n,r){if(u.isFunction(r))return r.call(this,t,n);if(!!u.isString(t)){if(u.isString(r))return t.indexOf(r)!==-1;if(u.isRegExp(r))return r.test(t)}}function gn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Rn(e,t){const n=u.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class oe{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,a){const l=K(d);if(!l)throw new Error("header name must be a non-empty string");const f=u.findKey(s,l);(!f||s[f]===void 0||a===!0||a===void 0&&s[f]!==!1)&&(s[f||d]=se(c))}const i=(c,d)=>u.forEach(c,(a,l)=>o(a,l,d));return u.isPlainObject(t)||t instanceof this.constructor?i(t,n):u.isString(t)&&(t=t.trim())&&!Sn(t)?i(wn(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=K(t),t){const r=u.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return On(s);if(u.isFunction(n))return n.call(this,s,r);if(u.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=K(t),t){const r=u.findKey(this,t);return!!(r&&(!n||ct(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=K(i),i){const c=u.findKey(r,i);c&&(!n||ct(r,r[c],c,n))&&(delete r[c],s=!0)}}return u.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return u.forEach(this,(s,o)=>{const i=u.findKey(r,o);if(i){n[i]=se(s),delete n[o];return}const c=t?gn(o):String(o).trim();c!==o&&delete n[o],n[c]=se(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return u.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&u.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ut]=this[ut]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=K(i);r[c]||(Rn(s,i),r[c]=!0)}return u.isArray(t)?t.forEach(o):o(t),this}}oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(oe.prototype),u.freezeMethods(oe);const F=oe;function Se(e,t){const n=this||Oe,r=t||n,s=F.from(r.headers);let o=r.data;return u.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function lt(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){y.call(this,e==null?"canceled":e,y.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(X,y,{__CANCEL__:!0});const An=null;function Tn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Nn=C.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const d=[];d.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),u.isString(o)&&d.push("path="+o),u.isString(i)&&d.push("domain="+i),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function xn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Cn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function ft(e,t){return e&&!xn(t)?Cn(e,t):t}const Pn=C.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=u.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function kn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Fn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),l=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,h=0;for(;f!==s;)h+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,d=r(c),a=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const ie={http:An,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=F.from(e.headers).normalize(),i=e.responseType;let c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(C.isStandardBrowserEnv||C.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const _=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(_+":"+p))}const l=ft(e.baseURL,e.url);a.open(e.method.toUpperCase(),st(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const _=F.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),m={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:_,config:e,request:a};Tn(function(b){n(b),d()},function(b){r(b),d()},m),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new y("Request aborted",y.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new y("Network Error",y.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const m=e.transitional||it;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new y(p,m.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,a)),a=null},C.isStandardBrowserEnv){const _=(e.withCredentials||Pn(l))&&e.xsrfCookieName&&Nn.read(e.xsrfCookieName);_&&o.set(e.xsrfHeaderName,_)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&u.forEach(o.toJSON(),function(p,m){a.setRequestHeader(m,p)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",dt(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",dt(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=_=>{!a||(r(!_||_.type?new X(null,e,a):_),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const h=kn(l);if(h&&C.protocols.indexOf(h)===-1){r(new y("Unsupported protocol "+h+":",y.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(ie,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Dn={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof F?e.toJSON():e;function H(e,t){t=t||{};const n={};function r(a,l,f){return u.isPlainObject(a)&&u.isPlainObject(l)?u.merge.call({caseless:f},a,l):u.isPlainObject(l)?u.merge({},l):u.isArray(l)?l.slice():l}function s(a,l,f){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a,f)}else return r(a,l,f)}function o(a,l){if(!u.isUndefined(l))return r(void 0,l)}function i(a,l){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function c(a,l,f){if(f in t)return r(a,l);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(a,l)=>s(ht(a),ht(l),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const f=d[l]||s,h=f(e[l],t[l],l);u.isUndefined(h)&&f!==c||(n[l]=h)}),n}const mt="1.2.1",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _t={};Re.transitional=function(t,n,r){function s(o,i){return"[Axios v"+mt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new y(s(i," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!_t[i]&&(_t[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Un(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new y("option "+o+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+o,y.ERR_BAD_OPTION)}}const Ae={assertOptions:Un,validators:Re},U=Ae.validators;class ae{constructor(t){this.defaults=t,this.interceptors={request:new ot,response:new ot}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=H(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Ae.assertOptions(r,{silentJSONParsing:U.transitional(U.boolean),forcedJSONParsing:U.transitional(U.boolean),clarifyTimeoutError:U.transitional(U.boolean)},!1),s!==void 0&&Ae.assertOptions(s,{encode:U.function,serialize:U.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&u.merge(o.common,o[n.method]),i&&u.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=F.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const a=[];this.interceptors.response.forEach(function(m){a.push(m.fulfilled,m.rejected)});let l,f=0,h;if(!d){const p=[pt.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,a),h=p.length,l=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new X(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Te(function(s){t=s}),cancel:t}}}const Bn=Te;function Ln(e){return function(n){return e.apply(null,n)}}function jn(e){return u.isObject(e)&&e.isAxiosError===!0}function yt(e){const t=new ue(e),n=qe(ue.prototype.request,t);return u.extend(n,ue.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yt(H(e,s))},n}const O=yt(Oe);O.Axios=ue,O.CanceledError=X,O.CancelToken=Bn,O.isCancel=lt,O.VERSION=mt,O.toFormData=ne,O.AxiosError=y,O.Cancel=O.CanceledError,O.all=function(t){return Promise.all(t)},O.spread=Ln,O.isAxiosError=jn,O.mergeConfig=H,O.AxiosHeaders=F,O.formToJSON=e=>at(u.isHTMLForm(e)?new FormData(e):e),O.default=O;const Hn=O,ar="";function Mn(e){let t,n,r,s,o,i=`${e[4]}%`;function c(f,h){return f[6]?zn:Jn}let d=c(e),a=d(e),l=e[7]&&Et();return{c(){t=T("div"),n=T("div"),a.c(),r=z(),l&&l.c(),s=z(),o=T("div"),w(n,"class","percentage-text svelte-1urn4xa"),w(o,"id","percentage-bar"),w(o,"class","svelte-1urn4xa"),Q(o,"width",i),w(t,"id","percentage"),w(t,"class","svelte-1urn4xa")},m(f,h){N(f,t,h),R(t,n),a.m(n,null),R(n,r),l&&l.m(n,null),R(t,s),R(t,o)},p(f,h){d===(d=c(f))&&a?a.p(f,h):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[7]?l||(l=Et(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),h&16&&i!==(i=`${f[4]}%`)&&Q(o,"width",i)},d(f){f&&A(t),a.d(),l&&l.d()}}}function In(e){let t;function n(o,i){return o[2]?vn:qn}let r=n(e),s=r(e);return{c(){s.c(),t=De()},m(o,i){s.m(o,i),N(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&A(t)}}}function zn(e){let t;return{c(){t=D("Waiting for data schema detection...")},m(n,r){N(n,t,r)},p:x,d(n){n&&A(t)}}}function Jn(e){let t,n=!e[7]&&bt(e);return{c(){n&&n.c(),t=De()},m(r,s){n&&n.m(r,s),N(r,t,s)},p(r,s){r[7]?n&&(n.d(1),n=null):n?n.p(r,s):(n=bt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&A(t)}}}function bt(e){let t,n;return{c(){t=D(e[4]),n=D("%")},m(r,s){N(r,t,s),N(r,n,s)},p(r,s){s&16&&St(t,r[4])},d(r){r&&A(t),r&&A(n)}}}function Et(e){let t;return{c(){t=D("File uploaded")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function qn(e){let t;return{c(){t=D("Select a file to upload")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function vn(e){let t;return{c(){t=D("Select a file to replace the current one")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function Vn(e){let t,n,r,s,o,i,c,d,a,l,f,h,_;function p(b,g){return!b[5]&&!b[6]&&!b[7]?In:Mn}let m=p(e),E=m(e);return{c(){t=T("div"),n=T("div"),r=T("div"),E.c(),s=z(),o=T("input"),i=z(),c=T("div"),d=T("label"),d.textContent="URL",a=z(),l=T("div"),f=T("input"),w(r,"id","widget-label"),w(r,"class","svelte-1urn4xa"),w(o,"id","fileUpload"),w(o,"type","file"),w(o,"class","svelte-1urn4xa"),w(n,"id","fileUploadWidget"),w(n,"class","svelte-1urn4xa"),w(d,"class","control-label"),w(d,"for","field_url"),w(f,"id","field_url"),w(f,"class","form-control"),w(f,"type","text"),w(f,"name","url"),w(l,"class","controls"),Q(c,"display",e[1]!="upload"?"inline":"none"),w(c,"class","controls"),w(t,"class","form-group")},m(b,g){N(b,t,g),R(t,n),R(n,r),E.m(r,null),R(n,s),R(n,o),R(t,i),R(t,c),R(c,d),R(c,a),R(c,l),R(l,f),Ue(f,e[0]),h||(_=[le(o,"change",e[12]),le(o,"change",e[8]),le(f,"input",e[13])],h=!0)},p(b,[g]){m===(m=p(b))&&E?E.p(b,g):(E.d(1),E=m(b),E&&(E.c(),E.m(r,null))),g&1&&f.value!==b[0]&&Ue(f,b[0]),g&2&&Q(c,"display",b[1]!="upload"?"inline":"none")},i:x,o:x,d(b){b&&A(t),E.d(),h=!1,I(_)}}}function Wn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:c}=t,{url_type:d=""}=t,a,l=0,f=!1,h=!1,_=!1,p=Be(),m=i?"update":"create";async function E(S,G){try{const P={onUploadProgress:xe=>{const{loaded:Zn,total:$n}=xe,Ce=Math.floor(Zn*100/$n);Ce<=100&&(G(Ce),Ce==100&&(n(5,f=!1),n(6,h=!0)))}},{data:ce}=await Hn.post(`${r}/api/3/action/resource_${m}_with_schema`,S,P);return ce}catch(P){console.log("ERROR",P.message)}}function b(S){n(4,l=S)}async function g(S){try{const G=S.target.files[0],P=new FormData;P.append("upload",G),P.append("package_id",s),i&&(P.append("id",o),P.append("clear_upload",!0),P.append("url_type",d)),n(5,f=!0);let ce=await E(P,b),xe={data:ce};n(0,c=ce.result.url),n(1,d="upload"),p("fileUploaded",xe),n(6,h=!1),n(7,_=!0)}catch(G){console.log("ERROR",G),b(0)}}function M(){a=this.files,n(3,a)}function Ne(){c=this.value,n(0,c)}return e.$$set=S=>{"upload_url"in S&&n(9,r=S.upload_url),"dataset_id"in S&&n(10,s=S.dataset_id),"resource_id"in S&&n(11,o=S.resource_id),"update"in S&&n(2,i=S.update),"current_url"in S&&n(0,c=S.current_url),"url_type"in S&&n(1,d=S.url_type)},[c,d,i,a,l,f,h,_,g,r,s,o,M,Ne]}class Kn extends Je{constructor(t){super(),ze(this,t,Wn,Vn,Fe,{upload_url:9,dataset_id:10,resource_id:11,update:2,current_url:0,url_type:1})}}function Xn(e){let t,n,r;return n=new Kn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=T("main"),Pt(n.$$.fragment)},m(s,o){N(s,t,o),Me(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(He(n.$$.fragment,s),r=!0)},o(s){Ct(n.$$.fragment,s),r=!1},d(s){s&&A(t),Ie(n),e[8](null)}}}function Gn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:c}=t,{url_type:d}=t;Be();let a;function l(h){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:h.detail.data.result}))}function f(h){fe[h?"unshift":"push"](()=>{a=h,n(6,a)})}return e.$$set=h=>{"upload_url"in h&&n(0,r=h.upload_url),"dataset_id"in h&&n(1,s=h.dataset_id),"resource_id"in h&&n(2,o=h.resource_id),"update"in h&&n(3,i=h.update),"current_url"in h&&n(4,c=h.current_url),"url_type"in h&&n(5,d=h.url_type)},[r,s,o,i,c,d,a,l,f]}class Qn extends Je{constructor(t){super(),ze(this,t,Gn,Xn,Fe,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function Yn(e,t="",n="",r="",s="",o="",i=""){new Qn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return Yn}); diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js index 8da9fd4d..09c97605 100644 --- a/ckanext/validation/webassets/js/module-ckan-uploader.js +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -4,9 +4,11 @@ ckan.module('ckan-uploader', function (jQuery) { return { options: { upload_url: '', + resource_id: '', }, afterUpload: (resource_id) => (evt) => { let resource = evt.detail + let resource_id = resource.id // Set name let field_name = document.getElementById('field-name') let url_parts = resource.url.split('/') @@ -23,14 +25,44 @@ ckan.module('ckan-uploader', function (jQuery) { json_schema_field.value = JSON.stringify(resource.schema, null, 2) let json_button = document.getElementById('open-json-button') json_button.dispatchEvent(new Event('click')) - + // Set the form action to save the created resource - if (resource_id == '' || resource_id == true) { + if (resource_id != '') { let resource_form = document.getElementById('resource-edit') let current_action = resource_form.action let lastIndexNew = current_action.lastIndexOf('new') resource_form.action = current_action.slice(0, lastIndexNew) + `${resource.id}/edit` } + + let save_add_another = function (evt) { + if (evt.submitter.value == 'again') { + evt.preventDefault(); + let resource_form = document.getElementById('resource-edit') + let form_data = $('form#resource-edit') + let save_input = document.createElement('input') + save_input.setAttribute('type', 'hidden') + save_input.setAttribute('name', 'save') + save_input.setAttribute('value', 'again') + form_data.append(save_input) + + let new_action = resource_form.action + let lastIndexNew = new_action.lastIndexOf('new') + let edit_action = new_action.slice(0, lastIndexNew) + `${resource_id}/edit` + + $.ajax({ + url: edit_action, + type: 'post', + data: form_data.serialize(), + success: function(data) { + location.href = new_action + } + }) + } + } + + let resource_form = document.getElementById("resource-edit") + resource_form.addEventListener('submit', save_add_another) + }, initialize: function() { let resource_id = document.getElementById('resource_id').value From a3c6e27e55b731c2eac32eb312df517a99d79f04 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Wed, 14 Dec 2022 18:17:30 +0100 Subject: [PATCH 12/43] Add some comments to ckan-uploader-module --- .../webassets/js/module-ckan-uploader.js | 44 ++++++++++++++----- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js index 09c97605..a18ea9a3 100644 --- a/ckanext/validation/webassets/js/module-ckan-uploader.js +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -3,52 +3,68 @@ ckan.module('ckan-uploader', function (jQuery) { return { options: { + // The CKAN instance base URL upload_url: '', - resource_id: '', }, afterUpload: (resource_id) => (evt) => { let resource = evt.detail let resource_id = resource.id - // Set name + + // Next step set automatically some fields (name based on + // the filename, mime type and the ckanext-validation schema + // field, infered using frictionless) in the form + // based in the uploaded file + + // Set `name` field let field_name = document.getElementById('field-name') let url_parts = resource.url.split('/') let resource_name = url_parts[url_parts.length - 1] field_name.value = resource_name - // Set mime type + // Set `mime type` field let resource_type = document.getElementById('field-format') jQuery('#field-format').select2("val", resource.format) resource_type.value = resource.format - // Set schema + // Set `schema` ckanext-validation field let json_schema_field = document.getElementById('field-schema-json') json_schema_field.value = JSON.stringify(resource.schema, null, 2) let json_button = document.getElementById('open-json-button') json_button.dispatchEvent(new Event('click')) // Set the form action to save the created resource - if (resource_id != '') { - let resource_form = document.getElementById('resource-edit') - let current_action = resource_form.action - let lastIndexNew = current_action.lastIndexOf('new') - resource_form.action = current_action.slice(0, lastIndexNew) + `${resource.id}/edit` - } + let resource_form = document.getElementById('resource-edit') + let current_action = resource_form.action + let lastIndexNew = current_action.lastIndexOf('new') + resource_form.action = current_action.slice(0, lastIndexNew) + `${resource.id}/edit` + + // Function to redirect the user to add another resource + // if "Save & Add another" button is clicked let save_add_another = function (evt) { if (evt.submitter.value == 'again') { evt.preventDefault(); - let resource_form = document.getElementById('resource-edit') + resource_form = document.getElementById('resource-edit') let form_data = $('form#resource-edit') + + // We need to add this because jquery .serialize don't + // serialize input of type submit. CKAN used this information + // to choose where to redirect an user after a new resource is + // created let save_input = document.createElement('input') save_input.setAttribute('type', 'hidden') save_input.setAttribute('name', 'save') save_input.setAttribute('value', 'again') form_data.append(save_input) + // new_action: the URL to a new resource creation form let new_action = resource_form.action let lastIndexNew = new_action.lastIndexOf('new') + // edit_action: the URL to update an already existing form let edit_action = new_action.slice(0, lastIndexNew) + `${resource_id}/edit` + // Here we send the form using ajax and redirect the user again to + // a new resource create form $.ajax({ url: edit_action, type: 'post', @@ -60,17 +76,20 @@ ckan.module('ckan-uploader', function (jQuery) { } } - let resource_form = document.getElementById("resource-edit") + resource_form = document.getElementById("resource-edit") resource_form.addEventListener('submit', save_add_another) }, initialize: function() { + // Because we can't access some dataset/resource metadata from + // the ckanext-schemming snippets, we need to add them somehow let resource_id = document.getElementById('resource_id').value let dataset_id = document.getElementById('dataset_id').value let current_url = document.getElementById('current_url').value let url_type = document.getElementById('url_type').value let update = document.getElementById('update').value + // Add the upload widget CkanUploader('ckan_uploader', this.options.upload_url, dataset_id, @@ -78,6 +97,7 @@ ckan.module('ckan-uploader', function (jQuery) { url_type, current_url, update) + // Event handler for when a resource file is uploaded document.getElementById('ckan_uploader').addEventListener('fileUploaded', this.afterUpload(resource_id)) } } From a2257424cd9991b761c4e796d79dae8685231521 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Thu, 15 Dec 2022 11:02:44 +0100 Subject: [PATCH 13/43] Corrects behaviour for uploaded file is not tabular --- ckanext/validation/logic.py | 66 +++++++++++++------ .../webassets/js/module-ckan-uploader.js | 22 +++++-- 2 files changed, 62 insertions(+), 26 deletions(-) diff --git a/ckanext/validation/logic.py b/ckanext/validation/logic.py index 963a889f..ea822fa5 100644 --- a/ckanext/validation/logic.py +++ b/ckanext/validation/logic.py @@ -5,7 +5,7 @@ import json from sqlalchemy.orm.exc import NoResultFound -from frictionless import system, Resource +from frictionless import system, Resource, FrictionlessException import ckan.plugins as plugins import ckan.lib.uploader as uploader @@ -25,6 +25,23 @@ log = logging.getLogger(__name__) +ACCEPTED_TABULAR_FORMATS = set([ + 'text/csv', + 'application/vnd.ms-excel', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' +]) + +ACCEPTED_TABULAR_EXTENSIONS = set([ + 'csv', + 'tsv', + 'xls', + 'xlsx' +]) + +def is_tabular(filename = '', mimetype = ''): + uploaded_file_extension = filename.split('.')[-1].lower() + return mimetype in ACCEPTED_TABULAR_FORMATS or \ + uploaded_file_extension in ACCEPTED_TABULAR_EXTENSIONS def enqueue_job(*args, **kwargs): try: @@ -199,17 +216,25 @@ def resource_table_schema_infer(context, data_dict): source = resource['url'] with system.use_context(trusted=True): - # TODO: check for valid formats - fric_resource = Resource({'path': source, 'format': resource.get('format', 'csv').lower()}) - fric_resource.infer() - resource['schema'] = fric_resource.schema.to_json() - - # TODO: check for exception - if store_schema: - t.get_action('resource_update')( - context, resource) - - return {u'schema': fric_resource.schema.to_dict()} + if is_tabular(filename=resource['url']): + try: + fric_resource = Resource({'path': source, 'format': resource['format'].lower()}) + fric_resource.infer() + resource['schema'] = fric_resource.schema.to_json() + + if store_schema: + t.get_action('resource_update')( + context, resource) + + return {u'schema': fric_resource.schema.to_dict()} + except FrictionlessException as e: + log.warning( + u'Error trying to infer schema for resource %s: %s', + resource['id'], e) + + return {u'schema': ''} + else: + return {u'schema': ''} def resource_validation_delete(context, data_dict): @@ -480,6 +505,7 @@ def resource_create_with_schema(context, data_dict): upload = uploader.get_resource_uploader(data_dict) + if 'mimetype' not in data_dict: if hasattr(upload, 'mimetype'): data_dict['mimetype'] = upload.mimetype @@ -494,7 +520,7 @@ def resource_create_with_schema(context, data_dict): context['defer_commit'] = True context['use_cache'] = False pkg_dict['state'] = 'active' - t.get_action('package_update')(context, pkg_dict) + package = t.get_action('package_update')(context, pkg_dict) context.pop('defer_commit') except t.ValidationError as e: try: @@ -510,9 +536,10 @@ def resource_create_with_schema(context, data_dict): model.repo.commit() - update_resource = t.get_action('resource_table_schema_infer')( - context, {'resource_id': resource_id, 'store_schema': True} - ) + if is_tabular(filename=upload.filename): + update_resource = t.get_action('resource_table_schema_infer')( + context, {'resource_id': resource_id, 'store_schema': True} + ) # Run package show again to get out actual last_resource updated_pkg_dict = t.get_action('package_show')( @@ -715,9 +742,10 @@ def resource_update_with_schema(context, data_dict): upload.upload(id, uploader.get_max_resource_size()) - update_resource = t.get_action('resource_table_schema_infer')( - context, {'resource_id': resource.id, 'store_schema': True} - ) + if is_tabular(upload): + update_resource = t.get_action('resource_table_schema_infer')( + context, {'resource_id': resource.id, 'store_schema': True} + ) # Run package show again to get out actual last_resource updated_pkg_dict = t.get_action('package_show')( diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js index a18ea9a3..d13d0ede 100644 --- a/ckanext/validation/webassets/js/module-ckan-uploader.js +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -28,15 +28,22 @@ ckan.module('ckan-uploader', function (jQuery) { // Set `schema` ckanext-validation field let json_schema_field = document.getElementById('field-schema-json') - json_schema_field.value = JSON.stringify(resource.schema, null, 2) - let json_button = document.getElementById('open-json-button') - json_button.dispatchEvent(new Event('click')) + if ('schema' in resource) { + json_schema_field.value = JSON.stringify(resource.schema, null, 2) + let json_button = document.getElementById('open-json-button') + json_button.dispatchEvent(new Event('click')) + } // Set the form action to save the created resource + let hidden_resource_id = document.getElementById('resource_id').value + let resource_form = document.getElementById('resource-edit') let current_action = resource_form.action - let lastIndexNew = current_action.lastIndexOf('new') - resource_form.action = current_action.slice(0, lastIndexNew) + `${resource.id}/edit` + + if (hidden_resource_id == '') { + let lastIndexNew = current_action.lastIndexOf('new') + resource_form.action = current_action.slice(0, lastIndexNew) + `${resource.id}/edit` + } // Function to redirect the user to add another resource // if "Save & Add another" button is clicked @@ -62,15 +69,16 @@ ckan.module('ckan-uploader', function (jQuery) { let lastIndexNew = new_action.lastIndexOf('new') // edit_action: the URL to update an already existing form let edit_action = new_action.slice(0, lastIndexNew) + `${resource_id}/edit` + console.log(new_action, edit_action) // Here we send the form using ajax and redirect the user again to // a new resource create form $.ajax({ - url: edit_action, + url: new_action, type: 'post', data: form_data.serialize(), success: function(data) { - location.href = new_action + location.href = current_action } }) } From 0644e0a730deab7d1ace8ffad48300265ddd85ec Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Thu, 15 Dec 2022 21:30:53 +0100 Subject: [PATCH 14/43] use custom resource_create and resource_update instead of new actions and fix bug when file format changes --- ckanext/validation/logic.py | 93 +++++++++++-------- ckanext/validation/plugin/__init__.py | 4 +- .../validation/webassets/js/ckan-uploader.js | 2 +- .../webassets/js/module-ckan-uploader.js | 4 + 4 files changed, 61 insertions(+), 42 deletions(-) diff --git a/ckanext/validation/logic.py b/ckanext/validation/logic.py index ea822fa5..202651a3 100644 --- a/ckanext/validation/logic.py +++ b/ckanext/validation/logic.py @@ -577,9 +577,6 @@ def resource_create(up_func, context, data_dict): ''' - if get_create_mode_from_config() != 'sync': - return up_func(context, data_dict) - model = context['model'] package_id = t.get_or_bust(data_dict, 'package_id') @@ -613,6 +610,7 @@ def resource_create(up_func, context, data_dict): try: context['defer_commit'] = True context['use_cache'] = False + pkg_dict['state'] = 'active' t.get_action('package_update')(context, pkg_dict) context.pop('defer_commit') except t.ValidationError as e: @@ -629,25 +627,32 @@ def resource_create(up_func, context, data_dict): # Custom code starts - run_validation = True + if get_create_mode_from_config() == 'sync': - for plugin in plugins.PluginImplementations(IDataValidation): - if not plugin.can_validate(context, data_dict): - log.debug('Skipping validation for resource {}'.format(resource_id)) - run_validation = False + run_validation = True - if run_validation: - is_local_upload = ( - hasattr(upload, 'filename') and - upload.filename is not None and - isinstance(upload, uploader.ResourceUpload)) - _run_sync_validation( - resource_id, local_upload=is_local_upload, new_resource=True) + for plugin in plugins.PluginImplementations(IDataValidation): + if not plugin.can_validate(context, data_dict): + log.debug('Skipping validation for resource {}'.format(resource_id)) + run_validation = False + + if run_validation: + is_local_upload = ( + hasattr(upload, 'filename') and + upload.filename is not None and + isinstance(upload, uploader.ResourceUpload)) + _run_sync_validation( + resource_id, local_upload=is_local_upload, new_resource=True) # Custom code ends model.repo.commit() + if upload.filename and is_tabular(filename=upload.filename): + update_resource = t.get_action('resource_table_schema_infer')( + context, {'resource_id': resource_id, 'store_schema': True} + ) + # Run package show again to get out actual last_resource updated_pkg_dict = t.get_action('package_show')( context, {'id': package_id}) @@ -805,9 +810,6 @@ def resource_update(up_func, context, data_dict): ''' - if get_update_mode_from_config() != 'sync': - return up_func(context, data_dict) - model = context['model'] id = t.get_or_bust(data_dict, "id") @@ -846,13 +848,13 @@ def resource_update(up_func, context, data_dict): upload = uploader.get_resource_uploader(data_dict) - if 'mimetype' not in data_dict: - if hasattr(upload, 'mimetype'): - data_dict['mimetype'] = upload.mimetype + if 'mimetype' not in data_dict or hasattr(upload, 'mimetype'): + data_dict['mimetype'] = upload.mimetype + if upload.filename: + data_dict['format'] = upload.filename.split('.')[-1] - if 'size' not in data_dict and 'url_type' in data_dict: - if hasattr(upload, 'filesize'): - data_dict['size'] = upload.filesize + if 'size' not in data_dict and 'url_type' in data_dict or hasattr(upload, 'filesize'): + data_dict['size'] = upload.filesize pkg_dict['resources'][n] = data_dict @@ -867,26 +869,39 @@ def resource_update(up_func, context, data_dict): except (KeyError, IndexError): raise t.ValidationError(e.error_dict) + resource = updated_pkg_dict['resources'][-1] upload.upload(id, uploader.get_max_resource_size()) - # Custom code starts + if upload.filename and is_tabular(filename=upload.filename): + update_resource = t.get_action('resource_table_schema_infer')( + context, {'resource_id': resource['id'], 'store_schema': True} + ) - run_validation = True - for plugin in plugins.PluginImplementations(IDataValidation): - if not plugin.can_validate(context, data_dict): - log.debug('Skipping validation for resource {}'.format(id)) - run_validation = False + # Run package show again to get out actual last_resource + updated_pkg_dict = t.get_action('package_show')( + context, {'id': package_id}) + resource = updated_pkg_dict['resources'][-1] - if run_validation: - run_validation = not data_dict.pop('_skip_next_validation', None) - if run_validation: - is_local_upload = ( - hasattr(upload, 'filename') and - upload.filename is not None and - isinstance(upload, uploader.ResourceUpload)) - _run_sync_validation( - id, local_upload=is_local_upload, new_resource=False) + # Custom code starts + + if get_update_mode_from_config() == 'sync': + run_validation = True + for plugin in plugins.PluginImplementations(IDataValidation): + if not plugin.can_validate(context, data_dict): + log.debug('Skipping validation for resource {}'.format(id)) + run_validation = False + + if run_validation: + run_validation = not data_dict.pop('_skip_next_validation', None) + + if run_validation: + is_local_upload = ( + hasattr(upload, 'filename') and + upload.filename is not None and + isinstance(upload, uploader.ResourceUpload)) + _run_sync_validation( + id, local_upload=is_local_upload, new_resource=False) # Custom code ends diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index fdf6c982..3b486056 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -95,8 +95,8 @@ def get_actions(self): u'resource_create': custom_resource_create, u'resource_update': custom_resource_update, u'resource_table_schema_infer': resource_table_schema_infer, - u'resource_create_with_schema': resource_create_with_schema, - u'resource_update_with_schema': resource_update_with_schema + # u'resource_create_with_schema': resource_create_with_schema, + # u'resource_update_with_schema': resource_update_with_schema } return new_actions diff --git a/ckanext/validation/webassets/js/ckan-uploader.js b/ckanext/validation/webassets/js/ckan-uploader.js index a2444951..ca6063f6 100644 --- a/ckanext/validation/webassets/js/ckan-uploader.js +++ b/ckanext/validation/webassets/js/ckan-uploader.js @@ -1,3 +1,3 @@ (function(x,L){typeof exports=="object"&&typeof module<"u"?module.exports=L():typeof define=="function"&&define.amd?define(L):(x=typeof globalThis<"u"?globalThis:x||self,x.CkanUploader=L())})(this,function(){"use strict";function x(){}function L(e){return e()}function Pe(){return Object.create(null)}function I(e){e.forEach(L)}function ke(e){return typeof e=="function"}function Fe(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function wt(e){return Object.keys(e).length===0}function R(e,t){e.appendChild(t)}function N(e,t,n){e.insertBefore(t,n||null)}function A(e){e.parentNode&&e.parentNode.removeChild(e)}function T(e){return document.createElement(e)}function D(e){return document.createTextNode(e)}function z(){return D(" ")}function De(){return D("")}function le(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function w(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Ot(e){return Array.from(e.childNodes)}function St(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Ue(e,t){e.value=t==null?"":t}function Q(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function gt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Rt(){if(!J)throw new Error("Function called outside component initialization");return J}function Be(){const e=Rt();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=gt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const v=[],fe=[],Y=[],Le=[],At=Promise.resolve();let de=!1;function Tt(){de||(de=!0,At.then(je))}function pe(e){Y.push(e)}const he=new Set;let Z=0;function je(){const e=J;do{for(;Z{$.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Pt(e){e&&e.c()}function Me(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||pe(()=>{const i=e.$$.on_mount.map(L).filter(ke);e.$$.on_destroy?e.$$.on_destroy.push(...i):I(i),e.$$.on_mount=[]}),o.forEach(pe)}function Ie(e,t){const n=e.$$;n.fragment!==null&&(I(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function kt(e,t){e.$$.dirty[0]===-1&&(v.push(e),Tt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=_.length?_[0]:h;return a.ctx&&s(a.ctx[f],a.ctx[f]=p)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](p),l&&kt(e,f)),h}):[],a.update(),l=!0,I(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Ot(t.target);a.fragment&&a.fragment.l(f),f.forEach(A)}else a.fragment&&a.fragment.c();t.intro&&He(e.$$.fragment),Me(e,t.target,t.anchor,t.customElement),je()}q(d)}class Je{$destroy(){Ie(this,1),this.$destroy=x}$on(t,n){if(!ke(n))return x;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!wt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function qe(e,t){return function(){return e.apply(t,arguments)}}const{toString:ve}=Object.prototype,{getPrototypeOf:me}=Object,_e=(e=>t=>{const n=ve.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),k=e=>(e=e.toLowerCase(),t=>_e(t)===e),ee=e=>t=>typeof t===e,{isArray:j}=Array,V=ee("undefined");function Ft(e){return e!==null&&!V(e)&&e.constructor!==null&&!V(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ve=k("ArrayBuffer");function Dt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ve(e.buffer),t}const Ut=ee("string"),B=ee("function"),We=ee("number"),ye=e=>e!==null&&typeof e=="object",Bt=e=>e===!0||e===!1,te=e=>{if(_e(e)!=="object")return!1;const t=me(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Lt=k("Date"),jt=k("File"),Ht=k("Blob"),Mt=k("FileList"),It=e=>ye(e)&&B(e.pipe),zt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||ve.call(e)===t||B(e.toString)&&e.toString()===t)},Jt=k("URLSearchParams"),qt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function W(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),j(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Xe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ge=e=>!V(e)&&e!==Xe;function be(){const{caseless:e}=Ge(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ke(t,s)||s;te(t[o])&&te(r)?t[o]=be(t[o],r):te(r)?t[o]=be({},r):j(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(W(t,(s,o)=>{n&&B(s)?e[o]=qe(s,n):e[o]=s},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Wt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Kt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&me(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Xt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Gt=e=>{if(!e)return null;if(j(e))return e;let t=e.length;if(!We(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Qt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&me(Uint8Array)),Yt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},Zt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},$t=k("HTMLFormElement"),en=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Qe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),tn=k("RegExp"),Ye=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};W(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},u={isArray:j,isArrayBuffer:Ve,isBuffer:Ft,isFormData:zt,isArrayBufferView:Dt,isString:Ut,isNumber:We,isBoolean:Bt,isObject:ye,isPlainObject:te,isUndefined:V,isDate:Lt,isFile:jt,isBlob:Ht,isRegExp:tn,isFunction:B,isStream:It,isURLSearchParams:Jt,isTypedArray:Qt,isFileList:Mt,forEach:W,merge:be,extend:vt,trim:qt,stripBOM:Vt,inherits:Wt,toFlatObject:Kt,kindOf:_e,kindOfTest:k,endsWith:Xt,toArray:Gt,forEachEntry:Yt,matchAll:Zt,isHTMLForm:$t,hasOwnProperty:Qe,hasOwnProp:Qe,reduceDescriptors:Ye,freezeMethods:e=>{Ye(e,(t,n)=>{if(B(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!B(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return j(e)?r(e):r(String(e).split(t)),n},toCamelCase:en,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ke,global:Xe,isContextDefined:Ge,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(ye(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=j(r)?[]:{};return W(r,(i,c)=>{const d=n(i,s+1);!V(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function y(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}u.inherits(y,Error,{toJSON:function(){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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ze=y.prototype,$e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{$e[e]={value:e}}),Object.defineProperties(y,$e),Object.defineProperty(Ze,"isAxiosError",{value:!0}),y.from=(e,t,n,r,s,o)=>{const i=Object.create(Ze);return u.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),y.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var nn=typeof self=="object"?self.FormData:window.FormData;const rn=nn;function Ee(e){return u.isPlainObject(e)||u.isArray(e)}function et(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,n){return e?e.concat(t).map(function(s,o){return s=et(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function sn(e){return u.isArray(e)&&!e.some(Ee)}const on=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function an(e){return e&&u.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function ne(e,t,n){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new(rn||FormData),n=u.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,E){return!u.isUndefined(E[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&an(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(u.isDate(p))return p.toISOString();if(!d&&u.isBlob(p))throw new y("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(p)||u.isTypedArray(p)?d&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function l(p,m,E){let b=p;if(p&&!E&&typeof p=="object"){if(u.endsWith(m,"{}"))m=r?m:m.slice(0,-2),p=JSON.stringify(p);else if(u.isArray(p)&&sn(p)||u.isFileList(p)||u.endsWith(m,"[]")&&(b=u.toArray(p)))return m=et(m),b.forEach(function(M,Ne){!(u.isUndefined(M)||M===null)&&t.append(i===!0?tt([m],Ne,o):i===null?m:m+"[]",a(M))}),!1}return Ee(p)?!0:(t.append(tt(E,m,o),a(p)),!1)}const f=[],h=Object.assign(on,{defaultVisitor:l,convertValue:a,isVisitable:Ee});function _(p,m){if(!u.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(p),u.forEach(p,function(b,g){(!(u.isUndefined(b)||b===null)&&s.call(t,b,u.isString(g)?g.trim():g,m,h))===!0&&_(b,m?m.concat(g):[g])}),f.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return _(e),t}function nt(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function we(e,t){this._pairs=[],e&&ne(e,this,t)}const rt=we.prototype;rt.append=function(t,n){this._pairs.push([t,n])},rt.toString=function(t){const n=t?function(r){return t.call(this,r,nt)}:nt;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function un(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function st(e,t,n){if(!t)return e;const r=n&&n.encode||un,s=n&&n.serialize;let o;if(s?o=s(t,n):o=u.isURLSearchParams(t)?t.toString():new we(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class cn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){u.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ot=cn,it={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ln=typeof URLSearchParams<"u"?URLSearchParams:we,fn=FormData,dn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),pn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),C={isBrowser:!0,classes:{URLSearchParams:ln,FormData:fn,Blob},isStandardBrowserEnv:dn,isStandardBrowserWebWorkerEnv:pn,protocols:["http","https","file","blob","url","data"]};function hn(e,t){return ne(e,new C.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return C.isNode&&u.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function mn(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function _n(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&u.isArray(s)?s.length:i,d?(u.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!u.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&u.isArray(s[i])&&(s[i]=_n(s[i])),!c)}if(u.isFormData(e)&&u.isFunction(e.entries)){const n={};return u.forEachEntry(e,(r,s)=>{t(mn(r),s,n,0)}),n}return null}const yn={"Content-Type":void 0};function bn(e,t,n){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const re={transitional:it,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=u.isObject(t);if(o&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(at(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return hn(t,this.formSerializer).toString();if((c=u.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return ne(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),bn(t)):t}],transformResponse:[function(t){const n=this.transitional||re.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&u.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};u.forEach(["delete","get","head"],function(t){re.headers[t]={}}),u.forEach(["post","put","patch"],function(t){re.headers[t]=u.merge(yn)});const Oe=re,En=u.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"]),wn=e=>{const t={};let n,r,s;return e&&e.split(` `).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&En[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ut=Symbol("internals");function K(e){return e&&String(e).trim().toLowerCase()}function se(e){return e===!1||e==null?e:u.isArray(e)?e.map(se):String(e)}function On(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}function Sn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ct(e,t,n,r){if(u.isFunction(r))return r.call(this,t,n);if(!!u.isString(t)){if(u.isString(r))return t.indexOf(r)!==-1;if(u.isRegExp(r))return r.test(t)}}function gn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Rn(e,t){const n=u.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class oe{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,a){const l=K(d);if(!l)throw new Error("header name must be a non-empty string");const f=u.findKey(s,l);(!f||s[f]===void 0||a===!0||a===void 0&&s[f]!==!1)&&(s[f||d]=se(c))}const i=(c,d)=>u.forEach(c,(a,l)=>o(a,l,d));return u.isPlainObject(t)||t instanceof this.constructor?i(t,n):u.isString(t)&&(t=t.trim())&&!Sn(t)?i(wn(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=K(t),t){const r=u.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return On(s);if(u.isFunction(n))return n.call(this,s,r);if(u.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=K(t),t){const r=u.findKey(this,t);return!!(r&&(!n||ct(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=K(i),i){const c=u.findKey(r,i);c&&(!n||ct(r,r[c],c,n))&&(delete r[c],s=!0)}}return u.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return u.forEach(this,(s,o)=>{const i=u.findKey(r,o);if(i){n[i]=se(s),delete n[o];return}const c=t?gn(o):String(o).trim();c!==o&&delete n[o],n[c]=se(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return u.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&u.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ut]=this[ut]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=K(i);r[c]||(Rn(s,i),r[c]=!0)}return u.isArray(t)?t.forEach(o):o(t),this}}oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(oe.prototype),u.freezeMethods(oe);const F=oe;function Se(e,t){const n=this||Oe,r=t||n,s=F.from(r.headers);let o=r.data;return u.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function lt(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){y.call(this,e==null?"canceled":e,y.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(X,y,{__CANCEL__:!0});const An=null;function Tn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Nn=C.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const d=[];d.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),u.isString(o)&&d.push("path="+o),u.isString(i)&&d.push("domain="+i),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function xn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Cn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function ft(e,t){return e&&!xn(t)?Cn(e,t):t}const Pn=C.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=u.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function kn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Fn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),l=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,h=0;for(;f!==s;)h+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,d=r(c),a=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const ie={http:An,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=F.from(e.headers).normalize(),i=e.responseType;let c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(C.isStandardBrowserEnv||C.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const _=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(_+":"+p))}const l=ft(e.baseURL,e.url);a.open(e.method.toUpperCase(),st(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const _=F.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),m={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:_,config:e,request:a};Tn(function(b){n(b),d()},function(b){r(b),d()},m),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new y("Request aborted",y.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new y("Network Error",y.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const m=e.transitional||it;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new y(p,m.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,a)),a=null},C.isStandardBrowserEnv){const _=(e.withCredentials||Pn(l))&&e.xsrfCookieName&&Nn.read(e.xsrfCookieName);_&&o.set(e.xsrfHeaderName,_)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&u.forEach(o.toJSON(),function(p,m){a.setRequestHeader(m,p)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",dt(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",dt(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=_=>{!a||(r(!_||_.type?new X(null,e,a):_),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const h=kn(l);if(h&&C.protocols.indexOf(h)===-1){r(new y("Unsupported protocol "+h+":",y.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(ie,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Dn={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof F?e.toJSON():e;function H(e,t){t=t||{};const n={};function r(a,l,f){return u.isPlainObject(a)&&u.isPlainObject(l)?u.merge.call({caseless:f},a,l):u.isPlainObject(l)?u.merge({},l):u.isArray(l)?l.slice():l}function s(a,l,f){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a,f)}else return r(a,l,f)}function o(a,l){if(!u.isUndefined(l))return r(void 0,l)}function i(a,l){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function c(a,l,f){if(f in t)return r(a,l);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(a,l)=>s(ht(a),ht(l),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const f=d[l]||s,h=f(e[l],t[l],l);u.isUndefined(h)&&f!==c||(n[l]=h)}),n}const mt="1.2.1",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _t={};Re.transitional=function(t,n,r){function s(o,i){return"[Axios v"+mt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new y(s(i," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!_t[i]&&(_t[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Un(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new y("option "+o+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+o,y.ERR_BAD_OPTION)}}const Ae={assertOptions:Un,validators:Re},U=Ae.validators;class ae{constructor(t){this.defaults=t,this.interceptors={request:new ot,response:new ot}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=H(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Ae.assertOptions(r,{silentJSONParsing:U.transitional(U.boolean),forcedJSONParsing:U.transitional(U.boolean),clarifyTimeoutError:U.transitional(U.boolean)},!1),s!==void 0&&Ae.assertOptions(s,{encode:U.function,serialize:U.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&u.merge(o.common,o[n.method]),i&&u.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=F.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const a=[];this.interceptors.response.forEach(function(m){a.push(m.fulfilled,m.rejected)});let l,f=0,h;if(!d){const p=[pt.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,a),h=p.length,l=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new X(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Te(function(s){t=s}),cancel:t}}}const Bn=Te;function Ln(e){return function(n){return e.apply(null,n)}}function jn(e){return u.isObject(e)&&e.isAxiosError===!0}function yt(e){const t=new ue(e),n=qe(ue.prototype.request,t);return u.extend(n,ue.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yt(H(e,s))},n}const O=yt(Oe);O.Axios=ue,O.CanceledError=X,O.CancelToken=Bn,O.isCancel=lt,O.VERSION=mt,O.toFormData=ne,O.AxiosError=y,O.Cancel=O.CanceledError,O.all=function(t){return Promise.all(t)},O.spread=Ln,O.isAxiosError=jn,O.mergeConfig=H,O.AxiosHeaders=F,O.formToJSON=e=>at(u.isHTMLForm(e)?new FormData(e):e),O.default=O;const Hn=O,ar="";function Mn(e){let t,n,r,s,o,i=`${e[4]}%`;function c(f,h){return f[6]?zn:Jn}let d=c(e),a=d(e),l=e[7]&&Et();return{c(){t=T("div"),n=T("div"),a.c(),r=z(),l&&l.c(),s=z(),o=T("div"),w(n,"class","percentage-text svelte-1urn4xa"),w(o,"id","percentage-bar"),w(o,"class","svelte-1urn4xa"),Q(o,"width",i),w(t,"id","percentage"),w(t,"class","svelte-1urn4xa")},m(f,h){N(f,t,h),R(t,n),a.m(n,null),R(n,r),l&&l.m(n,null),R(t,s),R(t,o)},p(f,h){d===(d=c(f))&&a?a.p(f,h):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[7]?l||(l=Et(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),h&16&&i!==(i=`${f[4]}%`)&&Q(o,"width",i)},d(f){f&&A(t),a.d(),l&&l.d()}}}function In(e){let t;function n(o,i){return o[2]?vn:qn}let r=n(e),s=r(e);return{c(){s.c(),t=De()},m(o,i){s.m(o,i),N(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&A(t)}}}function zn(e){let t;return{c(){t=D("Waiting for data schema detection...")},m(n,r){N(n,t,r)},p:x,d(n){n&&A(t)}}}function Jn(e){let t,n=!e[7]&&bt(e);return{c(){n&&n.c(),t=De()},m(r,s){n&&n.m(r,s),N(r,t,s)},p(r,s){r[7]?n&&(n.d(1),n=null):n?n.p(r,s):(n=bt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&A(t)}}}function bt(e){let t,n;return{c(){t=D(e[4]),n=D("%")},m(r,s){N(r,t,s),N(r,n,s)},p(r,s){s&16&&St(t,r[4])},d(r){r&&A(t),r&&A(n)}}}function Et(e){let t;return{c(){t=D("File uploaded")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function qn(e){let t;return{c(){t=D("Select a file to upload")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function vn(e){let t;return{c(){t=D("Select a file to replace the current one")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function Vn(e){let t,n,r,s,o,i,c,d,a,l,f,h,_;function p(b,g){return!b[5]&&!b[6]&&!b[7]?In:Mn}let m=p(e),E=m(e);return{c(){t=T("div"),n=T("div"),r=T("div"),E.c(),s=z(),o=T("input"),i=z(),c=T("div"),d=T("label"),d.textContent="URL",a=z(),l=T("div"),f=T("input"),w(r,"id","widget-label"),w(r,"class","svelte-1urn4xa"),w(o,"id","fileUpload"),w(o,"type","file"),w(o,"class","svelte-1urn4xa"),w(n,"id","fileUploadWidget"),w(n,"class","svelte-1urn4xa"),w(d,"class","control-label"),w(d,"for","field_url"),w(f,"id","field_url"),w(f,"class","form-control"),w(f,"type","text"),w(f,"name","url"),w(l,"class","controls"),Q(c,"display",e[1]!="upload"?"inline":"none"),w(c,"class","controls"),w(t,"class","form-group")},m(b,g){N(b,t,g),R(t,n),R(n,r),E.m(r,null),R(n,s),R(n,o),R(t,i),R(t,c),R(c,d),R(c,a),R(c,l),R(l,f),Ue(f,e[0]),h||(_=[le(o,"change",e[12]),le(o,"change",e[8]),le(f,"input",e[13])],h=!0)},p(b,[g]){m===(m=p(b))&&E?E.p(b,g):(E.d(1),E=m(b),E&&(E.c(),E.m(r,null))),g&1&&f.value!==b[0]&&Ue(f,b[0]),g&2&&Q(c,"display",b[1]!="upload"?"inline":"none")},i:x,o:x,d(b){b&&A(t),E.d(),h=!1,I(_)}}}function Wn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:c}=t,{url_type:d=""}=t,a,l=0,f=!1,h=!1,_=!1,p=Be(),m=i?"update":"create";async function E(S,G){try{const P={onUploadProgress:xe=>{const{loaded:Zn,total:$n}=xe,Ce=Math.floor(Zn*100/$n);Ce<=100&&(G(Ce),Ce==100&&(n(5,f=!1),n(6,h=!0)))}},{data:ce}=await Hn.post(`${r}/api/3/action/resource_${m}_with_schema`,S,P);return ce}catch(P){console.log("ERROR",P.message)}}function b(S){n(4,l=S)}async function g(S){try{const G=S.target.files[0],P=new FormData;P.append("upload",G),P.append("package_id",s),i&&(P.append("id",o),P.append("clear_upload",!0),P.append("url_type",d)),n(5,f=!0);let ce=await E(P,b),xe={data:ce};n(0,c=ce.result.url),n(1,d="upload"),p("fileUploaded",xe),n(6,h=!1),n(7,_=!0)}catch(G){console.log("ERROR",G),b(0)}}function M(){a=this.files,n(3,a)}function Ne(){c=this.value,n(0,c)}return e.$$set=S=>{"upload_url"in S&&n(9,r=S.upload_url),"dataset_id"in S&&n(10,s=S.dataset_id),"resource_id"in S&&n(11,o=S.resource_id),"update"in S&&n(2,i=S.update),"current_url"in S&&n(0,c=S.current_url),"url_type"in S&&n(1,d=S.url_type)},[c,d,i,a,l,f,h,_,g,r,s,o,M,Ne]}class Kn extends Je{constructor(t){super(),ze(this,t,Wn,Vn,Fe,{upload_url:9,dataset_id:10,resource_id:11,update:2,current_url:0,url_type:1})}}function Xn(e){let t,n,r;return n=new Kn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=T("main"),Pt(n.$$.fragment)},m(s,o){N(s,t,o),Me(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(He(n.$$.fragment,s),r=!0)},o(s){Ct(n.$$.fragment,s),r=!1},d(s){s&&A(t),Ie(n),e[8](null)}}}function Gn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:c}=t,{url_type:d}=t;Be();let a;function l(h){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:h.detail.data.result}))}function f(h){fe[h?"unshift":"push"](()=>{a=h,n(6,a)})}return e.$$set=h=>{"upload_url"in h&&n(0,r=h.upload_url),"dataset_id"in h&&n(1,s=h.dataset_id),"resource_id"in h&&n(2,o=h.resource_id),"update"in h&&n(3,i=h.update),"current_url"in h&&n(4,c=h.current_url),"url_type"in h&&n(5,d=h.url_type)},[r,s,o,i,c,d,a,l,f]}class Qn extends Je{constructor(t){super(),ze(this,t,Gn,Xn,Fe,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function Yn(e,t="",n="",r="",s="",o="",i=""){new Qn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return Yn}); +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ut]=this[ut]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=K(i);r[c]||(Rn(s,i),r[c]=!0)}return u.isArray(t)?t.forEach(o):o(t),this}}oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(oe.prototype),u.freezeMethods(oe);const F=oe;function Se(e,t){const n=this||Oe,r=t||n,s=F.from(r.headers);let o=r.data;return u.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function lt(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){y.call(this,e==null?"canceled":e,y.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(X,y,{__CANCEL__:!0});const An=null;function Tn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Nn=C.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const d=[];d.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),u.isString(o)&&d.push("path="+o),u.isString(i)&&d.push("domain="+i),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function xn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Cn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function ft(e,t){return e&&!xn(t)?Cn(e,t):t}const Pn=C.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=u.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function kn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Fn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),l=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,h=0;for(;f!==s;)h+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,d=r(c),a=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const ie={http:An,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=F.from(e.headers).normalize(),i=e.responseType;let c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(C.isStandardBrowserEnv||C.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const _=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(_+":"+p))}const l=ft(e.baseURL,e.url);a.open(e.method.toUpperCase(),st(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const _=F.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),m={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:_,config:e,request:a};Tn(function(b){n(b),d()},function(b){r(b),d()},m),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new y("Request aborted",y.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new y("Network Error",y.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const m=e.transitional||it;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new y(p,m.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,a)),a=null},C.isStandardBrowserEnv){const _=(e.withCredentials||Pn(l))&&e.xsrfCookieName&&Nn.read(e.xsrfCookieName);_&&o.set(e.xsrfHeaderName,_)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&u.forEach(o.toJSON(),function(p,m){a.setRequestHeader(m,p)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",dt(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",dt(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=_=>{!a||(r(!_||_.type?new X(null,e,a):_),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const h=kn(l);if(h&&C.protocols.indexOf(h)===-1){r(new y("Unsupported protocol "+h+":",y.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(ie,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Dn={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof F?e.toJSON():e;function H(e,t){t=t||{};const n={};function r(a,l,f){return u.isPlainObject(a)&&u.isPlainObject(l)?u.merge.call({caseless:f},a,l):u.isPlainObject(l)?u.merge({},l):u.isArray(l)?l.slice():l}function s(a,l,f){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a,f)}else return r(a,l,f)}function o(a,l){if(!u.isUndefined(l))return r(void 0,l)}function i(a,l){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function c(a,l,f){if(f in t)return r(a,l);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(a,l)=>s(ht(a),ht(l),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const f=d[l]||s,h=f(e[l],t[l],l);u.isUndefined(h)&&f!==c||(n[l]=h)}),n}const mt="1.2.1",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _t={};Re.transitional=function(t,n,r){function s(o,i){return"[Axios v"+mt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new y(s(i," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!_t[i]&&(_t[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Un(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new y("option "+o+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+o,y.ERR_BAD_OPTION)}}const Ae={assertOptions:Un,validators:Re},U=Ae.validators;class ae{constructor(t){this.defaults=t,this.interceptors={request:new ot,response:new ot}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=H(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Ae.assertOptions(r,{silentJSONParsing:U.transitional(U.boolean),forcedJSONParsing:U.transitional(U.boolean),clarifyTimeoutError:U.transitional(U.boolean)},!1),s!==void 0&&Ae.assertOptions(s,{encode:U.function,serialize:U.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&u.merge(o.common,o[n.method]),i&&u.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=F.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const a=[];this.interceptors.response.forEach(function(m){a.push(m.fulfilled,m.rejected)});let l,f=0,h;if(!d){const p=[pt.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,a),h=p.length,l=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new X(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Te(function(s){t=s}),cancel:t}}}const Bn=Te;function Ln(e){return function(n){return e.apply(null,n)}}function jn(e){return u.isObject(e)&&e.isAxiosError===!0}function yt(e){const t=new ue(e),n=qe(ue.prototype.request,t);return u.extend(n,ue.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yt(H(e,s))},n}const O=yt(Oe);O.Axios=ue,O.CanceledError=X,O.CancelToken=Bn,O.isCancel=lt,O.VERSION=mt,O.toFormData=ne,O.AxiosError=y,O.Cancel=O.CanceledError,O.all=function(t){return Promise.all(t)},O.spread=Ln,O.isAxiosError=jn,O.mergeConfig=H,O.AxiosHeaders=F,O.formToJSON=e=>at(u.isHTMLForm(e)?new FormData(e):e),O.default=O;const Hn=O,ar="";function Mn(e){let t,n,r,s,o,i=`${e[4]}%`;function c(f,h){return f[6]?zn:Jn}let d=c(e),a=d(e),l=e[7]&&Et();return{c(){t=T("div"),n=T("div"),a.c(),r=z(),l&&l.c(),s=z(),o=T("div"),w(n,"class","percentage-text svelte-1urn4xa"),w(o,"id","percentage-bar"),w(o,"class","svelte-1urn4xa"),Q(o,"width",i),w(t,"id","percentage"),w(t,"class","svelte-1urn4xa")},m(f,h){N(f,t,h),R(t,n),a.m(n,null),R(n,r),l&&l.m(n,null),R(t,s),R(t,o)},p(f,h){d===(d=c(f))&&a?a.p(f,h):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[7]?l||(l=Et(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),h&16&&i!==(i=`${f[4]}%`)&&Q(o,"width",i)},d(f){f&&A(t),a.d(),l&&l.d()}}}function In(e){let t;function n(o,i){return o[2]?vn:qn}let r=n(e),s=r(e);return{c(){s.c(),t=De()},m(o,i){s.m(o,i),N(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&A(t)}}}function zn(e){let t;return{c(){t=D("Waiting for data schema detection...")},m(n,r){N(n,t,r)},p:x,d(n){n&&A(t)}}}function Jn(e){let t,n=!e[7]&&bt(e);return{c(){n&&n.c(),t=De()},m(r,s){n&&n.m(r,s),N(r,t,s)},p(r,s){r[7]?n&&(n.d(1),n=null):n?n.p(r,s):(n=bt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&A(t)}}}function bt(e){let t,n;return{c(){t=D(e[4]),n=D("%")},m(r,s){N(r,t,s),N(r,n,s)},p(r,s){s&16&&St(t,r[4])},d(r){r&&A(t),r&&A(n)}}}function Et(e){let t;return{c(){t=D("File uploaded")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function qn(e){let t;return{c(){t=D("Select a file to upload")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function vn(e){let t;return{c(){t=D("Select a file to replace the current one")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function Vn(e){let t,n,r,s,o,i,c,d,a,l,f,h,_;function p(b,g){return!b[5]&&!b[6]&&!b[7]?In:Mn}let m=p(e),E=m(e);return{c(){t=T("div"),n=T("div"),r=T("div"),E.c(),s=z(),o=T("input"),i=z(),c=T("div"),d=T("label"),d.textContent="URL",a=z(),l=T("div"),f=T("input"),w(r,"id","widget-label"),w(r,"class","svelte-1urn4xa"),w(o,"id","fileUpload"),w(o,"type","file"),w(o,"class","svelte-1urn4xa"),w(n,"id","fileUploadWidget"),w(n,"class","svelte-1urn4xa"),w(d,"class","control-label"),w(d,"for","field_url"),w(f,"id","field_url"),w(f,"class","form-control"),w(f,"type","text"),w(f,"name","url"),w(l,"class","controls"),Q(c,"display",e[1]!="upload"?"inline":"none"),w(c,"class","controls"),w(t,"class","form-group")},m(b,g){N(b,t,g),R(t,n),R(n,r),E.m(r,null),R(n,s),R(n,o),R(t,i),R(t,c),R(c,d),R(c,a),R(c,l),R(l,f),Ue(f,e[0]),h||(_=[le(o,"change",e[12]),le(o,"change",e[8]),le(f,"input",e[13])],h=!0)},p(b,[g]){m===(m=p(b))&&E?E.p(b,g):(E.d(1),E=m(b),E&&(E.c(),E.m(r,null))),g&1&&f.value!==b[0]&&Ue(f,b[0]),g&2&&Q(c,"display",b[1]!="upload"?"inline":"none")},i:x,o:x,d(b){b&&A(t),E.d(),h=!1,I(_)}}}function Wn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:c}=t,{url_type:d=""}=t,a,l=0,f=!1,h=!1,_=!1,p=Be(),m=i?"update":"create";async function E(S,G){try{const P={onUploadProgress:xe=>{const{loaded:Zn,total:$n}=xe,Ce=Math.floor(Zn*100/$n);Ce<=100&&(G(Ce),Ce==100&&(n(5,f=!1),n(6,h=!0)))}},{data:ce}=await Hn.post(`${r}/api/3/action/resource_${m}`,S,P);return ce}catch(P){console.log("ERROR",P.message)}}function b(S){n(4,l=S)}async function g(S){try{const G=S.target.files[0],P=new FormData;P.append("upload",G),P.append("package_id",s),i&&(P.append("id",o),P.append("clear_upload",!0),P.append("url_type",d)),n(5,f=!0);let ce=await E(P,b),xe={data:ce};n(0,c=ce.result.url),n(1,d="upload"),p("fileUploaded",xe),n(6,h=!1),n(7,_=!0)}catch(G){console.log("ERROR",G),b(0)}}function M(){a=this.files,n(3,a)}function Ne(){c=this.value,n(0,c)}return e.$$set=S=>{"upload_url"in S&&n(9,r=S.upload_url),"dataset_id"in S&&n(10,s=S.dataset_id),"resource_id"in S&&n(11,o=S.resource_id),"update"in S&&n(2,i=S.update),"current_url"in S&&n(0,c=S.current_url),"url_type"in S&&n(1,d=S.url_type)},[c,d,i,a,l,f,h,_,g,r,s,o,M,Ne]}class Kn extends Je{constructor(t){super(),ze(this,t,Wn,Vn,Fe,{upload_url:9,dataset_id:10,resource_id:11,update:2,current_url:0,url_type:1})}}function Xn(e){let t,n,r;return n=new Kn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=T("main"),Pt(n.$$.fragment)},m(s,o){N(s,t,o),Me(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(He(n.$$.fragment,s),r=!0)},o(s){Ct(n.$$.fragment,s),r=!1},d(s){s&&A(t),Ie(n),e[8](null)}}}function Gn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:c}=t,{url_type:d}=t;Be();let a;function l(h){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:h.detail.data.result}))}function f(h){fe[h?"unshift":"push"](()=>{a=h,n(6,a)})}return e.$$set=h=>{"upload_url"in h&&n(0,r=h.upload_url),"dataset_id"in h&&n(1,s=h.dataset_id),"resource_id"in h&&n(2,o=h.resource_id),"update"in h&&n(3,i=h.update),"current_url"in h&&n(4,c=h.current_url),"url_type"in h&&n(5,d=h.url_type)},[r,s,o,i,c,d,a,l,f]}class Qn extends Je{constructor(t){super(),ze(this,t,Gn,Xn,Fe,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function Yn(e,t="",n="",r="",s="",o="",i=""){new Qn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return Yn}); diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js index d13d0ede..300671c8 100644 --- a/ckanext/validation/webassets/js/module-ckan-uploader.js +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -32,6 +32,10 @@ ckan.module('ckan-uploader', function (jQuery) { json_schema_field.value = JSON.stringify(resource.schema, null, 2) let json_button = document.getElementById('open-json-button') json_button.dispatchEvent(new Event('click')) + } else { + json_schema_field.value = '' + let json_clear_button = document.querySelector('[title=Clear]') + json_clear_button.dispatchEvent(new Event('click')) } // Set the form action to save the created resource From 4c61a0bb5a8a3d08fffa0b8b27482a72ddc0e1db Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Fri, 16 Dec 2022 10:44:53 +0100 Subject: [PATCH 15/43] remove check for content_length in uploaded resource schema file --- ckanext/validation/logic.py | 3 +++ ckanext/validation/plugin/__init__.py | 3 ++- ckanext/validation/webassets/js/module-ckan-uploader.js | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ckanext/validation/logic.py b/ckanext/validation/logic.py index 202651a3..5d12b9c9 100644 --- a/ckanext/validation/logic.py +++ b/ckanext/validation/logic.py @@ -843,6 +843,7 @@ def resource_update(up_func, context, data_dict): 'datastore_active' not in data_dict): data_dict['datastore_active'] = resource.extras['datastore_active'] + for plugin in plugins.PluginImplementations(plugins.IResourceController): plugin.before_update(context, pkg_dict['resources'][n], data_dict) @@ -858,6 +859,8 @@ def resource_update(up_func, context, data_dict): pkg_dict['resources'][n] = data_dict + + try: context['defer_commit'] = True context['use_cache'] = False diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index 3b486056..b9c3725d 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -145,9 +145,10 @@ def _process_schema_fields(self, data_dict): schema_upload = data_dict.pop(u'schema_upload', None) schema_url = data_dict.pop(u'schema_url', None) schema_json = data_dict.pop(u'schema_json', None) - if isinstance(schema_upload, ALLOWED_UPLOAD_TYPES) and schema_upload.content_length > 0: + if isinstance(schema_upload, ALLOWED_UPLOAD_TYPES): uploaded_file = _get_underlying_file(schema_upload) data_dict[u'schema'] = uploaded_file.read() + if isinstance(data_dict["schema"], (bytes, bytearray)): data_dict["schema"] = data_dict["schema"].decode() elif schema_url != '' and schema_url != None: diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js index 300671c8..636e4ff8 100644 --- a/ckanext/validation/webassets/js/module-ckan-uploader.js +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -29,6 +29,7 @@ ckan.module('ckan-uploader', function (jQuery) { // Set `schema` ckanext-validation field let json_schema_field = document.getElementById('field-schema-json') if ('schema' in resource) { + // If there is a schema, we open the JSON json_schema_field.value = JSON.stringify(resource.schema, null, 2) let json_button = document.getElementById('open-json-button') json_button.dispatchEvent(new Event('click')) From 6ece56394db04fd8dae7993e9cd71da963425b3e Mon Sep 17 00:00:00 2001 From: amercader Date: Fri, 16 Dec 2022 12:05:47 +0100 Subject: [PATCH 16/43] Remove unused actions --- ckanext/validation/logic.py | 203 -------------------------- ckanext/validation/plugin/__init__.py | 4 - 2 files changed, 207 deletions(-) diff --git a/ckanext/validation/logic.py b/ckanext/validation/logic.py index 5d12b9c9..22b06d1f 100644 --- a/ckanext/validation/logic.py +++ b/ckanext/validation/logic.py @@ -481,87 +481,6 @@ def _validation_dictize(validation): return out -def resource_create_with_schema(context, data_dict): - '''Appends a new resource to a datasets list of resources. - ''' - - model = context['model'] - - package_id = t.get_or_bust(data_dict, 'package_id') - if not data_dict.get('url'): - data_dict['url'] = '' - - pkg_dict = t.get_action('package_show')( - dict(context, return_type='dict'), - {'id': package_id}) - - t.check_access('resource_create', context, data_dict) - - for plugin in plugins.PluginImplementations(plugins.IResourceController): - plugin.before_create(context, data_dict) - - if 'resources' not in pkg_dict: - pkg_dict['resources'] = [] - - upload = uploader.get_resource_uploader(data_dict) - - - if 'mimetype' not in data_dict: - if hasattr(upload, 'mimetype'): - data_dict['mimetype'] = upload.mimetype - - if 'size' not in data_dict: - if hasattr(upload, 'filesize'): - data_dict['size'] = upload.filesize - - pkg_dict['resources'].append(data_dict) - - try: - context['defer_commit'] = True - context['use_cache'] = False - pkg_dict['state'] = 'active' - package = t.get_action('package_update')(context, pkg_dict) - context.pop('defer_commit') - except t.ValidationError as e: - try: - raise t.ValidationError(e.error_dict['resources'][-1]) - except (KeyError, IndexError): - raise t.ValidationError(e.error_dict) - - # Get out resource_id resource from model as it will not appear in - # package_show until after commit - resource_id = context['package'].resources[-1].id - upload.upload(resource_id, - uploader.get_max_resource_size()) - - model.repo.commit() - - if is_tabular(filename=upload.filename): - update_resource = t.get_action('resource_table_schema_infer')( - context, {'resource_id': resource_id, 'store_schema': True} - ) - - # Run package show again to get out actual last_resource - updated_pkg_dict = t.get_action('package_show')( - context, {'id': package_id}) - resource = updated_pkg_dict['resources'][-1] - - # Add the default views to the new resource - t.get_action('resource_create_default_resource_views')( - {'model': context['model'], - 'user': context['user'], - 'ignore_auth': True - }, - {'resource': resource, - 'package': updated_pkg_dict - }) - - for plugin in plugins.PluginImplementations(plugins.IResourceController): - plugin.after_create(context, resource) - - return resource - - @t.chained_action def resource_create(up_func, context, data_dict): @@ -673,128 +592,6 @@ def resource_create(up_func, context, data_dict): return resource -def resource_update_with_schema(context, data_dict): - '''Update a resource. - - This is duplicate of the CKAN core resource_update action, with just the - addition of a synchronous data validation step. - - This is of course not ideal but it's the only way right now to hook - reliably into the creation process without overcomplicating things. - Hopefully future versions of CKAN will incorporate more flexible hook - points that will allow a better approach. - - ''' - - model = context['model'] - id = t.get_or_bust(data_dict, "id") - - if not data_dict.get('url'): - data_dict['url'] = '' - - resource = model.Resource.get(id) - context["resource"] = resource - old_resource_format = resource.format - - if not resource: - log.debug('Could not find resource %s', id) - raise t.ObjectNotFound(t._('Resource was not found.')) - - t.check_access('resource_update', context, data_dict) - del context["resource"] - - package_id = resource.package.id - pkg_dict = t.get_action('package_show')(dict(context, return_type='dict'), - {'id': package_id}) - - for n, p in enumerate(pkg_dict['resources']): - if p['id'] == id: - break - else: - log.error('Could not find resource %s after all', id) - raise t.ObjectNotFound(t._('Resource was not found.')) - - # Persist the datastore_active extra if already present and not provided - if ('datastore_active' in resource.extras and - 'datastore_active' not in data_dict): - data_dict['datastore_active'] = resource.extras['datastore_active'] - - for plugin in plugins.PluginImplementations(plugins.IResourceController): - plugin.before_update(context, pkg_dict['resources'][n], data_dict) - - upload = uploader.get_resource_uploader(data_dict) - - if 'mimetype' not in data_dict: - if hasattr(upload, 'mimetype'): - data_dict['mimetype'] = upload.mimetype - - if 'size' not in data_dict and 'url_type' in data_dict: - if hasattr(upload, 'filesize'): - data_dict['size'] = upload.filesize - - pkg_dict['resources'][n] = data_dict - - try: - context['defer_commit'] = True - context['use_cache'] = False - updated_pkg_dict = t.get_action('package_update')(context, pkg_dict) - context.pop('defer_commit') - except t.ValidationError as e: - try: - raise t.ValidationError(e.error_dict['resources'][-1]) - except (KeyError, IndexError): - raise t.ValidationError(e.error_dict) - - upload.upload(id, uploader.get_max_resource_size()) - - if is_tabular(upload): - update_resource = t.get_action('resource_table_schema_infer')( - context, {'resource_id': resource.id, 'store_schema': True} - ) - - # Run package show again to get out actual last_resource - updated_pkg_dict = t.get_action('package_show')( - context, {'id': package_id}) - resource = updated_pkg_dict['resources'][-1] - - # Custom code starts - - run_validation = True - for plugin in plugins.PluginImplementations(IDataValidation): - if not plugin.can_validate(context, data_dict): - log.debug('Skipping validation for resource {}'.format(id)) - run_validation = False - - if run_validation: - run_validation = not data_dict.pop('_skip_next_validation', None) - - if run_validation: - is_local_upload = ( - hasattr(upload, 'filename') and - upload.filename is not None and - isinstance(upload, uploader.ResourceUpload)) - _run_sync_validation( - id, local_upload=is_local_upload, new_resource=False) - - # Custom code ends - - model.repo.commit() - - resource = t.get_action('resource_show')(context, {'id': id}) - - if old_resource_format != resource['format']: - t.get_action('resource_create_default_resource_views')( - {'model': context['model'], 'user': context['user'], - 'ignore_auth': True}, - {'package': updated_pkg_dict, - 'resource': resource}) - - for plugin in plugins.PluginImplementations(plugins.IResourceController): - plugin.after_update(context, resource) - - return resource - - @t.chained_action def resource_update(up_func, context, data_dict): diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index b9c3725d..5ea63d8b 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -19,8 +19,6 @@ resource_create as custom_resource_create, resource_update as custom_resource_update, resource_table_schema_infer, - resource_create_with_schema, - resource_update_with_schema, ) from ckanext.validation.helpers import ( get_validation_badge, @@ -95,8 +93,6 @@ def get_actions(self): u'resource_create': custom_resource_create, u'resource_update': custom_resource_update, u'resource_table_schema_infer': resource_table_schema_infer, - # u'resource_create_with_schema': resource_create_with_schema, - # u'resource_update_with_schema': resource_update_with_schema } return new_actions From 61ff6d49c5f382a7bc233c7f064a6af4198ae583 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Thu, 12 Jan 2023 13:21:04 +0100 Subject: [PATCH 17/43] Use helper to get package id from url --- ckanext/validation/blueprints.py | 58 ++++++++++++++++++- ckanext/validation/helpers.py | 10 +++- ckanext/validation/plugin/__init__.py | 14 +++-- .../scheming/form_snippets/ckan_uploader.html | 11 ++-- .../webassets/js/module-ckan-uploader.js | 4 +- 5 files changed, 80 insertions(+), 17 deletions(-) diff --git a/ckanext/validation/blueprints.py b/ckanext/validation/blueprints.py index 3ec0dc34..c4a52dfd 100644 --- a/ckanext/validation/blueprints.py +++ b/ckanext/validation/blueprints.py @@ -2,7 +2,19 @@ from flask import Blueprint -from ckantoolkit import c, NotAuthorized, ObjectNotFound, abort, _, render, get_action +from ckan.lib.navl.dictization_functions import unflatten +from ckan.logic import tuplize_dict, clean_dict, parse_params + +from ckantoolkit import ( + c, g, + NotAuthorized, + ObjectNotFound, + abort, + _, + render, + get_action, + request, +) validation = Blueprint("validation", __name__) @@ -40,6 +52,50 @@ def read(id, resource_id): abort(404, _(u"No validation report exists for this resource")) +def _get_data(): + data = clean_dict( + unflatten(tuplize_dict(parse_params(request.form))) + ) + data.update(clean_dict( + unflatten(tuplize_dict(parse_params(request.files))) + )) + + +def resource_file_create(id): + + # Get data from the request + data_dict = _get_data() + + # Call resource_create + # TODO: error handling + context = { + 'user': g.user, + } + data_dict["package_id"] = id + resource = get_action("resource_create")(context, data_dict) + + # If it's tabular (local OR remote), infer and store schema + if is_tabular(resource): + update_resource = t.get_action('resource_table_schema_infer')( + context, {'resource_id': resource_id, 'store_schema': True} + ) + + # Return resource + # TODO: set response format as JSON + return resource + + +def resource_file_update(id, resource_id): + # TODO: same as create, you can reuse as much code as needed + pass + + +validation.add_url_rule( + "/dataset//resource/file", view_func=resource_file_create, methods=["POST"] +) +validation.add_url_rule( + "/dataset//resource//file", view_func=resource_file_update, methods=["POST"] +) validation.add_url_rule( "/dataset//resource//validation", view_func=read diff --git a/ckanext/validation/helpers.py b/ckanext/validation/helpers.py index b6c856df..ea04e6d4 100644 --- a/ckanext/validation/helpers.py +++ b/ckanext/validation/helpers.py @@ -1,9 +1,9 @@ # encoding: utf-8 -import json - from ckan.lib.helpers import url_for_static -from ckantoolkit import url_for, _, config, asbool, literal, h +from ckantoolkit import url_for, _, config, asbool, literal, h, request +import json +import re def get_validation_badge(resource, in_listing=False): @@ -96,6 +96,10 @@ def bootstrap_version(): else: return '2' +def get_package_id_from_resource_url(): + match = re.match("/dataset/(.*)/resource/", request.path) + if match: + return model.Package.get(match.group(1)).id def use_webassets(): return int(h.ckan_version().split('.')[1]) >= 9 diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index 5ea63d8b..41e24d7a 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -27,6 +27,7 @@ bootstrap_version, validation_dict, use_webassets, + get_package_id_from_resource_url, ) from ckanext.validation.validators import ( resource_schema_validator, @@ -111,12 +112,13 @@ def get_auth_functions(self): def get_helpers(self): return { - u'get_validation_badge': get_validation_badge, - u'validation_extract_report_from_errors': validation_extract_report_from_errors, - u'dump_json_value': dump_json_value, - u'bootstrap_version': bootstrap_version, - u'validation_dict': validation_dict, - u'use_webassets': use_webassets, + 'get_validation_badge': get_validation_badge, + 'validation_extract_report_from_errors': validation_extract_report_from_errors, + 'dump_json_value': dump_json_value, + 'bootstrap_version': bootstrap_version, + 'validation_dict': validation_dict, + 'use_webassets': use_webassets, + 'get_package_id_from_resource_url': get_package_id_from_resource_url, } # IResourceController diff --git a/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html index b601c591..3fe3555f 100644 --- a/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html +++ b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html @@ -1,6 +1,7 @@ - -
- -
-
+{% set package_id = data.package_id or h.get_package_id_from_resource_url() %} + +
+ +
+
diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js index 636e4ff8..f5a4118e 100644 --- a/ckanext/validation/webassets/js/module-ckan-uploader.js +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -3,6 +3,7 @@ ckan.module('ckan-uploader', function (jQuery) { return { options: { + dataset_id: '', // The CKAN instance base URL upload_url: '', }, @@ -74,7 +75,6 @@ ckan.module('ckan-uploader', function (jQuery) { let lastIndexNew = new_action.lastIndexOf('new') // edit_action: the URL to update an already existing form let edit_action = new_action.slice(0, lastIndexNew) + `${resource_id}/edit` - console.log(new_action, edit_action) // Here we send the form using ajax and redirect the user again to // a new resource create form @@ -97,7 +97,7 @@ ckan.module('ckan-uploader', function (jQuery) { // Because we can't access some dataset/resource metadata from // the ckanext-schemming snippets, we need to add them somehow let resource_id = document.getElementById('resource_id').value - let dataset_id = document.getElementById('dataset_id').value + let dataset_id = this.options.dataset_id let current_url = document.getElementById('current_url').value let url_type = document.getElementById('url_type').value let update = document.getElementById('update').value From d744d2f8d46024062d58463a7304ef7b6e66975e Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Thu, 12 Jan 2023 13:25:22 +0100 Subject: [PATCH 18/43] Import ckan.model on helpers --- ckanext/validation/helpers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ckanext/validation/helpers.py b/ckanext/validation/helpers.py index ea04e6d4..8f7e5d85 100644 --- a/ckanext/validation/helpers.py +++ b/ckanext/validation/helpers.py @@ -1,5 +1,6 @@ # encoding: utf-8 from ckan.lib.helpers import url_for_static +from ckan import model from ckantoolkit import url_for, _, config, asbool, literal, h, request import json From 9c16f8fd12139ed769c1ab5048f2d215339e733a Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Thu, 12 Jan 2023 13:31:21 +0100 Subject: [PATCH 19/43] Fix blueprints missing imports --- ckanext/validation/blueprints.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ckanext/validation/blueprints.py b/ckanext/validation/blueprints.py index c4a52dfd..f6f0e8ca 100644 --- a/ckanext/validation/blueprints.py +++ b/ckanext/validation/blueprints.py @@ -4,6 +4,7 @@ from ckan.lib.navl.dictization_functions import unflatten from ckan.logic import tuplize_dict, clean_dict, parse_params +from ckanext.validation.logic import is_tabular from ckantoolkit import ( c, g, @@ -15,6 +16,7 @@ get_action, request, ) +import ckantoolkit as t validation = Blueprint("validation", __name__) @@ -76,8 +78,8 @@ def resource_file_create(id): # If it's tabular (local OR remote), infer and store schema if is_tabular(resource): - update_resource = t.get_action('resource_table_schema_infer')( - context, {'resource_id': resource_id, 'store_schema': True} + update_resource = get_action('resource_table_schema_infer')( + context, {'resource_id': resource.id, 'store_schema': True} ) # Return resource From fb8f7f7996f4b023eef0b5d8a670b2c9461da129 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Mon, 30 Jan 2023 11:53:33 +0100 Subject: [PATCH 20/43] add resource edit new endpoint --- ckanext/validation/blueprints.py | 26 ++++++++++++++----- ckanext/validation/helpers.py | 5 ++++ ckanext/validation/plugin/__init__.py | 2 ++ .../scheming/form_snippets/ckan_uploader.html | 4 ++- .../validation/webassets/js/ckan-uploader.js | 4 +-- .../webassets/js/module-ckan-uploader.js | 7 ++--- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/ckanext/validation/blueprints.py b/ckanext/validation/blueprints.py index f6f0e8ca..9e942980 100644 --- a/ckanext/validation/blueprints.py +++ b/ckanext/validation/blueprints.py @@ -56,10 +56,10 @@ def read(id, resource_id): def _get_data(): data = clean_dict( - unflatten(tuplize_dict(parse_params(request.form))) + unflatten(tuplize_dict(parse_params(request.form))) ) data.update(clean_dict( - unflatten(tuplize_dict(parse_params(request.files))) + unflatten(tuplize_dict(parse_params(request.files))) )) @@ -69,7 +69,6 @@ def resource_file_create(id): data_dict = _get_data() # Call resource_create - # TODO: error handling context = { 'user': g.user, } @@ -83,13 +82,28 @@ def resource_file_create(id): ) # Return resource - # TODO: set response format as JSON return resource def resource_file_update(id, resource_id): - # TODO: same as create, you can reuse as much code as needed - pass + # Get data from the request + data_dict = _get_data() + + # Call resource_create + context = { + 'user': g.user, + } + data_dict["package_id"] = id + resource = get_action("resource_update")(context, data_dict) + + # If it's tabular (local OR remote), infer and store schema + if is_tabular(resource): + update_resource = get_action('resource_table_schema_infer')( + context, {'resource_id': resource.id, 'store_schema': True} + ) + + # Return resource + return resource validation.add_url_rule( diff --git a/ckanext/validation/helpers.py b/ckanext/validation/helpers.py index 8f7e5d85..33eeb30e 100644 --- a/ckanext/validation/helpers.py +++ b/ckanext/validation/helpers.py @@ -102,5 +102,10 @@ def get_package_id_from_resource_url(): if match: return model.Package.get(match.group(1)).id +def get_resource_id_from_resource_url(): + match = re.match("/dataset/(.*)/resource/(.*)/edit", request.path) + if match: + return model.Resource.get(match.group(2)).id + def use_webassets(): return int(h.ckan_version().split('.')[1]) >= 9 diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index 41e24d7a..f958446e 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -28,6 +28,7 @@ validation_dict, use_webassets, get_package_id_from_resource_url, + get_resource_id_from_resource_url, ) from ckanext.validation.validators import ( resource_schema_validator, @@ -119,6 +120,7 @@ def get_helpers(self): 'validation_dict': validation_dict, 'use_webassets': use_webassets, 'get_package_id_from_resource_url': get_package_id_from_resource_url, + 'get_resource_id_from_resource_url': get_resource_id_from_resource_url, } # IResourceController diff --git a/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html index 3fe3555f..dbdbeeff 100644 --- a/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html +++ b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html @@ -1,7 +1,9 @@ {% set package_id = data.package_id or h.get_package_id_from_resource_url() %} +{% set resource_id = data.resource_id or h.get_resource_id_from_resource_url() %} +
-
+
diff --git a/ckanext/validation/webassets/js/ckan-uploader.js b/ckanext/validation/webassets/js/ckan-uploader.js index ca6063f6..721c1050 100644 --- a/ckanext/validation/webassets/js/ckan-uploader.js +++ b/ckanext/validation/webassets/js/ckan-uploader.js @@ -1,3 +1,3 @@ -(function(x,L){typeof exports=="object"&&typeof module<"u"?module.exports=L():typeof define=="function"&&define.amd?define(L):(x=typeof globalThis<"u"?globalThis:x||self,x.CkanUploader=L())})(this,function(){"use strict";function x(){}function L(e){return e()}function Pe(){return Object.create(null)}function I(e){e.forEach(L)}function ke(e){return typeof e=="function"}function Fe(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function wt(e){return Object.keys(e).length===0}function R(e,t){e.appendChild(t)}function N(e,t,n){e.insertBefore(t,n||null)}function A(e){e.parentNode&&e.parentNode.removeChild(e)}function T(e){return document.createElement(e)}function D(e){return document.createTextNode(e)}function z(){return D(" ")}function De(){return D("")}function le(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function w(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Ot(e){return Array.from(e.childNodes)}function St(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Ue(e,t){e.value=t==null?"":t}function Q(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function gt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Rt(){if(!J)throw new Error("Function called outside component initialization");return J}function Be(){const e=Rt();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=gt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const v=[],fe=[],Y=[],Le=[],At=Promise.resolve();let de=!1;function Tt(){de||(de=!0,At.then(je))}function pe(e){Y.push(e)}const he=new Set;let Z=0;function je(){const e=J;do{for(;Z{$.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Pt(e){e&&e.c()}function Me(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||pe(()=>{const i=e.$$.on_mount.map(L).filter(ke);e.$$.on_destroy?e.$$.on_destroy.push(...i):I(i),e.$$.on_mount=[]}),o.forEach(pe)}function Ie(e,t){const n=e.$$;n.fragment!==null&&(I(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function kt(e,t){e.$$.dirty[0]===-1&&(v.push(e),Tt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=_.length?_[0]:h;return a.ctx&&s(a.ctx[f],a.ctx[f]=p)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](p),l&&kt(e,f)),h}):[],a.update(),l=!0,I(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Ot(t.target);a.fragment&&a.fragment.l(f),f.forEach(A)}else a.fragment&&a.fragment.c();t.intro&&He(e.$$.fragment),Me(e,t.target,t.anchor,t.customElement),je()}q(d)}class Je{$destroy(){Ie(this,1),this.$destroy=x}$on(t,n){if(!ke(n))return x;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!wt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function qe(e,t){return function(){return e.apply(t,arguments)}}const{toString:ve}=Object.prototype,{getPrototypeOf:me}=Object,_e=(e=>t=>{const n=ve.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),k=e=>(e=e.toLowerCase(),t=>_e(t)===e),ee=e=>t=>typeof t===e,{isArray:j}=Array,V=ee("undefined");function Ft(e){return e!==null&&!V(e)&&e.constructor!==null&&!V(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ve=k("ArrayBuffer");function Dt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ve(e.buffer),t}const Ut=ee("string"),B=ee("function"),We=ee("number"),ye=e=>e!==null&&typeof e=="object",Bt=e=>e===!0||e===!1,te=e=>{if(_e(e)!=="object")return!1;const t=me(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Lt=k("Date"),jt=k("File"),Ht=k("Blob"),Mt=k("FileList"),It=e=>ye(e)&&B(e.pipe),zt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||ve.call(e)===t||B(e.toString)&&e.toString()===t)},Jt=k("URLSearchParams"),qt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function W(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),j(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Xe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ge=e=>!V(e)&&e!==Xe;function be(){const{caseless:e}=Ge(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ke(t,s)||s;te(t[o])&&te(r)?t[o]=be(t[o],r):te(r)?t[o]=be({},r):j(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(W(t,(s,o)=>{n&&B(s)?e[o]=qe(s,n):e[o]=s},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Wt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Kt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&me(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Xt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Gt=e=>{if(!e)return null;if(j(e))return e;let t=e.length;if(!We(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Qt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&me(Uint8Array)),Yt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},Zt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},$t=k("HTMLFormElement"),en=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Qe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),tn=k("RegExp"),Ye=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};W(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},u={isArray:j,isArrayBuffer:Ve,isBuffer:Ft,isFormData:zt,isArrayBufferView:Dt,isString:Ut,isNumber:We,isBoolean:Bt,isObject:ye,isPlainObject:te,isUndefined:V,isDate:Lt,isFile:jt,isBlob:Ht,isRegExp:tn,isFunction:B,isStream:It,isURLSearchParams:Jt,isTypedArray:Qt,isFileList:Mt,forEach:W,merge:be,extend:vt,trim:qt,stripBOM:Vt,inherits:Wt,toFlatObject:Kt,kindOf:_e,kindOfTest:k,endsWith:Xt,toArray:Gt,forEachEntry:Yt,matchAll:Zt,isHTMLForm:$t,hasOwnProperty:Qe,hasOwnProp:Qe,reduceDescriptors:Ye,freezeMethods:e=>{Ye(e,(t,n)=>{if(B(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!B(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return j(e)?r(e):r(String(e).split(t)),n},toCamelCase:en,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ke,global:Xe,isContextDefined:Ge,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(ye(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=j(r)?[]:{};return W(r,(i,c)=>{const d=n(i,s+1);!V(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function y(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}u.inherits(y,Error,{toJSON:function(){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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ze=y.prototype,$e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{$e[e]={value:e}}),Object.defineProperties(y,$e),Object.defineProperty(Ze,"isAxiosError",{value:!0}),y.from=(e,t,n,r,s,o)=>{const i=Object.create(Ze);return u.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),y.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var nn=typeof self=="object"?self.FormData:window.FormData;const rn=nn;function Ee(e){return u.isPlainObject(e)||u.isArray(e)}function et(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,n){return e?e.concat(t).map(function(s,o){return s=et(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function sn(e){return u.isArray(e)&&!e.some(Ee)}const on=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function an(e){return e&&u.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function ne(e,t,n){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new(rn||FormData),n=u.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,E){return!u.isUndefined(E[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&an(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(u.isDate(p))return p.toISOString();if(!d&&u.isBlob(p))throw new y("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(p)||u.isTypedArray(p)?d&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function l(p,m,E){let b=p;if(p&&!E&&typeof p=="object"){if(u.endsWith(m,"{}"))m=r?m:m.slice(0,-2),p=JSON.stringify(p);else if(u.isArray(p)&&sn(p)||u.isFileList(p)||u.endsWith(m,"[]")&&(b=u.toArray(p)))return m=et(m),b.forEach(function(M,Ne){!(u.isUndefined(M)||M===null)&&t.append(i===!0?tt([m],Ne,o):i===null?m:m+"[]",a(M))}),!1}return Ee(p)?!0:(t.append(tt(E,m,o),a(p)),!1)}const f=[],h=Object.assign(on,{defaultVisitor:l,convertValue:a,isVisitable:Ee});function _(p,m){if(!u.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(p),u.forEach(p,function(b,g){(!(u.isUndefined(b)||b===null)&&s.call(t,b,u.isString(g)?g.trim():g,m,h))===!0&&_(b,m?m.concat(g):[g])}),f.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return _(e),t}function nt(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function we(e,t){this._pairs=[],e&&ne(e,this,t)}const rt=we.prototype;rt.append=function(t,n){this._pairs.push([t,n])},rt.toString=function(t){const n=t?function(r){return t.call(this,r,nt)}:nt;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function un(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function st(e,t,n){if(!t)return e;const r=n&&n.encode||un,s=n&&n.serialize;let o;if(s?o=s(t,n):o=u.isURLSearchParams(t)?t.toString():new we(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class cn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){u.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ot=cn,it={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ln=typeof URLSearchParams<"u"?URLSearchParams:we,fn=FormData,dn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),pn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),C={isBrowser:!0,classes:{URLSearchParams:ln,FormData:fn,Blob},isStandardBrowserEnv:dn,isStandardBrowserWebWorkerEnv:pn,protocols:["http","https","file","blob","url","data"]};function hn(e,t){return ne(e,new C.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return C.isNode&&u.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function mn(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function _n(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&u.isArray(s)?s.length:i,d?(u.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!u.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&u.isArray(s[i])&&(s[i]=_n(s[i])),!c)}if(u.isFormData(e)&&u.isFunction(e.entries)){const n={};return u.forEachEntry(e,(r,s)=>{t(mn(r),s,n,0)}),n}return null}const yn={"Content-Type":void 0};function bn(e,t,n){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const re={transitional:it,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=u.isObject(t);if(o&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(at(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return hn(t,this.formSerializer).toString();if((c=u.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return ne(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),bn(t)):t}],transformResponse:[function(t){const n=this.transitional||re.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&u.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};u.forEach(["delete","get","head"],function(t){re.headers[t]={}}),u.forEach(["post","put","patch"],function(t){re.headers[t]=u.merge(yn)});const Oe=re,En=u.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"]),wn=e=>{const t={};let n,r,s;return e&&e.split(` +(function(x,L){typeof exports=="object"&&typeof module<"u"?module.exports=L():typeof define=="function"&&define.amd?define(L):(x=typeof globalThis<"u"?globalThis:x||self,x.CkanUploader=L())})(this,function(){"use strict";function x(){}function L(e){return e()}function Pe(){return Object.create(null)}function I(e){e.forEach(L)}function ke(e){return typeof e=="function"}function Fe(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function wt(e){return Object.keys(e).length===0}function R(e,t){e.appendChild(t)}function N(e,t,n){e.insertBefore(t,n||null)}function A(e){e.parentNode&&e.parentNode.removeChild(e)}function T(e){return document.createElement(e)}function D(e){return document.createTextNode(e)}function z(){return D(" ")}function De(){return D("")}function ce(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function w(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Ot(e){return Array.from(e.childNodes)}function St(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Ue(e,t){e.value=t==null?"":t}function Q(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function gt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Rt(){if(!J)throw new Error("Function called outside component initialization");return J}function Be(){const e=Rt();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=gt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const v=[],le=[],Y=[],Le=[],At=Promise.resolve();let fe=!1;function Tt(){fe||(fe=!0,At.then(je))}function de(e){Y.push(e)}const pe=new Set;let Z=0;function je(){const e=J;do{for(;Z{$.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Pt(e){e&&e.c()}function Me(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||de(()=>{const i=e.$$.on_mount.map(L).filter(ke);e.$$.on_destroy?e.$$.on_destroy.push(...i):I(i),e.$$.on_mount=[]}),o.forEach(de)}function Ie(e,t){const n=e.$$;n.fragment!==null&&(I(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function kt(e,t){e.$$.dirty[0]===-1&&(v.push(e),Tt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=_.length?_[0]:h;return a.ctx&&s(a.ctx[f],a.ctx[f]=p)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](p),l&&kt(e,f)),h}):[],a.update(),l=!0,I(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Ot(t.target);a.fragment&&a.fragment.l(f),f.forEach(A)}else a.fragment&&a.fragment.c();t.intro&&He(e.$$.fragment),Me(e,t.target,t.anchor,t.customElement),je()}q(d)}class Je{$destroy(){Ie(this,1),this.$destroy=x}$on(t,n){if(!ke(n))return x;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!wt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function qe(e,t){return function(){return e.apply(t,arguments)}}const{toString:ve}=Object.prototype,{getPrototypeOf:he}=Object,me=(e=>t=>{const n=ve.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),k=e=>(e=e.toLowerCase(),t=>me(t)===e),ee=e=>t=>typeof t===e,{isArray:j}=Array,V=ee("undefined");function Ft(e){return e!==null&&!V(e)&&e.constructor!==null&&!V(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ve=k("ArrayBuffer");function Dt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ve(e.buffer),t}const Ut=ee("string"),B=ee("function"),We=ee("number"),_e=e=>e!==null&&typeof e=="object",Bt=e=>e===!0||e===!1,te=e=>{if(me(e)!=="object")return!1;const t=he(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Lt=k("Date"),jt=k("File"),Ht=k("Blob"),Mt=k("FileList"),It=e=>_e(e)&&B(e.pipe),zt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||ve.call(e)===t||B(e.toString)&&e.toString()===t)},Jt=k("URLSearchParams"),qt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function W(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),j(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Xe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ge=e=>!V(e)&&e!==Xe;function ye(){const{caseless:e}=Ge(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ke(t,s)||s;te(t[o])&&te(r)?t[o]=ye(t[o],r):te(r)?t[o]=ye({},r):j(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(W(t,(s,o)=>{n&&B(s)?e[o]=qe(s,n):e[o]=s},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Wt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Kt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&he(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Xt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Gt=e=>{if(!e)return null;if(j(e))return e;let t=e.length;if(!We(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Qt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&he(Uint8Array)),Yt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},Zt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},$t=k("HTMLFormElement"),en=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Qe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),tn=k("RegExp"),Ye=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};W(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},u={isArray:j,isArrayBuffer:Ve,isBuffer:Ft,isFormData:zt,isArrayBufferView:Dt,isString:Ut,isNumber:We,isBoolean:Bt,isObject:_e,isPlainObject:te,isUndefined:V,isDate:Lt,isFile:jt,isBlob:Ht,isRegExp:tn,isFunction:B,isStream:It,isURLSearchParams:Jt,isTypedArray:Qt,isFileList:Mt,forEach:W,merge:ye,extend:vt,trim:qt,stripBOM:Vt,inherits:Wt,toFlatObject:Kt,kindOf:me,kindOfTest:k,endsWith:Xt,toArray:Gt,forEachEntry:Yt,matchAll:Zt,isHTMLForm:$t,hasOwnProperty:Qe,hasOwnProp:Qe,reduceDescriptors:Ye,freezeMethods:e=>{Ye(e,(t,n)=>{if(B(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!B(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return j(e)?r(e):r(String(e).split(t)),n},toCamelCase:en,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ke,global:Xe,isContextDefined:Ge,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(_e(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=j(r)?[]:{};return W(r,(i,c)=>{const d=n(i,s+1);!V(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function y(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}u.inherits(y,Error,{toJSON:function(){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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ze=y.prototype,$e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{$e[e]={value:e}}),Object.defineProperties(y,$e),Object.defineProperty(Ze,"isAxiosError",{value:!0}),y.from=(e,t,n,r,s,o)=>{const i=Object.create(Ze);return u.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),y.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var nn=typeof self=="object"?self.FormData:window.FormData;const rn=nn;function be(e){return u.isPlainObject(e)||u.isArray(e)}function et(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,n){return e?e.concat(t).map(function(s,o){return s=et(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function sn(e){return u.isArray(e)&&!e.some(be)}const on=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function an(e){return e&&u.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function ne(e,t,n){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new(rn||FormData),n=u.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,E){return!u.isUndefined(E[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&an(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(u.isDate(p))return p.toISOString();if(!d&&u.isBlob(p))throw new y("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(p)||u.isTypedArray(p)?d&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function l(p,m,E){let b=p;if(p&&!E&&typeof p=="object"){if(u.endsWith(m,"{}"))m=r?m:m.slice(0,-2),p=JSON.stringify(p);else if(u.isArray(p)&&sn(p)||u.isFileList(p)||u.endsWith(m,"[]")&&(b=u.toArray(p)))return m=et(m),b.forEach(function(M,Te){!(u.isUndefined(M)||M===null)&&t.append(i===!0?tt([m],Te,o):i===null?m:m+"[]",a(M))}),!1}return be(p)?!0:(t.append(tt(E,m,o),a(p)),!1)}const f=[],h=Object.assign(on,{defaultVisitor:l,convertValue:a,isVisitable:be});function _(p,m){if(!u.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(p),u.forEach(p,function(b,g){(!(u.isUndefined(b)||b===null)&&s.call(t,b,u.isString(g)?g.trim():g,m,h))===!0&&_(b,m?m.concat(g):[g])}),f.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return _(e),t}function nt(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ee(e,t){this._pairs=[],e&&ne(e,this,t)}const rt=Ee.prototype;rt.append=function(t,n){this._pairs.push([t,n])},rt.toString=function(t){const n=t?function(r){return t.call(this,r,nt)}:nt;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function un(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function st(e,t,n){if(!t)return e;const r=n&&n.encode||un,s=n&&n.serialize;let o;if(s?o=s(t,n):o=u.isURLSearchParams(t)?t.toString():new Ee(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class cn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){u.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ot=cn,it={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ln=typeof URLSearchParams<"u"?URLSearchParams:Ee,fn=FormData,dn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),pn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),C={isBrowser:!0,classes:{URLSearchParams:ln,FormData:fn,Blob},isStandardBrowserEnv:dn,isStandardBrowserWebWorkerEnv:pn,protocols:["http","https","file","blob","url","data"]};function hn(e,t){return ne(e,new C.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return C.isNode&&u.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function mn(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function _n(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&u.isArray(s)?s.length:i,d?(u.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!u.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&u.isArray(s[i])&&(s[i]=_n(s[i])),!c)}if(u.isFormData(e)&&u.isFunction(e.entries)){const n={};return u.forEachEntry(e,(r,s)=>{t(mn(r),s,n,0)}),n}return null}const yn={"Content-Type":void 0};function bn(e,t,n){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const re={transitional:it,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=u.isObject(t);if(o&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(at(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return hn(t,this.formSerializer).toString();if((c=u.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return ne(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),bn(t)):t}],transformResponse:[function(t){const n=this.transitional||re.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&u.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};u.forEach(["delete","get","head"],function(t){re.headers[t]={}}),u.forEach(["post","put","patch"],function(t){re.headers[t]=u.merge(yn)});const we=re,En=u.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"]),wn=e=>{const t={};let n,r,s;return e&&e.split(` `).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&En[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ut=Symbol("internals");function K(e){return e&&String(e).trim().toLowerCase()}function se(e){return e===!1||e==null?e:u.isArray(e)?e.map(se):String(e)}function On(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}function Sn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ct(e,t,n,r){if(u.isFunction(r))return r.call(this,t,n);if(!!u.isString(t)){if(u.isString(r))return t.indexOf(r)!==-1;if(u.isRegExp(r))return r.test(t)}}function gn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Rn(e,t){const n=u.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class oe{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,a){const l=K(d);if(!l)throw new Error("header name must be a non-empty string");const f=u.findKey(s,l);(!f||s[f]===void 0||a===!0||a===void 0&&s[f]!==!1)&&(s[f||d]=se(c))}const i=(c,d)=>u.forEach(c,(a,l)=>o(a,l,d));return u.isPlainObject(t)||t instanceof this.constructor?i(t,n):u.isString(t)&&(t=t.trim())&&!Sn(t)?i(wn(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=K(t),t){const r=u.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return On(s);if(u.isFunction(n))return n.call(this,s,r);if(u.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=K(t),t){const r=u.findKey(this,t);return!!(r&&(!n||ct(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=K(i),i){const c=u.findKey(r,i);c&&(!n||ct(r,r[c],c,n))&&(delete r[c],s=!0)}}return u.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return u.forEach(this,(s,o)=>{const i=u.findKey(r,o);if(i){n[i]=se(s),delete n[o];return}const c=t?gn(o):String(o).trim();c!==o&&delete n[o],n[c]=se(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return u.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&u.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ut]=this[ut]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=K(i);r[c]||(Rn(s,i),r[c]=!0)}return u.isArray(t)?t.forEach(o):o(t),this}}oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(oe.prototype),u.freezeMethods(oe);const F=oe;function Se(e,t){const n=this||Oe,r=t||n,s=F.from(r.headers);let o=r.data;return u.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function lt(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){y.call(this,e==null?"canceled":e,y.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(X,y,{__CANCEL__:!0});const An=null;function Tn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Nn=C.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const d=[];d.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),u.isString(o)&&d.push("path="+o),u.isString(i)&&d.push("domain="+i),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function xn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Cn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function ft(e,t){return e&&!xn(t)?Cn(e,t):t}const Pn=C.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=u.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function kn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Fn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),l=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,h=0;for(;f!==s;)h+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,d=r(c),a=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const ie={http:An,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=F.from(e.headers).normalize(),i=e.responseType;let c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(C.isStandardBrowserEnv||C.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const _=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(_+":"+p))}const l=ft(e.baseURL,e.url);a.open(e.method.toUpperCase(),st(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const _=F.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),m={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:_,config:e,request:a};Tn(function(b){n(b),d()},function(b){r(b),d()},m),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new y("Request aborted",y.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new y("Network Error",y.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const m=e.transitional||it;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new y(p,m.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,a)),a=null},C.isStandardBrowserEnv){const _=(e.withCredentials||Pn(l))&&e.xsrfCookieName&&Nn.read(e.xsrfCookieName);_&&o.set(e.xsrfHeaderName,_)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&u.forEach(o.toJSON(),function(p,m){a.setRequestHeader(m,p)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",dt(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",dt(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=_=>{!a||(r(!_||_.type?new X(null,e,a):_),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const h=kn(l);if(h&&C.protocols.indexOf(h)===-1){r(new y("Unsupported protocol "+h+":",y.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(ie,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Dn={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof F?e.toJSON():e;function H(e,t){t=t||{};const n={};function r(a,l,f){return u.isPlainObject(a)&&u.isPlainObject(l)?u.merge.call({caseless:f},a,l):u.isPlainObject(l)?u.merge({},l):u.isArray(l)?l.slice():l}function s(a,l,f){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a,f)}else return r(a,l,f)}function o(a,l){if(!u.isUndefined(l))return r(void 0,l)}function i(a,l){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function c(a,l,f){if(f in t)return r(a,l);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(a,l)=>s(ht(a),ht(l),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const f=d[l]||s,h=f(e[l],t[l],l);u.isUndefined(h)&&f!==c||(n[l]=h)}),n}const mt="1.2.1",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _t={};Re.transitional=function(t,n,r){function s(o,i){return"[Axios v"+mt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new y(s(i," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!_t[i]&&(_t[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Un(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new y("option "+o+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+o,y.ERR_BAD_OPTION)}}const Ae={assertOptions:Un,validators:Re},U=Ae.validators;class ae{constructor(t){this.defaults=t,this.interceptors={request:new ot,response:new ot}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=H(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Ae.assertOptions(r,{silentJSONParsing:U.transitional(U.boolean),forcedJSONParsing:U.transitional(U.boolean),clarifyTimeoutError:U.transitional(U.boolean)},!1),s!==void 0&&Ae.assertOptions(s,{encode:U.function,serialize:U.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&u.merge(o.common,o[n.method]),i&&u.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=F.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const a=[];this.interceptors.response.forEach(function(m){a.push(m.fulfilled,m.rejected)});let l,f=0,h;if(!d){const p=[pt.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,a),h=p.length,l=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new X(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Te(function(s){t=s}),cancel:t}}}const Bn=Te;function Ln(e){return function(n){return e.apply(null,n)}}function jn(e){return u.isObject(e)&&e.isAxiosError===!0}function yt(e){const t=new ue(e),n=qe(ue.prototype.request,t);return u.extend(n,ue.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yt(H(e,s))},n}const O=yt(Oe);O.Axios=ue,O.CanceledError=X,O.CancelToken=Bn,O.isCancel=lt,O.VERSION=mt,O.toFormData=ne,O.AxiosError=y,O.Cancel=O.CanceledError,O.all=function(t){return Promise.all(t)},O.spread=Ln,O.isAxiosError=jn,O.mergeConfig=H,O.AxiosHeaders=F,O.formToJSON=e=>at(u.isHTMLForm(e)?new FormData(e):e),O.default=O;const Hn=O,ar="";function Mn(e){let t,n,r,s,o,i=`${e[4]}%`;function c(f,h){return f[6]?zn:Jn}let d=c(e),a=d(e),l=e[7]&&Et();return{c(){t=T("div"),n=T("div"),a.c(),r=z(),l&&l.c(),s=z(),o=T("div"),w(n,"class","percentage-text svelte-1urn4xa"),w(o,"id","percentage-bar"),w(o,"class","svelte-1urn4xa"),Q(o,"width",i),w(t,"id","percentage"),w(t,"class","svelte-1urn4xa")},m(f,h){N(f,t,h),R(t,n),a.m(n,null),R(n,r),l&&l.m(n,null),R(t,s),R(t,o)},p(f,h){d===(d=c(f))&&a?a.p(f,h):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[7]?l||(l=Et(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),h&16&&i!==(i=`${f[4]}%`)&&Q(o,"width",i)},d(f){f&&A(t),a.d(),l&&l.d()}}}function In(e){let t;function n(o,i){return o[2]?vn:qn}let r=n(e),s=r(e);return{c(){s.c(),t=De()},m(o,i){s.m(o,i),N(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&A(t)}}}function zn(e){let t;return{c(){t=D("Waiting for data schema detection...")},m(n,r){N(n,t,r)},p:x,d(n){n&&A(t)}}}function Jn(e){let t,n=!e[7]&&bt(e);return{c(){n&&n.c(),t=De()},m(r,s){n&&n.m(r,s),N(r,t,s)},p(r,s){r[7]?n&&(n.d(1),n=null):n?n.p(r,s):(n=bt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&A(t)}}}function bt(e){let t,n;return{c(){t=D(e[4]),n=D("%")},m(r,s){N(r,t,s),N(r,n,s)},p(r,s){s&16&&St(t,r[4])},d(r){r&&A(t),r&&A(n)}}}function Et(e){let t;return{c(){t=D("File uploaded")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function qn(e){let t;return{c(){t=D("Select a file to upload")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function vn(e){let t;return{c(){t=D("Select a file to replace the current one")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function Vn(e){let t,n,r,s,o,i,c,d,a,l,f,h,_;function p(b,g){return!b[5]&&!b[6]&&!b[7]?In:Mn}let m=p(e),E=m(e);return{c(){t=T("div"),n=T("div"),r=T("div"),E.c(),s=z(),o=T("input"),i=z(),c=T("div"),d=T("label"),d.textContent="URL",a=z(),l=T("div"),f=T("input"),w(r,"id","widget-label"),w(r,"class","svelte-1urn4xa"),w(o,"id","fileUpload"),w(o,"type","file"),w(o,"class","svelte-1urn4xa"),w(n,"id","fileUploadWidget"),w(n,"class","svelte-1urn4xa"),w(d,"class","control-label"),w(d,"for","field_url"),w(f,"id","field_url"),w(f,"class","form-control"),w(f,"type","text"),w(f,"name","url"),w(l,"class","controls"),Q(c,"display",e[1]!="upload"?"inline":"none"),w(c,"class","controls"),w(t,"class","form-group")},m(b,g){N(b,t,g),R(t,n),R(n,r),E.m(r,null),R(n,s),R(n,o),R(t,i),R(t,c),R(c,d),R(c,a),R(c,l),R(l,f),Ue(f,e[0]),h||(_=[le(o,"change",e[12]),le(o,"change",e[8]),le(f,"input",e[13])],h=!0)},p(b,[g]){m===(m=p(b))&&E?E.p(b,g):(E.d(1),E=m(b),E&&(E.c(),E.m(r,null))),g&1&&f.value!==b[0]&&Ue(f,b[0]),g&2&&Q(c,"display",b[1]!="upload"?"inline":"none")},i:x,o:x,d(b){b&&A(t),E.d(),h=!1,I(_)}}}function Wn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:c}=t,{url_type:d=""}=t,a,l=0,f=!1,h=!1,_=!1,p=Be(),m=i?"update":"create";async function E(S,G){try{const P={onUploadProgress:xe=>{const{loaded:Zn,total:$n}=xe,Ce=Math.floor(Zn*100/$n);Ce<=100&&(G(Ce),Ce==100&&(n(5,f=!1),n(6,h=!0)))}},{data:ce}=await Hn.post(`${r}/api/3/action/resource_${m}`,S,P);return ce}catch(P){console.log("ERROR",P.message)}}function b(S){n(4,l=S)}async function g(S){try{const G=S.target.files[0],P=new FormData;P.append("upload",G),P.append("package_id",s),i&&(P.append("id",o),P.append("clear_upload",!0),P.append("url_type",d)),n(5,f=!0);let ce=await E(P,b),xe={data:ce};n(0,c=ce.result.url),n(1,d="upload"),p("fileUploaded",xe),n(6,h=!1),n(7,_=!0)}catch(G){console.log("ERROR",G),b(0)}}function M(){a=this.files,n(3,a)}function Ne(){c=this.value,n(0,c)}return e.$$set=S=>{"upload_url"in S&&n(9,r=S.upload_url),"dataset_id"in S&&n(10,s=S.dataset_id),"resource_id"in S&&n(11,o=S.resource_id),"update"in S&&n(2,i=S.update),"current_url"in S&&n(0,c=S.current_url),"url_type"in S&&n(1,d=S.url_type)},[c,d,i,a,l,f,h,_,g,r,s,o,M,Ne]}class Kn extends Je{constructor(t){super(),ze(this,t,Wn,Vn,Fe,{upload_url:9,dataset_id:10,resource_id:11,update:2,current_url:0,url_type:1})}}function Xn(e){let t,n,r;return n=new Kn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=T("main"),Pt(n.$$.fragment)},m(s,o){N(s,t,o),Me(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(He(n.$$.fragment,s),r=!0)},o(s){Ct(n.$$.fragment,s),r=!1},d(s){s&&A(t),Ie(n),e[8](null)}}}function Gn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:c}=t,{url_type:d}=t;Be();let a;function l(h){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:h.detail.data.result}))}function f(h){fe[h?"unshift":"push"](()=>{a=h,n(6,a)})}return e.$$set=h=>{"upload_url"in h&&n(0,r=h.upload_url),"dataset_id"in h&&n(1,s=h.dataset_id),"resource_id"in h&&n(2,o=h.resource_id),"update"in h&&n(3,i=h.update),"current_url"in h&&n(4,c=h.current_url),"url_type"in h&&n(5,d=h.url_type)},[r,s,o,i,c,d,a,l,f]}class Qn extends Je{constructor(t){super(),ze(this,t,Gn,Xn,Fe,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function Yn(e,t="",n="",r="",s="",o="",i=""){new Qn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return Yn}); +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ut]=this[ut]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=K(i);r[c]||(Rn(s,i),r[c]=!0)}return u.isArray(t)?t.forEach(o):o(t),this}}oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(oe.prototype),u.freezeMethods(oe);const F=oe;function Oe(e,t){const n=this||we,r=t||n,s=F.from(r.headers);let o=r.data;return u.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function lt(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){y.call(this,e==null?"canceled":e,y.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(X,y,{__CANCEL__:!0});const An=null;function Tn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Nn=C.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const d=[];d.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),u.isString(o)&&d.push("path="+o),u.isString(i)&&d.push("domain="+i),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function xn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Cn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function ft(e,t){return e&&!xn(t)?Cn(e,t):t}const Pn=C.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=u.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function kn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Fn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),l=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,h=0;for(;f!==s;)h+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,d=r(c),a=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const ie={http:An,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=F.from(e.headers).normalize(),i=e.responseType;let c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(C.isStandardBrowserEnv||C.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const _=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(_+":"+p))}const l=ft(e.baseURL,e.url);a.open(e.method.toUpperCase(),st(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const _=F.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),m={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:_,config:e,request:a};Tn(function(b){n(b),d()},function(b){r(b),d()},m),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new y("Request aborted",y.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new y("Network Error",y.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const m=e.transitional||it;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new y(p,m.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,a)),a=null},C.isStandardBrowserEnv){const _=(e.withCredentials||Pn(l))&&e.xsrfCookieName&&Nn.read(e.xsrfCookieName);_&&o.set(e.xsrfHeaderName,_)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&u.forEach(o.toJSON(),function(p,m){a.setRequestHeader(m,p)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",dt(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",dt(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=_=>{!a||(r(!_||_.type?new X(null,e,a):_),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const h=kn(l);if(h&&C.protocols.indexOf(h)===-1){r(new y("Unsupported protocol "+h+":",y.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(ie,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Dn={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof F?e.toJSON():e;function H(e,t){t=t||{};const n={};function r(a,l,f){return u.isPlainObject(a)&&u.isPlainObject(l)?u.merge.call({caseless:f},a,l):u.isPlainObject(l)?u.merge({},l):u.isArray(l)?l.slice():l}function s(a,l,f){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a,f)}else return r(a,l,f)}function o(a,l){if(!u.isUndefined(l))return r(void 0,l)}function i(a,l){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function c(a,l,f){if(f in t)return r(a,l);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(a,l)=>s(ht(a),ht(l),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const f=d[l]||s,h=f(e[l],t[l],l);u.isUndefined(h)&&f!==c||(n[l]=h)}),n}const mt="1.2.1",ge={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ge[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _t={};ge.transitional=function(t,n,r){function s(o,i){return"[Axios v"+mt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new y(s(i," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!_t[i]&&(_t[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Un(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new y("option "+o+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+o,y.ERR_BAD_OPTION)}}const Re={assertOptions:Un,validators:ge},U=Re.validators;class ae{constructor(t){this.defaults=t,this.interceptors={request:new ot,response:new ot}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=H(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Re.assertOptions(r,{silentJSONParsing:U.transitional(U.boolean),forcedJSONParsing:U.transitional(U.boolean),clarifyTimeoutError:U.transitional(U.boolean)},!1),s!==void 0&&Re.assertOptions(s,{encode:U.function,serialize:U.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&u.merge(o.common,o[n.method]),i&&u.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=F.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const a=[];this.interceptors.response.forEach(function(m){a.push(m.fulfilled,m.rejected)});let l,f=0,h;if(!d){const p=[pt.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,a),h=p.length,l=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new X(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Ae(function(s){t=s}),cancel:t}}}const Bn=Ae;function Ln(e){return function(n){return e.apply(null,n)}}function jn(e){return u.isObject(e)&&e.isAxiosError===!0}function yt(e){const t=new ue(e),n=qe(ue.prototype.request,t);return u.extend(n,ue.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yt(H(e,s))},n}const O=yt(we);O.Axios=ue,O.CanceledError=X,O.CancelToken=Bn,O.isCancel=lt,O.VERSION=mt,O.toFormData=ne,O.AxiosError=y,O.Cancel=O.CanceledError,O.all=function(t){return Promise.all(t)},O.spread=Ln,O.isAxiosError=jn,O.mergeConfig=H,O.AxiosHeaders=F,O.formToJSON=e=>at(u.isHTMLForm(e)?new FormData(e):e),O.default=O;const Hn=O,ur="";function Mn(e){let t,n,r,s,o,i=`${e[4]}%`;function c(f,h){return f[6]?zn:Jn}let d=c(e),a=d(e),l=e[7]&&Et();return{c(){t=T("div"),n=T("div"),a.c(),r=z(),l&&l.c(),s=z(),o=T("div"),w(n,"class","percentage-text svelte-1urn4xa"),w(o,"id","percentage-bar"),w(o,"class","svelte-1urn4xa"),Q(o,"width",i),w(t,"id","percentage"),w(t,"class","svelte-1urn4xa")},m(f,h){N(f,t,h),R(t,n),a.m(n,null),R(n,r),l&&l.m(n,null),R(t,s),R(t,o)},p(f,h){d===(d=c(f))&&a?a.p(f,h):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[7]?l||(l=Et(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),h&16&&i!==(i=`${f[4]}%`)&&Q(o,"width",i)},d(f){f&&A(t),a.d(),l&&l.d()}}}function In(e){let t;function n(o,i){return o[2]?vn:qn}let r=n(e),s=r(e);return{c(){s.c(),t=De()},m(o,i){s.m(o,i),N(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&A(t)}}}function zn(e){let t;return{c(){t=D("Waiting for data schema detection...")},m(n,r){N(n,t,r)},p:x,d(n){n&&A(t)}}}function Jn(e){let t,n=!e[7]&&bt(e);return{c(){n&&n.c(),t=De()},m(r,s){n&&n.m(r,s),N(r,t,s)},p(r,s){r[7]?n&&(n.d(1),n=null):n?n.p(r,s):(n=bt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&A(t)}}}function bt(e){let t,n;return{c(){t=D(e[4]),n=D("%")},m(r,s){N(r,t,s),N(r,n,s)},p(r,s){s&16&&St(t,r[4])},d(r){r&&A(t),r&&A(n)}}}function Et(e){let t;return{c(){t=D("File uploaded")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function qn(e){let t;return{c(){t=D("Select a file to upload")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function vn(e){let t;return{c(){t=D("Select a file to replace the current one")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function Vn(e){let t,n,r,s,o,i,c,d,a,l,f,h,_;function p(b,g){return!b[5]&&!b[6]&&!b[7]?In:Mn}let m=p(e),E=m(e);return{c(){t=T("div"),n=T("div"),r=T("div"),E.c(),s=z(),o=T("input"),i=z(),c=T("div"),d=T("label"),d.textContent="URL",a=z(),l=T("div"),f=T("input"),w(r,"id","widget-label"),w(r,"class","svelte-1urn4xa"),w(o,"id","fileUpload"),w(o,"type","file"),w(o,"class","svelte-1urn4xa"),w(n,"id","fileUploadWidget"),w(n,"class","svelte-1urn4xa"),w(d,"class","control-label"),w(d,"for","field_url"),w(f,"id","field_url"),w(f,"class","form-control"),w(f,"type","text"),w(f,"name","url"),w(l,"class","controls"),Q(c,"display",e[1]!="upload"?"inline":"none"),w(c,"class","controls"),w(t,"class","form-group")},m(b,g){N(b,t,g),R(t,n),R(n,r),E.m(r,null),R(n,s),R(n,o),R(t,i),R(t,c),R(c,d),R(c,a),R(c,l),R(l,f),Ue(f,e[0]),h||(_=[ce(o,"change",e[12]),ce(o,"change",e[8]),ce(f,"input",e[13])],h=!0)},p(b,[g]){m===(m=p(b))&&E?E.p(b,g):(E.d(1),E=m(b),E&&(E.c(),E.m(r,null))),g&1&&f.value!==b[0]&&Ue(f,b[0]),g&2&&Q(c,"display",b[1]!="upload"?"inline":"none")},i:x,o:x,d(b){b&&A(t),E.d(),h=!1,I(_)}}}function Wn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:c}=t,{url_type:d=""}=t,a,l=0,f=!1,h=!1,_=!1,p=Be(),m=i?"update":"create";async function E(S,G){try{const P={onUploadProgress:Zn=>{const{loaded:$n,total:er}=Zn,Ce=Math.floor($n*100/er);Ce<=100&&(G(Ce),Ce==100&&(n(5,f=!1),n(6,h=!0)))}},Ne=m=="update"?`${r}/dataset/${s}/resource/${o}/file`:`${r}/dataset/${s}/resource/file`,{data:xe}=await Hn.post(`${r}/dataset/${s}/resource/file`,S,P);return xe}catch(P){console.log("ERROR",P.message)}}function b(S){n(4,l=S)}async function g(S){try{const G=S.target.files[0],P=new FormData;P.append("upload",G),P.append("package_id",s),i&&(P.append("id",o),P.append("clear_upload",!0),P.append("url_type",d)),n(5,f=!0);let Ne=await E(P,b),xe={data:Ne};n(0,c=Ne.result.url),n(1,d="upload"),p("fileUploaded",xe),n(6,h=!1),n(7,_=!0)}catch(G){console.log("ERROR",G),b(0)}}function M(){a=this.files,n(3,a)}function Te(){c=this.value,n(0,c)}return e.$$set=S=>{"upload_url"in S&&n(9,r=S.upload_url),"dataset_id"in S&&n(10,s=S.dataset_id),"resource_id"in S&&n(11,o=S.resource_id),"update"in S&&n(2,i=S.update),"current_url"in S&&n(0,c=S.current_url),"url_type"in S&&n(1,d=S.url_type)},[c,d,i,a,l,f,h,_,g,r,s,o,M,Te]}class Kn extends Je{constructor(t){super(),ze(this,t,Wn,Vn,Fe,{upload_url:9,dataset_id:10,resource_id:11,update:2,current_url:0,url_type:1})}}function Xn(e){let t,n,r;return n=new Kn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=T("main"),Pt(n.$$.fragment)},m(s,o){N(s,t,o),Me(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(He(n.$$.fragment,s),r=!0)},o(s){Ct(n.$$.fragment,s),r=!1},d(s){s&&A(t),Ie(n),e[8](null)}}}function Gn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:c}=t,{url_type:d}=t;Be();let a;function l(h){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:h.detail.data.result}))}function f(h){le[h?"unshift":"push"](()=>{a=h,n(6,a)})}return e.$$set=h=>{"upload_url"in h&&n(0,r=h.upload_url),"dataset_id"in h&&n(1,s=h.dataset_id),"resource_id"in h&&n(2,o=h.resource_id),"update"in h&&n(3,i=h.update),"current_url"in h&&n(4,c=h.current_url),"url_type"in h&&n(5,d=h.url_type)},[r,s,o,i,c,d,a,l,f]}class Qn extends Je{constructor(t){super(),ze(this,t,Gn,Xn,Fe,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function Yn(e,t="",n="",r="",s="",o="",i=""){new Qn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return Yn}); diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js index f5a4118e..40e37cdf 100644 --- a/ckanext/validation/webassets/js/module-ckan-uploader.js +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -4,6 +4,7 @@ ckan.module('ckan-uploader', function (jQuery) { return { options: { dataset_id: '', + resource_id: '', // The CKAN instance base URL upload_url: '', }, @@ -94,14 +95,14 @@ ckan.module('ckan-uploader', function (jQuery) { }, initialize: function() { - // Because we can't access some dataset/resource metadata from - // the ckanext-schemming snippets, we need to add them somehow - let resource_id = document.getElementById('resource_id').value + let resource_id = this.options.resource_id let dataset_id = this.options.dataset_id let current_url = document.getElementById('current_url').value let url_type = document.getElementById('url_type').value let update = document.getElementById('update').value + console.log(resource_id, dataset_id, update, 'DEBUG') + // Add the upload widget CkanUploader('ckan_uploader', this.options.upload_url, From 28eec48aa8a083dc957248377fe23e9020d01afa Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Wed, 1 Feb 2023 10:49:02 +0100 Subject: [PATCH 21/43] Create resource update endpoint and update ckan-uploader widget * Fix helper to get resource and package id * Update ckan-uploader widget * Pass parameters to ckan-uploader widget in form-scheming template --- ckanext/validation/blueprints.py | 17 ++++++++++------- ckanext/validation/plugin/__init__.py | 3 ++- .../scheming/form_snippets/ckan_uploader.html | 2 +- .../validation/webassets/css/ckan-uploader.css | 2 +- .../validation/webassets/js/ckan-uploader.js | 4 ++-- .../webassets/js/module-ckan-uploader.js | 3 --- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/ckanext/validation/blueprints.py b/ckanext/validation/blueprints.py index 9e942980..c3da77f1 100644 --- a/ckanext/validation/blueprints.py +++ b/ckanext/validation/blueprints.py @@ -61,6 +61,7 @@ def _get_data(): data.update(clean_dict( unflatten(tuplize_dict(parse_params(request.files))) )) + return data def resource_file_create(id): @@ -72,13 +73,14 @@ def resource_file_create(id): context = { 'user': g.user, } + data_dict["package_id"] = id resource = get_action("resource_create")(context, data_dict) # If it's tabular (local OR remote), infer and store schema - if is_tabular(resource): + if is_tabular(filename=resource['url']): update_resource = get_action('resource_table_schema_infer')( - context, {'resource_id': resource.id, 'store_schema': True} + context, {'resource_id': resource['id'], 'store_schema': True} ) # Return resource @@ -97,20 +99,21 @@ def resource_file_update(id, resource_id): resource = get_action("resource_update")(context, data_dict) # If it's tabular (local OR remote), infer and store schema - if is_tabular(resource): + if is_tabular(resource['url']): + resource_id = resource['id'] update_resource = get_action('resource_table_schema_infer')( - context, {'resource_id': resource.id, 'store_schema': True} + context, {'resource_id': resource_id, 'store_schema': True} ) # Return resource return resource - validation.add_url_rule( - "/dataset//resource/file", view_func=resource_file_create, methods=["POST"] + "/dataset//resource//file", view_func=resource_file_update, methods=["POST"] ) + validation.add_url_rule( - "/dataset//resource//file", view_func=resource_file_update, methods=["POST"] + "/dataset//resource/file", view_func=resource_file_create, methods=["POST"] ) validation.add_url_rule( diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index f958446e..fd4a7d7e 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -145,7 +145,8 @@ def _process_schema_fields(self, data_dict): schema_upload = data_dict.pop(u'schema_upload', None) schema_url = data_dict.pop(u'schema_url', None) schema_json = data_dict.pop(u'schema_json', None) - if isinstance(schema_upload, ALLOWED_UPLOAD_TYPES): + + if isinstance(schema_upload, ALLOWED_UPLOAD_TYPES) and schema_upload.content_length > 0: uploaded_file = _get_underlying_file(schema_upload) data_dict[u'schema'] = uploaded_file.read() diff --git a/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html index dbdbeeff..c1754d29 100644 --- a/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html +++ b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html @@ -4,6 +4,6 @@
-
+
diff --git a/ckanext/validation/webassets/css/ckan-uploader.css b/ckanext/validation/webassets/css/ckan-uploader.css index 3c838dcc..5b3d1934 100644 --- a/ckanext/validation/webassets/css/ckan-uploader.css +++ b/ckanext/validation/webassets/css/ckan-uploader.css @@ -1 +1 @@ -#fileUploadWidget.svelte-1urn4xa.svelte-1urn4xa{position:relative;display:flex;max-width:400px;border:2px solid #0c4a6e;border-radius:4px;background-color:#0284c7;margin-bottom:10px}#fileUploadWidget.svelte-1urn4xa #widget-label.svelte-1urn4xa{width:100%;height:100%;color:#fff;justify-content:center;display:flex}#percentage.svelte-1urn4xa.svelte-1urn4xa{width:100%;height:100%;align:middle;justify-content:center;display:flex;position:relative}.percentage-text.svelte-1urn4xa.svelte-1urn4xa{z-index:20}#percentage-bar.svelte-1urn4xa.svelte-1urn4xa{z-index:10;position:absolute;top:0;left:0;bottom:0;background-color:#1e3a8a;transition:width .3s;transition-timing-function:ease-in}#fileUpload.svelte-1urn4xa.svelte-1urn4xa{position:absolute;width:100%;height:100%;top:0;left:0;opacity:0} +#fileUploadWidget.svelte-75w3tp.svelte-75w3tp{position:relative;display:flex;max-width:400px;border:2px solid #0c4a6e;border-radius:4px;background-color:#164959;margin-bottom:10px}#fileUploadWidget.svelte-75w3tp #widget-label.svelte-75w3tp{width:100%;height:100%;color:#fff;justify-content:center;display:flex}#percentage.svelte-75w3tp.svelte-75w3tp{width:100%;height:100%;align:middle;justify-content:center;display:flex;position:relative}.percentage-text.svelte-75w3tp.svelte-75w3tp{z-index:20}#percentage-bar.svelte-75w3tp.svelte-75w3tp{z-index:10;position:absolute;top:0;left:0;bottom:0;transition:width .3s;transition-timing-function:ease-in}#fileUpload.svelte-75w3tp.svelte-75w3tp{position:absolute;width:100%;height:100%;top:0;left:0;opacity:0} diff --git a/ckanext/validation/webassets/js/ckan-uploader.js b/ckanext/validation/webassets/js/ckan-uploader.js index 721c1050..5f84c293 100644 --- a/ckanext/validation/webassets/js/ckan-uploader.js +++ b/ckanext/validation/webassets/js/ckan-uploader.js @@ -1,3 +1,3 @@ -(function(x,L){typeof exports=="object"&&typeof module<"u"?module.exports=L():typeof define=="function"&&define.amd?define(L):(x=typeof globalThis<"u"?globalThis:x||self,x.CkanUploader=L())})(this,function(){"use strict";function x(){}function L(e){return e()}function Pe(){return Object.create(null)}function I(e){e.forEach(L)}function ke(e){return typeof e=="function"}function Fe(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function wt(e){return Object.keys(e).length===0}function R(e,t){e.appendChild(t)}function N(e,t,n){e.insertBefore(t,n||null)}function A(e){e.parentNode&&e.parentNode.removeChild(e)}function T(e){return document.createElement(e)}function D(e){return document.createTextNode(e)}function z(){return D(" ")}function De(){return D("")}function ce(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function w(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Ot(e){return Array.from(e.childNodes)}function St(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Ue(e,t){e.value=t==null?"":t}function Q(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function gt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Rt(){if(!J)throw new Error("Function called outside component initialization");return J}function Be(){const e=Rt();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=gt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const v=[],le=[],Y=[],Le=[],At=Promise.resolve();let fe=!1;function Tt(){fe||(fe=!0,At.then(je))}function de(e){Y.push(e)}const pe=new Set;let Z=0;function je(){const e=J;do{for(;Z{$.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Pt(e){e&&e.c()}function Me(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||de(()=>{const i=e.$$.on_mount.map(L).filter(ke);e.$$.on_destroy?e.$$.on_destroy.push(...i):I(i),e.$$.on_mount=[]}),o.forEach(de)}function Ie(e,t){const n=e.$$;n.fragment!==null&&(I(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function kt(e,t){e.$$.dirty[0]===-1&&(v.push(e),Tt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=_.length?_[0]:h;return a.ctx&&s(a.ctx[f],a.ctx[f]=p)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](p),l&&kt(e,f)),h}):[],a.update(),l=!0,I(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Ot(t.target);a.fragment&&a.fragment.l(f),f.forEach(A)}else a.fragment&&a.fragment.c();t.intro&&He(e.$$.fragment),Me(e,t.target,t.anchor,t.customElement),je()}q(d)}class Je{$destroy(){Ie(this,1),this.$destroy=x}$on(t,n){if(!ke(n))return x;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!wt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function qe(e,t){return function(){return e.apply(t,arguments)}}const{toString:ve}=Object.prototype,{getPrototypeOf:he}=Object,me=(e=>t=>{const n=ve.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),k=e=>(e=e.toLowerCase(),t=>me(t)===e),ee=e=>t=>typeof t===e,{isArray:j}=Array,V=ee("undefined");function Ft(e){return e!==null&&!V(e)&&e.constructor!==null&&!V(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ve=k("ArrayBuffer");function Dt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ve(e.buffer),t}const Ut=ee("string"),B=ee("function"),We=ee("number"),_e=e=>e!==null&&typeof e=="object",Bt=e=>e===!0||e===!1,te=e=>{if(me(e)!=="object")return!1;const t=he(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Lt=k("Date"),jt=k("File"),Ht=k("Blob"),Mt=k("FileList"),It=e=>_e(e)&&B(e.pipe),zt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||ve.call(e)===t||B(e.toString)&&e.toString()===t)},Jt=k("URLSearchParams"),qt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function W(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),j(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Xe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ge=e=>!V(e)&&e!==Xe;function ye(){const{caseless:e}=Ge(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ke(t,s)||s;te(t[o])&&te(r)?t[o]=ye(t[o],r):te(r)?t[o]=ye({},r):j(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(W(t,(s,o)=>{n&&B(s)?e[o]=qe(s,n):e[o]=s},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Wt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Kt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&he(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Xt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Gt=e=>{if(!e)return null;if(j(e))return e;let t=e.length;if(!We(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Qt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&he(Uint8Array)),Yt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},Zt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},$t=k("HTMLFormElement"),en=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Qe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),tn=k("RegExp"),Ye=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};W(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},u={isArray:j,isArrayBuffer:Ve,isBuffer:Ft,isFormData:zt,isArrayBufferView:Dt,isString:Ut,isNumber:We,isBoolean:Bt,isObject:_e,isPlainObject:te,isUndefined:V,isDate:Lt,isFile:jt,isBlob:Ht,isRegExp:tn,isFunction:B,isStream:It,isURLSearchParams:Jt,isTypedArray:Qt,isFileList:Mt,forEach:W,merge:ye,extend:vt,trim:qt,stripBOM:Vt,inherits:Wt,toFlatObject:Kt,kindOf:me,kindOfTest:k,endsWith:Xt,toArray:Gt,forEachEntry:Yt,matchAll:Zt,isHTMLForm:$t,hasOwnProperty:Qe,hasOwnProp:Qe,reduceDescriptors:Ye,freezeMethods:e=>{Ye(e,(t,n)=>{if(B(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!B(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return j(e)?r(e):r(String(e).split(t)),n},toCamelCase:en,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ke,global:Xe,isContextDefined:Ge,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(_e(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=j(r)?[]:{};return W(r,(i,c)=>{const d=n(i,s+1);!V(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function y(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}u.inherits(y,Error,{toJSON:function(){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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ze=y.prototype,$e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{$e[e]={value:e}}),Object.defineProperties(y,$e),Object.defineProperty(Ze,"isAxiosError",{value:!0}),y.from=(e,t,n,r,s,o)=>{const i=Object.create(Ze);return u.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),y.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var nn=typeof self=="object"?self.FormData:window.FormData;const rn=nn;function be(e){return u.isPlainObject(e)||u.isArray(e)}function et(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,n){return e?e.concat(t).map(function(s,o){return s=et(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function sn(e){return u.isArray(e)&&!e.some(be)}const on=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function an(e){return e&&u.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function ne(e,t,n){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new(rn||FormData),n=u.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,E){return!u.isUndefined(E[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&an(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(u.isDate(p))return p.toISOString();if(!d&&u.isBlob(p))throw new y("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(p)||u.isTypedArray(p)?d&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function l(p,m,E){let b=p;if(p&&!E&&typeof p=="object"){if(u.endsWith(m,"{}"))m=r?m:m.slice(0,-2),p=JSON.stringify(p);else if(u.isArray(p)&&sn(p)||u.isFileList(p)||u.endsWith(m,"[]")&&(b=u.toArray(p)))return m=et(m),b.forEach(function(M,Te){!(u.isUndefined(M)||M===null)&&t.append(i===!0?tt([m],Te,o):i===null?m:m+"[]",a(M))}),!1}return be(p)?!0:(t.append(tt(E,m,o),a(p)),!1)}const f=[],h=Object.assign(on,{defaultVisitor:l,convertValue:a,isVisitable:be});function _(p,m){if(!u.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(p),u.forEach(p,function(b,g){(!(u.isUndefined(b)||b===null)&&s.call(t,b,u.isString(g)?g.trim():g,m,h))===!0&&_(b,m?m.concat(g):[g])}),f.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return _(e),t}function nt(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ee(e,t){this._pairs=[],e&&ne(e,this,t)}const rt=Ee.prototype;rt.append=function(t,n){this._pairs.push([t,n])},rt.toString=function(t){const n=t?function(r){return t.call(this,r,nt)}:nt;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function un(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function st(e,t,n){if(!t)return e;const r=n&&n.encode||un,s=n&&n.serialize;let o;if(s?o=s(t,n):o=u.isURLSearchParams(t)?t.toString():new Ee(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class cn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){u.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ot=cn,it={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ln=typeof URLSearchParams<"u"?URLSearchParams:Ee,fn=FormData,dn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),pn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),C={isBrowser:!0,classes:{URLSearchParams:ln,FormData:fn,Blob},isStandardBrowserEnv:dn,isStandardBrowserWebWorkerEnv:pn,protocols:["http","https","file","blob","url","data"]};function hn(e,t){return ne(e,new C.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return C.isNode&&u.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function mn(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function _n(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&u.isArray(s)?s.length:i,d?(u.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!u.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&u.isArray(s[i])&&(s[i]=_n(s[i])),!c)}if(u.isFormData(e)&&u.isFunction(e.entries)){const n={};return u.forEachEntry(e,(r,s)=>{t(mn(r),s,n,0)}),n}return null}const yn={"Content-Type":void 0};function bn(e,t,n){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const re={transitional:it,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=u.isObject(t);if(o&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(at(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return hn(t,this.formSerializer).toString();if((c=u.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return ne(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),bn(t)):t}],transformResponse:[function(t){const n=this.transitional||re.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&u.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};u.forEach(["delete","get","head"],function(t){re.headers[t]={}}),u.forEach(["post","put","patch"],function(t){re.headers[t]=u.merge(yn)});const we=re,En=u.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"]),wn=e=>{const t={};let n,r,s;return e&&e.split(` +(function(C,L){typeof exports=="object"&&typeof module<"u"?module.exports=L():typeof define=="function"&&define.amd?define(L):(C=typeof globalThis<"u"?globalThis:C||self,C.CkanUploader=L())})(this,function(){"use strict";function C(){}function L(e){return e()}function xe(){return Object.create(null)}function I(e){e.forEach(L)}function ke(e){return typeof e=="function"}function Fe(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function wt(e){return Object.keys(e).length===0}function R(e,t){e.appendChild(t)}function N(e,t,n){e.insertBefore(t,n||null)}function A(e){e.parentNode&&e.parentNode.removeChild(e)}function T(e){return document.createElement(e)}function D(e){return document.createTextNode(e)}function z(){return D(" ")}function De(){return D("")}function le(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function w(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Ot(e){return Array.from(e.childNodes)}function St(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Ue(e,t){e.value=t==null?"":t}function Q(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function gt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Rt(){if(!J)throw new Error("Function called outside component initialization");return J}function Be(){const e=Rt();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=gt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const v=[],fe=[],Y=[],Le=[],At=Promise.resolve();let de=!1;function Tt(){de||(de=!0,At.then(je))}function pe(e){Y.push(e)}const he=new Set;let Z=0;function je(){const e=J;do{for(;Z{$.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function xt(e){e&&e.c()}function Me(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||pe(()=>{const i=e.$$.on_mount.map(L).filter(ke);e.$$.on_destroy?e.$$.on_destroy.push(...i):I(i),e.$$.on_mount=[]}),o.forEach(pe)}function Ie(e,t){const n=e.$$;n.fragment!==null&&(I(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function kt(e,t){e.$$.dirty[0]===-1&&(v.push(e),Tt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=_.length?_[0]:h;return a.ctx&&s(a.ctx[f],a.ctx[f]=p)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](p),l&&kt(e,f)),h}):[],a.update(),l=!0,I(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Ot(t.target);a.fragment&&a.fragment.l(f),f.forEach(A)}else a.fragment&&a.fragment.c();t.intro&&He(e.$$.fragment),Me(e,t.target,t.anchor,t.customElement),je()}q(d)}class Je{$destroy(){Ie(this,1),this.$destroy=C}$on(t,n){if(!ke(n))return C;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!wt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function qe(e,t){return function(){return e.apply(t,arguments)}}const{toString:ve}=Object.prototype,{getPrototypeOf:me}=Object,_e=(e=>t=>{const n=ve.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),k=e=>(e=e.toLowerCase(),t=>_e(t)===e),ee=e=>t=>typeof t===e,{isArray:j}=Array,V=ee("undefined");function Ft(e){return e!==null&&!V(e)&&e.constructor!==null&&!V(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ve=k("ArrayBuffer");function Dt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ve(e.buffer),t}const Ut=ee("string"),B=ee("function"),We=ee("number"),ye=e=>e!==null&&typeof e=="object",Bt=e=>e===!0||e===!1,te=e=>{if(_e(e)!=="object")return!1;const t=me(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Lt=k("Date"),jt=k("File"),Ht=k("Blob"),Mt=k("FileList"),It=e=>ye(e)&&B(e.pipe),zt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||ve.call(e)===t||B(e.toString)&&e.toString()===t)},Jt=k("URLSearchParams"),qt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function W(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),j(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Xe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ge=e=>!V(e)&&e!==Xe;function be(){const{caseless:e}=Ge(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ke(t,s)||s;te(t[o])&&te(r)?t[o]=be(t[o],r):te(r)?t[o]=be({},r):j(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(W(t,(s,o)=>{n&&B(s)?e[o]=qe(s,n):e[o]=s},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Wt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Kt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&me(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Xt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Gt=e=>{if(!e)return null;if(j(e))return e;let t=e.length;if(!We(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Qt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&me(Uint8Array)),Yt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},Zt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},$t=k("HTMLFormElement"),en=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Qe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),tn=k("RegExp"),Ye=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};W(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},u={isArray:j,isArrayBuffer:Ve,isBuffer:Ft,isFormData:zt,isArrayBufferView:Dt,isString:Ut,isNumber:We,isBoolean:Bt,isObject:ye,isPlainObject:te,isUndefined:V,isDate:Lt,isFile:jt,isBlob:Ht,isRegExp:tn,isFunction:B,isStream:It,isURLSearchParams:Jt,isTypedArray:Qt,isFileList:Mt,forEach:W,merge:be,extend:vt,trim:qt,stripBOM:Vt,inherits:Wt,toFlatObject:Kt,kindOf:_e,kindOfTest:k,endsWith:Xt,toArray:Gt,forEachEntry:Yt,matchAll:Zt,isHTMLForm:$t,hasOwnProperty:Qe,hasOwnProp:Qe,reduceDescriptors:Ye,freezeMethods:e=>{Ye(e,(t,n)=>{if(B(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!B(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return j(e)?r(e):r(String(e).split(t)),n},toCamelCase:en,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ke,global:Xe,isContextDefined:Ge,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(ye(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=j(r)?[]:{};return W(r,(i,c)=>{const d=n(i,s+1);!V(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function y(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}u.inherits(y,Error,{toJSON:function(){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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ze=y.prototype,$e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{$e[e]={value:e}}),Object.defineProperties(y,$e),Object.defineProperty(Ze,"isAxiosError",{value:!0}),y.from=(e,t,n,r,s,o)=>{const i=Object.create(Ze);return u.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),y.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var nn=typeof self=="object"?self.FormData:window.FormData;const rn=nn;function Ee(e){return u.isPlainObject(e)||u.isArray(e)}function et(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,n){return e?e.concat(t).map(function(s,o){return s=et(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function sn(e){return u.isArray(e)&&!e.some(Ee)}const on=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function an(e){return e&&u.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function ne(e,t,n){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new(rn||FormData),n=u.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,E){return!u.isUndefined(E[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&an(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(u.isDate(p))return p.toISOString();if(!d&&u.isBlob(p))throw new y("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(p)||u.isTypedArray(p)?d&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function l(p,m,E){let b=p;if(p&&!E&&typeof p=="object"){if(u.endsWith(m,"{}"))m=r?m:m.slice(0,-2),p=JSON.stringify(p);else if(u.isArray(p)&&sn(p)||u.isFileList(p)||u.endsWith(m,"[]")&&(b=u.toArray(p)))return m=et(m),b.forEach(function(M,Ne){!(u.isUndefined(M)||M===null)&&t.append(i===!0?tt([m],Ne,o):i===null?m:m+"[]",a(M))}),!1}return Ee(p)?!0:(t.append(tt(E,m,o),a(p)),!1)}const f=[],h=Object.assign(on,{defaultVisitor:l,convertValue:a,isVisitable:Ee});function _(p,m){if(!u.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(p),u.forEach(p,function(b,g){(!(u.isUndefined(b)||b===null)&&s.call(t,b,u.isString(g)?g.trim():g,m,h))===!0&&_(b,m?m.concat(g):[g])}),f.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return _(e),t}function nt(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function we(e,t){this._pairs=[],e&&ne(e,this,t)}const rt=we.prototype;rt.append=function(t,n){this._pairs.push([t,n])},rt.toString=function(t){const n=t?function(r){return t.call(this,r,nt)}:nt;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function un(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function st(e,t,n){if(!t)return e;const r=n&&n.encode||un,s=n&&n.serialize;let o;if(s?o=s(t,n):o=u.isURLSearchParams(t)?t.toString():new we(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class cn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){u.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ot=cn,it={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ln=typeof URLSearchParams<"u"?URLSearchParams:we,fn=FormData,dn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),pn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),P={isBrowser:!0,classes:{URLSearchParams:ln,FormData:fn,Blob},isStandardBrowserEnv:dn,isStandardBrowserWebWorkerEnv:pn,protocols:["http","https","file","blob","url","data"]};function hn(e,t){return ne(e,new P.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return P.isNode&&u.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function mn(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function _n(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&u.isArray(s)?s.length:i,d?(u.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!u.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&u.isArray(s[i])&&(s[i]=_n(s[i])),!c)}if(u.isFormData(e)&&u.isFunction(e.entries)){const n={};return u.forEachEntry(e,(r,s)=>{t(mn(r),s,n,0)}),n}return null}const yn={"Content-Type":void 0};function bn(e,t,n){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const re={transitional:it,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=u.isObject(t);if(o&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(at(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return hn(t,this.formSerializer).toString();if((c=u.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return ne(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),bn(t)):t}],transformResponse:[function(t){const n=this.transitional||re.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&u.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:P.classes.FormData,Blob:P.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};u.forEach(["delete","get","head"],function(t){re.headers[t]={}}),u.forEach(["post","put","patch"],function(t){re.headers[t]=u.merge(yn)});const Oe=re,En=u.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"]),wn=e=>{const t={};let n,r,s;return e&&e.split(` `).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&En[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ut=Symbol("internals");function K(e){return e&&String(e).trim().toLowerCase()}function se(e){return e===!1||e==null?e:u.isArray(e)?e.map(se):String(e)}function On(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}function Sn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ct(e,t,n,r){if(u.isFunction(r))return r.call(this,t,n);if(!!u.isString(t)){if(u.isString(r))return t.indexOf(r)!==-1;if(u.isRegExp(r))return r.test(t)}}function gn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Rn(e,t){const n=u.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class oe{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,a){const l=K(d);if(!l)throw new Error("header name must be a non-empty string");const f=u.findKey(s,l);(!f||s[f]===void 0||a===!0||a===void 0&&s[f]!==!1)&&(s[f||d]=se(c))}const i=(c,d)=>u.forEach(c,(a,l)=>o(a,l,d));return u.isPlainObject(t)||t instanceof this.constructor?i(t,n):u.isString(t)&&(t=t.trim())&&!Sn(t)?i(wn(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=K(t),t){const r=u.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return On(s);if(u.isFunction(n))return n.call(this,s,r);if(u.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=K(t),t){const r=u.findKey(this,t);return!!(r&&(!n||ct(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=K(i),i){const c=u.findKey(r,i);c&&(!n||ct(r,r[c],c,n))&&(delete r[c],s=!0)}}return u.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return u.forEach(this,(s,o)=>{const i=u.findKey(r,o);if(i){n[i]=se(s),delete n[o];return}const c=t?gn(o):String(o).trim();c!==o&&delete n[o],n[c]=se(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return u.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&u.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ut]=this[ut]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=K(i);r[c]||(Rn(s,i),r[c]=!0)}return u.isArray(t)?t.forEach(o):o(t),this}}oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(oe.prototype),u.freezeMethods(oe);const F=oe;function Oe(e,t){const n=this||we,r=t||n,s=F.from(r.headers);let o=r.data;return u.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function lt(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){y.call(this,e==null?"canceled":e,y.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(X,y,{__CANCEL__:!0});const An=null;function Tn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Nn=C.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const d=[];d.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),u.isString(o)&&d.push("path="+o),u.isString(i)&&d.push("domain="+i),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function xn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Cn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function ft(e,t){return e&&!xn(t)?Cn(e,t):t}const Pn=C.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=u.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function kn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Fn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),l=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,h=0;for(;f!==s;)h+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,d=r(c),a=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const ie={http:An,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=F.from(e.headers).normalize(),i=e.responseType;let c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(C.isStandardBrowserEnv||C.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const _=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(_+":"+p))}const l=ft(e.baseURL,e.url);a.open(e.method.toUpperCase(),st(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const _=F.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),m={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:_,config:e,request:a};Tn(function(b){n(b),d()},function(b){r(b),d()},m),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new y("Request aborted",y.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new y("Network Error",y.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const m=e.transitional||it;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new y(p,m.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,a)),a=null},C.isStandardBrowserEnv){const _=(e.withCredentials||Pn(l))&&e.xsrfCookieName&&Nn.read(e.xsrfCookieName);_&&o.set(e.xsrfHeaderName,_)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&u.forEach(o.toJSON(),function(p,m){a.setRequestHeader(m,p)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",dt(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",dt(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=_=>{!a||(r(!_||_.type?new X(null,e,a):_),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const h=kn(l);if(h&&C.protocols.indexOf(h)===-1){r(new y("Unsupported protocol "+h+":",y.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(ie,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Dn={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof F?e.toJSON():e;function H(e,t){t=t||{};const n={};function r(a,l,f){return u.isPlainObject(a)&&u.isPlainObject(l)?u.merge.call({caseless:f},a,l):u.isPlainObject(l)?u.merge({},l):u.isArray(l)?l.slice():l}function s(a,l,f){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a,f)}else return r(a,l,f)}function o(a,l){if(!u.isUndefined(l))return r(void 0,l)}function i(a,l){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function c(a,l,f){if(f in t)return r(a,l);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(a,l)=>s(ht(a),ht(l),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const f=d[l]||s,h=f(e[l],t[l],l);u.isUndefined(h)&&f!==c||(n[l]=h)}),n}const mt="1.2.1",ge={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ge[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _t={};ge.transitional=function(t,n,r){function s(o,i){return"[Axios v"+mt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new y(s(i," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!_t[i]&&(_t[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Un(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new y("option "+o+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+o,y.ERR_BAD_OPTION)}}const Re={assertOptions:Un,validators:ge},U=Re.validators;class ae{constructor(t){this.defaults=t,this.interceptors={request:new ot,response:new ot}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=H(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Re.assertOptions(r,{silentJSONParsing:U.transitional(U.boolean),forcedJSONParsing:U.transitional(U.boolean),clarifyTimeoutError:U.transitional(U.boolean)},!1),s!==void 0&&Re.assertOptions(s,{encode:U.function,serialize:U.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&u.merge(o.common,o[n.method]),i&&u.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=F.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const a=[];this.interceptors.response.forEach(function(m){a.push(m.fulfilled,m.rejected)});let l,f=0,h;if(!d){const p=[pt.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,a),h=p.length,l=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new X(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Ae(function(s){t=s}),cancel:t}}}const Bn=Ae;function Ln(e){return function(n){return e.apply(null,n)}}function jn(e){return u.isObject(e)&&e.isAxiosError===!0}function yt(e){const t=new ue(e),n=qe(ue.prototype.request,t);return u.extend(n,ue.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yt(H(e,s))},n}const O=yt(we);O.Axios=ue,O.CanceledError=X,O.CancelToken=Bn,O.isCancel=lt,O.VERSION=mt,O.toFormData=ne,O.AxiosError=y,O.Cancel=O.CanceledError,O.all=function(t){return Promise.all(t)},O.spread=Ln,O.isAxiosError=jn,O.mergeConfig=H,O.AxiosHeaders=F,O.formToJSON=e=>at(u.isHTMLForm(e)?new FormData(e):e),O.default=O;const Hn=O,ur="";function Mn(e){let t,n,r,s,o,i=`${e[4]}%`;function c(f,h){return f[6]?zn:Jn}let d=c(e),a=d(e),l=e[7]&&Et();return{c(){t=T("div"),n=T("div"),a.c(),r=z(),l&&l.c(),s=z(),o=T("div"),w(n,"class","percentage-text svelte-1urn4xa"),w(o,"id","percentage-bar"),w(o,"class","svelte-1urn4xa"),Q(o,"width",i),w(t,"id","percentage"),w(t,"class","svelte-1urn4xa")},m(f,h){N(f,t,h),R(t,n),a.m(n,null),R(n,r),l&&l.m(n,null),R(t,s),R(t,o)},p(f,h){d===(d=c(f))&&a?a.p(f,h):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[7]?l||(l=Et(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),h&16&&i!==(i=`${f[4]}%`)&&Q(o,"width",i)},d(f){f&&A(t),a.d(),l&&l.d()}}}function In(e){let t;function n(o,i){return o[2]?vn:qn}let r=n(e),s=r(e);return{c(){s.c(),t=De()},m(o,i){s.m(o,i),N(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&A(t)}}}function zn(e){let t;return{c(){t=D("Waiting for data schema detection...")},m(n,r){N(n,t,r)},p:x,d(n){n&&A(t)}}}function Jn(e){let t,n=!e[7]&&bt(e);return{c(){n&&n.c(),t=De()},m(r,s){n&&n.m(r,s),N(r,t,s)},p(r,s){r[7]?n&&(n.d(1),n=null):n?n.p(r,s):(n=bt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&A(t)}}}function bt(e){let t,n;return{c(){t=D(e[4]),n=D("%")},m(r,s){N(r,t,s),N(r,n,s)},p(r,s){s&16&&St(t,r[4])},d(r){r&&A(t),r&&A(n)}}}function Et(e){let t;return{c(){t=D("File uploaded")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function qn(e){let t;return{c(){t=D("Select a file to upload")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function vn(e){let t;return{c(){t=D("Select a file to replace the current one")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function Vn(e){let t,n,r,s,o,i,c,d,a,l,f,h,_;function p(b,g){return!b[5]&&!b[6]&&!b[7]?In:Mn}let m=p(e),E=m(e);return{c(){t=T("div"),n=T("div"),r=T("div"),E.c(),s=z(),o=T("input"),i=z(),c=T("div"),d=T("label"),d.textContent="URL",a=z(),l=T("div"),f=T("input"),w(r,"id","widget-label"),w(r,"class","svelte-1urn4xa"),w(o,"id","fileUpload"),w(o,"type","file"),w(o,"class","svelte-1urn4xa"),w(n,"id","fileUploadWidget"),w(n,"class","svelte-1urn4xa"),w(d,"class","control-label"),w(d,"for","field_url"),w(f,"id","field_url"),w(f,"class","form-control"),w(f,"type","text"),w(f,"name","url"),w(l,"class","controls"),Q(c,"display",e[1]!="upload"?"inline":"none"),w(c,"class","controls"),w(t,"class","form-group")},m(b,g){N(b,t,g),R(t,n),R(n,r),E.m(r,null),R(n,s),R(n,o),R(t,i),R(t,c),R(c,d),R(c,a),R(c,l),R(l,f),Ue(f,e[0]),h||(_=[ce(o,"change",e[12]),ce(o,"change",e[8]),ce(f,"input",e[13])],h=!0)},p(b,[g]){m===(m=p(b))&&E?E.p(b,g):(E.d(1),E=m(b),E&&(E.c(),E.m(r,null))),g&1&&f.value!==b[0]&&Ue(f,b[0]),g&2&&Q(c,"display",b[1]!="upload"?"inline":"none")},i:x,o:x,d(b){b&&A(t),E.d(),h=!1,I(_)}}}function Wn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:c}=t,{url_type:d=""}=t,a,l=0,f=!1,h=!1,_=!1,p=Be(),m=i?"update":"create";async function E(S,G){try{const P={onUploadProgress:Zn=>{const{loaded:$n,total:er}=Zn,Ce=Math.floor($n*100/er);Ce<=100&&(G(Ce),Ce==100&&(n(5,f=!1),n(6,h=!0)))}},Ne=m=="update"?`${r}/dataset/${s}/resource/${o}/file`:`${r}/dataset/${s}/resource/file`,{data:xe}=await Hn.post(`${r}/dataset/${s}/resource/file`,S,P);return xe}catch(P){console.log("ERROR",P.message)}}function b(S){n(4,l=S)}async function g(S){try{const G=S.target.files[0],P=new FormData;P.append("upload",G),P.append("package_id",s),i&&(P.append("id",o),P.append("clear_upload",!0),P.append("url_type",d)),n(5,f=!0);let Ne=await E(P,b),xe={data:Ne};n(0,c=Ne.result.url),n(1,d="upload"),p("fileUploaded",xe),n(6,h=!1),n(7,_=!0)}catch(G){console.log("ERROR",G),b(0)}}function M(){a=this.files,n(3,a)}function Te(){c=this.value,n(0,c)}return e.$$set=S=>{"upload_url"in S&&n(9,r=S.upload_url),"dataset_id"in S&&n(10,s=S.dataset_id),"resource_id"in S&&n(11,o=S.resource_id),"update"in S&&n(2,i=S.update),"current_url"in S&&n(0,c=S.current_url),"url_type"in S&&n(1,d=S.url_type)},[c,d,i,a,l,f,h,_,g,r,s,o,M,Te]}class Kn extends Je{constructor(t){super(),ze(this,t,Wn,Vn,Fe,{upload_url:9,dataset_id:10,resource_id:11,update:2,current_url:0,url_type:1})}}function Xn(e){let t,n,r;return n=new Kn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=T("main"),Pt(n.$$.fragment)},m(s,o){N(s,t,o),Me(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(He(n.$$.fragment,s),r=!0)},o(s){Ct(n.$$.fragment,s),r=!1},d(s){s&&A(t),Ie(n),e[8](null)}}}function Gn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:c}=t,{url_type:d}=t;Be();let a;function l(h){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:h.detail.data.result}))}function f(h){le[h?"unshift":"push"](()=>{a=h,n(6,a)})}return e.$$set=h=>{"upload_url"in h&&n(0,r=h.upload_url),"dataset_id"in h&&n(1,s=h.dataset_id),"resource_id"in h&&n(2,o=h.resource_id),"update"in h&&n(3,i=h.update),"current_url"in h&&n(4,c=h.current_url),"url_type"in h&&n(5,d=h.url_type)},[r,s,o,i,c,d,a,l,f]}class Qn extends Je{constructor(t){super(),ze(this,t,Gn,Xn,Fe,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function Yn(e,t="",n="",r="",s="",o="",i=""){new Qn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return Yn}); +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ut]=this[ut]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=K(i);r[c]||(Rn(s,i),r[c]=!0)}return u.isArray(t)?t.forEach(o):o(t),this}}oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(oe.prototype),u.freezeMethods(oe);const F=oe;function Se(e,t){const n=this||Oe,r=t||n,s=F.from(r.headers);let o=r.data;return u.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function lt(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){y.call(this,e==null?"canceled":e,y.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(X,y,{__CANCEL__:!0});const An=null;function Tn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Nn=P.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const d=[];d.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),u.isString(o)&&d.push("path="+o),u.isString(i)&&d.push("domain="+i),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Cn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Pn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function ft(e,t){return e&&!Cn(t)?Pn(e,t):t}const xn=P.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=u.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function kn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Fn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),l=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,h=0;for(;f!==s;)h+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,d=r(c),a=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const ie={http:An,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=F.from(e.headers).normalize(),i=e.responseType;let c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(P.isStandardBrowserEnv||P.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const _=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(_+":"+p))}const l=ft(e.baseURL,e.url);a.open(e.method.toUpperCase(),st(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const _=F.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),m={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:_,config:e,request:a};Tn(function(b){n(b),d()},function(b){r(b),d()},m),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new y("Request aborted",y.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new y("Network Error",y.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const m=e.transitional||it;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new y(p,m.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,a)),a=null},P.isStandardBrowserEnv){const _=(e.withCredentials||xn(l))&&e.xsrfCookieName&&Nn.read(e.xsrfCookieName);_&&o.set(e.xsrfHeaderName,_)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&u.forEach(o.toJSON(),function(p,m){a.setRequestHeader(m,p)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",dt(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",dt(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=_=>{!a||(r(!_||_.type?new X(null,e,a):_),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const h=kn(l);if(h&&P.protocols.indexOf(h)===-1){r(new y("Unsupported protocol "+h+":",y.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(ie,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Dn={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof F?e.toJSON():e;function H(e,t){t=t||{};const n={};function r(a,l,f){return u.isPlainObject(a)&&u.isPlainObject(l)?u.merge.call({caseless:f},a,l):u.isPlainObject(l)?u.merge({},l):u.isArray(l)?l.slice():l}function s(a,l,f){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a,f)}else return r(a,l,f)}function o(a,l){if(!u.isUndefined(l))return r(void 0,l)}function i(a,l){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function c(a,l,f){if(f in t)return r(a,l);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(a,l)=>s(ht(a),ht(l),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const f=d[l]||s,h=f(e[l],t[l],l);u.isUndefined(h)&&f!==c||(n[l]=h)}),n}const mt="1.2.1",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _t={};Re.transitional=function(t,n,r){function s(o,i){return"[Axios v"+mt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new y(s(i," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!_t[i]&&(_t[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Un(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new y("option "+o+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+o,y.ERR_BAD_OPTION)}}const Ae={assertOptions:Un,validators:Re},U=Ae.validators;class ae{constructor(t){this.defaults=t,this.interceptors={request:new ot,response:new ot}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=H(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Ae.assertOptions(r,{silentJSONParsing:U.transitional(U.boolean),forcedJSONParsing:U.transitional(U.boolean),clarifyTimeoutError:U.transitional(U.boolean)},!1),s!==void 0&&Ae.assertOptions(s,{encode:U.function,serialize:U.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&u.merge(o.common,o[n.method]),i&&u.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=F.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const a=[];this.interceptors.response.forEach(function(m){a.push(m.fulfilled,m.rejected)});let l,f=0,h;if(!d){const p=[pt.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,a),h=p.length,l=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new X(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Te(function(s){t=s}),cancel:t}}}const Bn=Te;function Ln(e){return function(n){return e.apply(null,n)}}function jn(e){return u.isObject(e)&&e.isAxiosError===!0}function yt(e){const t=new ue(e),n=qe(ue.prototype.request,t);return u.extend(n,ue.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yt(H(e,s))},n}const O=yt(Oe);O.Axios=ue,O.CanceledError=X,O.CancelToken=Bn,O.isCancel=lt,O.VERSION=mt,O.toFormData=ne,O.AxiosError=y,O.Cancel=O.CanceledError,O.all=function(t){return Promise.all(t)},O.spread=Ln,O.isAxiosError=jn,O.mergeConfig=H,O.AxiosHeaders=F,O.formToJSON=e=>at(u.isHTMLForm(e)?new FormData(e):e),O.default=O;const Hn=O,ur="";function Mn(e){let t,n,r,s,o,i=`${e[4]}%`;function c(f,h){return f[6]?zn:Jn}let d=c(e),a=d(e),l=e[7]&&Et();return{c(){t=T("div"),n=T("div"),a.c(),r=z(),l&&l.c(),s=z(),o=T("div"),w(n,"class","percentage-text svelte-75w3tp"),w(o,"id","percentage-bar"),w(o,"class","svelte-75w3tp"),Q(o,"width",i),w(t,"id","percentage"),w(t,"class","svelte-75w3tp")},m(f,h){N(f,t,h),R(t,n),a.m(n,null),R(n,r),l&&l.m(n,null),R(t,s),R(t,o)},p(f,h){d===(d=c(f))&&a?a.p(f,h):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[7]?l||(l=Et(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),h&16&&i!==(i=`${f[4]}%`)&&Q(o,"width",i)},d(f){f&&A(t),a.d(),l&&l.d()}}}function In(e){let t;function n(o,i){return o[2]?vn:qn}let r=n(e),s=r(e);return{c(){s.c(),t=De()},m(o,i){s.m(o,i),N(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&A(t)}}}function zn(e){let t;return{c(){t=D("Waiting for data schema detection...")},m(n,r){N(n,t,r)},p:C,d(n){n&&A(t)}}}function Jn(e){let t,n=!e[7]&&bt(e);return{c(){n&&n.c(),t=De()},m(r,s){n&&n.m(r,s),N(r,t,s)},p(r,s){r[7]?n&&(n.d(1),n=null):n?n.p(r,s):(n=bt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&A(t)}}}function bt(e){let t,n;return{c(){t=D(e[4]),n=D("%")},m(r,s){N(r,t,s),N(r,n,s)},p(r,s){s&16&&St(t,r[4])},d(r){r&&A(t),r&&A(n)}}}function Et(e){let t;return{c(){t=D("File uploaded")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function qn(e){let t;return{c(){t=D("Select a file to upload")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function vn(e){let t;return{c(){t=D("Select a file to replace the current one")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function Vn(e){let t,n,r,s,o,i,c,d,a,l,f,h,_;function p(b,g){return!b[5]&&!b[6]&&!b[7]?In:Mn}let m=p(e),E=m(e);return{c(){t=T("div"),n=T("div"),r=T("div"),E.c(),s=z(),o=T("input"),i=z(),c=T("div"),d=T("label"),d.textContent="URL",a=z(),l=T("div"),f=T("input"),w(r,"id","widget-label"),w(r,"class","svelte-75w3tp"),w(o,"id","fileUpload"),w(o,"type","file"),w(o,"class","svelte-75w3tp"),w(n,"id","fileUploadWidget"),w(n,"class","svelte-75w3tp"),w(d,"class","control-label"),w(d,"for","field_url"),w(f,"id","field_url"),w(f,"class","form-control"),w(f,"type","text"),w(f,"name","url"),w(l,"class","controls"),Q(c,"display",e[1]!="upload"?"inline":"none"),w(c,"class","controls"),w(t,"class","form-group")},m(b,g){N(b,t,g),R(t,n),R(n,r),E.m(r,null),R(n,s),R(n,o),R(t,i),R(t,c),R(c,d),R(c,a),R(c,l),R(l,f),Ue(f,e[0]),h||(_=[le(o,"change",e[12]),le(o,"change",e[8]),le(f,"input",e[13])],h=!0)},p(b,[g]){m===(m=p(b))&&E?E.p(b,g):(E.d(1),E=m(b),E&&(E.c(),E.m(r,null))),g&1&&f.value!==b[0]&&Ue(f,b[0]),g&2&&Q(c,"display",b[1]!="upload"?"inline":"none")},i:C,o:C,d(b){b&&A(t),E.d(),h=!1,I(_)}}}function Wn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:c}=t,{url_type:d=""}=t,a,l=0,f=!1,h=!1,_=!1,p=Be(),m=i?"update":"create";async function E(S,G){try{const x={onUploadProgress:Zn=>{const{loaded:$n,total:er}=Zn,Pe=Math.floor($n*100/er);Pe<=100&&(G(Pe),Pe==100&&(n(5,f=!1),n(6,h=!0)))}},ce=m=="update"?`${r}/dataset/${s}/resource/${o}/file`:`${r}/dataset/${s}/resource/file`,{data:Ce}=await Hn.post(ce,S,x);return Ce}catch(x){console.log("ERROR",x.message)}}function b(S){n(4,l=S)}async function g(S){try{const G=S.target.files[0],x=new FormData;x.append("upload",G),x.append("package_id",s),i&&(x.append("id",o),x.append("clear_upload",!0),x.append("url_type",d)),n(5,f=!0);let ce=await E(x,b),Ce={data:ce};n(0,c=ce.url),n(1,d="upload"),p("fileUploaded",Ce),n(6,h=!1),n(7,_=!0)}catch(G){console.log("ERROR",G),b(0)}}function M(){a=this.files,n(3,a)}function Ne(){c=this.value,n(0,c)}return e.$$set=S=>{"upload_url"in S&&n(9,r=S.upload_url),"dataset_id"in S&&n(10,s=S.dataset_id),"resource_id"in S&&n(11,o=S.resource_id),"update"in S&&n(2,i=S.update),"current_url"in S&&n(0,c=S.current_url),"url_type"in S&&n(1,d=S.url_type)},[c,d,i,a,l,f,h,_,g,r,s,o,M,Ne]}class Kn extends Je{constructor(t){super(),ze(this,t,Wn,Vn,Fe,{upload_url:9,dataset_id:10,resource_id:11,update:2,current_url:0,url_type:1})}}function Xn(e){let t,n,r;return n=new Kn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=T("main"),xt(n.$$.fragment)},m(s,o){N(s,t,o),Me(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(He(n.$$.fragment,s),r=!0)},o(s){Pt(n.$$.fragment,s),r=!1},d(s){s&&A(t),Ie(n),e[8](null)}}}function Gn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:c}=t,{url_type:d}=t;Be();let a;function l(h){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:h.detail.data}))}function f(h){fe[h?"unshift":"push"](()=>{a=h,n(6,a)})}return e.$$set=h=>{"upload_url"in h&&n(0,r=h.upload_url),"dataset_id"in h&&n(1,s=h.dataset_id),"resource_id"in h&&n(2,o=h.resource_id),"update"in h&&n(3,i=h.update),"current_url"in h&&n(4,c=h.current_url),"url_type"in h&&n(5,d=h.url_type)},[r,s,o,i,c,d,a,l,f]}class Qn extends Je{constructor(t){super(),ze(this,t,Gn,Xn,Fe,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function Yn(e,t="",n="",r="",s="",o="",i=""){new Qn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return Yn}); diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js index 40e37cdf..3d21274e 100644 --- a/ckanext/validation/webassets/js/module-ckan-uploader.js +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -10,7 +10,6 @@ ckan.module('ckan-uploader', function (jQuery) { }, afterUpload: (resource_id) => (evt) => { let resource = evt.detail - let resource_id = resource.id // Next step set automatically some fields (name based on // the filename, mime type and the ckanext-validation schema @@ -101,8 +100,6 @@ ckan.module('ckan-uploader', function (jQuery) { let url_type = document.getElementById('url_type').value let update = document.getElementById('update').value - console.log(resource_id, dataset_id, update, 'DEBUG') - // Add the upload widget CkanUploader('ckan_uploader', this.options.upload_url, From 547c5ac532d230fc6fef570ac870c446252161f7 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Wed, 1 Feb 2023 14:54:11 +0100 Subject: [PATCH 22/43] Correct default return values for helpers Otherwise there will be unexpected 'None' inside the template --- ckanext/validation/helpers.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ckanext/validation/helpers.py b/ckanext/validation/helpers.py index 33eeb30e..9290ad13 100644 --- a/ckanext/validation/helpers.py +++ b/ckanext/validation/helpers.py @@ -101,11 +101,28 @@ def get_package_id_from_resource_url(): match = re.match("/dataset/(.*)/resource/", request.path) if match: return model.Package.get(match.group(1)).id + else: + return '' def get_resource_id_from_resource_url(): match = re.match("/dataset/(.*)/resource/(.*)/edit", request.path) if match: return model.Resource.get(match.group(2)).id + else: + return '' + +def get_url_type(): + match = re.match("/dataset/(.*)/resource/(.*)/edit", request.path) + if match: + return model.Resource.get(match.group(2)).url_type + +def get_current_url(): + match = re.match("/dataset/(.*)/resource/(.*)/edit", request.path) + if match: + return model.Resource.get(match.group(2)).url + else: + return '' + def use_webassets(): return int(h.ckan_version().split('.')[1]) >= 9 From 5fb0ec0ab9e8691eb083cce0762fa9a0bc2edb34 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Wed, 1 Feb 2023 14:57:50 +0100 Subject: [PATCH 23/43] Get initialization variables for ckan-uploade its template. Remove the logic where the ckan-uploader variables where being passed using hidden input elements. --- .../validation/webassets/js/module-ckan-uploader.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ckanext/validation/webassets/js/module-ckan-uploader.js b/ckanext/validation/webassets/js/module-ckan-uploader.js index 3d21274e..9e85d61c 100644 --- a/ckanext/validation/webassets/js/module-ckan-uploader.js +++ b/ckanext/validation/webassets/js/module-ckan-uploader.js @@ -7,6 +7,8 @@ ckan.module('ckan-uploader', function (jQuery) { resource_id: '', // The CKAN instance base URL upload_url: '', + url_type: '', + current_url: '', }, afterUpload: (resource_id) => (evt) => { let resource = evt.detail @@ -18,7 +20,7 @@ ckan.module('ckan-uploader', function (jQuery) { // Set `name` field let field_name = document.getElementById('field-name') - let url_parts = resource.url.split('/') + let url_parts = resource['url'].split('/') let resource_name = url_parts[url_parts.length - 1] field_name.value = resource_name @@ -94,11 +96,13 @@ ckan.module('ckan-uploader', function (jQuery) { }, initialize: function() { + let resource_form = document.getElementById("resource-edit") + let resource_id = this.options.resource_id let dataset_id = this.options.dataset_id - let current_url = document.getElementById('current_url').value - let url_type = document.getElementById('url_type').value - let update = document.getElementById('update').value + let current_url = (typeof this.options.current_url == "boolean") ? '' : this.options.current_url + let url_type = this.options.url_type + let update = (resource_form.action.endsWith('edit'))? true : '' // Add the upload widget CkanUploader('ckan_uploader', From 8ac15f19aa8e54601570ed82c05c33198957cc11 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Wed, 1 Feb 2023 15:00:28 +0100 Subject: [PATCH 24/43] Remove custom resource_form.html template. Now we use the default one and customize only ckan_uploader.html field widget. --- .../package/snippets/resource_form.html | 91 ------------------- 1 file changed, 91 deletions(-) delete mode 100644 ckanext/validation/templates/package/snippets/resource_form.html diff --git a/ckanext/validation/templates/package/snippets/resource_form.html b/ckanext/validation/templates/package/snippets/resource_form.html deleted file mode 100644 index c89f0205..00000000 --- a/ckanext/validation/templates/package/snippets/resource_form.html +++ /dev/null @@ -1,91 +0,0 @@ -{% import 'macros/form.html' as form %} - -{% set data = data or {} %} -{% set errors = errors or {} %} -{% set action = form_action or h.url_for(dataset_type ~ '_resource.new', id=pkg_name) %} -{% asset 'ckanext-validation/ckan-uploader-js' %} -{% asset 'ckanext-validation/ckan-uploader-css' %} - -
- - {% block stages %} - {# An empty stages variable will not show the stages #} - {% if stage %} - {{ h.snippet('package/snippets/stages.html', stages=stage, pkg_name=pkg_name) }} - {% endif %} - {% endblock %} - - {% block errors %}{{ form.errors(error_summary) }}{% endblock %} - - {% block basic_fields %} - {% block basic_fields_url %} - {% endblock %} - - {% block basic_fields_name %} - {{ form.input('name', id='field-name', label=_('Name'), placeholder=_('eg. January 2011 Gold Prices'), value=data.name, error=errors.name, classes=['control-full']) }} - {% endblock %} - - {% block basic_fields_description %} - {{ form.markdown('description', id='field-description', label=_('Description'), placeholder=_('Some useful notes about the data'), value=data.description, error=errors.description) }} - {% endblock %} - - {% block basic_fields_format %} - {% set format_attrs = {'data-module': 'autocomplete', 'data-module-source': '/api/2/util/resource/format_autocomplete?incomplete=?'} %} - {% call form.input('format', id='field-format', label=_('Format'), placeholder=_('eg. CSV, XML or JSON'), value=data.format, error=errors.format, classes=['control-medium'], attrs=format_attrs) %} - - - {{ _('This will be guessed automatically. Leave blank if you wish') }} - - {% endcall %} - {% endblock %} - {% endblock basic_fields %} - - {% block metadata_fields %} - {% if include_metadata %} - {# TODO: Where do these come from, they don't exist in /package/new_package_form.html #} - {# {{ form.select('resource_type', id='field-type', label=_('Resource Type'), options=[{'value': 'empty', 'text': _('Select a type…')}], selected="empty", error=errors.type) }} #} - - {{ form.input('last_modified', id='field-last-modified', label=_('Last Modified'), placeholder=_('eg. 2012-06-05'), value=data.last_modified, error=errors.last_modified, classes=[]) }} - - {{ form.input('size', id='field-size', label=_('File Size'), placeholder=_('eg. 1024'), value=data.size, error=errors.size, classes=[]) }} - - {{ form.input('mimetype', id='field-mimetype', label=_('MIME Type'), placeholder=_('eg. application/json'), value=data.mimetype, error=errors.mimetype, classes=[]) }} - - {{ form.input('mimetype_inner', id='field-mimetype-inner', label=_('MIME Type'), placeholder=_('eg. application/json'), value=data.mimetype_inner, error=errors.mimetype_inner, classes=[]) }} - {% endif %} - {% endblock %} - -
- - - - - - - - {% block delete_button %} - {% if data.id %} - {% if h.check_access('resource_delete', {'id': data.id}) %} - {% block delete_button_text %}{{ _('Delete') }}{% endblock %} - {% endif %} - {% endif %} - {% endblock %} - {% if stage %} - {% block previous_button %} - - {% endblock %} - {% endif %} - {% block again_button %} - - {% endblock %} - {% if stage %} - {% block save_button %} - - {% endblock %} - {% else %} - {% block add_button %} - - {% endblock %} - {% endif %} -
-
From bfd400a726822a06add9253e0bd8c307f46cbf28 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Wed, 1 Feb 2023 15:02:11 +0100 Subject: [PATCH 25/43] Get the schema from the returned schema from the action 'resource_table_schema_infer' Now the resource_create and resource_update will not infer the schema. We need to use the action 'resource_table_schema' and add it to the resource. --- ckanext/validation/blueprints.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ckanext/validation/blueprints.py b/ckanext/validation/blueprints.py index c3da77f1..1f7d35aa 100644 --- a/ckanext/validation/blueprints.py +++ b/ckanext/validation/blueprints.py @@ -79,9 +79,10 @@ def resource_file_create(id): # If it's tabular (local OR remote), infer and store schema if is_tabular(filename=resource['url']): - update_resource = get_action('resource_table_schema_infer')( + update_resource_schema = get_action('resource_table_schema_infer')( context, {'resource_id': resource['id'], 'store_schema': True} ) + resource['schema'] = update_resource_schema['schema'] # Return resource return resource @@ -101,9 +102,10 @@ def resource_file_update(id, resource_id): # If it's tabular (local OR remote), infer and store schema if is_tabular(resource['url']): resource_id = resource['id'] - update_resource = get_action('resource_table_schema_infer')( + update_resource_schema = get_action('resource_table_schema_infer')( context, {'resource_id': resource_id, 'store_schema': True} ) + resource['schema'] = update_resource_schema['schema'] # Return resource return resource From 036262e4b9eb2973c447006602347eba8123ef7d Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Wed, 1 Feb 2023 15:04:23 +0100 Subject: [PATCH 26/43] Stop infering the schema as default in resource create and update --- ckanext/validation/logic.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ckanext/validation/logic.py b/ckanext/validation/logic.py index 22b06d1f..f3972add 100644 --- a/ckanext/validation/logic.py +++ b/ckanext/validation/logic.py @@ -567,10 +567,10 @@ def resource_create(up_func, context, data_dict): model.repo.commit() - if upload.filename and is_tabular(filename=upload.filename): - update_resource = t.get_action('resource_table_schema_infer')( - context, {'resource_id': resource_id, 'store_schema': True} - ) + #if upload.filename and is_tabular(filename=upload.filename): + # update_resource = t.get_action('resource_table_schema_infer')( + # context, {'resource_id': resource_id, 'store_schema': True} + # ) # Run package show again to get out actual last_resource updated_pkg_dict = t.get_action('package_show')( @@ -672,10 +672,10 @@ def resource_update(up_func, context, data_dict): resource = updated_pkg_dict['resources'][-1] upload.upload(id, uploader.get_max_resource_size()) - if upload.filename and is_tabular(filename=upload.filename): - update_resource = t.get_action('resource_table_schema_infer')( - context, {'resource_id': resource['id'], 'store_schema': True} - ) + #if upload.filename and is_tabular(filename=upload.filename): + # update_resource = t.get_action('resource_table_schema_infer')( + # context, {'resource_id': resource['id'], 'store_schema': True} + # ) # Run package show again to get out actual last_resource updated_pkg_dict = t.get_action('package_show')( From 25e39adda54fe0ff37510082297b4b1742f992f9 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Wed, 1 Feb 2023 15:04:59 +0100 Subject: [PATCH 27/43] Add helpers that are used by ckan_uploader.html template --- ckanext/validation/plugin/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index fd4a7d7e..aec0542d 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -29,6 +29,8 @@ use_webassets, get_package_id_from_resource_url, get_resource_id_from_resource_url, + get_url_type, + get_current_url ) from ckanext.validation.validators import ( resource_schema_validator, @@ -121,6 +123,8 @@ def get_helpers(self): 'use_webassets': use_webassets, 'get_package_id_from_resource_url': get_package_id_from_resource_url, 'get_resource_id_from_resource_url': get_resource_id_from_resource_url, + 'get_url_type': get_url_type, + 'get_current_url': get_current_url, } # IResourceController From 93e195613984b0f14e5cbe046435c5695e1c0785 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Wed, 1 Feb 2023 15:06:12 +0100 Subject: [PATCH 28/43] Fix template for ckan_uploader adding correctly the variables intial values --- .../templates/scheming/form_snippets/ckan_uploader.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html index c1754d29..95fbfaa9 100644 --- a/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html +++ b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html @@ -1,9 +1,15 @@ {% set package_id = data.package_id or h.get_package_id_from_resource_url() %} {% set resource_id = data.resource_id or h.get_resource_id_from_resource_url() %} +{% set url_type = h.get_url_type() %} +{% set current_url = h.get_current_url() %} +{% asset 'ckanext-validation/ckan-uploader-js' %} +{% asset 'ckanext-validation/ckan-uploader-css' %} + +
-
+
From 431beeb6fc0409f6e548a65f1518e03077163ce5 Mon Sep 17 00:00:00 2001 From: "Edgar Z. Alvarenga" Date: Mon, 6 Feb 2023 11:34:41 +0100 Subject: [PATCH 29/43] shorter form to compare schema_url value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adrià Mercader --- ckanext/validation/plugin/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index aec0542d..f785862b 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -156,7 +156,7 @@ def _process_schema_fields(self, data_dict): if isinstance(data_dict["schema"], (bytes, bytearray)): data_dict["schema"] = data_dict["schema"].decode() - elif schema_url != '' and schema_url != None: + elif schema_url not in ('', None): if (not isinstance(schema_url, str) or not schema_url.lower()[:4] == u'http'): raise t.ValidationError({u'schema_url': 'Must be a valid URL'}) From 63d8bcda4860cf00bd20e2b9f926b8e2b6cfe5c3 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Wed, 8 Feb 2023 17:07:35 +0100 Subject: [PATCH 30/43] add logic to switch between file upload and resource url --- ckanext/validation/helpers.py | 7 +++++++ ckanext/validation/logic.py | 6 +++--- ckanext/validation/plugin/__init__.py | 2 ++ .../templates/scheming/form_snippets/ckan_uploader.html | 4 ++-- ckanext/validation/webassets/css/ckan-uploader.css | 2 +- ckanext/validation/webassets/js/ckan-uploader.js | 6 +++--- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ckanext/validation/helpers.py b/ckanext/validation/helpers.py index 9290ad13..85eaa94e 100644 --- a/ckanext/validation/helpers.py +++ b/ckanext/validation/helpers.py @@ -104,6 +104,13 @@ def get_package_id_from_resource_url(): else: return '' +def get_resource_from_resource_url(): + match = re.match("/dataset/(.*)/resource/(.*)/edit", request.path) + if match: + return model.Resource.get(match.group(2)) + else: + return None + def get_resource_id_from_resource_url(): match = re.match("/dataset/(.*)/resource/(.*)/edit", request.path) if match: diff --git a/ckanext/validation/logic.py b/ckanext/validation/logic.py index f3972add..2078f6e5 100644 --- a/ckanext/validation/logic.py +++ b/ckanext/validation/logic.py @@ -651,13 +651,13 @@ def resource_update(up_func, context, data_dict): if upload.filename: data_dict['format'] = upload.filename.split('.')[-1] - if 'size' not in data_dict and 'url_type' in data_dict or hasattr(upload, 'filesize'): + #if 'size' not in data_dict and 'url_type' in data_dict: + # data_dict['size'] = 0 + if hasattr(upload, 'filesize'): data_dict['size'] = upload.filesize pkg_dict['resources'][n] = data_dict - - try: context['defer_commit'] = True context['use_cache'] = False diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index aec0542d..d87c7d21 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -29,6 +29,7 @@ use_webassets, get_package_id_from_resource_url, get_resource_id_from_resource_url, + get_resource_from_resource_url, get_url_type, get_current_url ) @@ -123,6 +124,7 @@ def get_helpers(self): 'use_webassets': use_webassets, 'get_package_id_from_resource_url': get_package_id_from_resource_url, 'get_resource_id_from_resource_url': get_resource_id_from_resource_url, + 'get_resource_from_resource_url': get_resource_from_resource_url, 'get_url_type': get_url_type, 'get_current_url': get_current_url, } diff --git a/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html index 95fbfaa9..8c8b921e 100644 --- a/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html +++ b/ckanext/validation/templates/scheming/form_snippets/ckan_uploader.html @@ -1,5 +1,6 @@ {% set package_id = data.package_id or h.get_package_id_from_resource_url() %} {% set resource_id = data.resource_id or h.get_resource_id_from_resource_url() %} +{% set resource = data.resource or h.get_resource_from_resource_url() %} {% set url_type = h.get_url_type() %} {% set current_url = h.get_current_url() %} @@ -7,9 +8,8 @@ {% asset 'ckanext-validation/ckan-uploader-css' %} -
- +
diff --git a/ckanext/validation/webassets/css/ckan-uploader.css b/ckanext/validation/webassets/css/ckan-uploader.css index 5b3d1934..7838453a 100644 --- a/ckanext/validation/webassets/css/ckan-uploader.css +++ b/ckanext/validation/webassets/css/ckan-uploader.css @@ -1 +1 @@ -#fileUploadWidget.svelte-75w3tp.svelte-75w3tp{position:relative;display:flex;max-width:400px;border:2px solid #0c4a6e;border-radius:4px;background-color:#164959;margin-bottom:10px}#fileUploadWidget.svelte-75w3tp #widget-label.svelte-75w3tp{width:100%;height:100%;color:#fff;justify-content:center;display:flex}#percentage.svelte-75w3tp.svelte-75w3tp{width:100%;height:100%;align:middle;justify-content:center;display:flex;position:relative}.percentage-text.svelte-75w3tp.svelte-75w3tp{z-index:20}#percentage-bar.svelte-75w3tp.svelte-75w3tp{z-index:10;position:absolute;top:0;left:0;bottom:0;transition:width .3s;transition-timing-function:ease-in}#fileUpload.svelte-75w3tp.svelte-75w3tp{position:absolute;width:100%;height:100%;top:0;left:0;opacity:0} +#resourceURL.svelte-1f4196f.svelte-1f4196f{margin-top:10px}#fileUploadWidget.svelte-1f4196f.svelte-1f4196f{position:relative;display:flex;max-width:400px;border:2px solid #0c4a6e;border-radius:4px;margin-top:10px;background-color:#164959;margin-bottom:10px}#fileUploadWidget.svelte-1f4196f #widget-label.svelte-1f4196f{width:100%;height:100%;color:#fff;justify-content:center;display:flex}#percentage.svelte-1f4196f.svelte-1f4196f{width:100%;height:100%;align:middle;justify-content:center;display:flex;position:relative}.percentage-text.svelte-1f4196f.svelte-1f4196f{z-index:20}#percentage-bar.svelte-1f4196f.svelte-1f4196f{z-index:10;position:absolute;top:0;left:0;bottom:0;transition:width .3s;transition-timing-function:ease-in;background-color:#ffffff54}#fileUpload.svelte-1f4196f.svelte-1f4196f{position:absolute;width:100%;height:100%;top:0;left:0;opacity:0} diff --git a/ckanext/validation/webassets/js/ckan-uploader.js b/ckanext/validation/webassets/js/ckan-uploader.js index 5f84c293..1b0c944a 100644 --- a/ckanext/validation/webassets/js/ckan-uploader.js +++ b/ckanext/validation/webassets/js/ckan-uploader.js @@ -1,3 +1,3 @@ -(function(C,L){typeof exports=="object"&&typeof module<"u"?module.exports=L():typeof define=="function"&&define.amd?define(L):(C=typeof globalThis<"u"?globalThis:C||self,C.CkanUploader=L())})(this,function(){"use strict";function C(){}function L(e){return e()}function xe(){return Object.create(null)}function I(e){e.forEach(L)}function ke(e){return typeof e=="function"}function Fe(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function wt(e){return Object.keys(e).length===0}function R(e,t){e.appendChild(t)}function N(e,t,n){e.insertBefore(t,n||null)}function A(e){e.parentNode&&e.parentNode.removeChild(e)}function T(e){return document.createElement(e)}function D(e){return document.createTextNode(e)}function z(){return D(" ")}function De(){return D("")}function le(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function w(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Ot(e){return Array.from(e.childNodes)}function St(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Ue(e,t){e.value=t==null?"":t}function Q(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function gt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Rt(){if(!J)throw new Error("Function called outside component initialization");return J}function Be(){const e=Rt();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=gt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const v=[],fe=[],Y=[],Le=[],At=Promise.resolve();let de=!1;function Tt(){de||(de=!0,At.then(je))}function pe(e){Y.push(e)}const he=new Set;let Z=0;function je(){const e=J;do{for(;Z{$.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function xt(e){e&&e.c()}function Me(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||pe(()=>{const i=e.$$.on_mount.map(L).filter(ke);e.$$.on_destroy?e.$$.on_destroy.push(...i):I(i),e.$$.on_mount=[]}),o.forEach(pe)}function Ie(e,t){const n=e.$$;n.fragment!==null&&(I(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function kt(e,t){e.$$.dirty[0]===-1&&(v.push(e),Tt(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=_.length?_[0]:h;return a.ctx&&s(a.ctx[f],a.ctx[f]=p)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](p),l&&kt(e,f)),h}):[],a.update(),l=!0,I(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Ot(t.target);a.fragment&&a.fragment.l(f),f.forEach(A)}else a.fragment&&a.fragment.c();t.intro&&He(e.$$.fragment),Me(e,t.target,t.anchor,t.customElement),je()}q(d)}class Je{$destroy(){Ie(this,1),this.$destroy=C}$on(t,n){if(!ke(n))return C;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!wt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function qe(e,t){return function(){return e.apply(t,arguments)}}const{toString:ve}=Object.prototype,{getPrototypeOf:me}=Object,_e=(e=>t=>{const n=ve.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),k=e=>(e=e.toLowerCase(),t=>_e(t)===e),ee=e=>t=>typeof t===e,{isArray:j}=Array,V=ee("undefined");function Ft(e){return e!==null&&!V(e)&&e.constructor!==null&&!V(e.constructor)&&B(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ve=k("ArrayBuffer");function Dt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ve(e.buffer),t}const Ut=ee("string"),B=ee("function"),We=ee("number"),ye=e=>e!==null&&typeof e=="object",Bt=e=>e===!0||e===!1,te=e=>{if(_e(e)!=="object")return!1;const t=me(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Lt=k("Date"),jt=k("File"),Ht=k("Blob"),Mt=k("FileList"),It=e=>ye(e)&&B(e.pipe),zt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||ve.call(e)===t||B(e.toString)&&e.toString()===t)},Jt=k("URLSearchParams"),qt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function W(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),j(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Xe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ge=e=>!V(e)&&e!==Xe;function be(){const{caseless:e}=Ge(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ke(t,s)||s;te(t[o])&&te(r)?t[o]=be(t[o],r):te(r)?t[o]=be({},r):j(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(W(t,(s,o)=>{n&&B(s)?e[o]=qe(s,n):e[o]=s},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Wt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Kt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&me(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Xt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Gt=e=>{if(!e)return null;if(j(e))return e;let t=e.length;if(!We(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Qt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&me(Uint8Array)),Yt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},Zt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},$t=k("HTMLFormElement"),en=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Qe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),tn=k("RegExp"),Ye=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};W(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},u={isArray:j,isArrayBuffer:Ve,isBuffer:Ft,isFormData:zt,isArrayBufferView:Dt,isString:Ut,isNumber:We,isBoolean:Bt,isObject:ye,isPlainObject:te,isUndefined:V,isDate:Lt,isFile:jt,isBlob:Ht,isRegExp:tn,isFunction:B,isStream:It,isURLSearchParams:Jt,isTypedArray:Qt,isFileList:Mt,forEach:W,merge:be,extend:vt,trim:qt,stripBOM:Vt,inherits:Wt,toFlatObject:Kt,kindOf:_e,kindOfTest:k,endsWith:Xt,toArray:Gt,forEachEntry:Yt,matchAll:Zt,isHTMLForm:$t,hasOwnProperty:Qe,hasOwnProp:Qe,reduceDescriptors:Ye,freezeMethods:e=>{Ye(e,(t,n)=>{if(B(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!B(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return j(e)?r(e):r(String(e).split(t)),n},toCamelCase:en,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ke,global:Xe,isContextDefined:Ge,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(ye(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=j(r)?[]:{};return W(r,(i,c)=>{const d=n(i,s+1);!V(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function y(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}u.inherits(y,Error,{toJSON:function(){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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ze=y.prototype,$e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{$e[e]={value:e}}),Object.defineProperties(y,$e),Object.defineProperty(Ze,"isAxiosError",{value:!0}),y.from=(e,t,n,r,s,o)=>{const i=Object.create(Ze);return u.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),y.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var nn=typeof self=="object"?self.FormData:window.FormData;const rn=nn;function Ee(e){return u.isPlainObject(e)||u.isArray(e)}function et(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,n){return e?e.concat(t).map(function(s,o){return s=et(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function sn(e){return u.isArray(e)&&!e.some(Ee)}const on=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function an(e){return e&&u.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function ne(e,t,n){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new(rn||FormData),n=u.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,E){return!u.isUndefined(E[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&an(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function a(p){if(p===null)return"";if(u.isDate(p))return p.toISOString();if(!d&&u.isBlob(p))throw new y("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(p)||u.isTypedArray(p)?d&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function l(p,m,E){let b=p;if(p&&!E&&typeof p=="object"){if(u.endsWith(m,"{}"))m=r?m:m.slice(0,-2),p=JSON.stringify(p);else if(u.isArray(p)&&sn(p)||u.isFileList(p)||u.endsWith(m,"[]")&&(b=u.toArray(p)))return m=et(m),b.forEach(function(M,Ne){!(u.isUndefined(M)||M===null)&&t.append(i===!0?tt([m],Ne,o):i===null?m:m+"[]",a(M))}),!1}return Ee(p)?!0:(t.append(tt(E,m,o),a(p)),!1)}const f=[],h=Object.assign(on,{defaultVisitor:l,convertValue:a,isVisitable:Ee});function _(p,m){if(!u.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(p),u.forEach(p,function(b,g){(!(u.isUndefined(b)||b===null)&&s.call(t,b,u.isString(g)?g.trim():g,m,h))===!0&&_(b,m?m.concat(g):[g])}),f.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return _(e),t}function nt(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function we(e,t){this._pairs=[],e&&ne(e,this,t)}const rt=we.prototype;rt.append=function(t,n){this._pairs.push([t,n])},rt.toString=function(t){const n=t?function(r){return t.call(this,r,nt)}:nt;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function un(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function st(e,t,n){if(!t)return e;const r=n&&n.encode||un,s=n&&n.serialize;let o;if(s?o=s(t,n):o=u.isURLSearchParams(t)?t.toString():new we(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class cn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){u.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ot=cn,it={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ln=typeof URLSearchParams<"u"?URLSearchParams:we,fn=FormData,dn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),pn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),P={isBrowser:!0,classes:{URLSearchParams:ln,FormData:fn,Blob},isStandardBrowserEnv:dn,isStandardBrowserWebWorkerEnv:pn,protocols:["http","https","file","blob","url","data"]};function hn(e,t){return ne(e,new P.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return P.isNode&&u.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function mn(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function _n(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&u.isArray(s)?s.length:i,d?(u.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!u.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&u.isArray(s[i])&&(s[i]=_n(s[i])),!c)}if(u.isFormData(e)&&u.isFunction(e.entries)){const n={};return u.forEachEntry(e,(r,s)=>{t(mn(r),s,n,0)}),n}return null}const yn={"Content-Type":void 0};function bn(e,t,n){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const re={transitional:it,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=u.isObject(t);if(o&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(at(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return hn(t,this.formSerializer).toString();if((c=u.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return ne(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),bn(t)):t}],transformResponse:[function(t){const n=this.transitional||re.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&u.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:P.classes.FormData,Blob:P.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};u.forEach(["delete","get","head"],function(t){re.headers[t]={}}),u.forEach(["post","put","patch"],function(t){re.headers[t]=u.merge(yn)});const Oe=re,En=u.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"]),wn=e=>{const t={};let n,r,s;return e&&e.split(` -`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&En[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ut=Symbol("internals");function K(e){return e&&String(e).trim().toLowerCase()}function se(e){return e===!1||e==null?e:u.isArray(e)?e.map(se):String(e)}function On(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}function Sn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ct(e,t,n,r){if(u.isFunction(r))return r.call(this,t,n);if(!!u.isString(t)){if(u.isString(r))return t.indexOf(r)!==-1;if(u.isRegExp(r))return r.test(t)}}function gn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Rn(e,t){const n=u.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class oe{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,a){const l=K(d);if(!l)throw new Error("header name must be a non-empty string");const f=u.findKey(s,l);(!f||s[f]===void 0||a===!0||a===void 0&&s[f]!==!1)&&(s[f||d]=se(c))}const i=(c,d)=>u.forEach(c,(a,l)=>o(a,l,d));return u.isPlainObject(t)||t instanceof this.constructor?i(t,n):u.isString(t)&&(t=t.trim())&&!Sn(t)?i(wn(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=K(t),t){const r=u.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return On(s);if(u.isFunction(n))return n.call(this,s,r);if(u.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=K(t),t){const r=u.findKey(this,t);return!!(r&&(!n||ct(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=K(i),i){const c=u.findKey(r,i);c&&(!n||ct(r,r[c],c,n))&&(delete r[c],s=!0)}}return u.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return u.forEach(this,(s,o)=>{const i=u.findKey(r,o);if(i){n[i]=se(s),delete n[o];return}const c=t?gn(o):String(o).trim();c!==o&&delete n[o],n[c]=se(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return u.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&u.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ut]=this[ut]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=K(i);r[c]||(Rn(s,i),r[c]=!0)}return u.isArray(t)?t.forEach(o):o(t),this}}oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),u.freezeMethods(oe.prototype),u.freezeMethods(oe);const F=oe;function Se(e,t){const n=this||Oe,r=t||n,s=F.from(r.headers);let o=r.data;return u.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function lt(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){y.call(this,e==null?"canceled":e,y.ERR_CANCELED,t,n),this.name="CanceledError"}u.inherits(X,y,{__CANCEL__:!0});const An=null;function Tn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Nn=P.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const d=[];d.push(n+"="+encodeURIComponent(r)),u.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),u.isString(o)&&d.push("path="+o),u.isString(i)&&d.push("domain="+i),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Cn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Pn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function ft(e,t){return e&&!Cn(t)?Pn(e,t):t}const xn=P.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=u.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function kn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Fn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),l=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,h=0;for(;f!==s;)h+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,d=r(c),a=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const ie={http:An,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=F.from(e.headers).normalize(),i=e.responseType;let c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}u.isFormData(s)&&(P.isStandardBrowserEnv||P.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const _=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(_+":"+p))}const l=ft(e.baseURL,e.url);a.open(e.method.toUpperCase(),st(l,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const _=F.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),m={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:_,config:e,request:a};Tn(function(b){n(b),d()},function(b){r(b),d()},m),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new y("Request aborted",y.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new y("Network Error",y.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const m=e.transitional||it;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),r(new y(p,m.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,a)),a=null},P.isStandardBrowserEnv){const _=(e.withCredentials||xn(l))&&e.xsrfCookieName&&Nn.read(e.xsrfCookieName);_&&o.set(e.xsrfHeaderName,_)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&u.forEach(o.toJSON(),function(p,m){a.setRequestHeader(m,p)}),u.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",dt(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",dt(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=_=>{!a||(r(!_||_.type?new X(null,e,a):_),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const h=kn(l);if(h&&P.protocols.indexOf(h)===-1){r(new y("Unsupported protocol "+h+":",y.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};u.forEach(ie,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Dn={getAdapter:e=>{e=u.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof F?e.toJSON():e;function H(e,t){t=t||{};const n={};function r(a,l,f){return u.isPlainObject(a)&&u.isPlainObject(l)?u.merge.call({caseless:f},a,l):u.isPlainObject(l)?u.merge({},l):u.isArray(l)?l.slice():l}function s(a,l,f){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a,f)}else return r(a,l,f)}function o(a,l){if(!u.isUndefined(l))return r(void 0,l)}function i(a,l){if(u.isUndefined(l)){if(!u.isUndefined(a))return r(void 0,a)}else return r(void 0,l)}function c(a,l,f){if(f in t)return r(a,l);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(a,l)=>s(ht(a),ht(l),!0)};return u.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const f=d[l]||s,h=f(e[l],t[l],l);u.isUndefined(h)&&f!==c||(n[l]=h)}),n}const mt="1.2.1",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _t={};Re.transitional=function(t,n,r){function s(o,i){return"[Axios v"+mt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new y(s(i," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!_t[i]&&(_t[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Un(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new y("option "+o+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+o,y.ERR_BAD_OPTION)}}const Ae={assertOptions:Un,validators:Re},U=Ae.validators;class ae{constructor(t){this.defaults=t,this.interceptors={request:new ot,response:new ot}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=H(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Ae.assertOptions(r,{silentJSONParsing:U.transitional(U.boolean),forcedJSONParsing:U.transitional(U.boolean),clarifyTimeoutError:U.transitional(U.boolean)},!1),s!==void 0&&Ae.assertOptions(s,{encode:U.function,serialize:U.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&u.merge(o.common,o[n.method]),i&&u.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=F.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const a=[];this.interceptors.response.forEach(function(m){a.push(m.fulfilled,m.rejected)});let l,f=0,h;if(!d){const p=[pt.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,a),h=p.length,l=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new X(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Te(function(s){t=s}),cancel:t}}}const Bn=Te;function Ln(e){return function(n){return e.apply(null,n)}}function jn(e){return u.isObject(e)&&e.isAxiosError===!0}function yt(e){const t=new ue(e),n=qe(ue.prototype.request,t);return u.extend(n,ue.prototype,t,{allOwnKeys:!0}),u.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return yt(H(e,s))},n}const O=yt(Oe);O.Axios=ue,O.CanceledError=X,O.CancelToken=Bn,O.isCancel=lt,O.VERSION=mt,O.toFormData=ne,O.AxiosError=y,O.Cancel=O.CanceledError,O.all=function(t){return Promise.all(t)},O.spread=Ln,O.isAxiosError=jn,O.mergeConfig=H,O.AxiosHeaders=F,O.formToJSON=e=>at(u.isHTMLForm(e)?new FormData(e):e),O.default=O;const Hn=O,ur="";function Mn(e){let t,n,r,s,o,i=`${e[4]}%`;function c(f,h){return f[6]?zn:Jn}let d=c(e),a=d(e),l=e[7]&&Et();return{c(){t=T("div"),n=T("div"),a.c(),r=z(),l&&l.c(),s=z(),o=T("div"),w(n,"class","percentage-text svelte-75w3tp"),w(o,"id","percentage-bar"),w(o,"class","svelte-75w3tp"),Q(o,"width",i),w(t,"id","percentage"),w(t,"class","svelte-75w3tp")},m(f,h){N(f,t,h),R(t,n),a.m(n,null),R(n,r),l&&l.m(n,null),R(t,s),R(t,o)},p(f,h){d===(d=c(f))&&a?a.p(f,h):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[7]?l||(l=Et(),l.c(),l.m(n,null)):l&&(l.d(1),l=null),h&16&&i!==(i=`${f[4]}%`)&&Q(o,"width",i)},d(f){f&&A(t),a.d(),l&&l.d()}}}function In(e){let t;function n(o,i){return o[2]?vn:qn}let r=n(e),s=r(e);return{c(){s.c(),t=De()},m(o,i){s.m(o,i),N(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&A(t)}}}function zn(e){let t;return{c(){t=D("Waiting for data schema detection...")},m(n,r){N(n,t,r)},p:C,d(n){n&&A(t)}}}function Jn(e){let t,n=!e[7]&&bt(e);return{c(){n&&n.c(),t=De()},m(r,s){n&&n.m(r,s),N(r,t,s)},p(r,s){r[7]?n&&(n.d(1),n=null):n?n.p(r,s):(n=bt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&A(t)}}}function bt(e){let t,n;return{c(){t=D(e[4]),n=D("%")},m(r,s){N(r,t,s),N(r,n,s)},p(r,s){s&16&&St(t,r[4])},d(r){r&&A(t),r&&A(n)}}}function Et(e){let t;return{c(){t=D("File uploaded")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function qn(e){let t;return{c(){t=D("Select a file to upload")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function vn(e){let t;return{c(){t=D("Select a file to replace the current one")},m(n,r){N(n,t,r)},d(n){n&&A(t)}}}function Vn(e){let t,n,r,s,o,i,c,d,a,l,f,h,_;function p(b,g){return!b[5]&&!b[6]&&!b[7]?In:Mn}let m=p(e),E=m(e);return{c(){t=T("div"),n=T("div"),r=T("div"),E.c(),s=z(),o=T("input"),i=z(),c=T("div"),d=T("label"),d.textContent="URL",a=z(),l=T("div"),f=T("input"),w(r,"id","widget-label"),w(r,"class","svelte-75w3tp"),w(o,"id","fileUpload"),w(o,"type","file"),w(o,"class","svelte-75w3tp"),w(n,"id","fileUploadWidget"),w(n,"class","svelte-75w3tp"),w(d,"class","control-label"),w(d,"for","field_url"),w(f,"id","field_url"),w(f,"class","form-control"),w(f,"type","text"),w(f,"name","url"),w(l,"class","controls"),Q(c,"display",e[1]!="upload"?"inline":"none"),w(c,"class","controls"),w(t,"class","form-group")},m(b,g){N(b,t,g),R(t,n),R(n,r),E.m(r,null),R(n,s),R(n,o),R(t,i),R(t,c),R(c,d),R(c,a),R(c,l),R(l,f),Ue(f,e[0]),h||(_=[le(o,"change",e[12]),le(o,"change",e[8]),le(f,"input",e[13])],h=!0)},p(b,[g]){m===(m=p(b))&&E?E.p(b,g):(E.d(1),E=m(b),E&&(E.c(),E.m(r,null))),g&1&&f.value!==b[0]&&Ue(f,b[0]),g&2&&Q(c,"display",b[1]!="upload"?"inline":"none")},i:C,o:C,d(b){b&&A(t),E.d(),h=!1,I(_)}}}function Wn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:c}=t,{url_type:d=""}=t,a,l=0,f=!1,h=!1,_=!1,p=Be(),m=i?"update":"create";async function E(S,G){try{const x={onUploadProgress:Zn=>{const{loaded:$n,total:er}=Zn,Pe=Math.floor($n*100/er);Pe<=100&&(G(Pe),Pe==100&&(n(5,f=!1),n(6,h=!0)))}},ce=m=="update"?`${r}/dataset/${s}/resource/${o}/file`:`${r}/dataset/${s}/resource/file`,{data:Ce}=await Hn.post(ce,S,x);return Ce}catch(x){console.log("ERROR",x.message)}}function b(S){n(4,l=S)}async function g(S){try{const G=S.target.files[0],x=new FormData;x.append("upload",G),x.append("package_id",s),i&&(x.append("id",o),x.append("clear_upload",!0),x.append("url_type",d)),n(5,f=!0);let ce=await E(x,b),Ce={data:ce};n(0,c=ce.url),n(1,d="upload"),p("fileUploaded",Ce),n(6,h=!1),n(7,_=!0)}catch(G){console.log("ERROR",G),b(0)}}function M(){a=this.files,n(3,a)}function Ne(){c=this.value,n(0,c)}return e.$$set=S=>{"upload_url"in S&&n(9,r=S.upload_url),"dataset_id"in S&&n(10,s=S.dataset_id),"resource_id"in S&&n(11,o=S.resource_id),"update"in S&&n(2,i=S.update),"current_url"in S&&n(0,c=S.current_url),"url_type"in S&&n(1,d=S.url_type)},[c,d,i,a,l,f,h,_,g,r,s,o,M,Ne]}class Kn extends Je{constructor(t){super(),ze(this,t,Wn,Vn,Fe,{upload_url:9,dataset_id:10,resource_id:11,update:2,current_url:0,url_type:1})}}function Xn(e){let t,n,r;return n=new Kn({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=T("main"),xt(n.$$.fragment)},m(s,o){N(s,t,o),Me(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(He(n.$$.fragment,s),r=!0)},o(s){Pt(n.$$.fragment,s),r=!1},d(s){s&&A(t),Ie(n),e[8](null)}}}function Gn(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:c}=t,{url_type:d}=t;Be();let a;function l(h){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:h.detail.data}))}function f(h){fe[h?"unshift":"push"](()=>{a=h,n(6,a)})}return e.$$set=h=>{"upload_url"in h&&n(0,r=h.upload_url),"dataset_id"in h&&n(1,s=h.dataset_id),"resource_id"in h&&n(2,o=h.resource_id),"update"in h&&n(3,i=h.update),"current_url"in h&&n(4,c=h.current_url),"url_type"in h&&n(5,d=h.url_type)},[r,s,o,i,c,d,a,l,f]}class Qn extends Je{constructor(t){super(),ze(this,t,Gn,Xn,Fe,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function Yn(e,t="",n="",r="",s="",o="",i=""){new Qn({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return Yn}); +(function(k,j){typeof exports=="object"&&typeof module<"u"?module.exports=j():typeof define=="function"&&define.amd?define(j):(k=typeof globalThis<"u"?globalThis:k||self,k.CkanUploader=j())})(this,function(){"use strict";function k(){}function j(e){return e()}function Ue(){return Object.create(null)}function H(e){e.forEach(j)}function Be(e){return typeof e=="function"}function Le(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function At(e){return Object.keys(e).length===0}function E(e,t){e.appendChild(t)}function A(e,t,n){e.insertBefore(t,n||null)}function S(e){e.parentNode&&e.parentNode.removeChild(e)}function O(e){return document.createElement(e)}function B(e){return document.createTextNode(e)}function F(){return B(" ")}function pe(){return B("")}function M(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function y(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Tt(e){return Array.from(e.childNodes)}function Nt(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Y(e,t){e.value=t==null?"":t}function xe(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function Z(e,t,n){e.classList[n?"add":"remove"](t)}function kt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Ct(){if(!J)throw new Error("Function called outside component initialization");return J}function je(){const e=Ct();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=kt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const V=[],he=[],$=[],He=[],Pt=Promise.resolve();let me=!1;function Ft(){me||(me=!0,Pt.then(Me))}function _e(e){$.push(e)}const ye=new Set;let ee=0;function Me(){const e=J;do{for(;ee{te.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Lt(e){e&&e.c()}function Ie(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||_e(()=>{const i=e.$$.on_mount.map(j).filter(Be);e.$$.on_destroy?e.$$.on_destroy.push(...i):H(i),e.$$.on_mount=[]}),o.forEach(_e)}function ze(e,t){const n=e.$$;n.fragment!==null&&(H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function xt(e,t){e.$$.dirty[0]===-1&&(V.push(e),Ft(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const h=m.length?m[0]:p;return a.ctx&&s(a.ctx[f],a.ctx[f]=h)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](h),c&&xt(e,f)),p}):[],a.update(),c=!0,H(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Tt(t.target);a.fragment&&a.fragment.l(f),f.forEach(S)}else a.fragment&&a.fragment.c();t.intro&&ve(e.$$.fragment),Ie(e,t.target,t.anchor,t.customElement),Me()}q(d)}class qe{$destroy(){ze(this,1),this.$destroy=k}$on(t,n){if(!Be(n))return k;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!At(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function Ve(e,t){return function(){return e.apply(t,arguments)}}const{toString:We}=Object.prototype,{getPrototypeOf:be}=Object,Ee=(e=>t=>{const n=We.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),D=e=>(e=e.toLowerCase(),t=>Ee(t)===e),ne=e=>t=>typeof t===e,{isArray:v}=Array,W=ne("undefined");function jt(e){return e!==null&&!W(e)&&e.constructor!==null&&!W(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ke=D("ArrayBuffer");function Ht(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ke(e.buffer),t}const Mt=ne("string"),x=ne("function"),Xe=ne("number"),we=e=>e!==null&&typeof e=="object",vt=e=>e===!0||e===!1,re=e=>{if(Ee(e)!=="object")return!1;const t=be(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},It=D("Date"),zt=D("File"),Jt=D("Blob"),qt=D("FileList"),Vt=e=>we(e)&&x(e.pipe),Wt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||We.call(e)===t||x(e.toString)&&e.toString()===t)},Kt=D("URLSearchParams"),Xt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function K(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),v(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Qe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ye=e=>!W(e)&&e!==Qe;function Oe(){const{caseless:e}=Ye(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ge(t,s)||s;re(t[o])&&re(r)?t[o]=Oe(t[o],r):re(r)?t[o]=Oe({},r):v(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(K(t,(s,o)=>{n&&x(s)?e[o]=Ve(s,n):e[o]=s},{allOwnKeys:r}),e),Qt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Yt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Zt=(e,t,n,r)=>{let s,o,i;const u={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!u[i]&&(t[i]=e[i],u[i]=!0);e=n!==!1&&be(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},$t=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},en=e=>{if(!e)return null;if(v(e))return e;let t=e.length;if(!Xe(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},tn=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&be(Uint8Array)),nn=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},rn=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},sn=D("HTMLFormElement"),on=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ze=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),an=D("RegExp"),$e=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};K(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},l={isArray:v,isArrayBuffer:Ke,isBuffer:jt,isFormData:Wt,isArrayBufferView:Ht,isString:Mt,isNumber:Xe,isBoolean:vt,isObject:we,isPlainObject:re,isUndefined:W,isDate:It,isFile:zt,isBlob:Jt,isRegExp:an,isFunction:x,isStream:Vt,isURLSearchParams:Kt,isTypedArray:tn,isFileList:qt,forEach:K,merge:Oe,extend:Gt,trim:Xt,stripBOM:Qt,inherits:Yt,toFlatObject:Zt,kindOf:Ee,kindOfTest:D,endsWith:$t,toArray:en,forEachEntry:nn,matchAll:rn,isHTMLForm:sn,hasOwnProperty:Ze,hasOwnProp:Ze,reduceDescriptors:$e,freezeMethods:e=>{$e(e,(t,n)=>{if(x(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!x(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return v(e)?r(e):r(String(e).split(t)),n},toCamelCase:on,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ge,global:Qe,isContextDefined:Ye,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(we(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=v(r)?[]:{};return K(r,(i,u)=>{const d=n(i,s+1);!W(d)&&(o[u]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function b(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}l.inherits(b,Error,{toJSON:function(){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:l.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const et=b.prototype,tt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{tt[e]={value:e}}),Object.defineProperties(b,tt),Object.defineProperty(et,"isAxiosError",{value:!0}),b.from=(e,t,n,r,s,o)=>{const i=Object.create(et);return l.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError"),b.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var ln=typeof self=="object"?self.FormData:window.FormData;const un=ln;function ge(e){return l.isPlainObject(e)||l.isArray(e)}function nt(e){return l.endsWith(e,"[]")?e.slice(0,-2):e}function rt(e,t,n){return e?e.concat(t).map(function(s,o){return s=nt(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function cn(e){return l.isArray(e)&&!e.some(ge)}const fn=l.toFlatObject(l,{},null,function(t){return/^is[A-Z]/.test(t)});function dn(e){return e&&l.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function se(e,t,n){if(!l.isObject(e))throw new TypeError("target must be an object");t=t||new(un||FormData),n=l.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(_,T){return!l.isUndefined(T[_])});const r=n.metaTokens,s=n.visitor||c,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&dn(t);if(!l.isFunction(s))throw new TypeError("visitor must be a function");function a(h){if(h===null)return"";if(l.isDate(h))return h.toISOString();if(!d&&l.isBlob(h))throw new b("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(h)||l.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function c(h,_,T){let R=h;if(h&&!T&&typeof h=="object"){if(l.endsWith(_,"{}"))_=r?_:_.slice(0,-2),h=JSON.stringify(h);else if(l.isArray(h)&&cn(h)||l.isFileList(h)||l.endsWith(_,"[]")&&(R=l.toArray(h)))return _=nt(_),R.forEach(function(z,fe){!(l.isUndefined(z)||z===null)&&t.append(i===!0?rt([_],fe,o):i===null?_:_+"[]",a(z))}),!1}return ge(h)?!0:(t.append(rt(T,_,o),a(h)),!1)}const f=[],p=Object.assign(fn,{defaultVisitor:c,convertValue:a,isVisitable:ge});function m(h,_){if(!l.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+_.join("."));f.push(h),l.forEach(h,function(R,N){(!(l.isUndefined(R)||R===null)&&s.call(t,R,l.isString(N)?N.trim():N,_,p))===!0&&m(R,_?_.concat(N):[N])}),f.pop()}}if(!l.isObject(e))throw new TypeError("data must be an object");return m(e),t}function st(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Se(e,t){this._pairs=[],e&&se(e,this,t)}const ot=Se.prototype;ot.append=function(t,n){this._pairs.push([t,n])},ot.toString=function(t){const n=t?function(r){return t.call(this,r,st)}:st;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function pn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function it(e,t,n){if(!t)return e;const r=n&&n.encode||pn,s=n&&n.serialize;let o;if(s?o=s(t,n):o=l.isURLSearchParams(t)?t.toString():new Se(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class hn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){l.forEach(this.handlers,function(r){r!==null&&t(r)})}}const at=hn,lt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},mn=typeof URLSearchParams<"u"?URLSearchParams:Se,_n=FormData,yn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),bn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),C={isBrowser:!0,classes:{URLSearchParams:mn,FormData:_n,Blob},isStandardBrowserEnv:yn,isStandardBrowserWebWorkerEnv:bn,protocols:["http","https","file","blob","url","data"]};function En(e,t){return se(e,new C.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return C.isNode&&l.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function wn(e){return l.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function On(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&l.isArray(s)?s.length:i,d?(l.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!u):((!s[i]||!l.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&l.isArray(s[i])&&(s[i]=On(s[i])),!u)}if(l.isFormData(e)&&l.isFunction(e.entries)){const n={};return l.forEachEntry(e,(r,s)=>{t(wn(r),s,n,0)}),n}return null}const gn={"Content-Type":void 0};function Sn(e,t,n){if(l.isString(e))try{return(t||JSON.parse)(e),l.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const oe={transitional:lt,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=l.isObject(t);if(o&&l.isHTMLForm(t)&&(t=new FormData(t)),l.isFormData(t))return s&&s?JSON.stringify(ut(t)):t;if(l.isArrayBuffer(t)||l.isBuffer(t)||l.isStream(t)||l.isFile(t)||l.isBlob(t))return t;if(l.isArrayBufferView(t))return t.buffer;if(l.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return En(t,this.formSerializer).toString();if((u=l.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return se(u?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Sn(t)):t}],transformResponse:[function(t){const n=this.transitional||oe.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&l.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(u){if(i)throw u.name==="SyntaxError"?b.from(u,b.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};l.forEach(["delete","get","head"],function(t){oe.headers[t]={}}),l.forEach(["post","put","patch"],function(t){oe.headers[t]=l.merge(gn)});const Re=oe,Rn=l.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"]),An=e=>{const t={};let n,r,s;return e&&e.split(` +`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&Rn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ct=Symbol("internals");function X(e){return e&&String(e).trim().toLowerCase()}function ie(e){return e===!1||e==null?e:l.isArray(e)?e.map(ie):String(e)}function Tn(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}function Nn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ft(e,t,n,r){if(l.isFunction(r))return r.call(this,t,n);if(!!l.isString(t)){if(l.isString(r))return t.indexOf(r)!==-1;if(l.isRegExp(r))return r.test(t)}}function kn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Cn(e,t){const n=l.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class ae{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(u,d,a){const c=X(d);if(!c)throw new Error("header name must be a non-empty string");const f=l.findKey(s,c);(!f||s[f]===void 0||a===!0||a===void 0&&s[f]!==!1)&&(s[f||d]=ie(u))}const i=(u,d)=>l.forEach(u,(a,c)=>o(a,c,d));return l.isPlainObject(t)||t instanceof this.constructor?i(t,n):l.isString(t)&&(t=t.trim())&&!Nn(t)?i(An(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=X(t),t){const r=l.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Tn(s);if(l.isFunction(n))return n.call(this,s,r);if(l.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=X(t),t){const r=l.findKey(this,t);return!!(r&&(!n||ft(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=X(i),i){const u=l.findKey(r,i);u&&(!n||ft(r,r[u],u,n))&&(delete r[u],s=!0)}}return l.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return l.forEach(this,(s,o)=>{const i=l.findKey(r,o);if(i){n[i]=ie(s),delete n[o];return}const u=t?kn(o):String(o).trim();u!==o&&delete n[o],n[u]=ie(s),r[u]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return l.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&l.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ct]=this[ct]={accessors:{}}).accessors,s=this.prototype;function o(i){const u=X(i);r[u]||(Cn(s,i),r[u]=!0)}return l.isArray(t)?t.forEach(o):o(t),this}}ae.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),l.freezeMethods(ae.prototype),l.freezeMethods(ae);const U=ae;function Ae(e,t){const n=this||Re,r=t||n,s=U.from(r.headers);let o=r.data;return l.forEach(e,function(u){o=u.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function dt(e){return!!(e&&e.__CANCEL__)}function G(e,t,n){b.call(this,e==null?"canceled":e,b.ERR_CANCELED,t,n),this.name="CanceledError"}l.inherits(G,b,{__CANCEL__:!0});const Pn=null;function Fn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new b("Request failed with status code "+n.status,[b.ERR_BAD_REQUEST,b.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Dn=C.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,u){const d=[];d.push(n+"="+encodeURIComponent(r)),l.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),l.isString(o)&&d.push("path="+o),l.isString(i)&&d.push("domain="+i),u===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Un(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Bn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function pt(e,t){return e&&!Un(t)?Bn(e,t):t}const Ln=C.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const u=l.isString(i)?s(i):i;return u.protocol===r.protocol&&u.host===r.host}}():function(){return function(){return!0}}();function xn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function jn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),c=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,p=0;for(;f!==s;)p+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,u=o-n,d=r(u),a=o<=i;n=o;const c={loaded:o,total:i,progress:i?o/i:void 0,bytes:u,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};c[t?"download":"upload"]=!0,e(c)}}const le={http:Pn,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=U.from(e.headers).normalize(),i=e.responseType;let u;function d(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}l.isFormData(s)&&(C.isStandardBrowserEnv||C.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const m=e.auth.username||"",h=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(m+":"+h))}const c=pt(e.baseURL,e.url);a.open(e.method.toUpperCase(),it(c,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const m=U.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),_={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:m,config:e,request:a};Fn(function(R){n(R),d()},function(R){r(R),d()},_),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new b("Request aborted",b.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new b("Network Error",b.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let h=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const _=e.transitional||lt;e.timeoutErrorMessage&&(h=e.timeoutErrorMessage),r(new b(h,_.clarifyTimeoutError?b.ETIMEDOUT:b.ECONNABORTED,e,a)),a=null},C.isStandardBrowserEnv){const m=(e.withCredentials||Ln(c))&&e.xsrfCookieName&&Dn.read(e.xsrfCookieName);m&&o.set(e.xsrfHeaderName,m)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&l.forEach(o.toJSON(),function(h,_){a.setRequestHeader(_,h)}),l.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",ht(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",ht(e.onUploadProgress)),(e.cancelToken||e.signal)&&(u=m=>{!a||(r(!m||m.type?new G(null,e,a):m),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u)));const p=xn(c);if(p&&C.protocols.indexOf(p)===-1){r(new b("Unsupported protocol "+p+":",b.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};l.forEach(le,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Hn={getAdapter:e=>{e=l.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof U?e.toJSON():e;function I(e,t){t=t||{};const n={};function r(a,c,f){return l.isPlainObject(a)&&l.isPlainObject(c)?l.merge.call({caseless:f},a,c):l.isPlainObject(c)?l.merge({},c):l.isArray(c)?c.slice():c}function s(a,c,f){if(l.isUndefined(c)){if(!l.isUndefined(a))return r(void 0,a,f)}else return r(a,c,f)}function o(a,c){if(!l.isUndefined(c))return r(void 0,c)}function i(a,c){if(l.isUndefined(c)){if(!l.isUndefined(a))return r(void 0,a)}else return r(void 0,c)}function u(a,c,f){if(f in t)return r(a,c);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:u,headers:(a,c)=>s(_t(a),_t(c),!0)};return l.forEach(Object.keys(e).concat(Object.keys(t)),function(c){const f=d[c]||s,p=f(e[c],t[c],c);l.isUndefined(p)&&f!==u||(n[c]=p)}),n}const yt="1.2.1",Ne={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ne[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const bt={};Ne.transitional=function(t,n,r){function s(o,i){return"[Axios v"+yt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,u)=>{if(t===!1)throw new b(s(i," has been removed"+(n?" in "+n:"")),b.ERR_DEPRECATED);return n&&!bt[i]&&(bt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,u):!0}};function Mn(e,t,n){if(typeof e!="object")throw new b("options must be an object",b.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const u=e[o],d=u===void 0||i(u,o,e);if(d!==!0)throw new b("option "+o+" must be "+d,b.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new b("Unknown option "+o,b.ERR_BAD_OPTION)}}const ke={assertOptions:Mn,validators:Ne},L=ke.validators;class ue{constructor(t){this.defaults=t,this.interceptors={request:new at,response:new at}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=I(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&ke.assertOptions(r,{silentJSONParsing:L.transitional(L.boolean),forcedJSONParsing:L.transitional(L.boolean),clarifyTimeoutError:L.transitional(L.boolean)},!1),s!==void 0&&ke.assertOptions(s,{encode:L.function,serialize:L.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&l.merge(o.common,o[n.method]),i&&l.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),n.headers=U.concat(i,o);const u=[];let d=!0;this.interceptors.request.forEach(function(_){typeof _.runWhen=="function"&&_.runWhen(n)===!1||(d=d&&_.synchronous,u.unshift(_.fulfilled,_.rejected))});const a=[];this.interceptors.response.forEach(function(_){a.push(_.fulfilled,_.rejected)});let c,f=0,p;if(!d){const h=[mt.bind(this),void 0];for(h.unshift.apply(h,u),h.push.apply(h,a),p=h.length,c=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(u=>{r.subscribe(u),o=u}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,u){r.reason||(r.reason=new G(o,i,u),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Ce(function(s){t=s}),cancel:t}}}const vn=Ce;function In(e){return function(n){return e.apply(null,n)}}function zn(e){return l.isObject(e)&&e.isAxiosError===!0}function Et(e){const t=new ce(e),n=Ve(ce.prototype.request,t);return l.extend(n,ce.prototype,t,{allOwnKeys:!0}),l.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Et(I(e,s))},n}const g=Et(Re);g.Axios=ce,g.CanceledError=G,g.CancelToken=vn,g.isCancel=dt,g.VERSION=yt,g.toFormData=se,g.AxiosError=b,g.Cancel=g.CanceledError,g.all=function(t){return Promise.all(t)},g.spread=In,g.isAxiosError=zn,g.mergeConfig=I,g.AxiosHeaders=U,g.formToJSON=e=>ut(l.isHTMLForm(e)?new FormData(e):e),g.default=g;const Jn=g,Or="";function wt(e){let t,n,r,s,o,i;function u(c,f){return!c[4]&&!c[5]&&!c[6]?Vn:qn}let d=u(e),a=d(e);return{c(){t=O("div"),n=O("div"),a.c(),r=F(),s=O("input"),y(n,"id","widget-label"),y(n,"class","svelte-1f4196f"),y(s,"id","fileUpload"),y(s,"type","file"),y(s,"class","svelte-1f4196f"),y(t,"id","fileUploadWidget"),y(t,"class","svelte-1f4196f")},m(c,f){A(c,t,f),E(t,n),a.m(n,null),E(t,r),E(t,s),o||(i=[M(s,"change",e[18]),M(s,"change",e[11])],o=!0)},p(c,f){d===(d=u(c))&&a?a.p(c,f):(a.d(1),a=d(c),a&&(a.c(),a.m(n,null)))},d(c){c&&S(t),a.d(),o=!1,H(i)}}}function qn(e){let t,n,r,s,o,i=`${e[3]}%`;function u(f,p){return f[5]?Wn:Kn}let d=u(e),a=d(e),c=e[6]&>();return{c(){t=O("div"),n=O("div"),a.c(),r=F(),c&&c.c(),s=F(),o=O("div"),y(n,"class","percentage-text svelte-1f4196f"),y(o,"id","percentage-bar"),y(o,"class","svelte-1f4196f"),xe(o,"width",i),y(t,"id","percentage"),y(t,"class","svelte-1f4196f")},m(f,p){A(f,t,p),E(t,n),a.m(n,null),E(n,r),c&&c.m(n,null),E(t,s),E(t,o)},p(f,p){d===(d=u(f))&&a?a.p(f,p):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[6]?c||(c=gt(),c.c(),c.m(n,null)):c&&(c.d(1),c=null),p&8&&i!==(i=`${f[3]}%`)&&xe(o,"width",i)},d(f){f&&S(t),a.d(),c&&c.d()}}}function Vn(e){let t;function n(o,i){return o[1]?Gn:Xn}let r=n(e),s=r(e);return{c(){s.c(),t=pe()},m(o,i){s.m(o,i),A(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&S(t)}}}function Wn(e){let t;return{c(){t=B("Waiting for data schema detection...")},m(n,r){A(n,t,r)},p:k,d(n){n&&S(t)}}}function Kn(e){let t,n=!e[6]&&Ot(e);return{c(){n&&n.c(),t=pe()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[6]?n&&(n.d(1),n=null):n?n.p(r,s):(n=Ot(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&S(t)}}}function Ot(e){let t,n;return{c(){t=B(e[3]),n=B("%")},m(r,s){A(r,t,s),A(r,n,s)},p(r,s){s&8&&Nt(t,r[3])},d(r){r&&S(t),r&&S(n)}}}function gt(e){let t;return{c(){t=B("File uploaded")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Xn(e){let t;return{c(){t=B("Select a file to upload")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Gn(e){let t;return{c(){t=B("Select a file to replace the current one")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Qn(e){let t,n,r,s,o,i,u,d,a;return{c(){t=O("div"),n=O("label"),n.textContent="URL",r=F(),s=O("div"),o=O("input"),i=F(),u=O("input"),y(n,"class","control-label"),y(n,"for","field_url"),y(o,"id","field_url"),y(o,"class","form-control"),y(o,"type","text"),y(o,"name","url"),y(u,"type","hidden"),y(u,"name","clear_upload"),u.value="true",y(s,"class","controls"),y(t,"id","resourceURL"),y(t,"class","controls svelte-1f4196f")},m(c,f){A(c,t,f),E(t,n),E(t,r),E(t,s),E(s,o),Y(o,e[8]),E(s,i),E(s,u),d||(a=M(o,"input",e[20]),d=!0)},p(c,f){f&256&&o.value!==c[8]&&Y(o,c[8])},d(c){c&&S(t),d=!1,a()}}}function Yn(e){let t,n=e[9]!=""&&St(e);return{c(){n&&n.c(),t=pe()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[9]!=""?n?n.p(r,s):(n=St(r),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},d(r){n&&n.d(r),r&&S(t)}}}function St(e){let t,n,r,s,o,i,u,d;return{c(){t=O("div"),n=O("label"),n.textContent="Current file",r=F(),s=O("div"),o=O("input"),y(n,"class","control-label"),y(n,"for","field_url"),o.readOnly=i=e[0]!="upload"?void 0:!0,y(o,"id","field_url"),y(o,"class","form-control"),y(o,"type","text"),y(o,"name","url"),y(s,"class","controls"),y(t,"class","controls")},m(a,c){A(a,t,c),E(t,n),E(t,r),E(t,s),E(s,o),Y(o,e[9]),u||(d=M(o,"input",e[19]),u=!0)},p(a,c){c&1&&i!==(i=a[0]!="upload"?void 0:!0)&&(o.readOnly=i),c&512&&o.value!==a[9]&&Y(o,a[9])},d(a){a&&S(t),u=!1,d()}}}function Zn(e){let t,n,r,s,o,i,u,d,a=e[7]=="upload"&&wt(e);function c(m,h){if(m[7]=="upload")return Yn;if(m[7]!="None")return Qn}let f=c(e),p=f&&f(e);return{c(){t=O("div"),n=O("a"),n.innerHTML='File',r=F(),s=O("a"),s.innerHTML='Link',o=F(),a&&a.c(),i=F(),p&&p.c(),y(n,"class","btn btn-default"),Z(n,"active",e[7]=="upload"),y(s,"class","btn btn-default"),Z(s,"active",e[7]!="upload"&&e[7]!="None"),y(t,"class","form-group")},m(m,h){A(m,t,h),E(t,n),E(t,r),E(t,s),E(t,o),a&&a.m(t,null),E(t,i),p&&p.m(t,null),u||(d=[M(n,"click",e[16]),M(s,"click",e[17])],u=!0)},p(m,[h]){h&128&&Z(n,"active",m[7]=="upload"),h&128&&Z(s,"active",m[7]!="upload"&&m[7]!="None"),m[7]=="upload"?a?a.p(m,h):(a=wt(m),a.c(),a.m(t,i)):a&&(a.d(1),a=null),f===(f=c(m))&&p?p.p(m,h):(p&&p.d(1),p=f&&f(m),p&&(p.c(),p.m(t,null)))},i:k,o:k,d(m){m&&S(t),a&&a.d(),p&&p.d(),u=!1,H(d)}}}function Rt(e){let t=e.split("/");return t.length>0?t[t.length-1]:t[0]}function $n(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:u}=t,{url_type:d=""}=t,a,c=0,f=!1,p=!1,m=!1,h=je(),_=i?"update":"create",T=d,R="",N="";d!="upload"?R=u:N=Rt(u);async function z(w,Q){try{const P={onUploadProgress:fr=>{const{loaded:dr,total:pr}=fr,De=Math.floor(dr*100/pr);De<=100&&(Q(De),De==100&&(n(4,f=!1),n(5,p=!0)))}},de=_=="update"?`${r}/dataset/${s}/resource/${o}/file`:`${r}/dataset/${s}/resource/file`,{data:Fe}=await Jn.post(de,w,P);return Fe}catch(P){console.log("ERROR",P.message)}}function fe(w){n(3,c=w)}function Pe(w){n(7,T=w)}async function or(w){try{const Q=w.target.files[0],P=new FormData;P.append("upload",Q),P.append("package_id",s),i&&(P.append("id",o),P.append("clear_upload",!0),P.append("url_type",d)),n(4,f=!0);let de=await z(P,fe),Fe={data:de};n(9,N=Rt(de.url)),n(0,d="upload"),h("fileUploaded",Fe),n(5,p=!1),n(6,m=!0)}catch(Q){console.log("ERROR",Q),fe(0)}}const ir=w=>{Pe("upload")},ar=w=>{Pe("")};function lr(){a=this.files,n(2,a)}function ur(){N=this.value,n(9,N)}function cr(){R=this.value,n(8,R)}return e.$$set=w=>{"upload_url"in w&&n(12,r=w.upload_url),"dataset_id"in w&&n(13,s=w.dataset_id),"resource_id"in w&&n(14,o=w.resource_id),"update"in w&&n(1,i=w.update),"current_url"in w&&n(15,u=w.current_url),"url_type"in w&&n(0,d=w.url_type)},[d,i,a,c,f,p,m,T,R,N,Pe,or,r,s,o,u,ir,ar,lr,ur,cr]}class er extends qe{constructor(t){super(),Je(this,t,$n,Zn,Le,{upload_url:12,dataset_id:13,resource_id:14,update:1,current_url:15,url_type:0})}}function tr(e){let t,n,r;return n=new er({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=O("main"),Lt(n.$$.fragment)},m(s,o){A(s,t,o),Ie(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(ve(n.$$.fragment,s),r=!0)},o(s){Bt(n.$$.fragment,s),r=!1},d(s){s&&S(t),ze(n),e[8](null)}}}function nr(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:u}=t,{url_type:d}=t;je();let a;function c(p){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:p.detail.data}))}function f(p){he[p?"unshift":"push"](()=>{a=p,n(6,a)})}return e.$$set=p=>{"upload_url"in p&&n(0,r=p.upload_url),"dataset_id"in p&&n(1,s=p.dataset_id),"resource_id"in p&&n(2,o=p.resource_id),"update"in p&&n(3,i=p.update),"current_url"in p&&n(4,u=p.current_url),"url_type"in p&&n(5,d=p.url_type)},[r,s,o,i,u,d,a,c,f]}class rr extends qe{constructor(t){super(),Je(this,t,nr,tr,Le,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function sr(e,t="",n="",r="",s="",o="",i=""){new rr({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return sr}); From a9e5459fcc2da021d7a464655cb8241cca913295 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Wed, 8 Feb 2023 22:21:57 +0100 Subject: [PATCH 31/43] remove erroneous test for schema file uploaded size --- ckanext/validation/plugin/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index d99a0714..68ec7c7c 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -152,7 +152,7 @@ def _process_schema_fields(self, data_dict): schema_url = data_dict.pop(u'schema_url', None) schema_json = data_dict.pop(u'schema_json', None) - if isinstance(schema_upload, ALLOWED_UPLOAD_TYPES) and schema_upload.content_length > 0: + if isinstance(schema_upload, ALLOWED_UPLOAD_TYPES): uploaded_file = _get_underlying_file(schema_upload) data_dict[u'schema'] = uploaded_file.read() From 56ab8bbb86a2892fa080accd9a831f90f22d19e6 Mon Sep 17 00:00:00 2001 From: Edgar Zanella Alvarenga Date: Wed, 8 Feb 2023 23:24:29 +0100 Subject: [PATCH 32/43] Remove scrolling to schema json on resource edit --- .../validation/webassets/js/module-resource-schema.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ckanext/validation/webassets/js/module-resource-schema.js b/ckanext/validation/webassets/js/module-resource-schema.js index c7edfaca..a1143c1e 100644 --- a/ckanext/validation/webassets/js/module-resource-schema.js +++ b/ckanext/validation/webassets/js/module-resource-schema.js @@ -59,10 +59,13 @@ ckan.module('resource-schema', function($) { this.label_url = $('label', this.field_url); this.field_upload_input.on('change', this._onInputChange); - this.field_url_input.focus() - .on('blur', this._onURLBlur); - this.field_json_input.focus() - .on('blur', this._onJSONBlur); + // With the follow lines the form is being scrolled down to the + // schema fields always when the user open the resource edit form + // + // this.field_url_input.focus() + // .on('blur', this._onURLBlur); + // this.field_json_input.focus() + // .on('blur', this._onJSONBlur); // Button to set upload a schema file this.button_upload = $('' + From ebcc71aed44707b865b87866d049dc31c8d70818 Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 23 Feb 2023 11:57:52 +0100 Subject: [PATCH 33/43] Add basic create/update tests --- ckanext/validation/blueprints.py | 1 + ckanext/validation/tests/test_uploader.py | 347 ++++++++++++++++++ .../validation/webassets/js/ckan-uploader.js | 4 +- dev-requirements.txt | 1 + 4 files changed, 351 insertions(+), 2 deletions(-) create mode 100644 ckanext/validation/tests/test_uploader.py diff --git a/ckanext/validation/blueprints.py b/ckanext/validation/blueprints.py index 1f7d35aa..ee576c95 100644 --- a/ckanext/validation/blueprints.py +++ b/ckanext/validation/blueprints.py @@ -96,6 +96,7 @@ def resource_file_update(id, resource_id): context = { 'user': g.user, } + data_dict["id"] = resource_id data_dict["package_id"] = id resource = get_action("resource_update")(context, data_dict) diff --git a/ckanext/validation/tests/test_uploader.py b/ckanext/validation/tests/test_uploader.py new file mode 100644 index 00000000..84847d4c --- /dev/null +++ b/ckanext/validation/tests/test_uploader.py @@ -0,0 +1,347 @@ +import io +import pytest +import responses + +from ckantoolkit import config +from ckantoolkit.tests.factories import Sysadmin, Dataset, Resource +from ckantoolkit.tests.helpers import call_action +from ckanext.validation.tests.helpers import VALID_CSV, INVALID_CSV + + +pytestmark = pytest.mark.usefixtures("clean_db", "validation_setup", "mock_uploads") + + +def _new_resource_upload_url(dataset_id): + + url = "/dataset/{}/resource/file".format(dataset_id) + + return url + + +def _edit_resource_upload_url(dataset_id, resource_id): + + url = "/dataset/{}/resource/{}/file".format(dataset_id, resource_id) + + return url + + +def _get_env(): + user = Sysadmin() + return {"REMOTE_USER": user["name"]} + + +# Create resources + + +def test_create_upload_with_schema(app): + + dataset = Dataset() + + data = { + "upload": (io.BytesIO(bytes(VALID_CSV.encode("utf8"))), "valid.csv"), + } + + app.post( + url=_new_resource_upload_url(dataset["id"]), extra_environ=_get_env(), data=data + ) + + dataset = call_action("package_show", id=dataset["id"]) + + assert len(dataset["resources"]) == 1 + assert dataset["resources"][0]["format"] == "CSV" + assert dataset["resources"][0]["url_type"] == "upload" + + assert dataset["resources"][0]["schema"] == { + "fields": [ + {"name": "a", "type": "integer"}, + {"name": "b", "type": "integer"}, + {"name": "c", "type": "integer"}, + {"name": "d", "type": "integer"}, + ] + } + + +def test_create_upload_no_tabular_no_schema(app): + + dataset = Dataset() + + data = { + "upload": (io.BytesIO(b"test file"), "some.txt"), + } + + app.post( + url=_new_resource_upload_url(dataset["id"]), extra_environ=_get_env(), data=data + ) + + dataset = call_action("package_show", id=dataset["id"]) + + assert len(dataset["resources"]) == 1 + assert dataset["resources"][0]["format"] == "TXT" + assert dataset["resources"][0]["url_type"] == "upload" + + assert "schema" not in dataset["resources"][0] + + +@responses.activate +def test_create_url_with_schema(app): + + url = "https://example.com/valid.csv" + + responses.add(responses.GET, url, body=VALID_CSV) + responses.add_passthru(config["solr_url"]) + + dataset = Dataset() + + data = {"url": url} + + app.post( + url=_new_resource_upload_url(dataset["id"]), extra_environ=_get_env(), data=data + ) + + dataset = call_action("package_show", id=dataset["id"]) + + assert len(dataset["resources"]) == 1 + assert dataset["resources"][0]["format"] == "CSV" + assert dataset["resources"][0]["url_type"] is None + + assert dataset["resources"][0]["schema"] == { + "fields": [ + {"name": "a", "type": "integer"}, + {"name": "b", "type": "integer"}, + {"name": "c", "type": "integer"}, + {"name": "d", "type": "integer"}, + ] + } + + +@responses.activate +def test_create_url_no_tabular(app): + + url = "https://example.com/some.txt" + + responses.add(responses.GET, url, body="some text") + responses.add_passthru(config["solr_url"]) + + dataset = Dataset() + + data = {"url": url} + + app.post( + url=_new_resource_upload_url(dataset["id"]), extra_environ=_get_env(), data=data + ) + + dataset = call_action("package_show", id=dataset["id"]) + + assert len(dataset["resources"]) == 1 + assert dataset["resources"][0]["format"] == "TXT" + assert dataset["resources"][0]["url_type"] is None + + assert "schema" not in dataset["resources"][0] + + +# Update resources + + +def test_update_upload_with_schema(app): + + resource = Resource() + + data = { + "upload": (io.BytesIO(bytes(VALID_CSV.encode("utf8"))), "valid.csv"), + } + + app.post( + url=_edit_resource_upload_url(resource["package_id"], resource["id"]), + extra_environ=_get_env(), + data=data, + ) + + resource = call_action("resource_show", id=resource["id"]) + + assert resource["format"] == "CSV" + assert resource["url_type"] == "upload" + + assert resource["schema"] == { + "fields": [ + {"name": "a", "type": "integer"}, + {"name": "b", "type": "integer"}, + {"name": "c", "type": "integer"}, + {"name": "d", "type": "integer"}, + ] + } + + +def test_update_upload_no_tabular_no_schema(app): + + resource = Resource() + + data = { + "upload": (io.BytesIO(b"test file"), "some.txt"), + } + + app.post( + url=_edit_resource_upload_url(resource["package_id"], resource["id"]), + extra_environ=_get_env(), + data=data, + ) + + resource = call_action("resource_show", id=resource["id"]) + + assert resource["format"] == "TXT" + assert resource["url_type"] == "upload" + + assert "schema" not in resource + + +def test_update_updates_schema(app): + + dataset = Dataset() + + data = { + "upload": (io.BytesIO(bytes(VALID_CSV.encode("utf8"))), "valid.csv"), + } + + app.post( + url=_new_resource_upload_url(dataset["id"]), extra_environ=_get_env(), data=data + ) + + dataset = call_action("package_show", id=dataset["id"]) + + assert dataset["resources"][0]["schema"] + + data = { + "upload": (io.BytesIO(b"e,f\n5,6"), "some.other.csv"), + } + + app.post( + url=_edit_resource_upload_url(dataset["id"], dataset["resources"][0]["id"]), + extra_environ=_get_env(), + data=data, + ) + + resource = call_action("resource_show", id=dataset["resources"][0]["id"]) + + assert resource["schema"] == { + "fields": [ + {"name": "e", "type": "integer"}, + {"name": "f", "type": "integer"}, + ] + } + + +def test_update_removes_schema(app): + + dataset = Dataset() + + data = { + "upload": (io.BytesIO(bytes(VALID_CSV.encode("utf8"))), "valid.csv"), + } + + app.post( + url=_new_resource_upload_url(dataset["id"]), extra_environ=_get_env(), data=data + ) + + dataset = call_action("package_show", id=dataset["id"]) + + assert dataset["resources"][0]["schema"] + + data = { + "upload": (io.BytesIO(b"test file"), "some.txt"), + } + + app.post( + url=_edit_resource_upload_url(dataset["id"], dataset["resources"][0]["id"]), + extra_environ=_get_env(), + data=data, + ) + + resource = call_action("resource_show", id=dataset["resources"][0]["id"]) + + assert "schema" not in resource + + +def test_update_upload_no_tabular_no_schema(app): + + resource = Resource() + + data = { + "upload": (io.BytesIO(b"test file"), "some.txt"), + } + + app.post( + url=_edit_resource_upload_url(resource["package_id"], resource["id"]), + extra_environ=_get_env(), + data=data, + ) + + resource = call_action("resource_show", id=resource["id"]) + + assert resource["format"] == "TXT" + assert resource["url_type"] == "upload" + + assert "schema" not in resource + + +@responses.activate +def test_update_url_with_schema(app): + url = "https://example.com/valid.csv" + + responses.add(responses.GET, url, body=VALID_CSV) + responses.add_passthru(config["solr_url"]) + + resource = Resource() + + data = { + "url": url, + # CKAN does not refresh the format, see https://github.com/ckan/ckan/issues/7415 + "format": "CSV", + } + + app.post( + url=_edit_resource_upload_url(resource["package_id"], resource["id"]), + extra_environ=_get_env(), + data=data, + ) + + resource = call_action("resource_show", id=resource["id"]) + + assert resource["format"] == "CSV" + assert resource["url_type"] is None + + assert resource["schema"] == { + "fields": [ + {"name": "a", "type": "integer"}, + {"name": "b", "type": "integer"}, + {"name": "c", "type": "integer"}, + {"name": "d", "type": "integer"}, + ] + } + + +@responses.activate +def test_update_url_no_tabular_no_schema(app): + url = "https://example.com/some.txt" + + responses.add(responses.GET, url, body="some text") + responses.add_passthru(config["solr_url"]) + + resource = Resource() + + data = { + "url": url, + # CKAN does not refresh the format, see https://github.com/ckan/ckan/issues/7415 + "format": "TXT", + } + + app.post( + url=_edit_resource_upload_url(resource["package_id"], resource["id"]), + extra_environ=_get_env(), + data=data, + ) + + resource = call_action("resource_show", id=resource["id"]) + + assert resource["format"] == "TXT" + assert resource["url_type"] is None + + assert "schema" not in resource diff --git a/ckanext/validation/webassets/js/ckan-uploader.js b/ckanext/validation/webassets/js/ckan-uploader.js index 1b0c944a..c540cc1f 100644 --- a/ckanext/validation/webassets/js/ckan-uploader.js +++ b/ckanext/validation/webassets/js/ckan-uploader.js @@ -1,3 +1,3 @@ -(function(k,j){typeof exports=="object"&&typeof module<"u"?module.exports=j():typeof define=="function"&&define.amd?define(j):(k=typeof globalThis<"u"?globalThis:k||self,k.CkanUploader=j())})(this,function(){"use strict";function k(){}function j(e){return e()}function Ue(){return Object.create(null)}function H(e){e.forEach(j)}function Be(e){return typeof e=="function"}function Le(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function At(e){return Object.keys(e).length===0}function E(e,t){e.appendChild(t)}function A(e,t,n){e.insertBefore(t,n||null)}function S(e){e.parentNode&&e.parentNode.removeChild(e)}function O(e){return document.createElement(e)}function B(e){return document.createTextNode(e)}function F(){return B(" ")}function pe(){return B("")}function M(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function y(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Tt(e){return Array.from(e.childNodes)}function Nt(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Y(e,t){e.value=t==null?"":t}function xe(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function Z(e,t,n){e.classList[n?"add":"remove"](t)}function kt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Ct(){if(!J)throw new Error("Function called outside component initialization");return J}function je(){const e=Ct();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=kt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const V=[],he=[],$=[],He=[],Pt=Promise.resolve();let me=!1;function Ft(){me||(me=!0,Pt.then(Me))}function _e(e){$.push(e)}const ye=new Set;let ee=0;function Me(){const e=J;do{for(;ee{te.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Lt(e){e&&e.c()}function Ie(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||_e(()=>{const i=e.$$.on_mount.map(j).filter(Be);e.$$.on_destroy?e.$$.on_destroy.push(...i):H(i),e.$$.on_mount=[]}),o.forEach(_e)}function ze(e,t){const n=e.$$;n.fragment!==null&&(H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function xt(e,t){e.$$.dirty[0]===-1&&(V.push(e),Ft(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const h=m.length?m[0]:p;return a.ctx&&s(a.ctx[f],a.ctx[f]=h)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](h),c&&xt(e,f)),p}):[],a.update(),c=!0,H(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Tt(t.target);a.fragment&&a.fragment.l(f),f.forEach(S)}else a.fragment&&a.fragment.c();t.intro&&ve(e.$$.fragment),Ie(e,t.target,t.anchor,t.customElement),Me()}q(d)}class qe{$destroy(){ze(this,1),this.$destroy=k}$on(t,n){if(!Be(n))return k;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!At(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function Ve(e,t){return function(){return e.apply(t,arguments)}}const{toString:We}=Object.prototype,{getPrototypeOf:be}=Object,Ee=(e=>t=>{const n=We.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),D=e=>(e=e.toLowerCase(),t=>Ee(t)===e),ne=e=>t=>typeof t===e,{isArray:v}=Array,W=ne("undefined");function jt(e){return e!==null&&!W(e)&&e.constructor!==null&&!W(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ke=D("ArrayBuffer");function Ht(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ke(e.buffer),t}const Mt=ne("string"),x=ne("function"),Xe=ne("number"),we=e=>e!==null&&typeof e=="object",vt=e=>e===!0||e===!1,re=e=>{if(Ee(e)!=="object")return!1;const t=be(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},It=D("Date"),zt=D("File"),Jt=D("Blob"),qt=D("FileList"),Vt=e=>we(e)&&x(e.pipe),Wt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||We.call(e)===t||x(e.toString)&&e.toString()===t)},Kt=D("URLSearchParams"),Xt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function K(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),v(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Qe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ye=e=>!W(e)&&e!==Qe;function Oe(){const{caseless:e}=Ye(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ge(t,s)||s;re(t[o])&&re(r)?t[o]=Oe(t[o],r):re(r)?t[o]=Oe({},r):v(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(K(t,(s,o)=>{n&&x(s)?e[o]=Ve(s,n):e[o]=s},{allOwnKeys:r}),e),Qt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Yt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Zt=(e,t,n,r)=>{let s,o,i;const u={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!u[i]&&(t[i]=e[i],u[i]=!0);e=n!==!1&&be(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},$t=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},en=e=>{if(!e)return null;if(v(e))return e;let t=e.length;if(!Xe(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},tn=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&be(Uint8Array)),nn=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},rn=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},sn=D("HTMLFormElement"),on=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ze=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),an=D("RegExp"),$e=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};K(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},l={isArray:v,isArrayBuffer:Ke,isBuffer:jt,isFormData:Wt,isArrayBufferView:Ht,isString:Mt,isNumber:Xe,isBoolean:vt,isObject:we,isPlainObject:re,isUndefined:W,isDate:It,isFile:zt,isBlob:Jt,isRegExp:an,isFunction:x,isStream:Vt,isURLSearchParams:Kt,isTypedArray:tn,isFileList:qt,forEach:K,merge:Oe,extend:Gt,trim:Xt,stripBOM:Qt,inherits:Yt,toFlatObject:Zt,kindOf:Ee,kindOfTest:D,endsWith:$t,toArray:en,forEachEntry:nn,matchAll:rn,isHTMLForm:sn,hasOwnProperty:Ze,hasOwnProp:Ze,reduceDescriptors:$e,freezeMethods:e=>{$e(e,(t,n)=>{if(x(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!x(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return v(e)?r(e):r(String(e).split(t)),n},toCamelCase:on,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ge,global:Qe,isContextDefined:Ye,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(we(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=v(r)?[]:{};return K(r,(i,u)=>{const d=n(i,s+1);!W(d)&&(o[u]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function b(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}l.inherits(b,Error,{toJSON:function(){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:l.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const et=b.prototype,tt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{tt[e]={value:e}}),Object.defineProperties(b,tt),Object.defineProperty(et,"isAxiosError",{value:!0}),b.from=(e,t,n,r,s,o)=>{const i=Object.create(et);return l.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError"),b.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var ln=typeof self=="object"?self.FormData:window.FormData;const un=ln;function ge(e){return l.isPlainObject(e)||l.isArray(e)}function nt(e){return l.endsWith(e,"[]")?e.slice(0,-2):e}function rt(e,t,n){return e?e.concat(t).map(function(s,o){return s=nt(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function cn(e){return l.isArray(e)&&!e.some(ge)}const fn=l.toFlatObject(l,{},null,function(t){return/^is[A-Z]/.test(t)});function dn(e){return e&&l.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function se(e,t,n){if(!l.isObject(e))throw new TypeError("target must be an object");t=t||new(un||FormData),n=l.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(_,T){return!l.isUndefined(T[_])});const r=n.metaTokens,s=n.visitor||c,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&dn(t);if(!l.isFunction(s))throw new TypeError("visitor must be a function");function a(h){if(h===null)return"";if(l.isDate(h))return h.toISOString();if(!d&&l.isBlob(h))throw new b("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(h)||l.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function c(h,_,T){let R=h;if(h&&!T&&typeof h=="object"){if(l.endsWith(_,"{}"))_=r?_:_.slice(0,-2),h=JSON.stringify(h);else if(l.isArray(h)&&cn(h)||l.isFileList(h)||l.endsWith(_,"[]")&&(R=l.toArray(h)))return _=nt(_),R.forEach(function(z,fe){!(l.isUndefined(z)||z===null)&&t.append(i===!0?rt([_],fe,o):i===null?_:_+"[]",a(z))}),!1}return ge(h)?!0:(t.append(rt(T,_,o),a(h)),!1)}const f=[],p=Object.assign(fn,{defaultVisitor:c,convertValue:a,isVisitable:ge});function m(h,_){if(!l.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+_.join("."));f.push(h),l.forEach(h,function(R,N){(!(l.isUndefined(R)||R===null)&&s.call(t,R,l.isString(N)?N.trim():N,_,p))===!0&&m(R,_?_.concat(N):[N])}),f.pop()}}if(!l.isObject(e))throw new TypeError("data must be an object");return m(e),t}function st(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Se(e,t){this._pairs=[],e&&se(e,this,t)}const ot=Se.prototype;ot.append=function(t,n){this._pairs.push([t,n])},ot.toString=function(t){const n=t?function(r){return t.call(this,r,st)}:st;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function pn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function it(e,t,n){if(!t)return e;const r=n&&n.encode||pn,s=n&&n.serialize;let o;if(s?o=s(t,n):o=l.isURLSearchParams(t)?t.toString():new Se(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class hn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){l.forEach(this.handlers,function(r){r!==null&&t(r)})}}const at=hn,lt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},mn=typeof URLSearchParams<"u"?URLSearchParams:Se,_n=FormData,yn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),bn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),C={isBrowser:!0,classes:{URLSearchParams:mn,FormData:_n,Blob},isStandardBrowserEnv:yn,isStandardBrowserWebWorkerEnv:bn,protocols:["http","https","file","blob","url","data"]};function En(e,t){return se(e,new C.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return C.isNode&&l.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function wn(e){return l.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function On(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&l.isArray(s)?s.length:i,d?(l.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!u):((!s[i]||!l.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&l.isArray(s[i])&&(s[i]=On(s[i])),!u)}if(l.isFormData(e)&&l.isFunction(e.entries)){const n={};return l.forEachEntry(e,(r,s)=>{t(wn(r),s,n,0)}),n}return null}const gn={"Content-Type":void 0};function Sn(e,t,n){if(l.isString(e))try{return(t||JSON.parse)(e),l.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const oe={transitional:lt,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=l.isObject(t);if(o&&l.isHTMLForm(t)&&(t=new FormData(t)),l.isFormData(t))return s&&s?JSON.stringify(ut(t)):t;if(l.isArrayBuffer(t)||l.isBuffer(t)||l.isStream(t)||l.isFile(t)||l.isBlob(t))return t;if(l.isArrayBufferView(t))return t.buffer;if(l.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return En(t,this.formSerializer).toString();if((u=l.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return se(u?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Sn(t)):t}],transformResponse:[function(t){const n=this.transitional||oe.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&l.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(u){if(i)throw u.name==="SyntaxError"?b.from(u,b.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};l.forEach(["delete","get","head"],function(t){oe.headers[t]={}}),l.forEach(["post","put","patch"],function(t){oe.headers[t]=l.merge(gn)});const Re=oe,Rn=l.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"]),An=e=>{const t={};let n,r,s;return e&&e.split(` +(function(k,j){typeof exports=="object"&&typeof module<"u"?module.exports=j():typeof define=="function"&&define.amd?define(j):(k=typeof globalThis<"u"?globalThis:k||self,k.CkanUploader=j())})(this,function(){"use strict";function k(){}function j(e){return e()}function Ue(){return Object.create(null)}function H(e){e.forEach(j)}function Be(e){return typeof e=="function"}function Le(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function At(e){return Object.keys(e).length===0}function E(e,t){e.appendChild(t)}function A(e,t,n){e.insertBefore(t,n||null)}function S(e){e.parentNode&&e.parentNode.removeChild(e)}function g(e){return document.createElement(e)}function B(e){return document.createTextNode(e)}function F(){return B(" ")}function pe(){return B("")}function M(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function y(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Tt(e){return Array.from(e.childNodes)}function Nt(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Y(e,t){e.value=t==null?"":t}function xe(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function Z(e,t,n){e.classList[n?"add":"remove"](t)}function kt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Ct(){if(!J)throw new Error("Function called outside component initialization");return J}function je(){const e=Ct();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=kt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const V=[],he=[],$=[],He=[],Pt=Promise.resolve();let me=!1;function Ft(){me||(me=!0,Pt.then(Me))}function _e(e){$.push(e)}const ye=new Set;let ee=0;function Me(){const e=J;do{for(;ee{te.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Lt(e){e&&e.c()}function Ie(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||_e(()=>{const i=e.$$.on_mount.map(j).filter(Be);e.$$.on_destroy?e.$$.on_destroy.push(...i):H(i),e.$$.on_mount=[]}),o.forEach(_e)}function ze(e,t){const n=e.$$;n.fragment!==null&&(H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function xt(e,t){e.$$.dirty[0]===-1&&(V.push(e),Ft(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const h=m.length?m[0]:p;return a.ctx&&s(a.ctx[f],a.ctx[f]=h)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](h),c&&xt(e,f)),p}):[],a.update(),c=!0,H(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Tt(t.target);a.fragment&&a.fragment.l(f),f.forEach(S)}else a.fragment&&a.fragment.c();t.intro&&ve(e.$$.fragment),Ie(e,t.target,t.anchor,t.customElement),Me()}q(d)}class qe{$destroy(){ze(this,1),this.$destroy=k}$on(t,n){if(!Be(n))return k;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!At(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function Ve(e,t){return function(){return e.apply(t,arguments)}}const{toString:We}=Object.prototype,{getPrototypeOf:be}=Object,Ee=(e=>t=>{const n=We.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),D=e=>(e=e.toLowerCase(),t=>Ee(t)===e),ne=e=>t=>typeof t===e,{isArray:v}=Array,W=ne("undefined");function jt(e){return e!==null&&!W(e)&&e.constructor!==null&&!W(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ke=D("ArrayBuffer");function Ht(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ke(e.buffer),t}const Mt=ne("string"),x=ne("function"),Xe=ne("number"),we=e=>e!==null&&typeof e=="object",vt=e=>e===!0||e===!1,re=e=>{if(Ee(e)!=="object")return!1;const t=be(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},It=D("Date"),zt=D("File"),Jt=D("Blob"),qt=D("FileList"),Vt=e=>we(e)&&x(e.pipe),Wt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||We.call(e)===t||x(e.toString)&&e.toString()===t)},Kt=D("URLSearchParams"),Xt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function K(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),v(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Qe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ye=e=>!W(e)&&e!==Qe;function ge(){const{caseless:e}=Ye(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ge(t,s)||s;re(t[o])&&re(r)?t[o]=ge(t[o],r):re(r)?t[o]=ge({},r):v(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(K(t,(s,o)=>{n&&x(s)?e[o]=Ve(s,n):e[o]=s},{allOwnKeys:r}),e),Qt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Yt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Zt=(e,t,n,r)=>{let s,o,i;const u={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!u[i]&&(t[i]=e[i],u[i]=!0);e=n!==!1&&be(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},$t=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},en=e=>{if(!e)return null;if(v(e))return e;let t=e.length;if(!Xe(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},tn=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&be(Uint8Array)),nn=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},rn=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},sn=D("HTMLFormElement"),on=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ze=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),an=D("RegExp"),$e=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};K(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},l={isArray:v,isArrayBuffer:Ke,isBuffer:jt,isFormData:Wt,isArrayBufferView:Ht,isString:Mt,isNumber:Xe,isBoolean:vt,isObject:we,isPlainObject:re,isUndefined:W,isDate:It,isFile:zt,isBlob:Jt,isRegExp:an,isFunction:x,isStream:Vt,isURLSearchParams:Kt,isTypedArray:tn,isFileList:qt,forEach:K,merge:ge,extend:Gt,trim:Xt,stripBOM:Qt,inherits:Yt,toFlatObject:Zt,kindOf:Ee,kindOfTest:D,endsWith:$t,toArray:en,forEachEntry:nn,matchAll:rn,isHTMLForm:sn,hasOwnProperty:Ze,hasOwnProp:Ze,reduceDescriptors:$e,freezeMethods:e=>{$e(e,(t,n)=>{if(x(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!x(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return v(e)?r(e):r(String(e).split(t)),n},toCamelCase:on,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ge,global:Qe,isContextDefined:Ye,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(we(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=v(r)?[]:{};return K(r,(i,u)=>{const d=n(i,s+1);!W(d)&&(o[u]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function b(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}l.inherits(b,Error,{toJSON:function(){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:l.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const et=b.prototype,tt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{tt[e]={value:e}}),Object.defineProperties(b,tt),Object.defineProperty(et,"isAxiosError",{value:!0}),b.from=(e,t,n,r,s,o)=>{const i=Object.create(et);return l.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError"),b.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var ln=typeof self=="object"?self.FormData:window.FormData;const un=ln;function Oe(e){return l.isPlainObject(e)||l.isArray(e)}function nt(e){return l.endsWith(e,"[]")?e.slice(0,-2):e}function rt(e,t,n){return e?e.concat(t).map(function(s,o){return s=nt(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function cn(e){return l.isArray(e)&&!e.some(Oe)}const fn=l.toFlatObject(l,{},null,function(t){return/^is[A-Z]/.test(t)});function dn(e){return e&&l.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function se(e,t,n){if(!l.isObject(e))throw new TypeError("target must be an object");t=t||new(un||FormData),n=l.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(_,T){return!l.isUndefined(T[_])});const r=n.metaTokens,s=n.visitor||c,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&dn(t);if(!l.isFunction(s))throw new TypeError("visitor must be a function");function a(h){if(h===null)return"";if(l.isDate(h))return h.toISOString();if(!d&&l.isBlob(h))throw new b("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(h)||l.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function c(h,_,T){let R=h;if(h&&!T&&typeof h=="object"){if(l.endsWith(_,"{}"))_=r?_:_.slice(0,-2),h=JSON.stringify(h);else if(l.isArray(h)&&cn(h)||l.isFileList(h)||l.endsWith(_,"[]")&&(R=l.toArray(h)))return _=nt(_),R.forEach(function(z,fe){!(l.isUndefined(z)||z===null)&&t.append(i===!0?rt([_],fe,o):i===null?_:_+"[]",a(z))}),!1}return Oe(h)?!0:(t.append(rt(T,_,o),a(h)),!1)}const f=[],p=Object.assign(fn,{defaultVisitor:c,convertValue:a,isVisitable:Oe});function m(h,_){if(!l.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+_.join("."));f.push(h),l.forEach(h,function(R,N){(!(l.isUndefined(R)||R===null)&&s.call(t,R,l.isString(N)?N.trim():N,_,p))===!0&&m(R,_?_.concat(N):[N])}),f.pop()}}if(!l.isObject(e))throw new TypeError("data must be an object");return m(e),t}function st(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Se(e,t){this._pairs=[],e&&se(e,this,t)}const ot=Se.prototype;ot.append=function(t,n){this._pairs.push([t,n])},ot.toString=function(t){const n=t?function(r){return t.call(this,r,st)}:st;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function pn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function it(e,t,n){if(!t)return e;const r=n&&n.encode||pn,s=n&&n.serialize;let o;if(s?o=s(t,n):o=l.isURLSearchParams(t)?t.toString():new Se(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class hn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){l.forEach(this.handlers,function(r){r!==null&&t(r)})}}const at=hn,lt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},mn=typeof URLSearchParams<"u"?URLSearchParams:Se,_n=FormData,yn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),bn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),C={isBrowser:!0,classes:{URLSearchParams:mn,FormData:_n,Blob},isStandardBrowserEnv:yn,isStandardBrowserWebWorkerEnv:bn,protocols:["http","https","file","blob","url","data"]};function En(e,t){return se(e,new C.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return C.isNode&&l.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function wn(e){return l.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function gn(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&l.isArray(s)?s.length:i,d?(l.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!u):((!s[i]||!l.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&l.isArray(s[i])&&(s[i]=gn(s[i])),!u)}if(l.isFormData(e)&&l.isFunction(e.entries)){const n={};return l.forEachEntry(e,(r,s)=>{t(wn(r),s,n,0)}),n}return null}const On={"Content-Type":void 0};function Sn(e,t,n){if(l.isString(e))try{return(t||JSON.parse)(e),l.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const oe={transitional:lt,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=l.isObject(t);if(o&&l.isHTMLForm(t)&&(t=new FormData(t)),l.isFormData(t))return s&&s?JSON.stringify(ut(t)):t;if(l.isArrayBuffer(t)||l.isBuffer(t)||l.isStream(t)||l.isFile(t)||l.isBlob(t))return t;if(l.isArrayBufferView(t))return t.buffer;if(l.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return En(t,this.formSerializer).toString();if((u=l.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return se(u?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Sn(t)):t}],transformResponse:[function(t){const n=this.transitional||oe.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&l.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(u){if(i)throw u.name==="SyntaxError"?b.from(u,b.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};l.forEach(["delete","get","head"],function(t){oe.headers[t]={}}),l.forEach(["post","put","patch"],function(t){oe.headers[t]=l.merge(On)});const Re=oe,Rn=l.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"]),An=e=>{const t={};let n,r,s;return e&&e.split(` `).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&Rn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ct=Symbol("internals");function X(e){return e&&String(e).trim().toLowerCase()}function ie(e){return e===!1||e==null?e:l.isArray(e)?e.map(ie):String(e)}function Tn(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}function Nn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ft(e,t,n,r){if(l.isFunction(r))return r.call(this,t,n);if(!!l.isString(t)){if(l.isString(r))return t.indexOf(r)!==-1;if(l.isRegExp(r))return r.test(t)}}function kn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Cn(e,t){const n=l.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class ae{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(u,d,a){const c=X(d);if(!c)throw new Error("header name must be a non-empty string");const f=l.findKey(s,c);(!f||s[f]===void 0||a===!0||a===void 0&&s[f]!==!1)&&(s[f||d]=ie(u))}const i=(u,d)=>l.forEach(u,(a,c)=>o(a,c,d));return l.isPlainObject(t)||t instanceof this.constructor?i(t,n):l.isString(t)&&(t=t.trim())&&!Nn(t)?i(An(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=X(t),t){const r=l.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Tn(s);if(l.isFunction(n))return n.call(this,s,r);if(l.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=X(t),t){const r=l.findKey(this,t);return!!(r&&(!n||ft(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=X(i),i){const u=l.findKey(r,i);u&&(!n||ft(r,r[u],u,n))&&(delete r[u],s=!0)}}return l.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return l.forEach(this,(s,o)=>{const i=l.findKey(r,o);if(i){n[i]=ie(s),delete n[o];return}const u=t?kn(o):String(o).trim();u!==o&&delete n[o],n[u]=ie(s),r[u]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return l.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&l.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ct]=this[ct]={accessors:{}}).accessors,s=this.prototype;function o(i){const u=X(i);r[u]||(Cn(s,i),r[u]=!0)}return l.isArray(t)?t.forEach(o):o(t),this}}ae.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),l.freezeMethods(ae.prototype),l.freezeMethods(ae);const U=ae;function Ae(e,t){const n=this||Re,r=t||n,s=U.from(r.headers);let o=r.data;return l.forEach(e,function(u){o=u.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function dt(e){return!!(e&&e.__CANCEL__)}function G(e,t,n){b.call(this,e==null?"canceled":e,b.ERR_CANCELED,t,n),this.name="CanceledError"}l.inherits(G,b,{__CANCEL__:!0});const Pn=null;function Fn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new b("Request failed with status code "+n.status,[b.ERR_BAD_REQUEST,b.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Dn=C.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,u){const d=[];d.push(n+"="+encodeURIComponent(r)),l.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),l.isString(o)&&d.push("path="+o),l.isString(i)&&d.push("domain="+i),u===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Un(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Bn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function pt(e,t){return e&&!Un(t)?Bn(e,t):t}const Ln=C.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const u=l.isString(i)?s(i):i;return u.protocol===r.protocol&&u.host===r.host}}():function(){return function(){return!0}}();function xn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function jn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),c=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,p=0;for(;f!==s;)p+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,u=o-n,d=r(u),a=o<=i;n=o;const c={loaded:o,total:i,progress:i?o/i:void 0,bytes:u,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};c[t?"download":"upload"]=!0,e(c)}}const le={http:Pn,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=U.from(e.headers).normalize(),i=e.responseType;let u;function d(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}l.isFormData(s)&&(C.isStandardBrowserEnv||C.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const m=e.auth.username||"",h=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(m+":"+h))}const c=pt(e.baseURL,e.url);a.open(e.method.toUpperCase(),it(c,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const m=U.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),_={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:m,config:e,request:a};Fn(function(R){n(R),d()},function(R){r(R),d()},_),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new b("Request aborted",b.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new b("Network Error",b.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let h=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const _=e.transitional||lt;e.timeoutErrorMessage&&(h=e.timeoutErrorMessage),r(new b(h,_.clarifyTimeoutError?b.ETIMEDOUT:b.ECONNABORTED,e,a)),a=null},C.isStandardBrowserEnv){const m=(e.withCredentials||Ln(c))&&e.xsrfCookieName&&Dn.read(e.xsrfCookieName);m&&o.set(e.xsrfHeaderName,m)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&l.forEach(o.toJSON(),function(h,_){a.setRequestHeader(_,h)}),l.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",ht(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",ht(e.onUploadProgress)),(e.cancelToken||e.signal)&&(u=m=>{!a||(r(!m||m.type?new G(null,e,a):m),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u)));const p=xn(c);if(p&&C.protocols.indexOf(p)===-1){r(new b("Unsupported protocol "+p+":",b.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};l.forEach(le,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Hn={getAdapter:e=>{e=l.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof U?e.toJSON():e;function I(e,t){t=t||{};const n={};function r(a,c,f){return l.isPlainObject(a)&&l.isPlainObject(c)?l.merge.call({caseless:f},a,c):l.isPlainObject(c)?l.merge({},c):l.isArray(c)?c.slice():c}function s(a,c,f){if(l.isUndefined(c)){if(!l.isUndefined(a))return r(void 0,a,f)}else return r(a,c,f)}function o(a,c){if(!l.isUndefined(c))return r(void 0,c)}function i(a,c){if(l.isUndefined(c)){if(!l.isUndefined(a))return r(void 0,a)}else return r(void 0,c)}function u(a,c,f){if(f in t)return r(a,c);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:u,headers:(a,c)=>s(_t(a),_t(c),!0)};return l.forEach(Object.keys(e).concat(Object.keys(t)),function(c){const f=d[c]||s,p=f(e[c],t[c],c);l.isUndefined(p)&&f!==u||(n[c]=p)}),n}const yt="1.2.1",Ne={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ne[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const bt={};Ne.transitional=function(t,n,r){function s(o,i){return"[Axios v"+yt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,u)=>{if(t===!1)throw new b(s(i," has been removed"+(n?" in "+n:"")),b.ERR_DEPRECATED);return n&&!bt[i]&&(bt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,u):!0}};function Mn(e,t,n){if(typeof e!="object")throw new b("options must be an object",b.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const u=e[o],d=u===void 0||i(u,o,e);if(d!==!0)throw new b("option "+o+" must be "+d,b.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new b("Unknown option "+o,b.ERR_BAD_OPTION)}}const ke={assertOptions:Mn,validators:Ne},L=ke.validators;class ue{constructor(t){this.defaults=t,this.interceptors={request:new at,response:new at}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=I(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&ke.assertOptions(r,{silentJSONParsing:L.transitional(L.boolean),forcedJSONParsing:L.transitional(L.boolean),clarifyTimeoutError:L.transitional(L.boolean)},!1),s!==void 0&&ke.assertOptions(s,{encode:L.function,serialize:L.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&l.merge(o.common,o[n.method]),i&&l.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),n.headers=U.concat(i,o);const u=[];let d=!0;this.interceptors.request.forEach(function(_){typeof _.runWhen=="function"&&_.runWhen(n)===!1||(d=d&&_.synchronous,u.unshift(_.fulfilled,_.rejected))});const a=[];this.interceptors.response.forEach(function(_){a.push(_.fulfilled,_.rejected)});let c,f=0,p;if(!d){const h=[mt.bind(this),void 0];for(h.unshift.apply(h,u),h.push.apply(h,a),p=h.length,c=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(u=>{r.subscribe(u),o=u}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,u){r.reason||(r.reason=new G(o,i,u),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Ce(function(s){t=s}),cancel:t}}}const vn=Ce;function In(e){return function(n){return e.apply(null,n)}}function zn(e){return l.isObject(e)&&e.isAxiosError===!0}function Et(e){const t=new ce(e),n=Ve(ce.prototype.request,t);return l.extend(n,ce.prototype,t,{allOwnKeys:!0}),l.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Et(I(e,s))},n}const g=Et(Re);g.Axios=ce,g.CanceledError=G,g.CancelToken=vn,g.isCancel=dt,g.VERSION=yt,g.toFormData=se,g.AxiosError=b,g.Cancel=g.CanceledError,g.all=function(t){return Promise.all(t)},g.spread=In,g.isAxiosError=zn,g.mergeConfig=I,g.AxiosHeaders=U,g.formToJSON=e=>ut(l.isHTMLForm(e)?new FormData(e):e),g.default=g;const Jn=g,Or="";function wt(e){let t,n,r,s,o,i;function u(c,f){return!c[4]&&!c[5]&&!c[6]?Vn:qn}let d=u(e),a=d(e);return{c(){t=O("div"),n=O("div"),a.c(),r=F(),s=O("input"),y(n,"id","widget-label"),y(n,"class","svelte-1f4196f"),y(s,"id","fileUpload"),y(s,"type","file"),y(s,"class","svelte-1f4196f"),y(t,"id","fileUploadWidget"),y(t,"class","svelte-1f4196f")},m(c,f){A(c,t,f),E(t,n),a.m(n,null),E(t,r),E(t,s),o||(i=[M(s,"change",e[18]),M(s,"change",e[11])],o=!0)},p(c,f){d===(d=u(c))&&a?a.p(c,f):(a.d(1),a=d(c),a&&(a.c(),a.m(n,null)))},d(c){c&&S(t),a.d(),o=!1,H(i)}}}function qn(e){let t,n,r,s,o,i=`${e[3]}%`;function u(f,p){return f[5]?Wn:Kn}let d=u(e),a=d(e),c=e[6]&>();return{c(){t=O("div"),n=O("div"),a.c(),r=F(),c&&c.c(),s=F(),o=O("div"),y(n,"class","percentage-text svelte-1f4196f"),y(o,"id","percentage-bar"),y(o,"class","svelte-1f4196f"),xe(o,"width",i),y(t,"id","percentage"),y(t,"class","svelte-1f4196f")},m(f,p){A(f,t,p),E(t,n),a.m(n,null),E(n,r),c&&c.m(n,null),E(t,s),E(t,o)},p(f,p){d===(d=u(f))&&a?a.p(f,p):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[6]?c||(c=gt(),c.c(),c.m(n,null)):c&&(c.d(1),c=null),p&8&&i!==(i=`${f[3]}%`)&&xe(o,"width",i)},d(f){f&&S(t),a.d(),c&&c.d()}}}function Vn(e){let t;function n(o,i){return o[1]?Gn:Xn}let r=n(e),s=r(e);return{c(){s.c(),t=pe()},m(o,i){s.m(o,i),A(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&S(t)}}}function Wn(e){let t;return{c(){t=B("Waiting for data schema detection...")},m(n,r){A(n,t,r)},p:k,d(n){n&&S(t)}}}function Kn(e){let t,n=!e[6]&&Ot(e);return{c(){n&&n.c(),t=pe()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[6]?n&&(n.d(1),n=null):n?n.p(r,s):(n=Ot(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&S(t)}}}function Ot(e){let t,n;return{c(){t=B(e[3]),n=B("%")},m(r,s){A(r,t,s),A(r,n,s)},p(r,s){s&8&&Nt(t,r[3])},d(r){r&&S(t),r&&S(n)}}}function gt(e){let t;return{c(){t=B("File uploaded")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Xn(e){let t;return{c(){t=B("Select a file to upload")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Gn(e){let t;return{c(){t=B("Select a file to replace the current one")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Qn(e){let t,n,r,s,o,i,u,d,a;return{c(){t=O("div"),n=O("label"),n.textContent="URL",r=F(),s=O("div"),o=O("input"),i=F(),u=O("input"),y(n,"class","control-label"),y(n,"for","field_url"),y(o,"id","field_url"),y(o,"class","form-control"),y(o,"type","text"),y(o,"name","url"),y(u,"type","hidden"),y(u,"name","clear_upload"),u.value="true",y(s,"class","controls"),y(t,"id","resourceURL"),y(t,"class","controls svelte-1f4196f")},m(c,f){A(c,t,f),E(t,n),E(t,r),E(t,s),E(s,o),Y(o,e[8]),E(s,i),E(s,u),d||(a=M(o,"input",e[20]),d=!0)},p(c,f){f&256&&o.value!==c[8]&&Y(o,c[8])},d(c){c&&S(t),d=!1,a()}}}function Yn(e){let t,n=e[9]!=""&&St(e);return{c(){n&&n.c(),t=pe()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[9]!=""?n?n.p(r,s):(n=St(r),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},d(r){n&&n.d(r),r&&S(t)}}}function St(e){let t,n,r,s,o,i,u,d;return{c(){t=O("div"),n=O("label"),n.textContent="Current file",r=F(),s=O("div"),o=O("input"),y(n,"class","control-label"),y(n,"for","field_url"),o.readOnly=i=e[0]!="upload"?void 0:!0,y(o,"id","field_url"),y(o,"class","form-control"),y(o,"type","text"),y(o,"name","url"),y(s,"class","controls"),y(t,"class","controls")},m(a,c){A(a,t,c),E(t,n),E(t,r),E(t,s),E(s,o),Y(o,e[9]),u||(d=M(o,"input",e[19]),u=!0)},p(a,c){c&1&&i!==(i=a[0]!="upload"?void 0:!0)&&(o.readOnly=i),c&512&&o.value!==a[9]&&Y(o,a[9])},d(a){a&&S(t),u=!1,d()}}}function Zn(e){let t,n,r,s,o,i,u,d,a=e[7]=="upload"&&wt(e);function c(m,h){if(m[7]=="upload")return Yn;if(m[7]!="None")return Qn}let f=c(e),p=f&&f(e);return{c(){t=O("div"),n=O("a"),n.innerHTML='File',r=F(),s=O("a"),s.innerHTML='Link',o=F(),a&&a.c(),i=F(),p&&p.c(),y(n,"class","btn btn-default"),Z(n,"active",e[7]=="upload"),y(s,"class","btn btn-default"),Z(s,"active",e[7]!="upload"&&e[7]!="None"),y(t,"class","form-group")},m(m,h){A(m,t,h),E(t,n),E(t,r),E(t,s),E(t,o),a&&a.m(t,null),E(t,i),p&&p.m(t,null),u||(d=[M(n,"click",e[16]),M(s,"click",e[17])],u=!0)},p(m,[h]){h&128&&Z(n,"active",m[7]=="upload"),h&128&&Z(s,"active",m[7]!="upload"&&m[7]!="None"),m[7]=="upload"?a?a.p(m,h):(a=wt(m),a.c(),a.m(t,i)):a&&(a.d(1),a=null),f===(f=c(m))&&p?p.p(m,h):(p&&p.d(1),p=f&&f(m),p&&(p.c(),p.m(t,null)))},i:k,o:k,d(m){m&&S(t),a&&a.d(),p&&p.d(),u=!1,H(d)}}}function Rt(e){let t=e.split("/");return t.length>0?t[t.length-1]:t[0]}function $n(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:u}=t,{url_type:d=""}=t,a,c=0,f=!1,p=!1,m=!1,h=je(),_=i?"update":"create",T=d,R="",N="";d!="upload"?R=u:N=Rt(u);async function z(w,Q){try{const P={onUploadProgress:fr=>{const{loaded:dr,total:pr}=fr,De=Math.floor(dr*100/pr);De<=100&&(Q(De),De==100&&(n(4,f=!1),n(5,p=!0)))}},de=_=="update"?`${r}/dataset/${s}/resource/${o}/file`:`${r}/dataset/${s}/resource/file`,{data:Fe}=await Jn.post(de,w,P);return Fe}catch(P){console.log("ERROR",P.message)}}function fe(w){n(3,c=w)}function Pe(w){n(7,T=w)}async function or(w){try{const Q=w.target.files[0],P=new FormData;P.append("upload",Q),P.append("package_id",s),i&&(P.append("id",o),P.append("clear_upload",!0),P.append("url_type",d)),n(4,f=!0);let de=await z(P,fe),Fe={data:de};n(9,N=Rt(de.url)),n(0,d="upload"),h("fileUploaded",Fe),n(5,p=!1),n(6,m=!0)}catch(Q){console.log("ERROR",Q),fe(0)}}const ir=w=>{Pe("upload")},ar=w=>{Pe("")};function lr(){a=this.files,n(2,a)}function ur(){N=this.value,n(9,N)}function cr(){R=this.value,n(8,R)}return e.$$set=w=>{"upload_url"in w&&n(12,r=w.upload_url),"dataset_id"in w&&n(13,s=w.dataset_id),"resource_id"in w&&n(14,o=w.resource_id),"update"in w&&n(1,i=w.update),"current_url"in w&&n(15,u=w.current_url),"url_type"in w&&n(0,d=w.url_type)},[d,i,a,c,f,p,m,T,R,N,Pe,or,r,s,o,u,ir,ar,lr,ur,cr]}class er extends qe{constructor(t){super(),Je(this,t,$n,Zn,Le,{upload_url:12,dataset_id:13,resource_id:14,update:1,current_url:15,url_type:0})}}function tr(e){let t,n,r;return n=new er({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=O("main"),Lt(n.$$.fragment)},m(s,o){A(s,t,o),Ie(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(ve(n.$$.fragment,s),r=!0)},o(s){Bt(n.$$.fragment,s),r=!1},d(s){s&&S(t),ze(n),e[8](null)}}}function nr(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:u}=t,{url_type:d}=t;je();let a;function c(p){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:p.detail.data}))}function f(p){he[p?"unshift":"push"](()=>{a=p,n(6,a)})}return e.$$set=p=>{"upload_url"in p&&n(0,r=p.upload_url),"dataset_id"in p&&n(1,s=p.dataset_id),"resource_id"in p&&n(2,o=p.resource_id),"update"in p&&n(3,i=p.update),"current_url"in p&&n(4,u=p.current_url),"url_type"in p&&n(5,d=p.url_type)},[r,s,o,i,u,d,a,c,f]}class rr extends qe{constructor(t){super(),Je(this,t,nr,tr,Le,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function sr(e,t="",n="",r="",s="",o="",i=""){new rr({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return sr}); +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ct]=this[ct]={accessors:{}}).accessors,s=this.prototype;function o(i){const u=X(i);r[u]||(Cn(s,i),r[u]=!0)}return l.isArray(t)?t.forEach(o):o(t),this}}ae.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),l.freezeMethods(ae.prototype),l.freezeMethods(ae);const U=ae;function Ae(e,t){const n=this||Re,r=t||n,s=U.from(r.headers);let o=r.data;return l.forEach(e,function(u){o=u.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function dt(e){return!!(e&&e.__CANCEL__)}function G(e,t,n){b.call(this,e==null?"canceled":e,b.ERR_CANCELED,t,n),this.name="CanceledError"}l.inherits(G,b,{__CANCEL__:!0});const Pn=null;function Fn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new b("Request failed with status code "+n.status,[b.ERR_BAD_REQUEST,b.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Dn=C.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,u){const d=[];d.push(n+"="+encodeURIComponent(r)),l.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),l.isString(o)&&d.push("path="+o),l.isString(i)&&d.push("domain="+i),u===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Un(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Bn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function pt(e,t){return e&&!Un(t)?Bn(e,t):t}const Ln=C.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const u=l.isString(i)?s(i):i;return u.protocol===r.protocol&&u.host===r.host}}():function(){return function(){return!0}}();function xn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function jn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),c=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,p=0;for(;f!==s;)p+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,u=o-n,d=r(u),a=o<=i;n=o;const c={loaded:o,total:i,progress:i?o/i:void 0,bytes:u,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};c[t?"download":"upload"]=!0,e(c)}}const le={http:Pn,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=U.from(e.headers).normalize(),i=e.responseType;let u;function d(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}l.isFormData(s)&&(C.isStandardBrowserEnv||C.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const m=e.auth.username||"",h=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(m+":"+h))}const c=pt(e.baseURL,e.url);a.open(e.method.toUpperCase(),it(c,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const m=U.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),_={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:m,config:e,request:a};Fn(function(R){n(R),d()},function(R){r(R),d()},_),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new b("Request aborted",b.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new b("Network Error",b.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let h=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const _=e.transitional||lt;e.timeoutErrorMessage&&(h=e.timeoutErrorMessage),r(new b(h,_.clarifyTimeoutError?b.ETIMEDOUT:b.ECONNABORTED,e,a)),a=null},C.isStandardBrowserEnv){const m=(e.withCredentials||Ln(c))&&e.xsrfCookieName&&Dn.read(e.xsrfCookieName);m&&o.set(e.xsrfHeaderName,m)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&l.forEach(o.toJSON(),function(h,_){a.setRequestHeader(_,h)}),l.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",ht(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",ht(e.onUploadProgress)),(e.cancelToken||e.signal)&&(u=m=>{!a||(r(!m||m.type?new G(null,e,a):m),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u)));const p=xn(c);if(p&&C.protocols.indexOf(p)===-1){r(new b("Unsupported protocol "+p+":",b.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};l.forEach(le,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Hn={getAdapter:e=>{e=l.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof U?e.toJSON():e;function I(e,t){t=t||{};const n={};function r(a,c,f){return l.isPlainObject(a)&&l.isPlainObject(c)?l.merge.call({caseless:f},a,c):l.isPlainObject(c)?l.merge({},c):l.isArray(c)?c.slice():c}function s(a,c,f){if(l.isUndefined(c)){if(!l.isUndefined(a))return r(void 0,a,f)}else return r(a,c,f)}function o(a,c){if(!l.isUndefined(c))return r(void 0,c)}function i(a,c){if(l.isUndefined(c)){if(!l.isUndefined(a))return r(void 0,a)}else return r(void 0,c)}function u(a,c,f){if(f in t)return r(a,c);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:u,headers:(a,c)=>s(_t(a),_t(c),!0)};return l.forEach(Object.keys(e).concat(Object.keys(t)),function(c){const f=d[c]||s,p=f(e[c],t[c],c);l.isUndefined(p)&&f!==u||(n[c]=p)}),n}const yt="1.2.1",Ne={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ne[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const bt={};Ne.transitional=function(t,n,r){function s(o,i){return"[Axios v"+yt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,u)=>{if(t===!1)throw new b(s(i," has been removed"+(n?" in "+n:"")),b.ERR_DEPRECATED);return n&&!bt[i]&&(bt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,u):!0}};function Mn(e,t,n){if(typeof e!="object")throw new b("options must be an object",b.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const u=e[o],d=u===void 0||i(u,o,e);if(d!==!0)throw new b("option "+o+" must be "+d,b.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new b("Unknown option "+o,b.ERR_BAD_OPTION)}}const ke={assertOptions:Mn,validators:Ne},L=ke.validators;class ue{constructor(t){this.defaults=t,this.interceptors={request:new at,response:new at}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=I(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&ke.assertOptions(r,{silentJSONParsing:L.transitional(L.boolean),forcedJSONParsing:L.transitional(L.boolean),clarifyTimeoutError:L.transitional(L.boolean)},!1),s!==void 0&&ke.assertOptions(s,{encode:L.function,serialize:L.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&l.merge(o.common,o[n.method]),i&&l.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),n.headers=U.concat(i,o);const u=[];let d=!0;this.interceptors.request.forEach(function(_){typeof _.runWhen=="function"&&_.runWhen(n)===!1||(d=d&&_.synchronous,u.unshift(_.fulfilled,_.rejected))});const a=[];this.interceptors.response.forEach(function(_){a.push(_.fulfilled,_.rejected)});let c,f=0,p;if(!d){const h=[mt.bind(this),void 0];for(h.unshift.apply(h,u),h.push.apply(h,a),p=h.length,c=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(u=>{r.subscribe(u),o=u}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,u){r.reason||(r.reason=new G(o,i,u),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Ce(function(s){t=s}),cancel:t}}}const vn=Ce;function In(e){return function(n){return e.apply(null,n)}}function zn(e){return l.isObject(e)&&e.isAxiosError===!0}function Et(e){const t=new ce(e),n=Ve(ce.prototype.request,t);return l.extend(n,ce.prototype,t,{allOwnKeys:!0}),l.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Et(I(e,s))},n}const O=Et(Re);O.Axios=ce,O.CanceledError=G,O.CancelToken=vn,O.isCancel=dt,O.VERSION=yt,O.toFormData=se,O.AxiosError=b,O.Cancel=O.CanceledError,O.all=function(t){return Promise.all(t)},O.spread=In,O.isAxiosError=zn,O.mergeConfig=I,O.AxiosHeaders=U,O.formToJSON=e=>ut(l.isHTMLForm(e)?new FormData(e):e),O.default=O;const Jn=O,gr="";function wt(e){let t,n,r,s,o,i;function u(c,f){return!c[4]&&!c[5]&&!c[6]?Vn:qn}let d=u(e),a=d(e);return{c(){t=g("div"),n=g("div"),a.c(),r=F(),s=g("input"),y(n,"id","widget-label"),y(n,"class","svelte-1f4196f"),y(s,"id","fileUpload"),y(s,"type","file"),y(s,"class","svelte-1f4196f"),y(t,"id","fileUploadWidget"),y(t,"class","svelte-1f4196f")},m(c,f){A(c,t,f),E(t,n),a.m(n,null),E(t,r),E(t,s),o||(i=[M(s,"change",e[18]),M(s,"change",e[11])],o=!0)},p(c,f){d===(d=u(c))&&a?a.p(c,f):(a.d(1),a=d(c),a&&(a.c(),a.m(n,null)))},d(c){c&&S(t),a.d(),o=!1,H(i)}}}function qn(e){let t,n,r,s,o,i=`${e[3]}%`;function u(f,p){return f[5]?Wn:Kn}let d=u(e),a=d(e),c=e[6]&&Ot();return{c(){t=g("div"),n=g("div"),a.c(),r=F(),c&&c.c(),s=F(),o=g("div"),y(n,"class","percentage-text svelte-1f4196f"),y(o,"id","percentage-bar"),y(o,"class","svelte-1f4196f"),xe(o,"width",i),y(t,"id","percentage"),y(t,"class","svelte-1f4196f")},m(f,p){A(f,t,p),E(t,n),a.m(n,null),E(n,r),c&&c.m(n,null),E(t,s),E(t,o)},p(f,p){d===(d=u(f))&&a?a.p(f,p):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[6]?c||(c=Ot(),c.c(),c.m(n,null)):c&&(c.d(1),c=null),p&8&&i!==(i=`${f[3]}%`)&&xe(o,"width",i)},d(f){f&&S(t),a.d(),c&&c.d()}}}function Vn(e){let t;function n(o,i){return o[1]?Gn:Xn}let r=n(e),s=r(e);return{c(){s.c(),t=pe()},m(o,i){s.m(o,i),A(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&S(t)}}}function Wn(e){let t;return{c(){t=B("Waiting for data schema detection...")},m(n,r){A(n,t,r)},p:k,d(n){n&&S(t)}}}function Kn(e){let t,n=!e[6]&>(e);return{c(){n&&n.c(),t=pe()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[6]?n&&(n.d(1),n=null):n?n.p(r,s):(n=gt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&S(t)}}}function gt(e){let t,n;return{c(){t=B(e[3]),n=B("%")},m(r,s){A(r,t,s),A(r,n,s)},p(r,s){s&8&&Nt(t,r[3])},d(r){r&&S(t),r&&S(n)}}}function Ot(e){let t;return{c(){t=B("File uploaded")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Xn(e){let t;return{c(){t=B("Select a file to upload")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Gn(e){let t;return{c(){t=B("Select a file to replace the current one")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Qn(e){let t,n,r,s,o,i,u,d,a;return{c(){t=g("div"),n=g("label"),n.textContent="URL",r=F(),s=g("div"),o=g("input"),i=F(),u=g("input"),y(n,"class","control-label"),y(n,"for","field_url"),y(o,"id","field_url"),y(o,"class","form-control"),y(o,"type","text"),y(o,"name","url"),y(u,"type","hidden"),y(u,"name","clear_upload"),u.value="true",y(s,"class","controls"),y(t,"id","resourceURL"),y(t,"class","controls svelte-1f4196f")},m(c,f){A(c,t,f),E(t,n),E(t,r),E(t,s),E(s,o),Y(o,e[8]),E(s,i),E(s,u),d||(a=M(o,"input",e[20]),d=!0)},p(c,f){f&256&&o.value!==c[8]&&Y(o,c[8])},d(c){c&&S(t),d=!1,a()}}}function Yn(e){let t,n=e[9]!=""&&St(e);return{c(){n&&n.c(),t=pe()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[9]!=""?n?n.p(r,s):(n=St(r),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},d(r){n&&n.d(r),r&&S(t)}}}function St(e){let t,n,r,s,o,i,u,d;return{c(){t=g("div"),n=g("label"),n.textContent="Current file",r=F(),s=g("div"),o=g("input"),y(n,"class","control-label"),y(n,"for","field_url"),o.readOnly=i=e[0]!="upload"?void 0:!0,y(o,"id","field_url"),y(o,"class","form-control"),y(o,"type","text"),y(o,"name","url"),y(s,"class","controls"),y(t,"class","controls")},m(a,c){A(a,t,c),E(t,n),E(t,r),E(t,s),E(s,o),Y(o,e[9]),u||(d=M(o,"input",e[19]),u=!0)},p(a,c){c&1&&i!==(i=a[0]!="upload"?void 0:!0)&&(o.readOnly=i),c&512&&o.value!==a[9]&&Y(o,a[9])},d(a){a&&S(t),u=!1,d()}}}function Zn(e){let t,n,r,s,o,i,u,d,a=e[7]=="upload"&&wt(e);function c(m,h){if(m[7]=="upload")return Yn;if(m[7]!="None")return Qn}let f=c(e),p=f&&f(e);return{c(){t=g("div"),n=g("a"),n.innerHTML='File',r=F(),s=g("a"),s.innerHTML='Link',o=F(),a&&a.c(),i=F(),p&&p.c(),y(n,"class","btn btn-default"),Z(n,"active",e[7]=="upload"),y(s,"class","btn btn-default"),Z(s,"active",e[7]!="upload"&&e[7]!="None"),y(t,"class","form-group")},m(m,h){A(m,t,h),E(t,n),E(t,r),E(t,s),E(t,o),a&&a.m(t,null),E(t,i),p&&p.m(t,null),u||(d=[M(n,"click",e[16]),M(s,"click",e[17])],u=!0)},p(m,[h]){h&128&&Z(n,"active",m[7]=="upload"),h&128&&Z(s,"active",m[7]!="upload"&&m[7]!="None"),m[7]=="upload"?a?a.p(m,h):(a=wt(m),a.c(),a.m(t,i)):a&&(a.d(1),a=null),f===(f=c(m))&&p?p.p(m,h):(p&&p.d(1),p=f&&f(m),p&&(p.c(),p.m(t,null)))},i:k,o:k,d(m){m&&S(t),a&&a.d(),p&&p.d(),u=!1,H(d)}}}function Rt(e){let t=e.split("/");return t.length>0?t[t.length-1]:t[0]}function $n(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:u}=t,{url_type:d=""}=t,a,c=0,f=!1,p=!1,m=!1,h=je(),_=i?"update":"create",T=d,R="",N="";d!="upload"?R=u:N=Rt(u);async function z(w,Q){try{const P={onUploadProgress:fr=>{const{loaded:dr,total:pr}=fr,De=Math.floor(dr*100/pr);De<=100&&(Q(De),De==100&&(n(4,f=!1),n(5,p=!0)))}},de=_=="update"?`${r}/dataset/${s}/resource/${o}/file`:`${r}/dataset/${s}/resource/file`,{data:Fe}=await Jn.post(de,w,P);return Fe}catch(P){console.log("ERROR",P.message)}}function fe(w){n(3,c=w)}function Pe(w){n(7,T=w),document.getElementById("fileUpload").click()}async function or(w){try{const Q=w.target.files[0],P=new FormData;P.append("upload",Q),P.append("package_id",s),i&&(P.append("id",o),P.append("clear_upload",!0),P.append("url_type",d)),n(4,f=!0);let de=await z(P,fe),Fe={data:de};n(9,N=Rt(de.url)),n(0,d="upload"),h("fileUploaded",Fe),n(5,p=!1),n(6,m=!0)}catch(Q){console.log("ERROR",Q),fe(0)}}const ir=w=>{Pe("upload")},ar=w=>{Pe("")};function lr(){a=this.files,n(2,a)}function ur(){N=this.value,n(9,N)}function cr(){R=this.value,n(8,R)}return e.$$set=w=>{"upload_url"in w&&n(12,r=w.upload_url),"dataset_id"in w&&n(13,s=w.dataset_id),"resource_id"in w&&n(14,o=w.resource_id),"update"in w&&n(1,i=w.update),"current_url"in w&&n(15,u=w.current_url),"url_type"in w&&n(0,d=w.url_type)},[d,i,a,c,f,p,m,T,R,N,Pe,or,r,s,o,u,ir,ar,lr,ur,cr]}class er extends qe{constructor(t){super(),Je(this,t,$n,Zn,Le,{upload_url:12,dataset_id:13,resource_id:14,update:1,current_url:15,url_type:0})}}function tr(e){let t,n,r;return n=new er({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=g("main"),Lt(n.$$.fragment)},m(s,o){A(s,t,o),Ie(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(ve(n.$$.fragment,s),r=!0)},o(s){Bt(n.$$.fragment,s),r=!1},d(s){s&&S(t),ze(n),e[8](null)}}}function nr(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:u}=t,{url_type:d}=t;je();let a;function c(p){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:p.detail.data}))}function f(p){he[p?"unshift":"push"](()=>{a=p,n(6,a)})}return e.$$set=p=>{"upload_url"in p&&n(0,r=p.upload_url),"dataset_id"in p&&n(1,s=p.dataset_id),"resource_id"in p&&n(2,o=p.resource_id),"update"in p&&n(3,i=p.update),"current_url"in p&&n(4,u=p.current_url),"url_type"in p&&n(5,d=p.url_type)},[r,s,o,i,u,d,a,c,f]}class rr extends qe{constructor(t){super(),Je(this,t,nr,tr,Le,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function sr(e,t="",n="",r="",s="",o="",i=""){new rr({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return sr}); diff --git a/dev-requirements.txt b/dev-requirements.txt index 51697501..4f437139 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,3 +1,4 @@ pyfakefs==4.6.* pytest-ckan pytest-cov +responses From 78a335109dd254aa4338c28589fc708d945f88eb Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 23 Feb 2023 12:24:57 +0100 Subject: [PATCH 34/43] Bump frictionless to fix schema infer errors --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ee7cb38c..324097b8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ ckantoolkit>=0.0.3 -frictionless==5.0.0b9 +frictionless==5.6.3 markupsafe==2.0.1 tableschema -e git+https://github.com/ckan/ckanext-scheming.git#egg=ckanext-scheming From 25dbed6e1864e393be4b0107a0783230088085d1 Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 23 Feb 2023 12:26:40 +0100 Subject: [PATCH 35/43] Revert accidental changes in ckan-uploader.js --- ckanext/validation/webassets/js/ckan-uploader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ckanext/validation/webassets/js/ckan-uploader.js b/ckanext/validation/webassets/js/ckan-uploader.js index c540cc1f..1b0c944a 100644 --- a/ckanext/validation/webassets/js/ckan-uploader.js +++ b/ckanext/validation/webassets/js/ckan-uploader.js @@ -1,3 +1,3 @@ -(function(k,j){typeof exports=="object"&&typeof module<"u"?module.exports=j():typeof define=="function"&&define.amd?define(j):(k=typeof globalThis<"u"?globalThis:k||self,k.CkanUploader=j())})(this,function(){"use strict";function k(){}function j(e){return e()}function Ue(){return Object.create(null)}function H(e){e.forEach(j)}function Be(e){return typeof e=="function"}function Le(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function At(e){return Object.keys(e).length===0}function E(e,t){e.appendChild(t)}function A(e,t,n){e.insertBefore(t,n||null)}function S(e){e.parentNode&&e.parentNode.removeChild(e)}function g(e){return document.createElement(e)}function B(e){return document.createTextNode(e)}function F(){return B(" ")}function pe(){return B("")}function M(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function y(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Tt(e){return Array.from(e.childNodes)}function Nt(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Y(e,t){e.value=t==null?"":t}function xe(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function Z(e,t,n){e.classList[n?"add":"remove"](t)}function kt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Ct(){if(!J)throw new Error("Function called outside component initialization");return J}function je(){const e=Ct();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=kt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const V=[],he=[],$=[],He=[],Pt=Promise.resolve();let me=!1;function Ft(){me||(me=!0,Pt.then(Me))}function _e(e){$.push(e)}const ye=new Set;let ee=0;function Me(){const e=J;do{for(;ee{te.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Lt(e){e&&e.c()}function Ie(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||_e(()=>{const i=e.$$.on_mount.map(j).filter(Be);e.$$.on_destroy?e.$$.on_destroy.push(...i):H(i),e.$$.on_mount=[]}),o.forEach(_e)}function ze(e,t){const n=e.$$;n.fragment!==null&&(H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function xt(e,t){e.$$.dirty[0]===-1&&(V.push(e),Ft(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const h=m.length?m[0]:p;return a.ctx&&s(a.ctx[f],a.ctx[f]=h)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](h),c&&xt(e,f)),p}):[],a.update(),c=!0,H(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Tt(t.target);a.fragment&&a.fragment.l(f),f.forEach(S)}else a.fragment&&a.fragment.c();t.intro&&ve(e.$$.fragment),Ie(e,t.target,t.anchor,t.customElement),Me()}q(d)}class qe{$destroy(){ze(this,1),this.$destroy=k}$on(t,n){if(!Be(n))return k;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!At(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function Ve(e,t){return function(){return e.apply(t,arguments)}}const{toString:We}=Object.prototype,{getPrototypeOf:be}=Object,Ee=(e=>t=>{const n=We.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),D=e=>(e=e.toLowerCase(),t=>Ee(t)===e),ne=e=>t=>typeof t===e,{isArray:v}=Array,W=ne("undefined");function jt(e){return e!==null&&!W(e)&&e.constructor!==null&&!W(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ke=D("ArrayBuffer");function Ht(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ke(e.buffer),t}const Mt=ne("string"),x=ne("function"),Xe=ne("number"),we=e=>e!==null&&typeof e=="object",vt=e=>e===!0||e===!1,re=e=>{if(Ee(e)!=="object")return!1;const t=be(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},It=D("Date"),zt=D("File"),Jt=D("Blob"),qt=D("FileList"),Vt=e=>we(e)&&x(e.pipe),Wt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||We.call(e)===t||x(e.toString)&&e.toString()===t)},Kt=D("URLSearchParams"),Xt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function K(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),v(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Qe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ye=e=>!W(e)&&e!==Qe;function ge(){const{caseless:e}=Ye(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ge(t,s)||s;re(t[o])&&re(r)?t[o]=ge(t[o],r):re(r)?t[o]=ge({},r):v(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(K(t,(s,o)=>{n&&x(s)?e[o]=Ve(s,n):e[o]=s},{allOwnKeys:r}),e),Qt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Yt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Zt=(e,t,n,r)=>{let s,o,i;const u={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!u[i]&&(t[i]=e[i],u[i]=!0);e=n!==!1&&be(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},$t=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},en=e=>{if(!e)return null;if(v(e))return e;let t=e.length;if(!Xe(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},tn=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&be(Uint8Array)),nn=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},rn=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},sn=D("HTMLFormElement"),on=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ze=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),an=D("RegExp"),$e=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};K(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},l={isArray:v,isArrayBuffer:Ke,isBuffer:jt,isFormData:Wt,isArrayBufferView:Ht,isString:Mt,isNumber:Xe,isBoolean:vt,isObject:we,isPlainObject:re,isUndefined:W,isDate:It,isFile:zt,isBlob:Jt,isRegExp:an,isFunction:x,isStream:Vt,isURLSearchParams:Kt,isTypedArray:tn,isFileList:qt,forEach:K,merge:ge,extend:Gt,trim:Xt,stripBOM:Qt,inherits:Yt,toFlatObject:Zt,kindOf:Ee,kindOfTest:D,endsWith:$t,toArray:en,forEachEntry:nn,matchAll:rn,isHTMLForm:sn,hasOwnProperty:Ze,hasOwnProp:Ze,reduceDescriptors:$e,freezeMethods:e=>{$e(e,(t,n)=>{if(x(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!x(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return v(e)?r(e):r(String(e).split(t)),n},toCamelCase:on,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ge,global:Qe,isContextDefined:Ye,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(we(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=v(r)?[]:{};return K(r,(i,u)=>{const d=n(i,s+1);!W(d)&&(o[u]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function b(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}l.inherits(b,Error,{toJSON:function(){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:l.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const et=b.prototype,tt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{tt[e]={value:e}}),Object.defineProperties(b,tt),Object.defineProperty(et,"isAxiosError",{value:!0}),b.from=(e,t,n,r,s,o)=>{const i=Object.create(et);return l.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError"),b.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var ln=typeof self=="object"?self.FormData:window.FormData;const un=ln;function Oe(e){return l.isPlainObject(e)||l.isArray(e)}function nt(e){return l.endsWith(e,"[]")?e.slice(0,-2):e}function rt(e,t,n){return e?e.concat(t).map(function(s,o){return s=nt(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function cn(e){return l.isArray(e)&&!e.some(Oe)}const fn=l.toFlatObject(l,{},null,function(t){return/^is[A-Z]/.test(t)});function dn(e){return e&&l.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function se(e,t,n){if(!l.isObject(e))throw new TypeError("target must be an object");t=t||new(un||FormData),n=l.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(_,T){return!l.isUndefined(T[_])});const r=n.metaTokens,s=n.visitor||c,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&dn(t);if(!l.isFunction(s))throw new TypeError("visitor must be a function");function a(h){if(h===null)return"";if(l.isDate(h))return h.toISOString();if(!d&&l.isBlob(h))throw new b("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(h)||l.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function c(h,_,T){let R=h;if(h&&!T&&typeof h=="object"){if(l.endsWith(_,"{}"))_=r?_:_.slice(0,-2),h=JSON.stringify(h);else if(l.isArray(h)&&cn(h)||l.isFileList(h)||l.endsWith(_,"[]")&&(R=l.toArray(h)))return _=nt(_),R.forEach(function(z,fe){!(l.isUndefined(z)||z===null)&&t.append(i===!0?rt([_],fe,o):i===null?_:_+"[]",a(z))}),!1}return Oe(h)?!0:(t.append(rt(T,_,o),a(h)),!1)}const f=[],p=Object.assign(fn,{defaultVisitor:c,convertValue:a,isVisitable:Oe});function m(h,_){if(!l.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+_.join("."));f.push(h),l.forEach(h,function(R,N){(!(l.isUndefined(R)||R===null)&&s.call(t,R,l.isString(N)?N.trim():N,_,p))===!0&&m(R,_?_.concat(N):[N])}),f.pop()}}if(!l.isObject(e))throw new TypeError("data must be an object");return m(e),t}function st(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Se(e,t){this._pairs=[],e&&se(e,this,t)}const ot=Se.prototype;ot.append=function(t,n){this._pairs.push([t,n])},ot.toString=function(t){const n=t?function(r){return t.call(this,r,st)}:st;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function pn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function it(e,t,n){if(!t)return e;const r=n&&n.encode||pn,s=n&&n.serialize;let o;if(s?o=s(t,n):o=l.isURLSearchParams(t)?t.toString():new Se(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class hn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){l.forEach(this.handlers,function(r){r!==null&&t(r)})}}const at=hn,lt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},mn=typeof URLSearchParams<"u"?URLSearchParams:Se,_n=FormData,yn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),bn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),C={isBrowser:!0,classes:{URLSearchParams:mn,FormData:_n,Blob},isStandardBrowserEnv:yn,isStandardBrowserWebWorkerEnv:bn,protocols:["http","https","file","blob","url","data"]};function En(e,t){return se(e,new C.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return C.isNode&&l.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function wn(e){return l.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function gn(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&l.isArray(s)?s.length:i,d?(l.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!u):((!s[i]||!l.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&l.isArray(s[i])&&(s[i]=gn(s[i])),!u)}if(l.isFormData(e)&&l.isFunction(e.entries)){const n={};return l.forEachEntry(e,(r,s)=>{t(wn(r),s,n,0)}),n}return null}const On={"Content-Type":void 0};function Sn(e,t,n){if(l.isString(e))try{return(t||JSON.parse)(e),l.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const oe={transitional:lt,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=l.isObject(t);if(o&&l.isHTMLForm(t)&&(t=new FormData(t)),l.isFormData(t))return s&&s?JSON.stringify(ut(t)):t;if(l.isArrayBuffer(t)||l.isBuffer(t)||l.isStream(t)||l.isFile(t)||l.isBlob(t))return t;if(l.isArrayBufferView(t))return t.buffer;if(l.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return En(t,this.formSerializer).toString();if((u=l.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return se(u?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Sn(t)):t}],transformResponse:[function(t){const n=this.transitional||oe.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&l.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(u){if(i)throw u.name==="SyntaxError"?b.from(u,b.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};l.forEach(["delete","get","head"],function(t){oe.headers[t]={}}),l.forEach(["post","put","patch"],function(t){oe.headers[t]=l.merge(On)});const Re=oe,Rn=l.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"]),An=e=>{const t={};let n,r,s;return e&&e.split(` +(function(k,j){typeof exports=="object"&&typeof module<"u"?module.exports=j():typeof define=="function"&&define.amd?define(j):(k=typeof globalThis<"u"?globalThis:k||self,k.CkanUploader=j())})(this,function(){"use strict";function k(){}function j(e){return e()}function Ue(){return Object.create(null)}function H(e){e.forEach(j)}function Be(e){return typeof e=="function"}function Le(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function At(e){return Object.keys(e).length===0}function E(e,t){e.appendChild(t)}function A(e,t,n){e.insertBefore(t,n||null)}function S(e){e.parentNode&&e.parentNode.removeChild(e)}function O(e){return document.createElement(e)}function B(e){return document.createTextNode(e)}function F(){return B(" ")}function pe(){return B("")}function M(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function y(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Tt(e){return Array.from(e.childNodes)}function Nt(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Y(e,t){e.value=t==null?"":t}function xe(e,t,n,r){n===null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function Z(e,t,n){e.classList[n?"add":"remove"](t)}function kt(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,r,t),s}let J;function q(e){J=e}function Ct(){if(!J)throw new Error("Function called outside component initialization");return J}function je(){const e=Ct();return(t,n,{cancelable:r=!1}={})=>{const s=e.$$.callbacks[t];if(s){const o=kt(t,n,{cancelable:r});return s.slice().forEach(i=>{i.call(e,o)}),!o.defaultPrevented}return!0}}const V=[],he=[],$=[],He=[],Pt=Promise.resolve();let me=!1;function Ft(){me||(me=!0,Pt.then(Me))}function _e(e){$.push(e)}const ye=new Set;let ee=0;function Me(){const e=J;do{for(;ee{te.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Lt(e){e&&e.c()}function Ie(e,t,n,r){const{fragment:s,after_update:o}=e.$$;s&&s.m(t,n),r||_e(()=>{const i=e.$$.on_mount.map(j).filter(Be);e.$$.on_destroy?e.$$.on_destroy.push(...i):H(i),e.$$.on_mount=[]}),o.forEach(_e)}function ze(e,t){const n=e.$$;n.fragment!==null&&(H(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function xt(e,t){e.$$.dirty[0]===-1&&(V.push(e),Ft(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const h=m.length?m[0]:p;return a.ctx&&s(a.ctx[f],a.ctx[f]=h)&&(!a.skip_bound&&a.bound[f]&&a.bound[f](h),c&&xt(e,f)),p}):[],a.update(),c=!0,H(a.before_update),a.fragment=r?r(a.ctx):!1,t.target){if(t.hydrate){const f=Tt(t.target);a.fragment&&a.fragment.l(f),f.forEach(S)}else a.fragment&&a.fragment.c();t.intro&&ve(e.$$.fragment),Ie(e,t.target,t.anchor,t.customElement),Me()}q(d)}class qe{$destroy(){ze(this,1),this.$destroy=k}$on(t,n){if(!Be(n))return k;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}$set(t){this.$$set&&!At(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function Ve(e,t){return function(){return e.apply(t,arguments)}}const{toString:We}=Object.prototype,{getPrototypeOf:be}=Object,Ee=(e=>t=>{const n=We.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),D=e=>(e=e.toLowerCase(),t=>Ee(t)===e),ne=e=>t=>typeof t===e,{isArray:v}=Array,W=ne("undefined");function jt(e){return e!==null&&!W(e)&&e.constructor!==null&&!W(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ke=D("ArrayBuffer");function Ht(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ke(e.buffer),t}const Mt=ne("string"),x=ne("function"),Xe=ne("number"),we=e=>e!==null&&typeof e=="object",vt=e=>e===!0||e===!1,re=e=>{if(Ee(e)!=="object")return!1;const t=be(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},It=D("Date"),zt=D("File"),Jt=D("Blob"),qt=D("FileList"),Vt=e=>we(e)&&x(e.pipe),Wt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||We.call(e)===t||x(e.toString)&&e.toString()===t)},Kt=D("URLSearchParams"),Xt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function K(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),v(e))for(r=0,s=e.length;r0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Qe=typeof self>"u"?typeof global>"u"?globalThis:global:self,Ye=e=>!W(e)&&e!==Qe;function Oe(){const{caseless:e}=Ye(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ge(t,s)||s;re(t[o])&&re(r)?t[o]=Oe(t[o],r):re(r)?t[o]=Oe({},r):v(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r(K(t,(s,o)=>{n&&x(s)?e[o]=Ve(s,n):e[o]=s},{allOwnKeys:r}),e),Qt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Yt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Zt=(e,t,n,r)=>{let s,o,i;const u={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!u[i]&&(t[i]=e[i],u[i]=!0);e=n!==!1&&be(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},$t=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},en=e=>{if(!e)return null;if(v(e))return e;let t=e.length;if(!Xe(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},tn=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&be(Uint8Array)),nn=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},rn=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},sn=D("HTMLFormElement"),on=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ze=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),an=D("RegExp"),$e=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};K(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},l={isArray:v,isArrayBuffer:Ke,isBuffer:jt,isFormData:Wt,isArrayBufferView:Ht,isString:Mt,isNumber:Xe,isBoolean:vt,isObject:we,isPlainObject:re,isUndefined:W,isDate:It,isFile:zt,isBlob:Jt,isRegExp:an,isFunction:x,isStream:Vt,isURLSearchParams:Kt,isTypedArray:tn,isFileList:qt,forEach:K,merge:Oe,extend:Gt,trim:Xt,stripBOM:Qt,inherits:Yt,toFlatObject:Zt,kindOf:Ee,kindOfTest:D,endsWith:$t,toArray:en,forEachEntry:nn,matchAll:rn,isHTMLForm:sn,hasOwnProperty:Ze,hasOwnProp:Ze,reduceDescriptors:$e,freezeMethods:e=>{$e(e,(t,n)=>{if(x(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(!!x(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},toObjectSet:(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return v(e)?r(e):r(String(e).split(t)),n},toCamelCase:on,noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ge,global:Qe,isContextDefined:Ye,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(we(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=v(r)?[]:{};return K(r,(i,u)=>{const d=n(i,s+1);!W(d)&&(o[u]=d)}),t[s]=void 0,o}}return r};return n(e,0)}};function b(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}l.inherits(b,Error,{toJSON:function(){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:l.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const et=b.prototype,tt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{tt[e]={value:e}}),Object.defineProperties(b,tt),Object.defineProperty(et,"isAxiosError",{value:!0}),b.from=(e,t,n,r,s,o)=>{const i=Object.create(et);return l.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError"),b.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};var ln=typeof self=="object"?self.FormData:window.FormData;const un=ln;function ge(e){return l.isPlainObject(e)||l.isArray(e)}function nt(e){return l.endsWith(e,"[]")?e.slice(0,-2):e}function rt(e,t,n){return e?e.concat(t).map(function(s,o){return s=nt(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function cn(e){return l.isArray(e)&&!e.some(ge)}const fn=l.toFlatObject(l,{},null,function(t){return/^is[A-Z]/.test(t)});function dn(e){return e&&l.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function se(e,t,n){if(!l.isObject(e))throw new TypeError("target must be an object");t=t||new(un||FormData),n=l.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(_,T){return!l.isUndefined(T[_])});const r=n.metaTokens,s=n.visitor||c,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&dn(t);if(!l.isFunction(s))throw new TypeError("visitor must be a function");function a(h){if(h===null)return"";if(l.isDate(h))return h.toISOString();if(!d&&l.isBlob(h))throw new b("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(h)||l.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function c(h,_,T){let R=h;if(h&&!T&&typeof h=="object"){if(l.endsWith(_,"{}"))_=r?_:_.slice(0,-2),h=JSON.stringify(h);else if(l.isArray(h)&&cn(h)||l.isFileList(h)||l.endsWith(_,"[]")&&(R=l.toArray(h)))return _=nt(_),R.forEach(function(z,fe){!(l.isUndefined(z)||z===null)&&t.append(i===!0?rt([_],fe,o):i===null?_:_+"[]",a(z))}),!1}return ge(h)?!0:(t.append(rt(T,_,o),a(h)),!1)}const f=[],p=Object.assign(fn,{defaultVisitor:c,convertValue:a,isVisitable:ge});function m(h,_){if(!l.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+_.join("."));f.push(h),l.forEach(h,function(R,N){(!(l.isUndefined(R)||R===null)&&s.call(t,R,l.isString(N)?N.trim():N,_,p))===!0&&m(R,_?_.concat(N):[N])}),f.pop()}}if(!l.isObject(e))throw new TypeError("data must be an object");return m(e),t}function st(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Se(e,t){this._pairs=[],e&&se(e,this,t)}const ot=Se.prototype;ot.append=function(t,n){this._pairs.push([t,n])},ot.toString=function(t){const n=t?function(r){return t.call(this,r,st)}:st;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function pn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function it(e,t,n){if(!t)return e;const r=n&&n.encode||pn,s=n&&n.serialize;let o;if(s?o=s(t,n):o=l.isURLSearchParams(t)?t.toString():new Se(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class hn{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){l.forEach(this.handlers,function(r){r!==null&&t(r)})}}const at=hn,lt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},mn=typeof URLSearchParams<"u"?URLSearchParams:Se,_n=FormData,yn=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),bn=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),C={isBrowser:!0,classes:{URLSearchParams:mn,FormData:_n,Blob},isStandardBrowserEnv:yn,isStandardBrowserWebWorkerEnv:bn,protocols:["http","https","file","blob","url","data"]};function En(e,t){return se(e,new C.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return C.isNode&&l.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function wn(e){return l.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function On(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r=n.length;return i=!i&&l.isArray(s)?s.length:i,d?(l.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!u):((!s[i]||!l.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&l.isArray(s[i])&&(s[i]=On(s[i])),!u)}if(l.isFormData(e)&&l.isFunction(e.entries)){const n={};return l.forEachEntry(e,(r,s)=>{t(wn(r),s,n,0)}),n}return null}const gn={"Content-Type":void 0};function Sn(e,t,n){if(l.isString(e))try{return(t||JSON.parse)(e),l.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const oe={transitional:lt,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=l.isObject(t);if(o&&l.isHTMLForm(t)&&(t=new FormData(t)),l.isFormData(t))return s&&s?JSON.stringify(ut(t)):t;if(l.isArrayBuffer(t)||l.isBuffer(t)||l.isStream(t)||l.isFile(t)||l.isBlob(t))return t;if(l.isArrayBufferView(t))return t.buffer;if(l.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return En(t,this.formSerializer).toString();if((u=l.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return se(u?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Sn(t)):t}],transformResponse:[function(t){const n=this.transitional||oe.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&l.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(u){if(i)throw u.name==="SyntaxError"?b.from(u,b.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};l.forEach(["delete","get","head"],function(t){oe.headers[t]={}}),l.forEach(["post","put","patch"],function(t){oe.headers[t]=l.merge(gn)});const Re=oe,Rn=l.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"]),An=e=>{const t={};let n,r,s;return e&&e.split(` `).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&Rn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ct=Symbol("internals");function X(e){return e&&String(e).trim().toLowerCase()}function ie(e){return e===!1||e==null?e:l.isArray(e)?e.map(ie):String(e)}function Tn(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}function Nn(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function ft(e,t,n,r){if(l.isFunction(r))return r.call(this,t,n);if(!!l.isString(t)){if(l.isString(r))return t.indexOf(r)!==-1;if(l.isRegExp(r))return r.test(t)}}function kn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Cn(e,t){const n=l.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}class ae{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(u,d,a){const c=X(d);if(!c)throw new Error("header name must be a non-empty string");const f=l.findKey(s,c);(!f||s[f]===void 0||a===!0||a===void 0&&s[f]!==!1)&&(s[f||d]=ie(u))}const i=(u,d)=>l.forEach(u,(a,c)=>o(a,c,d));return l.isPlainObject(t)||t instanceof this.constructor?i(t,n):l.isString(t)&&(t=t.trim())&&!Nn(t)?i(An(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=X(t),t){const r=l.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Tn(s);if(l.isFunction(n))return n.call(this,s,r);if(l.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=X(t),t){const r=l.findKey(this,t);return!!(r&&(!n||ft(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=X(i),i){const u=l.findKey(r,i);u&&(!n||ft(r,r[u],u,n))&&(delete r[u],s=!0)}}return l.isArray(t)?t.forEach(o):o(t),s}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,r={};return l.forEach(this,(s,o)=>{const i=l.findKey(r,o);if(i){n[i]=ie(s),delete n[o];return}const u=t?kn(o):String(o).trim();u!==o&&delete n[o],n[u]=ie(s),r[u]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return l.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&l.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ct]=this[ct]={accessors:{}}).accessors,s=this.prototype;function o(i){const u=X(i);r[u]||(Cn(s,i),r[u]=!0)}return l.isArray(t)?t.forEach(o):o(t),this}}ae.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),l.freezeMethods(ae.prototype),l.freezeMethods(ae);const U=ae;function Ae(e,t){const n=this||Re,r=t||n,s=U.from(r.headers);let o=r.data;return l.forEach(e,function(u){o=u.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function dt(e){return!!(e&&e.__CANCEL__)}function G(e,t,n){b.call(this,e==null?"canceled":e,b.ERR_CANCELED,t,n),this.name="CanceledError"}l.inherits(G,b,{__CANCEL__:!0});const Pn=null;function Fn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new b("Request failed with status code "+n.status,[b.ERR_BAD_REQUEST,b.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Dn=C.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,u){const d=[];d.push(n+"="+encodeURIComponent(r)),l.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),l.isString(o)&&d.push("path="+o),l.isString(i)&&d.push("domain="+i),u===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Un(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Bn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function pt(e,t){return e&&!Un(t)?Bn(e,t):t}const Ln=C.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const u=l.isString(i)?s(i):i;return u.protocol===r.protocol&&u.host===r.host}}():function(){return function(){return!0}}();function xn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function jn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),c=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,p=0;for(;f!==s;)p+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,u=o-n,d=r(u),a=o<=i;n=o;const c={loaded:o,total:i,progress:i?o/i:void 0,bytes:u,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};c[t?"download":"upload"]=!0,e(c)}}const le={http:Pn,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=U.from(e.headers).normalize(),i=e.responseType;let u;function d(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}l.isFormData(s)&&(C.isStandardBrowserEnv||C.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const m=e.auth.username||"",h=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(m+":"+h))}const c=pt(e.baseURL,e.url);a.open(e.method.toUpperCase(),it(c,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const m=U.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),_={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:m,config:e,request:a};Fn(function(R){n(R),d()},function(R){r(R),d()},_),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new b("Request aborted",b.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new b("Network Error",b.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let h=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const _=e.transitional||lt;e.timeoutErrorMessage&&(h=e.timeoutErrorMessage),r(new b(h,_.clarifyTimeoutError?b.ETIMEDOUT:b.ECONNABORTED,e,a)),a=null},C.isStandardBrowserEnv){const m=(e.withCredentials||Ln(c))&&e.xsrfCookieName&&Dn.read(e.xsrfCookieName);m&&o.set(e.xsrfHeaderName,m)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&l.forEach(o.toJSON(),function(h,_){a.setRequestHeader(_,h)}),l.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",ht(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",ht(e.onUploadProgress)),(e.cancelToken||e.signal)&&(u=m=>{!a||(r(!m||m.type?new G(null,e,a):m),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u)));const p=xn(c);if(p&&C.protocols.indexOf(p)===-1){r(new b("Unsupported protocol "+p+":",b.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};l.forEach(le,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Hn={getAdapter:e=>{e=l.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof U?e.toJSON():e;function I(e,t){t=t||{};const n={};function r(a,c,f){return l.isPlainObject(a)&&l.isPlainObject(c)?l.merge.call({caseless:f},a,c):l.isPlainObject(c)?l.merge({},c):l.isArray(c)?c.slice():c}function s(a,c,f){if(l.isUndefined(c)){if(!l.isUndefined(a))return r(void 0,a,f)}else return r(a,c,f)}function o(a,c){if(!l.isUndefined(c))return r(void 0,c)}function i(a,c){if(l.isUndefined(c)){if(!l.isUndefined(a))return r(void 0,a)}else return r(void 0,c)}function u(a,c,f){if(f in t)return r(a,c);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:u,headers:(a,c)=>s(_t(a),_t(c),!0)};return l.forEach(Object.keys(e).concat(Object.keys(t)),function(c){const f=d[c]||s,p=f(e[c],t[c],c);l.isUndefined(p)&&f!==u||(n[c]=p)}),n}const yt="1.2.1",Ne={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ne[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const bt={};Ne.transitional=function(t,n,r){function s(o,i){return"[Axios v"+yt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,u)=>{if(t===!1)throw new b(s(i," has been removed"+(n?" in "+n:"")),b.ERR_DEPRECATED);return n&&!bt[i]&&(bt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,u):!0}};function Mn(e,t,n){if(typeof e!="object")throw new b("options must be an object",b.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const u=e[o],d=u===void 0||i(u,o,e);if(d!==!0)throw new b("option "+o+" must be "+d,b.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new b("Unknown option "+o,b.ERR_BAD_OPTION)}}const ke={assertOptions:Mn,validators:Ne},L=ke.validators;class ue{constructor(t){this.defaults=t,this.interceptors={request:new at,response:new at}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=I(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&ke.assertOptions(r,{silentJSONParsing:L.transitional(L.boolean),forcedJSONParsing:L.transitional(L.boolean),clarifyTimeoutError:L.transitional(L.boolean)},!1),s!==void 0&&ke.assertOptions(s,{encode:L.function,serialize:L.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&l.merge(o.common,o[n.method]),i&&l.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),n.headers=U.concat(i,o);const u=[];let d=!0;this.interceptors.request.forEach(function(_){typeof _.runWhen=="function"&&_.runWhen(n)===!1||(d=d&&_.synchronous,u.unshift(_.fulfilled,_.rejected))});const a=[];this.interceptors.response.forEach(function(_){a.push(_.fulfilled,_.rejected)});let c,f=0,p;if(!d){const h=[mt.bind(this),void 0];for(h.unshift.apply(h,u),h.push.apply(h,a),p=h.length,c=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(u=>{r.subscribe(u),o=u}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,u){r.reason||(r.reason=new G(o,i,u),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Ce(function(s){t=s}),cancel:t}}}const vn=Ce;function In(e){return function(n){return e.apply(null,n)}}function zn(e){return l.isObject(e)&&e.isAxiosError===!0}function Et(e){const t=new ce(e),n=Ve(ce.prototype.request,t);return l.extend(n,ce.prototype,t,{allOwnKeys:!0}),l.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Et(I(e,s))},n}const O=Et(Re);O.Axios=ce,O.CanceledError=G,O.CancelToken=vn,O.isCancel=dt,O.VERSION=yt,O.toFormData=se,O.AxiosError=b,O.Cancel=O.CanceledError,O.all=function(t){return Promise.all(t)},O.spread=In,O.isAxiosError=zn,O.mergeConfig=I,O.AxiosHeaders=U,O.formToJSON=e=>ut(l.isHTMLForm(e)?new FormData(e):e),O.default=O;const Jn=O,gr="";function wt(e){let t,n,r,s,o,i;function u(c,f){return!c[4]&&!c[5]&&!c[6]?Vn:qn}let d=u(e),a=d(e);return{c(){t=g("div"),n=g("div"),a.c(),r=F(),s=g("input"),y(n,"id","widget-label"),y(n,"class","svelte-1f4196f"),y(s,"id","fileUpload"),y(s,"type","file"),y(s,"class","svelte-1f4196f"),y(t,"id","fileUploadWidget"),y(t,"class","svelte-1f4196f")},m(c,f){A(c,t,f),E(t,n),a.m(n,null),E(t,r),E(t,s),o||(i=[M(s,"change",e[18]),M(s,"change",e[11])],o=!0)},p(c,f){d===(d=u(c))&&a?a.p(c,f):(a.d(1),a=d(c),a&&(a.c(),a.m(n,null)))},d(c){c&&S(t),a.d(),o=!1,H(i)}}}function qn(e){let t,n,r,s,o,i=`${e[3]}%`;function u(f,p){return f[5]?Wn:Kn}let d=u(e),a=d(e),c=e[6]&&Ot();return{c(){t=g("div"),n=g("div"),a.c(),r=F(),c&&c.c(),s=F(),o=g("div"),y(n,"class","percentage-text svelte-1f4196f"),y(o,"id","percentage-bar"),y(o,"class","svelte-1f4196f"),xe(o,"width",i),y(t,"id","percentage"),y(t,"class","svelte-1f4196f")},m(f,p){A(f,t,p),E(t,n),a.m(n,null),E(n,r),c&&c.m(n,null),E(t,s),E(t,o)},p(f,p){d===(d=u(f))&&a?a.p(f,p):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[6]?c||(c=Ot(),c.c(),c.m(n,null)):c&&(c.d(1),c=null),p&8&&i!==(i=`${f[3]}%`)&&xe(o,"width",i)},d(f){f&&S(t),a.d(),c&&c.d()}}}function Vn(e){let t;function n(o,i){return o[1]?Gn:Xn}let r=n(e),s=r(e);return{c(){s.c(),t=pe()},m(o,i){s.m(o,i),A(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&S(t)}}}function Wn(e){let t;return{c(){t=B("Waiting for data schema detection...")},m(n,r){A(n,t,r)},p:k,d(n){n&&S(t)}}}function Kn(e){let t,n=!e[6]&>(e);return{c(){n&&n.c(),t=pe()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[6]?n&&(n.d(1),n=null):n?n.p(r,s):(n=gt(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&S(t)}}}function gt(e){let t,n;return{c(){t=B(e[3]),n=B("%")},m(r,s){A(r,t,s),A(r,n,s)},p(r,s){s&8&&Nt(t,r[3])},d(r){r&&S(t),r&&S(n)}}}function Ot(e){let t;return{c(){t=B("File uploaded")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Xn(e){let t;return{c(){t=B("Select a file to upload")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Gn(e){let t;return{c(){t=B("Select a file to replace the current one")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Qn(e){let t,n,r,s,o,i,u,d,a;return{c(){t=g("div"),n=g("label"),n.textContent="URL",r=F(),s=g("div"),o=g("input"),i=F(),u=g("input"),y(n,"class","control-label"),y(n,"for","field_url"),y(o,"id","field_url"),y(o,"class","form-control"),y(o,"type","text"),y(o,"name","url"),y(u,"type","hidden"),y(u,"name","clear_upload"),u.value="true",y(s,"class","controls"),y(t,"id","resourceURL"),y(t,"class","controls svelte-1f4196f")},m(c,f){A(c,t,f),E(t,n),E(t,r),E(t,s),E(s,o),Y(o,e[8]),E(s,i),E(s,u),d||(a=M(o,"input",e[20]),d=!0)},p(c,f){f&256&&o.value!==c[8]&&Y(o,c[8])},d(c){c&&S(t),d=!1,a()}}}function Yn(e){let t,n=e[9]!=""&&St(e);return{c(){n&&n.c(),t=pe()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[9]!=""?n?n.p(r,s):(n=St(r),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},d(r){n&&n.d(r),r&&S(t)}}}function St(e){let t,n,r,s,o,i,u,d;return{c(){t=g("div"),n=g("label"),n.textContent="Current file",r=F(),s=g("div"),o=g("input"),y(n,"class","control-label"),y(n,"for","field_url"),o.readOnly=i=e[0]!="upload"?void 0:!0,y(o,"id","field_url"),y(o,"class","form-control"),y(o,"type","text"),y(o,"name","url"),y(s,"class","controls"),y(t,"class","controls")},m(a,c){A(a,t,c),E(t,n),E(t,r),E(t,s),E(s,o),Y(o,e[9]),u||(d=M(o,"input",e[19]),u=!0)},p(a,c){c&1&&i!==(i=a[0]!="upload"?void 0:!0)&&(o.readOnly=i),c&512&&o.value!==a[9]&&Y(o,a[9])},d(a){a&&S(t),u=!1,d()}}}function Zn(e){let t,n,r,s,o,i,u,d,a=e[7]=="upload"&&wt(e);function c(m,h){if(m[7]=="upload")return Yn;if(m[7]!="None")return Qn}let f=c(e),p=f&&f(e);return{c(){t=g("div"),n=g("a"),n.innerHTML='File',r=F(),s=g("a"),s.innerHTML='Link',o=F(),a&&a.c(),i=F(),p&&p.c(),y(n,"class","btn btn-default"),Z(n,"active",e[7]=="upload"),y(s,"class","btn btn-default"),Z(s,"active",e[7]!="upload"&&e[7]!="None"),y(t,"class","form-group")},m(m,h){A(m,t,h),E(t,n),E(t,r),E(t,s),E(t,o),a&&a.m(t,null),E(t,i),p&&p.m(t,null),u||(d=[M(n,"click",e[16]),M(s,"click",e[17])],u=!0)},p(m,[h]){h&128&&Z(n,"active",m[7]=="upload"),h&128&&Z(s,"active",m[7]!="upload"&&m[7]!="None"),m[7]=="upload"?a?a.p(m,h):(a=wt(m),a.c(),a.m(t,i)):a&&(a.d(1),a=null),f===(f=c(m))&&p?p.p(m,h):(p&&p.d(1),p=f&&f(m),p&&(p.c(),p.m(t,null)))},i:k,o:k,d(m){m&&S(t),a&&a.d(),p&&p.d(),u=!1,H(d)}}}function Rt(e){let t=e.split("/");return t.length>0?t[t.length-1]:t[0]}function $n(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:u}=t,{url_type:d=""}=t,a,c=0,f=!1,p=!1,m=!1,h=je(),_=i?"update":"create",T=d,R="",N="";d!="upload"?R=u:N=Rt(u);async function z(w,Q){try{const P={onUploadProgress:fr=>{const{loaded:dr,total:pr}=fr,De=Math.floor(dr*100/pr);De<=100&&(Q(De),De==100&&(n(4,f=!1),n(5,p=!0)))}},de=_=="update"?`${r}/dataset/${s}/resource/${o}/file`:`${r}/dataset/${s}/resource/file`,{data:Fe}=await Jn.post(de,w,P);return Fe}catch(P){console.log("ERROR",P.message)}}function fe(w){n(3,c=w)}function Pe(w){n(7,T=w),document.getElementById("fileUpload").click()}async function or(w){try{const Q=w.target.files[0],P=new FormData;P.append("upload",Q),P.append("package_id",s),i&&(P.append("id",o),P.append("clear_upload",!0),P.append("url_type",d)),n(4,f=!0);let de=await z(P,fe),Fe={data:de};n(9,N=Rt(de.url)),n(0,d="upload"),h("fileUploaded",Fe),n(5,p=!1),n(6,m=!0)}catch(Q){console.log("ERROR",Q),fe(0)}}const ir=w=>{Pe("upload")},ar=w=>{Pe("")};function lr(){a=this.files,n(2,a)}function ur(){N=this.value,n(9,N)}function cr(){R=this.value,n(8,R)}return e.$$set=w=>{"upload_url"in w&&n(12,r=w.upload_url),"dataset_id"in w&&n(13,s=w.dataset_id),"resource_id"in w&&n(14,o=w.resource_id),"update"in w&&n(1,i=w.update),"current_url"in w&&n(15,u=w.current_url),"url_type"in w&&n(0,d=w.url_type)},[d,i,a,c,f,p,m,T,R,N,Pe,or,r,s,o,u,ir,ar,lr,ur,cr]}class er extends qe{constructor(t){super(),Je(this,t,$n,Zn,Le,{upload_url:12,dataset_id:13,resource_id:14,update:1,current_url:15,url_type:0})}}function tr(e){let t,n,r;return n=new er({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=g("main"),Lt(n.$$.fragment)},m(s,o){A(s,t,o),Ie(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(ve(n.$$.fragment,s),r=!0)},o(s){Bt(n.$$.fragment,s),r=!1},d(s){s&&S(t),ze(n),e[8](null)}}}function nr(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:u}=t,{url_type:d}=t;je();let a;function c(p){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:p.detail.data}))}function f(p){he[p?"unshift":"push"](()=>{a=p,n(6,a)})}return e.$$set=p=>{"upload_url"in p&&n(0,r=p.upload_url),"dataset_id"in p&&n(1,s=p.dataset_id),"resource_id"in p&&n(2,o=p.resource_id),"update"in p&&n(3,i=p.update),"current_url"in p&&n(4,u=p.current_url),"url_type"in p&&n(5,d=p.url_type)},[r,s,o,i,u,d,a,c,f]}class rr extends qe{constructor(t){super(),Je(this,t,nr,tr,Le,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function sr(e,t="",n="",r="",s="",o="",i=""){new rr({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return sr}); +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ct]=this[ct]={accessors:{}}).accessors,s=this.prototype;function o(i){const u=X(i);r[u]||(Cn(s,i),r[u]=!0)}return l.isArray(t)?t.forEach(o):o(t),this}}ae.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),l.freezeMethods(ae.prototype),l.freezeMethods(ae);const U=ae;function Ae(e,t){const n=this||Re,r=t||n,s=U.from(r.headers);let o=r.data;return l.forEach(e,function(u){o=u.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function dt(e){return!!(e&&e.__CANCEL__)}function G(e,t,n){b.call(this,e==null?"canceled":e,b.ERR_CANCELED,t,n),this.name="CanceledError"}l.inherits(G,b,{__CANCEL__:!0});const Pn=null;function Fn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new b("Request failed with status code "+n.status,[b.ERR_BAD_REQUEST,b.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Dn=C.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,u){const d=[];d.push(n+"="+encodeURIComponent(r)),l.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),l.isString(o)&&d.push("path="+o),l.isString(i)&&d.push("domain="+i),u===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Un(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Bn(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function pt(e,t){return e&&!Un(t)?Bn(e,t):t}const Ln=C.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const u=l.isString(i)?s(i):i;return u.protocol===r.protocol&&u.host===r.host}}():function(){return function(){return!0}}();function xn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function jn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const a=Date.now(),c=r[o];i||(i=a),n[s]=d,r[s]=a;let f=o,p=0;for(;f!==s;)p+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),a-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,u=o-n,d=r(u),a=o<=i;n=o;const c={loaded:o,total:i,progress:i?o/i:void 0,bytes:u,rate:d||void 0,estimated:d&&i&&a?(i-o)/d:void 0,event:s};c[t?"download":"upload"]=!0,e(c)}}const le={http:Pn,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=U.from(e.headers).normalize(),i=e.responseType;let u;function d(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}l.isFormData(s)&&(C.isStandardBrowserEnv||C.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let a=new XMLHttpRequest;if(e.auth){const m=e.auth.username||"",h=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(m+":"+h))}const c=pt(e.baseURL,e.url);a.open(e.method.toUpperCase(),it(c,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function f(){if(!a)return;const m=U.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),_={data:!i||i==="text"||i==="json"?a.responseText:a.response,status:a.status,statusText:a.statusText,headers:m,config:e,request:a};Fn(function(R){n(R),d()},function(R){r(R),d()},_),a=null}if("onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(f)},a.onabort=function(){!a||(r(new b("Request aborted",b.ECONNABORTED,e,a)),a=null)},a.onerror=function(){r(new b("Network Error",b.ERR_NETWORK,e,a)),a=null},a.ontimeout=function(){let h=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const _=e.transitional||lt;e.timeoutErrorMessage&&(h=e.timeoutErrorMessage),r(new b(h,_.clarifyTimeoutError?b.ETIMEDOUT:b.ECONNABORTED,e,a)),a=null},C.isStandardBrowserEnv){const m=(e.withCredentials||Ln(c))&&e.xsrfCookieName&&Dn.read(e.xsrfCookieName);m&&o.set(e.xsrfHeaderName,m)}s===void 0&&o.setContentType(null),"setRequestHeader"in a&&l.forEach(o.toJSON(),function(h,_){a.setRequestHeader(_,h)}),l.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&i!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",ht(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",ht(e.onUploadProgress)),(e.cancelToken||e.signal)&&(u=m=>{!a||(r(!m||m.type?new G(null,e,a):m),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u)));const p=xn(c);if(p&&C.protocols.indexOf(p)===-1){r(new b("Unsupported protocol "+p+":",b.ERR_BAD_REQUEST,e));return}a.send(s||null)})}};l.forEach(le,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Hn={getAdapter:e=>{e=l.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;se instanceof U?e.toJSON():e;function I(e,t){t=t||{};const n={};function r(a,c,f){return l.isPlainObject(a)&&l.isPlainObject(c)?l.merge.call({caseless:f},a,c):l.isPlainObject(c)?l.merge({},c):l.isArray(c)?c.slice():c}function s(a,c,f){if(l.isUndefined(c)){if(!l.isUndefined(a))return r(void 0,a,f)}else return r(a,c,f)}function o(a,c){if(!l.isUndefined(c))return r(void 0,c)}function i(a,c){if(l.isUndefined(c)){if(!l.isUndefined(a))return r(void 0,a)}else return r(void 0,c)}function u(a,c,f){if(f in t)return r(a,c);if(f in e)return r(void 0,a)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:u,headers:(a,c)=>s(_t(a),_t(c),!0)};return l.forEach(Object.keys(e).concat(Object.keys(t)),function(c){const f=d[c]||s,p=f(e[c],t[c],c);l.isUndefined(p)&&f!==u||(n[c]=p)}),n}const yt="1.2.1",Ne={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ne[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const bt={};Ne.transitional=function(t,n,r){function s(o,i){return"[Axios v"+yt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,u)=>{if(t===!1)throw new b(s(i," has been removed"+(n?" in "+n:"")),b.ERR_DEPRECATED);return n&&!bt[i]&&(bt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,u):!0}};function Mn(e,t,n){if(typeof e!="object")throw new b("options must be an object",b.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const u=e[o],d=u===void 0||i(u,o,e);if(d!==!0)throw new b("option "+o+" must be "+d,b.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new b("Unknown option "+o,b.ERR_BAD_OPTION)}}const ke={assertOptions:Mn,validators:Ne},L=ke.validators;class ue{constructor(t){this.defaults=t,this.interceptors={request:new at,response:new at}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=I(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&ke.assertOptions(r,{silentJSONParsing:L.transitional(L.boolean),forcedJSONParsing:L.transitional(L.boolean),clarifyTimeoutError:L.transitional(L.boolean)},!1),s!==void 0&&ke.assertOptions(s,{encode:L.function,serialize:L.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&l.merge(o.common,o[n.method]),i&&l.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),n.headers=U.concat(i,o);const u=[];let d=!0;this.interceptors.request.forEach(function(_){typeof _.runWhen=="function"&&_.runWhen(n)===!1||(d=d&&_.synchronous,u.unshift(_.fulfilled,_.rejected))});const a=[];this.interceptors.response.forEach(function(_){a.push(_.fulfilled,_.rejected)});let c,f=0,p;if(!d){const h=[mt.bind(this),void 0];for(h.unshift.apply(h,u),h.push.apply(h,a),p=h.length,c=Promise.resolve(n);f{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(u=>{r.subscribe(u),o=u}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,u){r.reason||(r.reason=new G(o,i,u),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Ce(function(s){t=s}),cancel:t}}}const vn=Ce;function In(e){return function(n){return e.apply(null,n)}}function zn(e){return l.isObject(e)&&e.isAxiosError===!0}function Et(e){const t=new ce(e),n=Ve(ce.prototype.request,t);return l.extend(n,ce.prototype,t,{allOwnKeys:!0}),l.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Et(I(e,s))},n}const g=Et(Re);g.Axios=ce,g.CanceledError=G,g.CancelToken=vn,g.isCancel=dt,g.VERSION=yt,g.toFormData=se,g.AxiosError=b,g.Cancel=g.CanceledError,g.all=function(t){return Promise.all(t)},g.spread=In,g.isAxiosError=zn,g.mergeConfig=I,g.AxiosHeaders=U,g.formToJSON=e=>ut(l.isHTMLForm(e)?new FormData(e):e),g.default=g;const Jn=g,Or="";function wt(e){let t,n,r,s,o,i;function u(c,f){return!c[4]&&!c[5]&&!c[6]?Vn:qn}let d=u(e),a=d(e);return{c(){t=O("div"),n=O("div"),a.c(),r=F(),s=O("input"),y(n,"id","widget-label"),y(n,"class","svelte-1f4196f"),y(s,"id","fileUpload"),y(s,"type","file"),y(s,"class","svelte-1f4196f"),y(t,"id","fileUploadWidget"),y(t,"class","svelte-1f4196f")},m(c,f){A(c,t,f),E(t,n),a.m(n,null),E(t,r),E(t,s),o||(i=[M(s,"change",e[18]),M(s,"change",e[11])],o=!0)},p(c,f){d===(d=u(c))&&a?a.p(c,f):(a.d(1),a=d(c),a&&(a.c(),a.m(n,null)))},d(c){c&&S(t),a.d(),o=!1,H(i)}}}function qn(e){let t,n,r,s,o,i=`${e[3]}%`;function u(f,p){return f[5]?Wn:Kn}let d=u(e),a=d(e),c=e[6]&>();return{c(){t=O("div"),n=O("div"),a.c(),r=F(),c&&c.c(),s=F(),o=O("div"),y(n,"class","percentage-text svelte-1f4196f"),y(o,"id","percentage-bar"),y(o,"class","svelte-1f4196f"),xe(o,"width",i),y(t,"id","percentage"),y(t,"class","svelte-1f4196f")},m(f,p){A(f,t,p),E(t,n),a.m(n,null),E(n,r),c&&c.m(n,null),E(t,s),E(t,o)},p(f,p){d===(d=u(f))&&a?a.p(f,p):(a.d(1),a=d(f),a&&(a.c(),a.m(n,r))),f[6]?c||(c=gt(),c.c(),c.m(n,null)):c&&(c.d(1),c=null),p&8&&i!==(i=`${f[3]}%`)&&xe(o,"width",i)},d(f){f&&S(t),a.d(),c&&c.d()}}}function Vn(e){let t;function n(o,i){return o[1]?Gn:Xn}let r=n(e),s=r(e);return{c(){s.c(),t=pe()},m(o,i){s.m(o,i),A(o,t,i)},p(o,i){r!==(r=n(o))&&(s.d(1),s=r(o),s&&(s.c(),s.m(t.parentNode,t)))},d(o){s.d(o),o&&S(t)}}}function Wn(e){let t;return{c(){t=B("Waiting for data schema detection...")},m(n,r){A(n,t,r)},p:k,d(n){n&&S(t)}}}function Kn(e){let t,n=!e[6]&&Ot(e);return{c(){n&&n.c(),t=pe()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[6]?n&&(n.d(1),n=null):n?n.p(r,s):(n=Ot(r),n.c(),n.m(t.parentNode,t))},d(r){n&&n.d(r),r&&S(t)}}}function Ot(e){let t,n;return{c(){t=B(e[3]),n=B("%")},m(r,s){A(r,t,s),A(r,n,s)},p(r,s){s&8&&Nt(t,r[3])},d(r){r&&S(t),r&&S(n)}}}function gt(e){let t;return{c(){t=B("File uploaded")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Xn(e){let t;return{c(){t=B("Select a file to upload")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Gn(e){let t;return{c(){t=B("Select a file to replace the current one")},m(n,r){A(n,t,r)},d(n){n&&S(t)}}}function Qn(e){let t,n,r,s,o,i,u,d,a;return{c(){t=O("div"),n=O("label"),n.textContent="URL",r=F(),s=O("div"),o=O("input"),i=F(),u=O("input"),y(n,"class","control-label"),y(n,"for","field_url"),y(o,"id","field_url"),y(o,"class","form-control"),y(o,"type","text"),y(o,"name","url"),y(u,"type","hidden"),y(u,"name","clear_upload"),u.value="true",y(s,"class","controls"),y(t,"id","resourceURL"),y(t,"class","controls svelte-1f4196f")},m(c,f){A(c,t,f),E(t,n),E(t,r),E(t,s),E(s,o),Y(o,e[8]),E(s,i),E(s,u),d||(a=M(o,"input",e[20]),d=!0)},p(c,f){f&256&&o.value!==c[8]&&Y(o,c[8])},d(c){c&&S(t),d=!1,a()}}}function Yn(e){let t,n=e[9]!=""&&St(e);return{c(){n&&n.c(),t=pe()},m(r,s){n&&n.m(r,s),A(r,t,s)},p(r,s){r[9]!=""?n?n.p(r,s):(n=St(r),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},d(r){n&&n.d(r),r&&S(t)}}}function St(e){let t,n,r,s,o,i,u,d;return{c(){t=O("div"),n=O("label"),n.textContent="Current file",r=F(),s=O("div"),o=O("input"),y(n,"class","control-label"),y(n,"for","field_url"),o.readOnly=i=e[0]!="upload"?void 0:!0,y(o,"id","field_url"),y(o,"class","form-control"),y(o,"type","text"),y(o,"name","url"),y(s,"class","controls"),y(t,"class","controls")},m(a,c){A(a,t,c),E(t,n),E(t,r),E(t,s),E(s,o),Y(o,e[9]),u||(d=M(o,"input",e[19]),u=!0)},p(a,c){c&1&&i!==(i=a[0]!="upload"?void 0:!0)&&(o.readOnly=i),c&512&&o.value!==a[9]&&Y(o,a[9])},d(a){a&&S(t),u=!1,d()}}}function Zn(e){let t,n,r,s,o,i,u,d,a=e[7]=="upload"&&wt(e);function c(m,h){if(m[7]=="upload")return Yn;if(m[7]!="None")return Qn}let f=c(e),p=f&&f(e);return{c(){t=O("div"),n=O("a"),n.innerHTML='File',r=F(),s=O("a"),s.innerHTML='Link',o=F(),a&&a.c(),i=F(),p&&p.c(),y(n,"class","btn btn-default"),Z(n,"active",e[7]=="upload"),y(s,"class","btn btn-default"),Z(s,"active",e[7]!="upload"&&e[7]!="None"),y(t,"class","form-group")},m(m,h){A(m,t,h),E(t,n),E(t,r),E(t,s),E(t,o),a&&a.m(t,null),E(t,i),p&&p.m(t,null),u||(d=[M(n,"click",e[16]),M(s,"click",e[17])],u=!0)},p(m,[h]){h&128&&Z(n,"active",m[7]=="upload"),h&128&&Z(s,"active",m[7]!="upload"&&m[7]!="None"),m[7]=="upload"?a?a.p(m,h):(a=wt(m),a.c(),a.m(t,i)):a&&(a.d(1),a=null),f===(f=c(m))&&p?p.p(m,h):(p&&p.d(1),p=f&&f(m),p&&(p.c(),p.m(t,null)))},i:k,o:k,d(m){m&&S(t),a&&a.d(),p&&p.d(),u=!1,H(d)}}}function Rt(e){let t=e.split("/");return t.length>0?t[t.length-1]:t[0]}function $n(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i=""}=t,{current_url:u}=t,{url_type:d=""}=t,a,c=0,f=!1,p=!1,m=!1,h=je(),_=i?"update":"create",T=d,R="",N="";d!="upload"?R=u:N=Rt(u);async function z(w,Q){try{const P={onUploadProgress:fr=>{const{loaded:dr,total:pr}=fr,De=Math.floor(dr*100/pr);De<=100&&(Q(De),De==100&&(n(4,f=!1),n(5,p=!0)))}},de=_=="update"?`${r}/dataset/${s}/resource/${o}/file`:`${r}/dataset/${s}/resource/file`,{data:Fe}=await Jn.post(de,w,P);return Fe}catch(P){console.log("ERROR",P.message)}}function fe(w){n(3,c=w)}function Pe(w){n(7,T=w)}async function or(w){try{const Q=w.target.files[0],P=new FormData;P.append("upload",Q),P.append("package_id",s),i&&(P.append("id",o),P.append("clear_upload",!0),P.append("url_type",d)),n(4,f=!0);let de=await z(P,fe),Fe={data:de};n(9,N=Rt(de.url)),n(0,d="upload"),h("fileUploaded",Fe),n(5,p=!1),n(6,m=!0)}catch(Q){console.log("ERROR",Q),fe(0)}}const ir=w=>{Pe("upload")},ar=w=>{Pe("")};function lr(){a=this.files,n(2,a)}function ur(){N=this.value,n(9,N)}function cr(){R=this.value,n(8,R)}return e.$$set=w=>{"upload_url"in w&&n(12,r=w.upload_url),"dataset_id"in w&&n(13,s=w.dataset_id),"resource_id"in w&&n(14,o=w.resource_id),"update"in w&&n(1,i=w.update),"current_url"in w&&n(15,u=w.current_url),"url_type"in w&&n(0,d=w.url_type)},[d,i,a,c,f,p,m,T,R,N,Pe,or,r,s,o,u,ir,ar,lr,ur,cr]}class er extends qe{constructor(t){super(),Je(this,t,$n,Zn,Le,{upload_url:12,dataset_id:13,resource_id:14,update:1,current_url:15,url_type:0})}}function tr(e){let t,n,r;return n=new er({props:{upload_url:e[0],dataset_id:e[1],resource_id:e[2],update:e[3],current_url:e[4],url_type:e[5]}}),n.$on("fileUploaded",e[7]),{c(){t=O("main"),Lt(n.$$.fragment)},m(s,o){A(s,t,o),Ie(n,t,null),e[8](t),r=!0},p(s,[o]){const i={};o&1&&(i.upload_url=s[0]),o&2&&(i.dataset_id=s[1]),o&4&&(i.resource_id=s[2]),o&8&&(i.update=s[3]),o&16&&(i.current_url=s[4]),o&32&&(i.url_type=s[5]),n.$set(i)},i(s){r||(ve(n.$$.fragment,s),r=!0)},o(s){Bt(n.$$.fragment,s),r=!1},d(s){s&&S(t),ze(n),e[8](null)}}}function nr(e,t,n){let{upload_url:r}=t,{dataset_id:s}=t,{resource_id:o}=t,{update:i}=t,{current_url:u}=t,{url_type:d}=t;je();let a;function c(p){a.parentNode.dispatchEvent(new CustomEvent("fileUploaded",{detail:p.detail.data}))}function f(p){he[p?"unshift":"push"](()=>{a=p,n(6,a)})}return e.$$set=p=>{"upload_url"in p&&n(0,r=p.upload_url),"dataset_id"in p&&n(1,s=p.dataset_id),"resource_id"in p&&n(2,o=p.resource_id),"update"in p&&n(3,i=p.update),"current_url"in p&&n(4,u=p.current_url),"url_type"in p&&n(5,d=p.url_type)},[r,s,o,i,u,d,a,c,f]}class rr extends qe{constructor(t){super(),Je(this,t,nr,tr,Le,{upload_url:0,dataset_id:1,resource_id:2,update:3,current_url:4,url_type:5})}}function sr(e,t="",n="",r="",s="",o="",i=""){new rr({target:document.getElementById(e),props:{upload_url:t,dataset_id:n,resource_id:r,url_type:s,current_url:o,update:i}})}return sr}); From 95f31e4a9714e750bf08b910731acce536dcae89 Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 23 Feb 2023 12:28:12 +0100 Subject: [PATCH 36/43] Revert changes made to resource_create / resource_update actions These should be as in current master, ie identical to the upstream core ones except for the bit where the sync validation is triggered --- ckanext/validation/logic.py | 98 +++++++++++++++---------------------- 1 file changed, 40 insertions(+), 58 deletions(-) diff --git a/ckanext/validation/logic.py b/ckanext/validation/logic.py index 2078f6e5..d98a9e8d 100644 --- a/ckanext/validation/logic.py +++ b/ckanext/validation/logic.py @@ -496,6 +496,9 @@ def resource_create(up_func, context, data_dict): ''' + if get_create_mode_from_config() != 'sync': + return up_func(context, data_dict) + model = context['model'] package_id = t.get_or_bust(data_dict, 'package_id') @@ -529,7 +532,6 @@ def resource_create(up_func, context, data_dict): try: context['defer_commit'] = True context['use_cache'] = False - pkg_dict['state'] = 'active' t.get_action('package_update')(context, pkg_dict) context.pop('defer_commit') except t.ValidationError as e: @@ -546,32 +548,25 @@ def resource_create(up_func, context, data_dict): # Custom code starts - if get_create_mode_from_config() == 'sync': - - run_validation = True + run_validation = True - for plugin in plugins.PluginImplementations(IDataValidation): - if not plugin.can_validate(context, data_dict): - log.debug('Skipping validation for resource {}'.format(resource_id)) - run_validation = False + for plugin in plugins.PluginImplementations(IDataValidation): + if not plugin.can_validate(context, data_dict): + log.debug('Skipping validation for resource {}'.format(resource_id)) + run_validation = False - if run_validation: - is_local_upload = ( - hasattr(upload, 'filename') and - upload.filename is not None and - isinstance(upload, uploader.ResourceUpload)) - _run_sync_validation( - resource_id, local_upload=is_local_upload, new_resource=True) + if run_validation: + is_local_upload = ( + hasattr(upload, 'filename') and + upload.filename is not None and + isinstance(upload, uploader.ResourceUpload)) + _run_sync_validation( + resource_id, local_upload=is_local_upload, new_resource=True) # Custom code ends model.repo.commit() - #if upload.filename and is_tabular(filename=upload.filename): - # update_resource = t.get_action('resource_table_schema_infer')( - # context, {'resource_id': resource_id, 'store_schema': True} - # ) - # Run package show again to get out actual last_resource updated_pkg_dict = t.get_action('package_show')( context, {'id': package_id}) @@ -607,6 +602,9 @@ def resource_update(up_func, context, data_dict): ''' + if get_update_mode_from_config() != 'sync': + return up_func(context, data_dict) + model = context['model'] id = t.get_or_bust(data_dict, "id") @@ -640,21 +638,18 @@ def resource_update(up_func, context, data_dict): 'datastore_active' not in data_dict): data_dict['datastore_active'] = resource.extras['datastore_active'] - for plugin in plugins.PluginImplementations(plugins.IResourceController): plugin.before_update(context, pkg_dict['resources'][n], data_dict) upload = uploader.get_resource_uploader(data_dict) - if 'mimetype' not in data_dict or hasattr(upload, 'mimetype'): - data_dict['mimetype'] = upload.mimetype - if upload.filename: - data_dict['format'] = upload.filename.split('.')[-1] + if 'mimetype' not in data_dict: + if hasattr(upload, 'mimetype'): + data_dict['mimetype'] = upload.mimetype - #if 'size' not in data_dict and 'url_type' in data_dict: - # data_dict['size'] = 0 - if hasattr(upload, 'filesize'): - data_dict['size'] = upload.filesize + if 'size' not in data_dict and 'url_type' in data_dict: + if hasattr(upload, 'filesize'): + data_dict['size'] = upload.filesize pkg_dict['resources'][n] = data_dict @@ -669,39 +664,26 @@ def resource_update(up_func, context, data_dict): except (KeyError, IndexError): raise t.ValidationError(e.error_dict) - resource = updated_pkg_dict['resources'][-1] upload.upload(id, uploader.get_max_resource_size()) - #if upload.filename and is_tabular(filename=upload.filename): - # update_resource = t.get_action('resource_table_schema_infer')( - # context, {'resource_id': resource['id'], 'store_schema': True} - # ) - - # Run package show again to get out actual last_resource - updated_pkg_dict = t.get_action('package_show')( - context, {'id': package_id}) - resource = updated_pkg_dict['resources'][-1] - - # Custom code starts - if get_update_mode_from_config() == 'sync': - run_validation = True - for plugin in plugins.PluginImplementations(IDataValidation): - if not plugin.can_validate(context, data_dict): - log.debug('Skipping validation for resource {}'.format(id)) - run_validation = False - - if run_validation: - run_validation = not data_dict.pop('_skip_next_validation', None) - - if run_validation: - is_local_upload = ( - hasattr(upload, 'filename') and - upload.filename is not None and - isinstance(upload, uploader.ResourceUpload)) - _run_sync_validation( - id, local_upload=is_local_upload, new_resource=False) + run_validation = True + for plugin in plugins.PluginImplementations(IDataValidation): + if not plugin.can_validate(context, data_dict): + log.debug('Skipping validation for resource {}'.format(id)) + run_validation = False + + if run_validation: + run_validation = not data_dict.pop('_skip_next_validation', None) + + if run_validation: + is_local_upload = ( + hasattr(upload, 'filename') and + upload.filename is not None and + isinstance(upload, uploader.ResourceUpload)) + _run_sync_validation( + id, local_upload=is_local_upload, new_resource=False) # Custom code ends From 9cbb7546aa2917c42f9815fffa6cae8f20059b10 Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 23 Feb 2023 15:37:10 +0100 Subject: [PATCH 37/43] Add turn_off_validation context manager Rather than try to deal with complex logic on the plugin hooks with dodgy context keys, it offers a way to shut down completely the validation process in a specific block of code. Works by explicitly setting all the validation config options to False and restoring the previous values afterwards. --- ckanext/validation/tests/test_utils.py | 74 ++++++++++++++++++++++++++ ckanext/validation/utils.py | 30 +++++++++++ 2 files changed, 104 insertions(+) diff --git a/ckanext/validation/tests/test_utils.py b/ckanext/validation/tests/test_utils.py index ee890eb7..b090d726 100644 --- a/ckanext/validation/tests/test_utils.py +++ b/ckanext/validation/tests/test_utils.py @@ -2,6 +2,10 @@ import uuid from unittest import mock +from ckantoolkit import config + +from ckantoolkit.tests.factories import Resource + import pytest from pyfakefs import fake_filesystem_unittest @@ -11,6 +15,7 @@ get_update_mode_from_config, get_local_upload_path, delete_local_uploaded_file, + turn_off_validation, ) @@ -68,6 +73,75 @@ def test_config_both_false(self): assert get_create_mode_from_config() is None +@pytest.mark.usefixtures("clean_db", "validation_setup", "mock_uploads") +class TestTurnOffValidation(object): + + @pytest.mark.ckan_config("ckanext.validation.run_on_update_async", True) + @pytest.mark.ckan_config("ckanext.validation.run_on_create_async", True) + def test_turn_off_async(self): + assert config["ckanext.validation.run_on_update_async"] is True + assert config["ckanext.validation.run_on_create_async"] is True + + with turn_off_validation(): + assert config["ckanext.validation.run_on_update_async"] is False + assert config["ckanext.validation.run_on_create_async"] is False + + with mock.patch("ckanext.validation.plugin._run_async_validation") as mock_validate: + + Resource() + + assert not mock_validate.called + + assert config["ckanext.validation.run_on_update_async"] is True + assert config["ckanext.validation.run_on_create_async"] is True + + @pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", True) + @pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", True) + def test_turn_off_sync(self): + assert config["ckanext.validation.run_on_update_sync"] is True + assert config["ckanext.validation.run_on_create_sync"] is True + + with turn_off_validation(): + assert config["ckanext.validation.run_on_update_sync"] is False + assert config["ckanext.validation.run_on_create_sync"] is False + + with mock.patch("ckanext.validation.logic._run_sync_validation") as mock_validate: + + Resource() + + assert not mock_validate.called + + assert config["ckanext.validation.run_on_update_sync"] is True + assert config["ckanext.validation.run_on_create_sync"] is True + + + @pytest.mark.ckan_config("ckanext.validation.run_on_update_async", False) + @pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", True) + @pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", False) + def test_turn_off_preserves_values(self): + assert config["ckanext.validation.run_on_update_async"] is False + assert "ckanext.validation.run_on_create_async" not in config + assert config["ckanext.validation.run_on_create_sync"] is True + assert config["ckanext.validation.run_on_update_sync"] is False + + with turn_off_validation(): + assert config["ckanext.validation.run_on_update_async"] is False + assert config["ckanext.validation.run_on_create_async"] is False + assert config["ckanext.validation.run_on_update_sync"] is False + assert config["ckanext.validation.run_on_create_sync"] is False + + with mock.patch("ckanext.validation.logic._run_sync_validation") as mock_validate: + + Resource() + + assert not mock_validate.called + + assert config["ckanext.validation.run_on_update_async"] is False + assert "ckanext.validation.run_on_create_async" not in config + assert config["ckanext.validation.run_on_create_sync"] is True + assert config["ckanext.validation.run_on_update_sync"] is False + + class TestFiles(object): @mock_uploads_fake_fs def test_local_path(self, mock_open): diff --git a/ckanext/validation/utils.py b/ckanext/validation/utils.py index 060b216d..bb512f3e 100644 --- a/ckanext/validation/utils.py +++ b/ckanext/validation/utils.py @@ -1,6 +1,8 @@ import os import logging +from contextlib import contextmanager + from ckan.lib.uploader import ResourceUpload from ckantoolkit import config, asbool @@ -8,6 +10,34 @@ log = logging.getLogger(__name__) +@contextmanager +def turn_off_validation(): + + keys = ( + 'ckanext.validation.run_on_update_sync', + 'ckanext.validation.run_on_update_async', + 'ckanext.validation.run_on_create_sync', + 'ckanext.validation.run_on_create_async', + ) + + # Store current state + current = {} + for key in keys: + current[key] = config.get(key) + + # Turn off all validation + for key in keys: + config[key] = False + + yield + + # Restore state + for key in keys: + config.pop(key, None) + if current[key] is not None: + config[key] = current[key] + + def get_update_mode_from_config(): if asbool( config.get(u'ckanext.validation.run_on_update_sync', False)): From d9598c59a657e7a11a748f6dbe15b441efa96bfe Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 23 Feb 2023 15:51:29 +0100 Subject: [PATCH 38/43] Don't run validations when creating the draft resource It makes more sense to do it when the user actually saves the final resource, as the file or the schema might have changed --- ckanext/validation/blueprints.py | 43 ++++++------ ckanext/validation/tests/test_uploader.py | 79 +++++++++++++++++++++++ 2 files changed, 101 insertions(+), 21 deletions(-) diff --git a/ckanext/validation/blueprints.py b/ckanext/validation/blueprints.py index ee576c95..d7c87c57 100644 --- a/ckanext/validation/blueprints.py +++ b/ckanext/validation/blueprints.py @@ -5,6 +5,7 @@ from ckan.lib.navl.dictization_functions import unflatten from ckan.logic import tuplize_dict, clean_dict, parse_params from ckanext.validation.logic import is_tabular +from ckanext.validation.utils import turn_off_validation from ckantoolkit import ( c, g, @@ -15,8 +16,9 @@ render, get_action, request, + config, ) -import ckantoolkit as t + validation = Blueprint("validation", __name__) @@ -66,25 +68,23 @@ def _get_data(): def resource_file_create(id): - # Get data from the request data_dict = _get_data() - # Call resource_create context = { 'user': g.user, } - data_dict["package_id"] = id - resource = get_action("resource_create")(context, data_dict) - # If it's tabular (local OR remote), infer and store schema - if is_tabular(filename=resource['url']): - update_resource_schema = get_action('resource_table_schema_infer')( - context, {'resource_id': resource['id'], 'store_schema': True} - ) - resource['schema'] = update_resource_schema['schema'] + with turn_off_validation(): + resource = get_action("resource_create")(context, data_dict) + + # If it's tabular (local OR remote), infer and store schema + if is_tabular(filename=resource['url']): + update_resource_schema = get_action('resource_table_schema_infer')( + context, {'resource_id': resource['id'], 'store_schema': True} + ) + resource['schema'] = update_resource_schema['schema'] - # Return resource return resource @@ -98,17 +98,18 @@ def resource_file_update(id, resource_id): } data_dict["id"] = resource_id data_dict["package_id"] = id - resource = get_action("resource_update")(context, data_dict) - # If it's tabular (local OR remote), infer and store schema - if is_tabular(resource['url']): - resource_id = resource['id'] - update_resource_schema = get_action('resource_table_schema_infer')( - context, {'resource_id': resource_id, 'store_schema': True} - ) - resource['schema'] = update_resource_schema['schema'] + with turn_off_validation(): + resource = get_action("resource_update")(context, data_dict) + + # If it's tabular (local OR remote), infer and store schema + if is_tabular(resource['url']): + resource_id = resource['id'] + update_resource_schema = get_action('resource_table_schema_infer')( + context, {'resource_id': resource_id, 'store_schema': True} + ) + resource['schema'] = update_resource_schema['schema'] - # Return resource return resource validation.add_url_rule( diff --git a/ckanext/validation/tests/test_uploader.py b/ckanext/validation/tests/test_uploader.py index 84847d4c..85d6f85d 100644 --- a/ckanext/validation/tests/test_uploader.py +++ b/ckanext/validation/tests/test_uploader.py @@ -1,4 +1,6 @@ import io +from unittest import mock + import pytest import responses @@ -345,3 +347,80 @@ def test_update_url_no_tabular_no_schema(app): assert resource["url_type"] is None assert "schema" not in resource + + +# Jobs + +@pytest.mark.ckan_config("ckanext.validation.run_on_create_async", True) +def test_create_upload_does_not_trigger_async_validations(app): + + dataset = Dataset() + + data = { + "upload": (io.BytesIO(bytes(VALID_CSV.encode("utf8"))), "valid.csv"), + } + with mock.patch("ckanext.validation.plugin._run_async_validation") as mock_validate: + app.post( + url=_new_resource_upload_url(dataset["id"]), extra_environ=_get_env(), data=data + ) + + assert not mock_validate.called + + +@pytest.mark.ckan_config("ckanext.validation.run_on_create_sync", True) +def test_create_upload_does_not_trigger_sync_validations(app): + + dataset = Dataset() + + data = { + "upload": (io.BytesIO(bytes(VALID_CSV.encode("utf8"))), "valid.csv"), + } + + with mock.patch("ckanext.validation.logic._run_sync_validation") as mock_validate: + app.post( + url=_new_resource_upload_url(dataset["id"]), extra_environ=_get_env(), data=data + ) + + assert not mock_validate.called + + +@pytest.mark.ckan_config("ckanext.validation.run_on_update_async", True) +def test_update_upload_does_not_trigger_async_validations(app): + + resource = Resource() + + data = { + "upload": (io.BytesIO(bytes(VALID_CSV.encode("utf8"))), "valid.csv"), + # CKAN does not refresh the format, see https://github.com/ckan/ckan/issues/7415 + "format": "CSV", + } + + with mock.patch("ckanext.validation.plugin._run_async_validation") as mock_validate: + app.post( + url=_edit_resource_upload_url(resource["package_id"], resource["id"]), + extra_environ=_get_env(), + data=data, + ) + + assert not mock_validate.called + + +@pytest.mark.ckan_config("ckanext.validation.run_on_update_sync", True) +def test_update_upload_does_not_trigger_sync_validations(app): + + resource = Resource() + + data = { + "upload": (io.BytesIO(bytes(VALID_CSV.encode("utf8"))), "valid.csv"), + # CKAN does not refresh the format, see https://github.com/ckan/ckan/issues/7415 + "format": "CSV", + } + + with mock.patch("ckanext.validation.logic._run_sync_validation") as mock_validate: + app.post( + url=_edit_resource_upload_url(resource["package_id"], resource["id"]), + extra_environ=_get_env(), + data=data, + ) + + assert not mock_validate.called From 3af20e2211c7ce76a83f081f4b5ffc997a3c540b Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 23 Feb 2023 16:05:25 +0100 Subject: [PATCH 39/43] Specify format in tests because of ckan/ckan#7415 --- ckanext/validation/tests/test_uploader.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ckanext/validation/tests/test_uploader.py b/ckanext/validation/tests/test_uploader.py index 85d6f85d..af869a9b 100644 --- a/ckanext/validation/tests/test_uploader.py +++ b/ckanext/validation/tests/test_uploader.py @@ -150,6 +150,7 @@ def test_update_upload_with_schema(app): data = { "upload": (io.BytesIO(bytes(VALID_CSV.encode("utf8"))), "valid.csv"), + "format": "CSV", } app.post( @@ -179,6 +180,8 @@ def test_update_upload_no_tabular_no_schema(app): data = { "upload": (io.BytesIO(b"test file"), "some.txt"), + "format": "TXT", + } app.post( From 9236615f25498042867edd7317129b60137b11df Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 28 Feb 2023 11:46:46 +0100 Subject: [PATCH 40/43] Remove duplicated test --- ckanext/validation/tests/test_uploader.py | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/ckanext/validation/tests/test_uploader.py b/ckanext/validation/tests/test_uploader.py index af869a9b..c5d26599 100644 --- a/ckanext/validation/tests/test_uploader.py +++ b/ckanext/validation/tests/test_uploader.py @@ -265,28 +265,6 @@ def test_update_removes_schema(app): assert "schema" not in resource -def test_update_upload_no_tabular_no_schema(app): - - resource = Resource() - - data = { - "upload": (io.BytesIO(b"test file"), "some.txt"), - } - - app.post( - url=_edit_resource_upload_url(resource["package_id"], resource["id"]), - extra_environ=_get_env(), - data=data, - ) - - resource = call_action("resource_show", id=resource["id"]) - - assert resource["format"] == "TXT" - assert resource["url_type"] == "upload" - - assert "schema" not in resource - - @responses.activate def test_update_url_with_schema(app): url = "https://example.com/valid.csv" From 0198797899deb0e9f6f3bdec154f5e01ab78d7e6 Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 28 Feb 2023 12:02:01 +0100 Subject: [PATCH 41/43] Bump responses --- dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 4f437139..75356a24 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,4 @@ pyfakefs==4.6.* pytest-ckan pytest-cov -responses +responses>=0.22.0 From d0f780d124bfa4a86ff7fe4fc50cc49d4779230b Mon Sep 17 00:00:00 2001 From: amercader Date: Wed, 29 Mar 2023 12:48:37 +0200 Subject: [PATCH 42/43] Revert file size check removal in a9e5459 Refactor the schema file processing function to work both when an empty file upload is sent (ie when pasting a text schema) and the tests (where upload.content_length is always 0) --- ckanext/validation/plugin/__init__.py | 28 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index 68ec7c7c..35e218f9 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -147,6 +147,7 @@ def _process_schema_fields(self, data_dict): All the 3 `schema_*` fields are removed from the data_dict. Note that the data_dict still needs to pass validation ''' + schema = None schema_upload = data_dict.pop(u'schema_upload', None) schema_url = data_dict.pop(u'schema_url', None) @@ -154,17 +155,22 @@ def _process_schema_fields(self, data_dict): if isinstance(schema_upload, ALLOWED_UPLOAD_TYPES): uploaded_file = _get_underlying_file(schema_upload) - data_dict[u'schema'] = uploaded_file.read() - - if isinstance(data_dict["schema"], (bytes, bytearray)): - data_dict["schema"] = data_dict["schema"].decode() - elif schema_url not in ('', None): - if (not isinstance(schema_url, str) or - not schema_url.lower()[:4] == u'http'): - raise t.ValidationError({u'schema_url': 'Must be a valid URL'}) - data_dict[u'schema'] = schema_url - elif schema_json: - data_dict[u'schema'] = schema_json + file_contents = uploaded_file.read() + if len(file_contents): + schema = file_contents + if isinstance(schema, (bytes, bytearray)): + schema = schema.decode() + if not schema: + if schema_url not in ('', None): + if (not isinstance(schema_url, str) or + not schema_url.lower()[:4] == u'http'): + raise t.ValidationError({u'schema_url': 'Must be a valid URL'}) + schema = schema_url + if schema_json: + schema = schema_json + import ipdb; ipdb.set_trace() + if schema: + data_dict["schema"] = schema return data_dict From f99096915eaaaa6ba8dfda4003ec17dbdd77b507 Mon Sep 17 00:00:00 2001 From: amercader Date: Wed, 29 Mar 2023 12:53:21 +0200 Subject: [PATCH 43/43] Remove debugger --- ckanext/validation/plugin/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index 35e218f9..0f67f3ca 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -168,7 +168,7 @@ def _process_schema_fields(self, data_dict): schema = schema_url if schema_json: schema = schema_json - import ipdb; ipdb.set_trace() + if schema: data_dict["schema"] = schema