shopar-plugin 0.8.4-alpha.1 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,7 +32,7 @@ There are two distinct ways of integrating the plugin: via Script tag and via NP
32
32
  Add the following script to your HTML.
33
33
 
34
34
  ```html
35
- <script src="https://cdn.jsdelivr.net/npm/shopar-plugin@{{VERSION}}/dist/shopar-plugin.js"></script>
35
+ <script src="https://cdn.jsdelivr.net/npm/shopar-plugin@0.8.4/dist/shopar-plugin.js"></script>
36
36
  ```
37
37
 
38
38
  It is possible to use a different CDN instead of [jsDelivr](https://www.jsdelivr.com/) (e.g. [cdnjs](https://cdnjs.com/), [unpkg](https://www.unpkg.com/)), or even a relative path if the plugin is distributed as a static asset to your app. Just make sure to set the `baseUrl` parameter accordingly (see [setup options](#shoparpluginsetupoptions) for more details).
@@ -153,7 +153,7 @@ Options used for the plugin setup:
153
153
  - `baseUrl` (optional)
154
154
  - Type: `string`
155
155
  - If provided, defines where the additional ShopAR plugin files are fetched from.
156
- - Default value: `https://cdn.jsdelivr.net/npm/shopar-plugin@{{VERSION}}/dist`
156
+ - Default value: `https://cdn.jsdelivr.net/npm/shopar-plugin@0.8.4/dist`
157
157
  - `defaultUI` (optional)
158
158
  - Type: `boolean`
159
159
  - If provided and set to `false`, disables the default UI such as buttons, loading and error views.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ShopAR__analytics={})}(this,(function(t){"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t){return Number.isInteger(t)&&t>=0}function n(t){this.name="ArgumentError",this.message=t}var s=e((function(t,e){if(e=e||{},"function"!=typeof t)throw new n("fetch must be a function");if("object"!=typeof e)throw new n("defaults must be an object");if(void 0!==e.retries&&!i(e.retries))throw new n("retries must be a positive integer");if(void 0!==e.retryDelay&&!i(e.retryDelay)&&"function"!=typeof e.retryDelay)throw new n("retryDelay must be a positive integer or a function returning a positive integer");if(void 0!==e.retryOn&&!Array.isArray(e.retryOn)&&"function"!=typeof e.retryOn)throw new n("retryOn property expects an array or function");return e=Object.assign({retries:3,retryDelay:1e3,retryOn:[]},e),function(s,r){var a=e.retries,o=e.retryDelay,c=e.retryOn;if(r&&void 0!==r.retries){if(!i(r.retries))throw new n("retries must be a positive integer");a=r.retries}if(r&&void 0!==r.retryDelay){if(!i(r.retryDelay)&&"function"!=typeof r.retryDelay)throw new n("retryDelay must be a positive integer or a function returning a positive integer");o=r.retryDelay}if(r&&r.retryOn){if(!Array.isArray(r.retryOn)&&"function"!=typeof r.retryOn)throw new n("retryOn property expects an array or function");c=r.retryOn}return new Promise((function(e,i){var n=function(n){var o="undefined"!=typeof Request&&s instanceof Request?s.clone():s;t(o,r).then((function(t){if(Array.isArray(c)&&-1===c.indexOf(t.status))e(t);else if("function"==typeof c)try{return Promise.resolve(c(n,null,t)).then((function(i){i?u(n,null,t):e(t)})).catch(i)}catch(t){i(t)}else n<a?u(n,null,t):e(t)})).catch((function(t){if("function"==typeof c)try{Promise.resolve(c(n,t,null)).then((function(e){e?u(n,t,null):i(t)})).catch((function(t){i(t)}))}catch(t){i(t)}else n<a?u(n,t,null):i(t)}))};function u(t,e,i){var s="function"==typeof o?o(t,e,i):o;setTimeout((function(){n(++t)}),s)}n(0)}))}}));var r,a;!function(t){t.unknown="unknown",t.user="user",t.organization="organization",t.anonymous="anonymous"}(r||(r={})),function(t){t.api="api",t.query="query",t.ingest="ingest"}(a||(a={}));class o{scope;type;value;remaining;reset;constructor(t=r.unknown,e=a.api,i=0,n=-1,s=new Date){this.scope=t,this.type=e,this.value=i,this.remaining=n,this.reset=s}}function c(t,e,i,n,s){let a=new o;const c=t.headers.get(e.toLowerCase())||r.unknown;a.scope=r[c];const u=t.headers.get(i.toLowerCase())||"",h=parseInt(u,10);isNaN(h)||(a.value=h);const l=t.headers.get(n.toLowerCase())||"",f=parseInt(l,10);isNaN(f)||(a.remaining=f);const m=t.headers.get(s.toLowerCase())||"",y=parseInt(m,10);return isNaN(y)||(a.reset=new Date(1e3*y)),a}class u{config;constructor(t){this.config=t}async doReq(t,e,i={},n={}){let r=`${this.config.baseUrl}${t}`;const o=this._prepareSearchParams(n);o&&(r+=`?${o.toString()}`);const u={...this.config.headers,...i.headers},l=await s(fetch)(r,{retries:3,retryDelay:function(t,e,i){return 1e3*Math.pow(2,t)},retryOn:[503,502,504,500],headers:u,method:e,body:i.body?i.body:void 0});if(204===l.status)return l;if(429==l.status){const t=function(t){let e;return t.url?.endsWith("/ingest")?(e=c(t,"","X-IngestLimit-Limit","X-IngestLimit-Remaining","X-IngestLimit-Reset"),e.type=a.ingest):t.url?.endsWith("/query")||t.url?.endsWith("/_apl")?(e=c(t,"","X-QueryLimit-Limit","X-QueryLimit-Remaining","X-QueryLimit-Reset"),e.type=a.query):(e=c(t,"X-RateLimit-Scope","X-RateLimit-Limit","X-RateLimit-Remaining","X-RateLimit-Reset"),e.type=a.api),e}(l);return Promise.reject(new h(t))}if(401===l.status)return Promise.reject(new Error("Forbidden"));if(l.status>=400){const t=await l.json();return Promise.reject(new Error(t.message))}return await l.json()}post(t,e={},i={}){return this.doReq(t,"POST",e,i)}get(t,e={},i={}){return this.doReq(t,"GET",e,i)}put(t,e={},i={}){return this.doReq(t,"PUT",e,i)}delete(t,e={},i={}){return this.doReq(t,"DELETE",e,i)}_prepareSearchParams=t=>{const e=new URLSearchParams;let i=!1;return Object.keys(t).forEach((n=>{t[n]&&(e.append(n,t[n]),i=!0)})),i?e:null}}class h extends Error{limit;shortcircuit;message="";constructor(t,e=!1){super(),this.limit=t,this.shortcircuit=e,Object.setPrototypeOf(this,h.prototype);const i=h.timeUntilReset(t);this.message=`${t.type} limit exceeded, try again in ${i.minutes}m${i.seconds}s`,t.type==a.api&&(this.message=`${t.scope} `+this.message)}static timeUntilReset(t){const e=t.reset.getTime()-(new Date).getTime(),i=Math.floor(e/1e3%60);return{total:e,minutes:Math.floor(e/1e3/60%60),seconds:i}}}class l{client;constructor({orgId:t="",token:e,url:i}){e||console.warn("Missing Axiom token");const n=i??"https://api.axiom.co",s={Accept:"application/json","Content-Type":"application/json",Authorization:"Bearer "+e};"undefined"==typeof window&&(s["User-Agent"]="axiom-js/1.0.0-rc.1"),t&&(s["X-Axiom-Org-Id"]=t),this.client=new u({baseUrl:n,headers:s,timeout:3e3})}}var f,m,y,p,d,g;!function(t){t.TimestampField="_time";t.Service=class extends l{localPath="/v1/datasets";list=()=>this.client.get(this.localPath);get=t=>this.client.get(this.localPath+"/"+t);create=t=>this.client.post(this.localPath,{body:JSON.stringify(t)});update=(t,e)=>this.client.put(this.localPath+"/"+t,{body:JSON.stringify(e)});delete=t=>this.client.delete(this.localPath+"/"+t);trim=(t,e)=>{const i={maxDuration:e};return this.client.post(this.localPath+"/"+t+"/trim",{body:JSON.stringify(i)})}}}(f||(f={})),function(t){t.Service=class extends l{current=()=>this.client.get("/v1/user")}}(m||(m={}));class w{ingestFn;id;options;events=[];activeFlush=Promise.resolve();nextFlush=setTimeout((()=>{}),0);lastFlush=new Date;constructor(t,e,i){this.ingestFn=t,this.id=e,this.options=i}ingest=t=>{Array.isArray(t)?this.events=this.events.concat(t):this.events.push(t),this.events.length>=1e3||this.lastFlush.getTime()<Date.now()-1e3?(clearTimeout(this.nextFlush),this.activeFlush=this.flush()):(clearTimeout(this.nextFlush),this.nextFlush=setTimeout((()=>{this.activeFlush=this.flush()}),1e3))};flush=async()=>{const t=this.events.splice(0,this.events.length);if(clearTimeout(this.nextFlush),await this.activeFlush,0===t.length)return void(this.lastFlush=new Date);const e=await this.ingestFn(this.id,t,this.options);return this.lastFlush=new Date,e}}class v extends l{datasets;users;localPath="/v1";constructor(t){super(t),this.datasets=new f.Service(t),this.users=new m.Service(t)}ingestRaw=(t,e,i=y.JSON,n=p.Identity,s)=>this.client.post(this.localPath+"/datasets/"+t+"/ingest",{headers:{"Content-Type":i,"Content-Encoding":n},body:e},{"timestamp-field":s?.timestampField,"timestamp-format":s?.timestampFormat,"csv-delimiter":s?.csvDelimiter});queryLegacy=(t,e,i)=>this.client.post(this.localPath+"/datasets/"+t+"/query",{body:JSON.stringify(e)},{"streaming-duration":i?.streamingDuration,nocache:i?.noCache});query=(t,e)=>{const i={apl:t};return e?.startTime&&(i.startTime=e?.startTime),e?.endTime&&(i.endTime=e?.endTime),this.client.post(this.localPath+"/datasets/_apl",{body:JSON.stringify(i)},{"streaming-duration":e?.streamingDuration,nocache:e?.noCache,format:"legacy"})};aplQuery=(t,e)=>this.query(t,e)}class b extends v{batch={};ingest=(t,e,i)=>{const n=function(t,e){return`${t}:${e?.timestampField||"-"}:${e?.timestampFormat||"-"}:${e?.csvDelimiter||"-"}`}(t,i);return this.batch[n]||(this.batch[n]=new w(((t,e,i)=>{const n=(Array.isArray(e)?e:[e]).map((t=>JSON.stringify(t))).join("\n");return this.ingestRaw(t,n,y.NDJSON,p.Identity,i)}),t,i)),this.batch[n].ingest(e)};flush=async()=>{let t=[];for(const e in this.batch)t.push(this.batch[e].flush());await Promise.all(t)}}let x;!function(t){t.JSON="application/json",t.NDJSON="application/x-ndjson",t.CSV="text/csv"}(y||(y={})),function(t){t.Identity="",t.GZIP="gzip"}(p||(p={})),function(t){t.Count="count",t.Distinct="distinct",t.Sum="sum",t.Avg="avg",t.Min="min",t.Max="max",t.Topk="topk",t.Percentiles="percentiles",t.Histogram="histogram",t.Variance="variance",t.Stdev="stdev",t.ArgMin="argmin",t.ArgMax="argmax",t.MakeSet="makeset",t.MakeSetIf="makesetif",t.CountIf="countif",t.CountDistinctIf="distinctif"}(d||(d={})),function(t){t.And="and",t.Or="or",t.Not="not",t.Equal="==",t.NotEqual="!=",t.Exists="exists",t.NotExists="not-exists",t.GreaterThan=">",t.GreaterThanOrEqualTo=">=",t.LessThan="<",t.LessThanOrEqualTo="<=",t.Gt="gt",t.Gte="gte",t.Lt="lt",t.Lte="lte",t.StartsWith="starts-with",t.NotStartsWith="not-starts-with",t.EndsWith="ends-with",t.NotEndsWith="not-ends-with",t.Contains="contains",t.NotContains="not-contains",t.Regexp="regexp",t.NotRegexp="not-regexp"}(g||(g={})),t.initializeImpl=function(){x=new b({token:"xaat-16d05fdd-4ab9-4990-acba-7cee24974bfb"})},t.trackEventImpl=function(t,e){x.ingest("shopar-plugin-alpha",Object.assign({name:t},e))}}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ShopAR__analytics={})}(this,(function(t){"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t){return Number.isInteger(t)&&t>=0}function n(t){this.name="ArgumentError",this.message=t}var s=e((function(t,e){if(e=e||{},"function"!=typeof t)throw new n("fetch must be a function");if("object"!=typeof e)throw new n("defaults must be an object");if(void 0!==e.retries&&!i(e.retries))throw new n("retries must be a positive integer");if(void 0!==e.retryDelay&&!i(e.retryDelay)&&"function"!=typeof e.retryDelay)throw new n("retryDelay must be a positive integer or a function returning a positive integer");if(void 0!==e.retryOn&&!Array.isArray(e.retryOn)&&"function"!=typeof e.retryOn)throw new n("retryOn property expects an array or function");return e=Object.assign({retries:3,retryDelay:1e3,retryOn:[]},e),function(s,r){var a=e.retries,o=e.retryDelay,c=e.retryOn;if(r&&void 0!==r.retries){if(!i(r.retries))throw new n("retries must be a positive integer");a=r.retries}if(r&&void 0!==r.retryDelay){if(!i(r.retryDelay)&&"function"!=typeof r.retryDelay)throw new n("retryDelay must be a positive integer or a function returning a positive integer");o=r.retryDelay}if(r&&r.retryOn){if(!Array.isArray(r.retryOn)&&"function"!=typeof r.retryOn)throw new n("retryOn property expects an array or function");c=r.retryOn}return new Promise((function(e,i){var n=function(n){var o="undefined"!=typeof Request&&s instanceof Request?s.clone():s;t(o,r).then((function(t){if(Array.isArray(c)&&-1===c.indexOf(t.status))e(t);else if("function"==typeof c)try{return Promise.resolve(c(n,null,t)).then((function(i){i?u(n,null,t):e(t)})).catch(i)}catch(t){i(t)}else n<a?u(n,null,t):e(t)})).catch((function(t){if("function"==typeof c)try{Promise.resolve(c(n,t,null)).then((function(e){e?u(n,t,null):i(t)})).catch((function(t){i(t)}))}catch(t){i(t)}else n<a?u(n,t,null):i(t)}))};function u(t,e,i){var s="function"==typeof o?o(t,e,i):o;setTimeout((function(){n(++t)}),s)}n(0)}))}}));var r,a;!function(t){t.unknown="unknown",t.user="user",t.organization="organization",t.anonymous="anonymous"}(r||(r={})),function(t){t.api="api",t.query="query",t.ingest="ingest"}(a||(a={}));class o{scope;type;value;remaining;reset;constructor(t=r.unknown,e=a.api,i=0,n=-1,s=new Date){this.scope=t,this.type=e,this.value=i,this.remaining=n,this.reset=s}}function c(t,e,i,n,s){let a=new o;const c=t.headers.get(e.toLowerCase())||r.unknown;a.scope=r[c];const u=t.headers.get(i.toLowerCase())||"",h=parseInt(u,10);isNaN(h)||(a.value=h);const l=t.headers.get(n.toLowerCase())||"",f=parseInt(l,10);isNaN(f)||(a.remaining=f);const m=t.headers.get(s.toLowerCase())||"",y=parseInt(m,10);return isNaN(y)||(a.reset=new Date(1e3*y)),a}class u{config;constructor(t){this.config=t}async doReq(t,e,i={},n={}){let r=`${this.config.baseUrl}${t}`;const o=this._prepareSearchParams(n);o&&(r+=`?${o.toString()}`);const u={...this.config.headers,...i.headers},l=await s(fetch)(r,{retries:3,retryDelay:function(t,e,i){return 1e3*Math.pow(2,t)},retryOn:[503,502,504,500],headers:u,method:e,body:i.body?i.body:void 0});if(204===l.status)return l;if(429==l.status){const t=function(t){let e;return t.url?.endsWith("/ingest")?(e=c(t,"","X-IngestLimit-Limit","X-IngestLimit-Remaining","X-IngestLimit-Reset"),e.type=a.ingest):t.url?.endsWith("/query")||t.url?.endsWith("/_apl")?(e=c(t,"","X-QueryLimit-Limit","X-QueryLimit-Remaining","X-QueryLimit-Reset"),e.type=a.query):(e=c(t,"X-RateLimit-Scope","X-RateLimit-Limit","X-RateLimit-Remaining","X-RateLimit-Reset"),e.type=a.api),e}(l);return Promise.reject(new h(t))}if(401===l.status)return Promise.reject(new Error("Forbidden"));if(l.status>=400){const t=await l.json();return Promise.reject(new Error(t.message))}return await l.json()}post(t,e={},i={}){return this.doReq(t,"POST",e,i)}get(t,e={},i={}){return this.doReq(t,"GET",e,i)}put(t,e={},i={}){return this.doReq(t,"PUT",e,i)}delete(t,e={},i={}){return this.doReq(t,"DELETE",e,i)}_prepareSearchParams=t=>{const e=new URLSearchParams;let i=!1;return Object.keys(t).forEach((n=>{t[n]&&(e.append(n,t[n]),i=!0)})),i?e:null}}class h extends Error{limit;shortcircuit;message="";constructor(t,e=!1){super(),this.limit=t,this.shortcircuit=e,Object.setPrototypeOf(this,h.prototype);const i=h.timeUntilReset(t);this.message=`${t.type} limit exceeded, try again in ${i.minutes}m${i.seconds}s`,t.type==a.api&&(this.message=`${t.scope} `+this.message)}static timeUntilReset(t){const e=t.reset.getTime()-(new Date).getTime(),i=Math.floor(e/1e3%60);return{total:e,minutes:Math.floor(e/1e3/60%60),seconds:i}}}class l{client;constructor({orgId:t="",token:e,url:i}){e||console.warn("Missing Axiom token");const n=i??"https://api.axiom.co",s={Accept:"application/json","Content-Type":"application/json",Authorization:"Bearer "+e};"undefined"==typeof window&&(s["User-Agent"]="axiom-js/1.0.0-rc.1"),t&&(s["X-Axiom-Org-Id"]=t),this.client=new u({baseUrl:n,headers:s,timeout:3e3})}}var f,m,y,p,d,g;!function(t){t.TimestampField="_time";t.Service=class extends l{localPath="/v1/datasets";list=()=>this.client.get(this.localPath);get=t=>this.client.get(this.localPath+"/"+t);create=t=>this.client.post(this.localPath,{body:JSON.stringify(t)});update=(t,e)=>this.client.put(this.localPath+"/"+t,{body:JSON.stringify(e)});delete=t=>this.client.delete(this.localPath+"/"+t);trim=(t,e)=>{const i={maxDuration:e};return this.client.post(this.localPath+"/"+t+"/trim",{body:JSON.stringify(i)})}}}(f||(f={})),function(t){t.Service=class extends l{current=()=>this.client.get("/v1/user")}}(m||(m={}));class w{ingestFn;id;options;events=[];activeFlush=Promise.resolve();nextFlush=setTimeout((()=>{}),0);lastFlush=new Date;constructor(t,e,i){this.ingestFn=t,this.id=e,this.options=i}ingest=t=>{Array.isArray(t)?this.events=this.events.concat(t):this.events.push(t),this.events.length>=1e3||this.lastFlush.getTime()<Date.now()-1e3?(clearTimeout(this.nextFlush),this.activeFlush=this.flush()):(clearTimeout(this.nextFlush),this.nextFlush=setTimeout((()=>{this.activeFlush=this.flush()}),1e3))};flush=async()=>{const t=this.events.splice(0,this.events.length);if(clearTimeout(this.nextFlush),await this.activeFlush,0===t.length)return void(this.lastFlush=new Date);const e=await this.ingestFn(this.id,t,this.options);return this.lastFlush=new Date,e}}class v extends l{datasets;users;localPath="/v1";constructor(t){super(t),this.datasets=new f.Service(t),this.users=new m.Service(t)}ingestRaw=(t,e,i=y.JSON,n=p.Identity,s)=>this.client.post(this.localPath+"/datasets/"+t+"/ingest",{headers:{"Content-Type":i,"Content-Encoding":n},body:e},{"timestamp-field":s?.timestampField,"timestamp-format":s?.timestampFormat,"csv-delimiter":s?.csvDelimiter});queryLegacy=(t,e,i)=>this.client.post(this.localPath+"/datasets/"+t+"/query",{body:JSON.stringify(e)},{"streaming-duration":i?.streamingDuration,nocache:i?.noCache});query=(t,e)=>{const i={apl:t};return e?.startTime&&(i.startTime=e?.startTime),e?.endTime&&(i.endTime=e?.endTime),this.client.post(this.localPath+"/datasets/_apl",{body:JSON.stringify(i)},{"streaming-duration":e?.streamingDuration,nocache:e?.noCache,format:"legacy"})};aplQuery=(t,e)=>this.query(t,e)}class x extends v{batch={};ingest=(t,e,i)=>{const n=function(t,e){return`${t}:${e?.timestampField||"-"}:${e?.timestampFormat||"-"}:${e?.csvDelimiter||"-"}`}(t,i);return this.batch[n]||(this.batch[n]=new w(((t,e,i)=>{const n=(Array.isArray(e)?e:[e]).map((t=>JSON.stringify(t))).join("\n");return this.ingestRaw(t,n,y.NDJSON,p.Identity,i)}),t,i)),this.batch[n].ingest(e)};flush=async()=>{let t=[];for(const e in this.batch)t.push(this.batch[e].flush());await Promise.all(t)}}let b;!function(t){t.JSON="application/json",t.NDJSON="application/x-ndjson",t.CSV="text/csv"}(y||(y={})),function(t){t.Identity="",t.GZIP="gzip"}(p||(p={})),function(t){t.Count="count",t.Distinct="distinct",t.Sum="sum",t.Avg="avg",t.Min="min",t.Max="max",t.Topk="topk",t.Percentiles="percentiles",t.Histogram="histogram",t.Variance="variance",t.Stdev="stdev",t.ArgMin="argmin",t.ArgMax="argmax",t.MakeSet="makeset",t.MakeSetIf="makesetif",t.CountIf="countif",t.CountDistinctIf="distinctif"}(d||(d={})),function(t){t.And="and",t.Or="or",t.Not="not",t.Equal="==",t.NotEqual="!=",t.Exists="exists",t.NotExists="not-exists",t.GreaterThan=">",t.GreaterThanOrEqualTo=">=",t.LessThan="<",t.LessThanOrEqualTo="<=",t.Gt="gt",t.Gte="gte",t.Lt="lt",t.Lte="lte",t.StartsWith="starts-with",t.NotStartsWith="not-starts-with",t.EndsWith="ends-with",t.NotEndsWith="not-ends-with",t.Contains="contains",t.NotContains="not-contains",t.Regexp="regexp",t.NotRegexp="not-regexp"}(g||(g={})),t.initializeImpl=function(){b=new x({token:"xaat-f69a9dd7-3988-4fc2-849b-4a0978468c25"})},t.trackEventImpl=function(t,e){b.ingest("shopar-plugin",Object.assign({name:t},e))}}));
@@ -1,4 +1,4 @@
1
- function e(e,t,n,i){return new(n||(n=Promise))((function(r,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function o(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}l((i=i.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class t extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const n=[Uint8Array,Uint32Array].length-2,i=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],r=[2,12,7,1],a=window[i[r[r[n]]]][i[r[r[r.length-1]]]];function s(){const e=(new TextEncoder).encode(a),t=i.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[i[t[2]]](String.fromCodePoint(...e))}a.charCodeAt(n);const o=[1e3,2e3,4e3],l=o.length;function c(t,n=0){return e(this,void 0,void 0,(function*(){try{return yield t()}catch(e){if(n>=l)throw e;return yield new Promise((e=>setTimeout(e,o[n]))),c(t,n+1)}}))}function h(e){return e*(180/Math.PI)}function A(e){return Math.round(100*e)/100}const u=["Glasses","Shoes","Watches","Bracelets","Scarves","Hats","Necklaces"],d=["Shoes"];const p={};function f(n){return null==p[n]&&(p[n]=function(n){return e(this,void 0,void 0,(function*(){const i=yield c((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(n).catch((e=>{throw console.error(e),new t("Resource unavailable.")}));if(!e.ok)throw new t(`Resource download failed with status ${e.status}.`);return e}))));try{return yield(yield i.blob()).arrayBuffer()}catch(e){throw console.error(e),new t("Resource has invalid body.")}}))}(n)),p[n]}const g="0.8.4-alpha.1";let m=`https://cdn.jsdelivr.net/npm/shopar-plugin@${g}/dist`;const v={update:e=>{null!=e&&(m=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>m};function E(t){return e(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise((t=>{e.addEventListener("load",(()=>t()),!1),e.addEventListener("error",(()=>t()),!1),document.body.appendChild(e)}))}importScripts(t.toString())}))}let b;function C(t,n){let i=!0;return{qrPaused:()=>i,qrDraw:(r,a)=>e(this,void 0,void 0,(function*(){!function(){e(this,void 0,void 0,(function*(){null==b&&(b=E(`${v}/shopar-qr.js`))}))}(),yield b;const s=`https://ar.shopar.ai/${g.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:r,s:a,h:location.href})}`,o=yield window.ShopAR__QR.toDataURL(s),l=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=o,yield l,i=!1,t.style.display=""})),qrPause:()=>e(this,void 0,void 0,(function*(){i=!0,t.style.display="none"}))}}const _={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},I=Object.keys(_);const x="shopar-error";function y(e,t,n,i){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn",r.appendChild(i);{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;const a=r.style;return a.display="none",a.pointerEvents="auto",r}const M="shopar-control";const w="shopar-deepar-output";const S="shopar-main";const B="shopar-qr-output";function T(e,t,n,i){return new(n||(n=Promise))((function(r,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function o(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}l((i=i.apply(e,t||[])).next())}))}function R(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function D(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;const Q=4,U=.001,L=1e-7,P=10,N=11,F=1/(N-1),O="function"==typeof Float32Array;function k(e,t){return 1-3*t+3*e}function G(e,t){return 3*t-6*e}function H(e){return 3*e}function z(e,t,n){return((k(t,n)*e+G(t,n))*e+H(t))*e}function V(e,t,n){return 3*k(t,n)*e*e+2*G(t,n)*e+H(t)}function W(e){return e}function q(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=function(e,t,n,i){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===i)return W;const r=O?new Float32Array(N):new Array(N);for(let t=0;t<N;++t)r[t]=z(t*F,e,n);function a(t){let i=0,a=1;const s=N-1;for(;a!==s&&r[a]<=t;++a)i+=F;--a;const o=i+(t-r[a])/(r[a+1]-r[a])*F,l=V(o,e,n);return l>=U?function(e,t,n,i){for(let r=0;r<Q;++r){const r=V(t,n,i);if(0===r)return t;t-=(z(t,n,i)-e)/r}return t}(t,o,e,n):0===l?o:function(e,t,n,i,r){let a,s,o=0;do{s=t+(n-t)/2,a=z(s,i,r)-e,a>0?n=s:t=s}while(Math.abs(a)>L&&++o<P);return s}(t,i,i+F,e,n)}return function(e){return 0===e||1===e?e:z(a(e),t,i)}}(e.x1,e.y1,e.x2,e.y2);return e=>t(e)}throw new Error(`Unknown interpolation: ${e}`)}function j(e){if(e.length<2)throw new Error("Expected at least two key frames.");const t=e[e.length-1].time,n=[...e].sort(((e,t)=>e.time-t.time)).map((({time:e,value:t,interpolation:n})=>({time:e,value:t,interpolate:q(n)})));let i=0,r=n[0].value;const a=()=>{for(i<0&&(i=0);i>=t;)i-=t;for(let e=0;e<n.length-1;e++){const t=n[e],a=n[e+1];if(i>=t.time&&i<a.time){const e=t.interpolate((i-t.time)/(a.time-t.time));r=t.value+e*(a.value-t.value)}}};return{reset:()=>{i=0,a()},update:e=>{i+=e,a()},seek:e=>{i=e,a()},get:()=>r}}const Y="#",X="time",K="interpolation",J="yaw",Z="pitch",$="fov",ee=[X,J,Z,$,K],te="s",ne="ms",ie=1e3,re="deg",ae="rad",se=Math.PI/180,oe="ease-in-out",le="cubic-bezier(",ce=")";function he(e){if("string"==typeof e)return function(e){const[t,...n]=function(e){return e.split(/\r?\n/).map((e=>function(e){const t=e.indexOf(Y);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const i=function(e){const t=[];for(let n=0;n<e.length;n++){const i=e[n];if(!ee.includes(i))throw new Error(`Invalid token in header: '${i}'.`);if(t.includes(i))throw new Error(`Duplicate token in header: '${i}'.`);t.push(i)}if(!t.includes(X))throw new Error(`Missing required token: '${X}'.`);return t}(t.split(/\s+/)),r={};if(n.length<2)throw new Error("Expected at least two key frames.");for(const e of n){const{theta:t,phi:n,fov:a}=Ae(i,e);null!=t&&(null==r.theta&&(r.theta=[]),r.theta.push(t)),null!=n&&(null==r.phi&&(r.phi=[]),r.phi.push(n)),null!=a&&(null==r.fov&&(r.fov=[]),r.fov.push(a))}if(0===Object.values(r).length)throw new Error("At least one parameter should be animated.");return r}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const i of e){const{time:e,pitch:r,yaw:a,fov:s}=i;if(null==e)throw new Error("Time missing.");const o=de(null!==(t=i.interpolation)&&void 0!==t?t:oe);null!=a&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:a*se,interpolation:o})),null!=r&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:r*se,interpolation:o})),null!=s&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:s*se,interpolation:o}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function Ae(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const i=e.indexOf(X),r=function(e){return e.endsWith(ne)?fe(e.substring(0,e.length-ne.length)):e.endsWith(te)?fe(e.substring(0,e.length-te.length))*ie:fe(e)}(n[i]),a=e.indexOf(K),s=de(-1===a?oe:n[a]),o={};for(let t=0;t<n.length;t++){if(t===i||t===a)continue;const l=e[t],c=n[t];switch(l){case J:o.theta={time:r,value:ue(c),interpolation:s};break;case Z:o.phi={time:r,value:ue(c),interpolation:s};break;case $:o.fov={time:r,value:ue(c),interpolation:s};break;default:throw new Error(`Unhandled value for header '${l}'.`)}}return o}function ue(e){return e.endsWith(re)?fe(e.substring(0,e.length-re.length))*se:e.endsWith(ae)?fe(e.substring(0,e.length-ae.length)):fe(e)*se}function de(e){if("hold"===e)return{type:"hold"};if("linear"===e)return pe(0,0,1,1);if("sine"===e)return pe(.37,0,.63,1);if("sine-in"===e)return pe(.12,0,.39,0);if("sine-out"===e)return pe(.61,1,.88,1);if("ease"===e)return pe(.25,.1,.25,1);if("ease-in"===e)return pe(.42,0,1,1);if("ease-out"===e)return pe(0,0,.58,1);if("ease-in-out"===e)return pe(.42,0,.58,1);if(e.startsWith(le)&&e.endsWith(ce)){const t=e.substring(le.length,e.length-ce.length).split(/\s*,\s*/);if(4!==t.length)throw new Error(`Expected 4 parameters for the Bezier curve, but got '${t}'.`);return{type:"bezier",x1:fe(t[0]),y1:fe(t[1]),x2:fe(t[2]),y2:fe(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function pe(e,t,n,i){return{type:"bezier",x1:e,y1:t,x2:n,y2:i}}function fe(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}
1
+ function e(e,t,n,i){return new(n||(n=Promise))((function(r,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function o(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}l((i=i.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class t extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const n=[Uint8Array,Uint32Array].length-2,i=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],r=[2,12,7,1],a=window[i[r[r[n]]]][i[r[r[r.length-1]]]];function s(){const e=(new TextEncoder).encode(a),t=i.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[i[t[2]]](String.fromCodePoint(...e))}a.charCodeAt(n);const o=[1e3,2e3,4e3],l=o.length;function c(t,n=0){return e(this,void 0,void 0,(function*(){try{return yield t()}catch(e){if(n>=l)throw e;return yield new Promise((e=>setTimeout(e,o[n]))),c(t,n+1)}}))}function h(e){return e*(180/Math.PI)}function A(e){return Math.round(100*e)/100}const u=["Glasses","Shoes","Watches","Bracelets","Scarves","Hats","Necklaces"],d=["Shoes"];const p={};function f(n){return null==p[n]&&(p[n]=function(n){return e(this,void 0,void 0,(function*(){const i=yield c((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(n).catch((e=>{throw console.error(e),new t("Resource unavailable.")}));if(!e.ok)throw new t(`Resource download failed with status ${e.status}.`);return e}))));try{return yield(yield i.blob()).arrayBuffer()}catch(e){throw console.error(e),new t("Resource has invalid body.")}}))}(n)),p[n]}const g="0.8.4";let m=`https://cdn.jsdelivr.net/npm/shopar-plugin@${g}/dist`;const v={update:e=>{null!=e&&(m=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>m};function E(t){return e(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise((t=>{e.addEventListener("load",(()=>t()),!1),e.addEventListener("error",(()=>t()),!1),document.body.appendChild(e)}))}importScripts(t.toString())}))}let b;function C(t,n){let i=!0;return{qrPaused:()=>i,qrDraw:(r,a)=>e(this,void 0,void 0,(function*(){!function(){e(this,void 0,void 0,(function*(){null==b&&(b=E(`${v}/shopar-qr.js`))}))}(),yield b;const s=`https://ar.shopar.ai/${g.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:r,s:a,h:location.href})}`,o=yield window.ShopAR__QR.toDataURL(s),l=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=o,yield l,i=!1,t.style.display=""})),qrPause:()=>e(this,void 0,void 0,(function*(){i=!0,t.style.display="none"}))}}const _={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},I=Object.keys(_);const x="shopar-error";function y(e,t,n,i){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn",r.appendChild(i);{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;const a=r.style;return a.display="none",a.pointerEvents="auto",r}const M="shopar-control";const w="shopar-deepar-output";const S="shopar-main";const B="shopar-qr-output";function T(e,t,n,i){return new(n||(n=Promise))((function(r,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function o(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}l((i=i.apply(e,t||[])).next())}))}function R(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function D(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;const Q=4,U=.001,L=1e-7,P=10,N=11,F=1/(N-1),O="function"==typeof Float32Array;function k(e,t){return 1-3*t+3*e}function G(e,t){return 3*t-6*e}function H(e){return 3*e}function z(e,t,n){return((k(t,n)*e+G(t,n))*e+H(t))*e}function V(e,t,n){return 3*k(t,n)*e*e+2*G(t,n)*e+H(t)}function W(e){return e}function q(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=function(e,t,n,i){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===i)return W;const r=O?new Float32Array(N):new Array(N);for(let t=0;t<N;++t)r[t]=z(t*F,e,n);function a(t){let i=0,a=1;const s=N-1;for(;a!==s&&r[a]<=t;++a)i+=F;--a;const o=i+(t-r[a])/(r[a+1]-r[a])*F,l=V(o,e,n);return l>=U?function(e,t,n,i){for(let r=0;r<Q;++r){const r=V(t,n,i);if(0===r)return t;t-=(z(t,n,i)-e)/r}return t}(t,o,e,n):0===l?o:function(e,t,n,i,r){let a,s,o=0;do{s=t+(n-t)/2,a=z(s,i,r)-e,a>0?n=s:t=s}while(Math.abs(a)>L&&++o<P);return s}(t,i,i+F,e,n)}return function(e){return 0===e||1===e?e:z(a(e),t,i)}}(e.x1,e.y1,e.x2,e.y2);return e=>t(e)}throw new Error(`Unknown interpolation: ${e}`)}function j(e){if(e.length<2)throw new Error("Expected at least two key frames.");const t=e[e.length-1].time,n=[...e].sort(((e,t)=>e.time-t.time)).map((({time:e,value:t,interpolation:n})=>({time:e,value:t,interpolate:q(n)})));let i=0,r=n[0].value;const a=()=>{for(i<0&&(i=0);i>=t;)i-=t;for(let e=0;e<n.length-1;e++){const t=n[e],a=n[e+1];if(i>=t.time&&i<a.time){const e=t.interpolate((i-t.time)/(a.time-t.time));r=t.value+e*(a.value-t.value)}}};return{reset:()=>{i=0,a()},update:e=>{i+=e,a()},seek:e=>{i=e,a()},get:()=>r}}const Y="#",X="time",K="interpolation",J="yaw",Z="pitch",$="fov",ee=[X,J,Z,$,K],te="s",ne="ms",ie=1e3,re="deg",ae="rad",se=Math.PI/180,oe="ease-in-out",le="cubic-bezier(",ce=")";function he(e){if("string"==typeof e)return function(e){const[t,...n]=function(e){return e.split(/\r?\n/).map((e=>function(e){const t=e.indexOf(Y);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const i=function(e){const t=[];for(let n=0;n<e.length;n++){const i=e[n];if(!ee.includes(i))throw new Error(`Invalid token in header: '${i}'.`);if(t.includes(i))throw new Error(`Duplicate token in header: '${i}'.`);t.push(i)}if(!t.includes(X))throw new Error(`Missing required token: '${X}'.`);return t}(t.split(/\s+/)),r={};if(n.length<2)throw new Error("Expected at least two key frames.");for(const e of n){const{theta:t,phi:n,fov:a}=Ae(i,e);null!=t&&(null==r.theta&&(r.theta=[]),r.theta.push(t)),null!=n&&(null==r.phi&&(r.phi=[]),r.phi.push(n)),null!=a&&(null==r.fov&&(r.fov=[]),r.fov.push(a))}if(0===Object.values(r).length)throw new Error("At least one parameter should be animated.");return r}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const i of e){const{time:e,pitch:r,yaw:a,fov:s}=i;if(null==e)throw new Error("Time missing.");const o=de(null!==(t=i.interpolation)&&void 0!==t?t:oe);null!=a&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:a*se,interpolation:o})),null!=r&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:r*se,interpolation:o})),null!=s&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:s*se,interpolation:o}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function Ae(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const i=e.indexOf(X),r=function(e){return e.endsWith(ne)?fe(e.substring(0,e.length-ne.length)):e.endsWith(te)?fe(e.substring(0,e.length-te.length))*ie:fe(e)}(n[i]),a=e.indexOf(K),s=de(-1===a?oe:n[a]),o={};for(let t=0;t<n.length;t++){if(t===i||t===a)continue;const l=e[t],c=n[t];switch(l){case J:o.theta={time:r,value:ue(c),interpolation:s};break;case Z:o.phi={time:r,value:ue(c),interpolation:s};break;case $:o.fov={time:r,value:ue(c),interpolation:s};break;default:throw new Error(`Unhandled value for header '${l}'.`)}}return o}function ue(e){return e.endsWith(re)?fe(e.substring(0,e.length-re.length))*se:e.endsWith(ae)?fe(e.substring(0,e.length-ae.length)):fe(e)*se}function de(e){if("hold"===e)return{type:"hold"};if("linear"===e)return pe(0,0,1,1);if("sine"===e)return pe(.37,0,.63,1);if("sine-in"===e)return pe(.12,0,.39,0);if("sine-out"===e)return pe(.61,1,.88,1);if("ease"===e)return pe(.25,.1,.25,1);if("ease-in"===e)return pe(.42,0,1,1);if("ease-out"===e)return pe(0,0,.58,1);if("ease-in-out"===e)return pe(.42,0,.58,1);if(e.startsWith(le)&&e.endsWith(ce)){const t=e.substring(le.length,e.length-ce.length).split(/\s*,\s*/);if(4!==t.length)throw new Error(`Expected 4 parameters for the Bezier curve, but got '${t}'.`);return{type:"bezier",x1:fe(t[0]),y1:fe(t[1]),x2:fe(t[2]),y2:fe(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function pe(e,t,n,i){return{type:"bezier",x1:e,y1:t,x2:n,y2:i}}function fe(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2010-2024 Three.js Authors
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ShopAR={})}(this,(function(e){"use strict";function t(e,t,n,i){return new(n||(n=Promise))((function(r,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function o(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}l((i=i.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class n extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const i=[Uint8Array,Uint32Array].length-2,r=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],a=[2,12,7,1],s=window[r[a[a[i]]]][r[a[a[a.length-1]]]];function o(){const e=(new TextEncoder).encode(s),t=r.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[r[t[2]]](String.fromCodePoint(...e))}s.charCodeAt(i);const l=[1e3,2e3,4e3],c=l.length;function h(e,n=0){return t(this,void 0,void 0,(function*(){try{return yield e()}catch(t){if(n>=c)throw t;return yield new Promise((e=>setTimeout(e,l[n]))),h(e,n+1)}}))}function A(e){return e*(180/Math.PI)}function u(e){return Math.round(100*e)/100}const d=["Glasses","Shoes","Watches","Bracelets","Scarves","Hats","Necklaces"],p=["Shoes"];const f={};function g(e){return null==f[e]&&(f[e]=function(e){return t(this,void 0,void 0,(function*(){const i=yield h((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(e).catch((e=>{throw console.error(e),new n("Resource unavailable.")}));if(!t.ok)throw new n(`Resource download failed with status ${t.status}.`);return t}))));try{return yield(yield i.blob()).arrayBuffer()}catch(e){throw console.error(e),new n("Resource has invalid body.")}}))}(e)),f[e]}const m="0.8.4-alpha.1";let v=`https://cdn.jsdelivr.net/npm/shopar-plugin@${m}/dist`;const E={update:e=>{null!=e&&(v=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>v};function b(e){return t(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const t=document.createElement("script");return t.setAttribute("src",e),t.setAttribute("crossorigin","anonymous"),new Promise((e=>{t.addEventListener("load",(()=>e()),!1),t.addEventListener("error",(()=>e()),!1),document.body.appendChild(t)}))}importScripts(e.toString())}))}let C;function _(e,n){let i=!0;return{qrPaused:()=>i,qrDraw:(r,a)=>t(this,void 0,void 0,(function*(){!function(){t(this,void 0,void 0,(function*(){null==C&&(C=b(`${E}/shopar-qr.js`))}))}(),yield C;const s=`https://ar.shopar.ai/${m.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:r,s:a,h:location.href})}`,o=yield window.ShopAR__QR.toDataURL(s),l=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=o,yield l,i=!1,e.style.display=""})),qrPause:()=>t(this,void 0,void 0,(function*(){i=!0,e.style.display="none"}))}}const I={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},x=Object.keys(I);const y="shopar-error";function M(e,t,n,i){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn",r.appendChild(i);{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;const a=r.style;return a.display="none",a.pointerEvents="auto",r}const w="shopar-control";const S="shopar-deepar-output";const B="shopar-main";const T="shopar-qr-output";function R(e,t,n,i){return new(n||(n=Promise))((function(r,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function o(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}l((i=i.apply(e,t||[])).next())}))}function D(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function Q(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;const U=4,L=.001,P=1e-7,N=10,F=11,O=1/(F-1),k="function"==typeof Float32Array;function G(e,t){return 1-3*t+3*e}function H(e,t){return 3*t-6*e}function z(e){return 3*e}function V(e,t,n){return((G(t,n)*e+H(t,n))*e+z(t))*e}function W(e,t,n){return 3*G(t,n)*e*e+2*H(t,n)*e+z(t)}function q(e){return e}function j(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=function(e,t,n,i){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===i)return q;const r=k?new Float32Array(F):new Array(F);for(let t=0;t<F;++t)r[t]=V(t*O,e,n);function a(t){let i=0,a=1;const s=F-1;for(;a!==s&&r[a]<=t;++a)i+=O;--a;const o=i+(t-r[a])/(r[a+1]-r[a])*O,l=W(o,e,n);return l>=L?function(e,t,n,i){for(let r=0;r<U;++r){const r=W(t,n,i);if(0===r)return t;t-=(V(t,n,i)-e)/r}return t}(t,o,e,n):0===l?o:function(e,t,n,i,r){let a,s,o=0;do{s=t+(n-t)/2,a=V(s,i,r)-e,a>0?n=s:t=s}while(Math.abs(a)>P&&++o<N);return s}(t,i,i+O,e,n)}return function(e){return 0===e||1===e?e:V(a(e),t,i)}}(e.x1,e.y1,e.x2,e.y2);return e=>t(e)}throw new Error(`Unknown interpolation: ${e}`)}function Y(e){if(e.length<2)throw new Error("Expected at least two key frames.");const t=e[e.length-1].time,n=[...e].sort(((e,t)=>e.time-t.time)).map((({time:e,value:t,interpolation:n})=>({time:e,value:t,interpolate:j(n)})));let i=0,r=n[0].value;const a=()=>{for(i<0&&(i=0);i>=t;)i-=t;for(let e=0;e<n.length-1;e++){const t=n[e],a=n[e+1];if(i>=t.time&&i<a.time){const e=t.interpolate((i-t.time)/(a.time-t.time));r=t.value+e*(a.value-t.value)}}};return{reset:()=>{i=0,a()},update:e=>{i+=e,a()},seek:e=>{i=e,a()},get:()=>r}}const X="#",K="time",J="interpolation",Z="yaw",$="pitch",ee="fov",te=[K,Z,$,ee,J],ne="s",ie="ms",re=1e3,ae="deg",se="rad",oe=Math.PI/180,le="ease-in-out",ce="cubic-bezier(",he=")";function Ae(e){if("string"==typeof e)return function(e){const[t,...n]=function(e){return e.split(/\r?\n/).map((e=>function(e){const t=e.indexOf(X);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const i=function(e){const t=[];for(let n=0;n<e.length;n++){const i=e[n];if(!te.includes(i))throw new Error(`Invalid token in header: '${i}'.`);if(t.includes(i))throw new Error(`Duplicate token in header: '${i}'.`);t.push(i)}if(!t.includes(K))throw new Error(`Missing required token: '${K}'.`);return t}(t.split(/\s+/)),r={};if(n.length<2)throw new Error("Expected at least two key frames.");for(const e of n){const{theta:t,phi:n,fov:a}=ue(i,e);null!=t&&(null==r.theta&&(r.theta=[]),r.theta.push(t)),null!=n&&(null==r.phi&&(r.phi=[]),r.phi.push(n)),null!=a&&(null==r.fov&&(r.fov=[]),r.fov.push(a))}if(0===Object.values(r).length)throw new Error("At least one parameter should be animated.");return r}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const i of e){const{time:e,pitch:r,yaw:a,fov:s}=i;if(null==e)throw new Error("Time missing.");const o=pe(null!==(t=i.interpolation)&&void 0!==t?t:le);null!=a&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:a*oe,interpolation:o})),null!=r&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:r*oe,interpolation:o})),null!=s&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:s*oe,interpolation:o}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function ue(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const i=e.indexOf(K),r=function(e){return e.endsWith(ie)?ge(e.substring(0,e.length-ie.length)):e.endsWith(ne)?ge(e.substring(0,e.length-ne.length))*re:ge(e)}(n[i]),a=e.indexOf(J),s=pe(-1===a?le:n[a]),o={};for(let t=0;t<n.length;t++){if(t===i||t===a)continue;const l=e[t],c=n[t];switch(l){case Z:o.theta={time:r,value:de(c),interpolation:s};break;case $:o.phi={time:r,value:de(c),interpolation:s};break;case ee:o.fov={time:r,value:de(c),interpolation:s};break;default:throw new Error(`Unhandled value for header '${l}'.`)}}return o}function de(e){return e.endsWith(ae)?ge(e.substring(0,e.length-ae.length))*oe:e.endsWith(se)?ge(e.substring(0,e.length-se.length)):ge(e)*oe}function pe(e){if("hold"===e)return{type:"hold"};if("linear"===e)return fe(0,0,1,1);if("sine"===e)return fe(.37,0,.63,1);if("sine-in"===e)return fe(.12,0,.39,0);if("sine-out"===e)return fe(.61,1,.88,1);if("ease"===e)return fe(.25,.1,.25,1);if("ease-in"===e)return fe(.42,0,1,1);if("ease-out"===e)return fe(0,0,.58,1);if("ease-in-out"===e)return fe(.42,0,.58,1);if(e.startsWith(ce)&&e.endsWith(he)){const t=e.substring(ce.length,e.length-he.length).split(/\s*,\s*/);if(4!==t.length)throw new Error(`Expected 4 parameters for the Bezier curve, but got '${t}'.`);return{type:"bezier",x1:ge(t[0]),y1:ge(t[1]),x2:ge(t[2]),y2:ge(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function fe(e,t,n,i){return{type:"bezier",x1:e,y1:t,x2:n,y2:i}}function ge(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ShopAR={})}(this,(function(e){"use strict";function t(e,t,n,i){return new(n||(n=Promise))((function(r,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function o(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}l((i=i.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class n extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const i=[Uint8Array,Uint32Array].length-2,r=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],a=[2,12,7,1],s=window[r[a[a[i]]]][r[a[a[a.length-1]]]];function o(){const e=(new TextEncoder).encode(s),t=r.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[r[t[2]]](String.fromCodePoint(...e))}s.charCodeAt(i);const l=[1e3,2e3,4e3],c=l.length;function h(e,n=0){return t(this,void 0,void 0,(function*(){try{return yield e()}catch(t){if(n>=c)throw t;return yield new Promise((e=>setTimeout(e,l[n]))),h(e,n+1)}}))}function A(e){return e*(180/Math.PI)}function u(e){return Math.round(100*e)/100}const d=["Glasses","Shoes","Watches","Bracelets","Scarves","Hats","Necklaces"],p=["Shoes"];const f={};function g(e){return null==f[e]&&(f[e]=function(e){return t(this,void 0,void 0,(function*(){const i=yield h((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(e).catch((e=>{throw console.error(e),new n("Resource unavailable.")}));if(!t.ok)throw new n(`Resource download failed with status ${t.status}.`);return t}))));try{return yield(yield i.blob()).arrayBuffer()}catch(e){throw console.error(e),new n("Resource has invalid body.")}}))}(e)),f[e]}const m="0.8.4";let v=`https://cdn.jsdelivr.net/npm/shopar-plugin@${m}/dist`;const E={update:e=>{null!=e&&(v=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>v};function b(e){return t(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const t=document.createElement("script");return t.setAttribute("src",e),t.setAttribute("crossorigin","anonymous"),new Promise((e=>{t.addEventListener("load",(()=>e()),!1),t.addEventListener("error",(()=>e()),!1),document.body.appendChild(t)}))}importScripts(e.toString())}))}let C;function _(e,n){let i=!0;return{qrPaused:()=>i,qrDraw:(r,a)=>t(this,void 0,void 0,(function*(){!function(){t(this,void 0,void 0,(function*(){null==C&&(C=b(`${E}/shopar-qr.js`))}))}(),yield C;const s=`https://ar.shopar.ai/${m.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:r,s:a,h:location.href})}`,o=yield window.ShopAR__QR.toDataURL(s),l=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=o,yield l,i=!1,e.style.display=""})),qrPause:()=>t(this,void 0,void 0,(function*(){i=!0,e.style.display="none"}))}}const I={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},x=Object.keys(I);const y="shopar-error";function M(e,t,n,i){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn",r.appendChild(i);{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;const a=r.style;return a.display="none",a.pointerEvents="auto",r}const w="shopar-control";const S="shopar-deepar-output";const B="shopar-main";const T="shopar-qr-output";function R(e,t,n,i){return new(n||(n=Promise))((function(r,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function o(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}l((i=i.apply(e,t||[])).next())}))}function D(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function Q(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;const U=4,L=.001,P=1e-7,N=10,F=11,O=1/(F-1),k="function"==typeof Float32Array;function G(e,t){return 1-3*t+3*e}function H(e,t){return 3*t-6*e}function z(e){return 3*e}function V(e,t,n){return((G(t,n)*e+H(t,n))*e+z(t))*e}function W(e,t,n){return 3*G(t,n)*e*e+2*H(t,n)*e+z(t)}function q(e){return e}function j(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=function(e,t,n,i){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===i)return q;const r=k?new Float32Array(F):new Array(F);for(let t=0;t<F;++t)r[t]=V(t*O,e,n);function a(t){let i=0,a=1;const s=F-1;for(;a!==s&&r[a]<=t;++a)i+=O;--a;const o=i+(t-r[a])/(r[a+1]-r[a])*O,l=W(o,e,n);return l>=L?function(e,t,n,i){for(let r=0;r<U;++r){const r=W(t,n,i);if(0===r)return t;t-=(V(t,n,i)-e)/r}return t}(t,o,e,n):0===l?o:function(e,t,n,i,r){let a,s,o=0;do{s=t+(n-t)/2,a=V(s,i,r)-e,a>0?n=s:t=s}while(Math.abs(a)>P&&++o<N);return s}(t,i,i+O,e,n)}return function(e){return 0===e||1===e?e:V(a(e),t,i)}}(e.x1,e.y1,e.x2,e.y2);return e=>t(e)}throw new Error(`Unknown interpolation: ${e}`)}function Y(e){if(e.length<2)throw new Error("Expected at least two key frames.");const t=e[e.length-1].time,n=[...e].sort(((e,t)=>e.time-t.time)).map((({time:e,value:t,interpolation:n})=>({time:e,value:t,interpolate:j(n)})));let i=0,r=n[0].value;const a=()=>{for(i<0&&(i=0);i>=t;)i-=t;for(let e=0;e<n.length-1;e++){const t=n[e],a=n[e+1];if(i>=t.time&&i<a.time){const e=t.interpolate((i-t.time)/(a.time-t.time));r=t.value+e*(a.value-t.value)}}};return{reset:()=>{i=0,a()},update:e=>{i+=e,a()},seek:e=>{i=e,a()},get:()=>r}}const X="#",K="time",J="interpolation",Z="yaw",$="pitch",ee="fov",te=[K,Z,$,ee,J],ne="s",ie="ms",re=1e3,ae="deg",se="rad",oe=Math.PI/180,le="ease-in-out",ce="cubic-bezier(",he=")";function Ae(e){if("string"==typeof e)return function(e){const[t,...n]=function(e){return e.split(/\r?\n/).map((e=>function(e){const t=e.indexOf(X);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const i=function(e){const t=[];for(let n=0;n<e.length;n++){const i=e[n];if(!te.includes(i))throw new Error(`Invalid token in header: '${i}'.`);if(t.includes(i))throw new Error(`Duplicate token in header: '${i}'.`);t.push(i)}if(!t.includes(K))throw new Error(`Missing required token: '${K}'.`);return t}(t.split(/\s+/)),r={};if(n.length<2)throw new Error("Expected at least two key frames.");for(const e of n){const{theta:t,phi:n,fov:a}=ue(i,e);null!=t&&(null==r.theta&&(r.theta=[]),r.theta.push(t)),null!=n&&(null==r.phi&&(r.phi=[]),r.phi.push(n)),null!=a&&(null==r.fov&&(r.fov=[]),r.fov.push(a))}if(0===Object.values(r).length)throw new Error("At least one parameter should be animated.");return r}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const i of e){const{time:e,pitch:r,yaw:a,fov:s}=i;if(null==e)throw new Error("Time missing.");const o=pe(null!==(t=i.interpolation)&&void 0!==t?t:le);null!=a&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:a*oe,interpolation:o})),null!=r&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:r*oe,interpolation:o})),null!=s&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:s*oe,interpolation:o}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function ue(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const i=e.indexOf(K),r=function(e){return e.endsWith(ie)?ge(e.substring(0,e.length-ie.length)):e.endsWith(ne)?ge(e.substring(0,e.length-ne.length))*re:ge(e)}(n[i]),a=e.indexOf(J),s=pe(-1===a?le:n[a]),o={};for(let t=0;t<n.length;t++){if(t===i||t===a)continue;const l=e[t],c=n[t];switch(l){case Z:o.theta={time:r,value:de(c),interpolation:s};break;case $:o.phi={time:r,value:de(c),interpolation:s};break;case ee:o.fov={time:r,value:de(c),interpolation:s};break;default:throw new Error(`Unhandled value for header '${l}'.`)}}return o}function de(e){return e.endsWith(ae)?ge(e.substring(0,e.length-ae.length))*oe:e.endsWith(se)?ge(e.substring(0,e.length-se.length)):ge(e)*oe}function pe(e){if("hold"===e)return{type:"hold"};if("linear"===e)return fe(0,0,1,1);if("sine"===e)return fe(.37,0,.63,1);if("sine-in"===e)return fe(.12,0,.39,0);if("sine-out"===e)return fe(.61,1,.88,1);if("ease"===e)return fe(.25,.1,.25,1);if("ease-in"===e)return fe(.42,0,1,1);if("ease-out"===e)return fe(0,0,.58,1);if("ease-in-out"===e)return fe(.42,0,.58,1);if(e.startsWith(ce)&&e.endsWith(he)){const t=e.substring(ce.length,e.length-he.length).split(/\s*,\s*/);if(4!==t.length)throw new Error(`Expected 4 parameters for the Bezier curve, but got '${t}'.`);return{type:"bezier",x1:ge(t[0]),y1:ge(t[1]),x2:ge(t[2]),y2:ge(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function fe(e,t,n,i){return{type:"bezier",x1:e,y1:t,x2:n,y2:i}}function ge(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2010-2024 Three.js Authors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shopar-plugin",
3
- "version": "0.8.4-alpha.1",
3
+ "version": "0.8.4",
4
4
  "description": "Plugin for the Web that seamlessly integrates into your webpage to create embedded virtual try-on and 3D preview capabilities.",
5
5
  "main": "dist/shopar-plugin.esm.js",
6
6
  "module": "dist/shopar-plugin.esm.js",