@simplesmoothsafe/pptb-dependency-cleaner 1.0.1 → 1.0.2

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
@@ -6,21 +6,33 @@ Built by [Simple Smooth Safe](https://simplesmoothsafe.com).
6
6
 
7
7
  ## What it does
8
8
 
9
- - **Diagnose** — for each component of the solution, asks Dataverse for its required components (`RetrieveRequiredComponents`, 4 in parallel, with progress, cancel and a per-session cache), finds the managed solution that owns each one, and groups the result by the component you can act on. A component that is itself owned by a managed solution (a Field Service column pulled in by "add all assets") counts too.
9
+ - **Diagnose** — for each component of the solution, asks Dataverse for its required components (`RetrieveRequiredComponents`, 4 in parallel, with progress, cancel and a per-session cache), finds the managed solution that owns each one (see *How ownership is decided*), and groups the result by the component you can act on. A component that is itself owned by a managed solution (a Field Service column pulled in by "add all assets") counts too.
10
10
  - **Filter** — publisher prefixes or solution names, default `msdyn, msdynce, mspp`. Editable, so it works for any ISV.
11
11
  - **Target awareness** — with a secondary connection (the target environment), solutions already there are marked "present in target" and hidden by default; any managed solution missing in the target is a blocker. Without one, everything matching the filter is a blocker.
12
12
  - **Fix** — per finding, pick a fix:
13
13
  - *Convert table to shell*: a table added with all assets is removed and added back with `DoNotIncludeSubcomponents`. Every subcomponent that would leave is listed and can be ticked back in or out. Ticked by default: columns with your publisher prefix, the forms/views you edit, and every form, view and chart not owned by a managed solution matching the filter (these are named by display name, so ownership decides, not the prefix). A table cannot be converted to a shell by one finding and removed by another: the preview refuses the conflict until you pick one.
14
14
  - *Remove from solution* for a column, form or view included directly.
15
- - *Edit form*: remove the cells/controls bound to the msdyn columns (never the primary name or a required column, which are reported instead), drop empty sections.
15
+ - *Edit form*: remove the cells/controls bound to the msdyn columns, hidden fields (`<hiddencontrols>`) bound to them, and subgrids / quick views on msdyn tables (quick views are read from the entity-escaped `<QuickForms>` text real formxml uses); never the primary name or a required column, which are reported instead; drop empty sections.
16
16
  - *Edit view*: strip the msdyn attributes, conditions, orders and link-entities from fetchxml and the matching cells from layoutxml.
17
17
  - Relationships, sitemap, apps, ribbon, charts, processes, web resources and plugin steps are report only, with a link to the solution in the maker portal.
18
18
  - **Preview → backup → confirm** — the preview lists every operation with a before/after XML diff. Confirm stays disabled until the backup (`dependency-cleaner-backup-<solution>-<timestamp>.json`: original form/view XML and the full solution membership) is saved. Then: membership changes → form/view updates → one `PublishXml` for the touched tables → the diagnosis runs again and shows fixed / still present.
19
19
  - **Restore** — load a backup, preview, apply: original XML written back, removed components re-added, tables put back to all assets, then published. A backup only restores into the environment it was taken in (its url is recorded in the file).
20
20
  - **Offline** — open an exported solution zip and read `solution.xml` `<MissingDependencies>` (the list the import checks), grouped and filtered the same way. No connection needed.
21
+ - **Name lookups that fail** (metadata, form or view names) are shown as a warning above the findings, and every finding that involves such a component is report only: an edit keyed on an unresolved name would change nothing. Reads by id run 4 at a time; a throttled read (HTTP 429) is retried once after its `Retry-After`.
21
22
  - **Export** — findings as JSON or CSV (cells a spreadsheet would read as a formula are prefixed with `'`).
22
23
 
23
- Safety: managed solutions are never offered and writes are refused if the solution turns out to be managed when re-checked right before writing; a Production-looking connection needs an explicit tick. Changing the connection clears the diagnosis, the preview and the backup tick; Confirm and Restore re-read the current connection and refuse when it is not the one the plan was made on. After a new diagnosis, a picked fix the finding no longer offers is dropped.
24
+ ## How ownership is decided
25
+
26
+ A component belongs to the solution that **created** it, not to every managed solution that has a solution component row for it. In a D365 dev environment every msdyn app that extends account or contact (Sales, Field Service…) has a row for the table and often for its main form; those tables and forms are still System's. First match wins:
27
+
28
+ 1. Dataverse names the base (creating) solution in a dependency row (`requiredcomponentbasesolutionid`), and it is managed: that solution.
29
+ 2. Platform component: table `IsCustomEntity = false`, column `IsCustomAttribute = false`, or, for forms, views and other types, the System solution contains it. Owner System, never in the filter, always present in the target.
30
+ 3. Exactly one other managed solution contains it: that one.
31
+ 4. Several: the one whose publisher prefix is the component's schema-name prefix (`msdyn_x` → `msdyn`); else the first when all match the filter; else the first outside the filter. Ambiguous ownership is never read as msdyn-owned, so nothing is removed or dropped on a guess.
32
+
33
+ A dependency is present in the target when any managed solution that contains the component is installed there.
34
+
35
+ Safety: managed solutions are never offered and writes are refused if the solution turns out to be managed when re-checked right before writing; a Production-looking connection needs an explicit tick. Changing the connection clears the diagnosis, the preview and the backup tick; Confirm and Restore re-read the current connection and refuse when it is not the one the plan was made on. After a new diagnosis, a picked fix the finding no longer offers is dropped. Confirm runs once, however often it is clicked, and the re-diagnosis after a fix always covers the solution that was fixed, whatever the picker shows.
24
36
 
25
37
  ## Install
26
38
 
@@ -49,7 +61,7 @@ Then in ToolBox: Debug → *Load Local Tool* → select the `tools/dependency-cl
49
61
  - `RetrieveRequiredComponents` is one call per component: a large solution means hundreds of calls. They run 4 at a time, can be cancelled, and are cached for the session. Its response shape through the host is also **UNVERIFIED**; the tool accepts `EntityCollection` as an array or as `{ Entities }`.
50
62
  - Forms with msdyn PCF controls, libraries or event handlers get warnings, not edits. A view whose only filter or sort used msdyn columns gets a warning.
51
63
  - Converting a table to a shell in a solution other developers use removes subcomponents they may rely on: read the list in the preview.
52
- - The owning solution of a required component comes from its solution membership; when several managed solutions contain it, one matching the filter is shown.
64
+ - Ownership (above) relies on the base solution Dataverse reports, table / column metadata and System membership. A custom form or view contained by several managed solutions of different publishers is treated as not msdyn-owned.
53
65
 
54
66
  ## Privacy
55
67
 
@@ -0,0 +1,16 @@
1
+ var Or=Object.defineProperty;var $r=(Y,ze,W)=>ze in Y?Or(Y,ze,{enumerable:!0,configurable:!0,writable:!0,value:W}):Y[ze]=W;var wt=(Y,ze,W)=>$r(Y,typeof ze!="symbol"?ze+"":ze,W);(function(){"use strict";const Y=t=>{const a=document.querySelector(t);if(!a)throw new Error(`missing ${t}`);return a};function ze(t,...a){for(const e of a)e!=null&&e!==!1&&t.append(e)}function W(t,a={},...e){const d=document.createElement(t);for(const[i,r]of Object.entries(a))r===void 0||r===!1||(i==="class"?d.className=String(r):r===!0?d.setAttribute(i,""):d.setAttribute(i,r));for(const i of e)i!=null&&i!==!1&&d.append(typeof i=="string"?document.createTextNode(i):i);return d}const me=(t,a="")=>W("span",{class:`badge${a?` badge-${a}`:""}`},t),Be=(t,a)=>W("div",{class:"empty-state"},W("strong",{},t),a);function kn(t){const a=Y("#dlg");Y("#dlg-title").textContent=t.title;const e=Y("#dlg-target");e.replaceChildren(),t.target&&e.append(t.target),Y("#dlg-body").replaceChildren(t.body);const d=Y("#dlg-ok");return d.textContent=t.okLabel??"",d.className=`btn ${t.danger?"btn-danger":"btn-primary"}`,d.style.flex="none",d.hidden=!t.okLabel,new Promise(i=>{let r=!1;const s=o=>{r||(r=!0,d.onclick=null,Y("#dlg-cancel").onclick=null,a.onclose=null,a.open?(a.addEventListener("close",()=>i(o),{once:!0}),a.close()):i(o))};d.onclick=()=>s(!0),Y("#dlg-cancel").onclick=()=>s(!1),a.onclose=()=>s(!1),a.showModal()})}function xn(t){document.querySelectorAll(".tab").forEach(a=>a.addEventListener("click",()=>{const e=a.dataset.tab;document.querySelectorAll(".tab").forEach(d=>d.classList.toggle("is-active",d===a)),document.querySelectorAll(".panel[id^='tab-']").forEach(d=>d.hidden=d.id!==`tab-${e}`)}))}const ne={Entity:1,Attribute:2,Relationship:3,OptionSet:9,EntityRelationship:10,View:26,Workflow:29,Chart:59,Form:60,WebResource:61,SiteMap:62,AppModule:80,PluginStep:92},Sn={1:"Table",2:"Column",3:"Relationship",9:"Choice",10:"Relationship",14:"Key",20:"Security role",24:"Form",26:"View",29:"Process",31:"Report",36:"Email template",48:"Ribbon command",50:"Ribbon",55:"Ribbon diff",59:"Chart",60:"Form",61:"Web resource",62:"Site map",63:"Connection role",65:"Hierarchy rule",66:"Custom control",70:"Field security profile",80:"Model-driven app",90:"Plugin type",91:"Plugin assembly",92:"Plugin step",300:"Canvas app",371:"Connector",372:"Connection reference",380:"Environment variable"},_e=t=>Sn[t]??`Type ${t}`,Cn=["msdyn","msdynce","mspp"],ot=t=>t==null||t===""?null:String(t),ye=t=>String(t??"").toLowerCase(),Ot=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function st(t,a="id"){if(!Ot.test(t))throw new Error(`${a} is not a guid: ${t}`);return t.toLowerCase()}function En(t){const a=t.match(/\/api\/data\/v\d+(?:\.\d+)*\/(.*)$/i);return a?a[1]:t}const $t=500;async function bt(t,a,e="primary"){const d=[],i=new Set;let r=a;for(let s=0;r&&s<$t;s++){const o=await t.queryData(r,e);d.push(...o.value??[]);const u=o["@odata.nextLink"];if(r=typeof u=="string"&&u?En(u):null,r&&i.has(r))throw new Error(`paging loop at ${r}`);r&&i.add(r)}if(r)throw new Error(`more than ${$t} pages for ${a.split("?")[0]}`);return d}const Tt=40,An=4,In=1500,Nn=3e4;function zn(t){let a=0;const e=[];return async d=>{a>=t?await new Promise(i=>e.push(i)):a++;try{return await d()}finally{const i=e.shift();i?i():a--}}}const Rn=zn(An);function On(t){var s,o,u,v,_;const a=t??{},e=String(a.message??t??"");if(Number(a.status??a.statusCode??((s=a.response)==null?void 0:s.status)??NaN)!==429&&!/\b429\b|too many requests/i.test(e))return null;const i=a.retryAfter??((o=a.headers)==null?void 0:o["retry-after"])??((v=(u=a.response)==null?void 0:u.headers)==null?void 0:v["retry-after"])??((_=/retry-after\W+(\d+(?:\.\d+)?)/i.exec(e))==null?void 0:_[1]),r=Number(i);return Number.isFinite(r)&&r>=0?Math.min(r*1e3,Nn):In}async function $n(t){try{return await t()}catch(a){const e=On(a);if(e===null)throw a;return await new Promise(d=>setTimeout(d,e)),t()}}async function at(t,a,e,d,i="primary"){const r=[...new Set(a.map(u=>u.toLowerCase()))].filter(u=>Ot.test(u)),s=[];for(let u=0;u<r.length;u+=Tt)s.push(r.slice(u,u+Tt));return(await Promise.all(s.map(u=>Rn(()=>$n(()=>bt(t,d(u.map(v=>`${e} eq ${v}`).join(" or ")),i)))))).flat()}async function Tn(t,a,e,d=()=>!1){let i=0;const r=async()=>{for(;i<t.length&&!d();){const s=t[i++];await e(s)}};await Promise.all(Array.from({length:Math.min(a,t.length)},r))}async function vt(t,a="primary"){const[e,d]=await Promise.all([t.getSolutions(["solutionid","uniquename","friendlyname","version","ismanaged","_publisherid_value"],a),bt(t,"publishers?$select=publisherid,uniquename,customizationprefix",a).catch(()=>[])]),i=new Map(d.map(r=>[ye(r.publisherid),String(r.customizationprefix??"").toLowerCase()]));return e.value.map(r=>{const s=r._publisherid_value?ye(r._publisherid_value):null;return{id:ye(r.solutionid),uniqueName:String(r.uniquename??""),friendlyName:ot(r.friendlyname)??String(r.uniquename??""),version:String(r.version??""),isManaged:!!r.ismanaged,publisherId:s,prefix:s?i.get(s)??"":""}}).sort((r,s)=>r.friendlyName.localeCompare(s.friendlyName))}async function Bt(t,a){const d=(await t.queryData(`solutions?$select=solutionid,uniquename,ismanaged&$filter=solutionid eq ${st(a,"solution id")}`)).value[0];return d?{isManaged:!!d.ismanaged,uniqueName:String(d.uniquename??"")}:null}async function jt(t,a){return(await bt(t,`solutioncomponents?$select=solutioncomponentid,objectid,componenttype,rootcomponentbehavior,_rootsolutioncomponentid_value&$filter=_solutionid_value eq ${st(a,"solution id")}`)).map(d=>({rowId:ye(d.solutioncomponentid),objectId:ye(d.objectid),type:Number(d.componenttype??0),behavior:d.rootcomponentbehavior==null?null:Number(d.rootcomponentbehavior),rootRowId:d._rootsolutioncomponentid_value?ye(d._rootsolutioncomponentid_value):null}))}function Bn(t){const a=t;if(!a)return[];const e=a.EntityCollection;if(Array.isArray(e))return e;if(e&&typeof e=="object"){const d=e.Entities??e.value;if(Array.isArray(d))return d}return Array.isArray(a.value)?a.value:[]}const We=(t,a)=>t[a]??t[`_${a}_value`];async function jn(t,a,e){const d=st(a,"component id");if(!Number.isInteger(e))throw new Error(`bad component type ${e}`);const i=await t.queryData(`RetrieveRequiredComponents(ObjectId=${d},ComponentType=${e})`);return Bn(i).map(r=>({requiredId:ye(We(r,"requiredcomponentobjectid")),requiredType:Number(We(r,"requiredcomponenttype")??0),requiredParentId:We(r,"requiredcomponentparentid")?ye(We(r,"requiredcomponentparentid")):null,requiredBaseSolutionId:We(r,"requiredcomponentbasesolutionid")?ye(We(r,"requiredcomponentbasesolutionid")):null}))}async function Dn(t,a){const e=await at(t,a,"objectid",i=>`solutioncomponents?$select=objectid,componenttype,_solutionid_value&$filter=${i}`),d=new Map;for(const i of e){const r=ye(i.objectid),s=d.get(r)??[],o=ye(i._solutionid_value);o&&!s.includes(o)&&s.push(o),d.set(r,s)}return d}const Dt=t=>typeof t=="boolean"?t:null;class Lt{constructor(){wt(this,"entities",null);wt(this,"attributes",new Map);wt(this,"names",new Map)}async entitiesById(a){if(this.entities)return this.entities;const e=await a.getAllEntitiesMetadata(["LogicalName","MetadataId","PrimaryNameAttribute","IsCustomEntity"]);return this.entities=new Map(e.value.map(d=>[ye(d.MetadataId),{id:ye(d.MetadataId),logicalName:String(d.LogicalName??""),primaryName:ot(d.PrimaryNameAttribute),isCustom:Dt(d.IsCustomEntity)}])),this.entities}async entityByName(a,e){const d=await this.entitiesById(a);for(const i of d.values())if(i.logicalName===e)return i}async attributesOf(a,e){const d=this.attributes.get(e);if(d)return d;const r=(await a.getEntityRelatedMetadata(e,"Attributes",["LogicalName","MetadataId","RequiredLevel","IsCustomAttribute"])).value.map(s=>{var o;return{id:ye(s.MetadataId),logicalName:String(s.LogicalName??""),requiredLevel:String(((o=s.RequiredLevel)==null?void 0:o.Value)??s.RequiredLevel??"None"),isCustom:Dt(s.IsCustomAttribute)}});return this.attributes.set(e,r),r}async protectedColumns(a,e){const d=await this.entityByName(a,e),i=await this.attributesOf(a,e).catch(()=>[]),r=new Set;d!=null&&d.primaryName&&r.add(d.primaryName);for(const s of i)(s.requiredLevel==="ApplicationRequired"||s.requiredLevel==="SystemRequired")&&r.add(s.logicalName);return[...r]}}const Ft={[ne.View]:["savedqueries","savedqueryid","name","returnedtypecode"],[ne.Form]:["systemforms","formid","name","objecttypecode"],[ne.Chart]:["savedqueryvisualizations","savedqueryvisualizationid","name","primaryentitytypecode"],[ne.WebResource]:["webresourceset","webresourceid","name"],[ne.Workflow]:["workflows","workflowid","name","primaryentity"],[ne.SiteMap]:["sitemaps","sitemapid","sitemapname"],[ne.AppModule]:["appmodules","appmoduleid","name"],[ne.PluginStep]:["sdkmessageprocessingsteps","sdkmessageprocessingstepid","name"],20:["roles","roleid","name"],300:["canvasapps","canvasappid","name"],372:["connectionreferences","connectionreferenceid","connectionreferencelogicalname"],380:["environmentvariabledefinitions","environmentvariabledefinitionid","schemaname"]};async function Ln(t,a,e,d){var f;const i=(m,l)=>`${m}:${l}`,r=new Map,s=e.filter(m=>{const l=a.names.get(i(m.type,m.id));return l&&r.set(i(m.type,m.id),l),!l});if(!s.length)return r;const o=m=>{r.set(i(m.type,m.id),m),a.names.set(i(m.type,m.id),m)},u=m=>(m==null?void 0:m.message)??String(m),v=(m,l)=>{for(const h of m)d==null||d.set(i(h.type,h.id),u(l))},_=await a.entitiesById(t).catch(m=>(v(s.filter(l=>l.type===ne.Entity||l.type===ne.Attribute),m),new Map));for(const m of s.filter(l=>l.type===ne.Entity)){const l=_.get(m.id);l&&o({type:m.type,id:m.id,name:l.logicalName,table:l.logicalName})}const w=new Map;for(const m of s.filter(l=>l.type===ne.Attribute)){const l=m.parentId??"";w.set(l,[...w.get(l)??[],m])}for(const[m,l]of w){const h=(f=_.get(m))==null?void 0:f.logicalName;if(!h)continue;const p=await a.attributesOf(t,h).catch(g=>(v(l,g),[]));for(const g of l){const k=p.find(y=>y.id===g.id);k&&o({type:g.type,id:g.id,name:k.logicalName,table:h})}}const C=new Map;for(const m of s)Ft[m.type]&&C.set(m.type,[...C.get(m.type)??[],m.id]);await Promise.all([...C].map(async([m,l])=>{const[h,p,g,k]=Ft[m],y=await at(t,l,p,x=>`${h}?$select=${[p,g,k].filter(Boolean).join(",")}&$filter=${x}`).catch(x=>(v(l.map(z=>({type:m,id:z})),x),[]));for(const x of y)o({type:m,id:ye(x[p]),name:ot(x[g])??ye(x[p]),table:k?ot(x[k])??void 0:void 0})}));for(const m of s.filter(l=>l.type===ne.EntityRelationship||l.type===ne.Relationship))try{const l=await t.queryData(`RelationshipDefinitions(${st(m.id)})?$select=SchemaName`);l!=null&&l.SchemaName&&o({type:m.type,id:m.id,name:String(l.SchemaName)})}catch(l){v([m],l)}for(const m of s)r.has(i(m.type,m.id))||r.set(i(m.type,m.id),{type:m.type,id:m.id,name:m.id});return r}async function Pt(t,a){return(await at(t,a,"formid",d=>`systemforms?$select=formid,name,objecttypecode,formxml&$filter=${d}`)).map(d=>({id:ye(d.formid),name:String(d.name??""),table:String(d.objecttypecode??""),formxml:String(d.formxml??"")}))}async function qt(t,a){return(await at(t,a,"savedqueryid",d=>`savedqueries?$select=savedqueryid,name,returnedtypecode,fetchxml,layoutxml&$filter=${d}`)).map(d=>({id:ye(d.savedqueryid),name:String(d.name??""),table:String(d.returnedtypecode??""),fetchxml:String(d.fetchxml??""),layoutxml:String(d.layoutxml??"")}))}async function Fn(t){var a;try{const e=await t.execute({operationName:"RetrieveCurrentOrganization",operationType:"function",parameters:{AccessType:"Microsoft.Dynamics.CRM.EndpointAccessType'Default'"}}),d=(a=e==null?void 0:e.Detail)==null?void 0:a.EnvironmentId;return typeof d=="string"&&d?d:null}catch{return null}}const le=t=>(t??"").trim().toLowerCase();function _t(t,a){const e=new DOMParser().parseFromString(t,"application/xml");if(e.getElementsByTagName("parsererror").length)throw new Error(`${a}: invalid XML`);return e}function kt(t,a){const e=/^?\s*<\?xml[^?]*\?>\s*/.exec(a),d=new XMLSerializer().serializeToString(t).replace(/^<\?xml[^?]*\?>\s*/,"");return(e?e[0]:"")+d}const he=(t,a)=>Array.from(t.getElementsByTagName(a)),Fe=(t,a)=>Array.from(t.children).filter(e=>!a||e.localName===a);function xe(t){var e,d;const a=t.previousSibling;a&&a.nodeType===3&&!(a.nodeValue??"").trim()&&((e=a.parentNode)==null||e.removeChild(a)),(d=t.parentNode)==null||d.removeChild(t)}function Ze(t){if(t.children.length===0&&!(t.textContent??"").trim())for(;t.firstChild;)t.removeChild(t.firstChild)}const lt=(t,a)=>{for(let e=t.parentElement;e;e=e.parentElement)if(e.localName===a)return e;return null},xt=t=>{var e;return t&&(((e=t.getElementsByTagName("label")[0])==null?void 0:e.getAttribute("description"))||t.getAttribute("name")||t.getAttribute("id"))||""},Pn=t=>new Set(t.map(a=>{var e;return(e=/^([a-z0-9]+_)/.exec(a))==null?void 0:e[1]}).filter(a=>!!a));function qn(t){const a=he(t,"QuickFormId").map(e=>le(e.getAttribute("entityname")));for(const e of he(t,"QuickForms")){if(e.children.length)continue;const d=(e.textContent??"").trim();if(!d.startsWith("<"))continue;const i=new DOMParser().parseFromString(d,"application/xml");if(i.getElementsByTagName("parsererror").length){for(const r of d.matchAll(/entityname\s*=\s*["']([^"']+)["']/gi))a.push(le(r[1]));continue}a.push(...he(i,"QuickFormId").map(r=>le(r.getAttribute("entityname"))))}return a.filter(Boolean)}function Un(t,a,e,d=[]){var k;const i=new Set(a.map(le)),r=new Set(e.map(le)),s=new Set(d.map(le)),o=[],u=[],v=[],_=y=>!o.includes(y)&&o.push(y),w=(y,x)=>!u.some(z=>z.name===y)&&u.push({name:y,reason:x}),C=_t(t,"formxml"),f=new Set,m=new Set,l=new Set,h=new Set;for(const y of he(C,"control")){if(!y.parentNode||!C.documentElement.contains(y))continue;const x=le(y.getAttribute("datafieldname"));let z=null;if(x&&i.has(x)){if(r.has(x)){w(x,"protected: primary name or ApplicationRequired column");continue}z=x}else if(s.size){const A=y.getElementsByTagName("parameters")[0];if(A){const B=le((k=A.getElementsByTagName("TargetEntityType")[0])==null?void 0:k.textContent),K=qn(A).find(E=>s.has(E));B&&s.has(B)?z=`subgrid ${y.getAttribute("id")??"?"} (${B})`:K&&(z=`quickview ${y.getAttribute("id")??"?"} (${K})`)}}if(!z)continue;const I=lt(y,"cell"),F=I&&lt(I,"row");for(const A of[y.getAttribute("id"),y.getAttribute("uniqueid")])A&&f.add(le(A));x&&z===x&&m.add(x),_(z),I?(xe(I),F&&l.add(F)):xe(y)}for(const y of he(C,"hiddencontrols").flatMap(x=>Fe(x,"data"))){const x=le(y.getAttribute("datafieldname"));if(!x||!i.has(x))continue;if(r.has(x)){w(x,"protected: primary name or ApplicationRequired column");continue}for(const I of[y.getAttribute("id"),y.getAttribute("uniqueid")])I&&f.add(le(I));m.add(x),_(x);const z=y.parentElement;xe(y),z&&Ze(z)}for(const y of l){const x=lt(y,"section");if(x&&h.add(x),Fe(y,"cell").length===0){const z=y.parentElement;xe(y),z&&Ze(z)}}const p=new Set;for(const y of h){const x=lt(y,"tab");if(x&&p.add(x),!he(y,"row").some(I=>Fe(I,"cell").some(F=>F.getElementsByTagName("control").length>0))){v.push(`Section "${xt(y)}"${x?` in tab "${xt(x)}"`:""} became empty and was removed.`);const I=y.parentElement;xe(y),I&&Ze(I)}}for(const y of p)he(y,"control").length===0&&v.push(`Tab "${xt(y)}" is now empty (kept; remove or hide it by hand).`);for(const y of he(C,"controlDescription")){const x=le(y.getAttribute("forControl"));if(x&&f.has(x)){const I=y.parentElement;xe(y),I&&Ze(I);continue}const z=he(y,"*").filter(I=>I.children.length===0).map(I=>le(I.textContent)).find(I=>m.has(I));z&&v.push(`Custom control (controlDescription for ${y.getAttribute("forControl")}) references removed column ${z}; review it by hand.`)}for(const y of he(C,"event")){const x=le(y.getAttribute("attribute"));if(x&&m.has(x)){const z=he(y,"Handler").map(I=>`${I.getAttribute("libraryName")}:${I.getAttribute("functionName")}`);v.push(`Event "${y.getAttribute("name")}" on removed column ${x} still has handlers${z.length?` (${z.join(", ")})`:""}; review the form events.`)}}const g=Pn([...m,...s]);if(o.length&&g.size){const y=new Set,x=[...he(C,"Library").map(z=>z.getAttribute("name")??""),...he(C,"Handler").map(z=>z.getAttribute("libraryName")??"")];for(const z of x){const I=le(z);!I||y.has(I)||(y.add(I),[...g].some(F=>I.startsWith(F)||I.includes("/"+F))&&v.push(`Form library "${z}" belongs to the same publisher as removed components; it may still depend on them.`))}}return{xml:o.length?kt(C,t):t,removed:o,kept:u,warnings:v}}function Mn(t,a,e,d){const i=new Set(e.map(le)),r=new Set(d.map(le)),s=[],o=[],u=new Set,v=new Set;let _=!1,w=t;if(t.trim()){const f=_t(t,"fetchxml"),m=he(f,"entity")[0],l=m?Fe(m,"order").length:0;for(const y of he(f,"link-entity")){if(!f.documentElement.contains(y))continue;const x=le(y.getAttribute("name")),z=le(y.getAttribute("alias"));if(r.has(x)){z&&u.add(z);for(const I of he(y,"link-entity"))I.getAttribute("alias")&&u.add(le(I.getAttribute("alias")));s.push(`link-entity ${x}${z?` (${z})`:""}`),xe(y),_=!0}else z&&v.add(z)}for(const y of he(f,"link-entity"))for(const x of["from","to"]){const z=le(y.getAttribute(x));z&&i.has(z)&&o.push(`link-entity ${y.getAttribute("name")} joins ${x}="${z}", a removed column; the view will break until this join is fixed.`)}for(const y of he(f,"attribute")){const x=le(y.getAttribute("name"));i.has(x)&&(s.push(`attribute ${x}`),xe(y),_=!0)}let h=0;for(const y of he(f,"order")){const x=le(y.getAttribute("attribute")),z=le(y.getAttribute("entityname"));(i.has(x)||z&&u.has(z))&&(s.push(`order ${z?z+".":""}${x}`),xe(y),h++,_=!0)}const p=new Set;let g=0;for(const y of he(f,"condition")){const x=le(y.getAttribute("attribute")),z=le(y.getAttribute("entityname"));if(i.has(x)||z&&u.has(z)){s.push(`condition ${z?z+".":""}${x} ${y.getAttribute("operator")??""}`.trim());const I=y.parentElement;xe(y),(I==null?void 0:I.localName)==="filter"&&p.add(I),g++,_=!0}}const k=[...p];for(;k.length;){const y=k.shift();if(!y.parentNode||Fe(y).some(z=>z.localName==="condition"||z.localName==="filter"))continue;const x=y.parentElement;xe(y),x&&(Ze(x),x.localName==="filter"&&k.push(x))}g&&o.push(`${g} filter condition(s) removed: the view now returns a different (usually larger) set of rows. Review the filter.`),h&&l>0&&m&&Fe(m,"order").length===0&&o.push("The view's only sort order was removed; it will fall back to the default order."),m&&_&&Fe(m,"attribute").length===0&&!m.getElementsByTagName("all-attributes").length&&o.push("The root entity has no attributes left in the view."),_&&(w=kt(f,t))}let C=a;if(a.trim()){const f=_t(a,"layoutxml");let m=!1;for(const l of he(f,"cell")){const h=le(l.getAttribute("name"));if(!h)continue;const p=h.indexOf("."),g=p>=0?h.slice(0,p):"",k=p>=0?h.slice(p+1):h;if(g?u.has(g)||v.has(g)&&i.has(k):i.has(k)){s.push(`cell ${h}`);const x=l.parentElement;xe(l),x&&Ze(x),m=!0}}for(const l of he(f,"grid")){const h=le(l.getAttribute("jump"));h&&i.has(h)&&o.push(`Layout jump column "${h}" was removed; set another primary column for the grid.`)}m&&(C=kt(f,a))}return{fetchxml:w,layoutxml:C,removed:s,warnings:o}}const Wn=t=>({type:t.type,id:t.objectId,name:t.name??t.objectId,table:t.table}),ct=(t,a)=>[...new Set(t.required.filter(e=>e.type===a).map(e=>e.name))];async function Zn(t,a,e,d){var p;const i=[],r=d.filter(g=>g.fix==="edit-form"),s=d.filter(g=>g.fix==="edit-view"),[o,u]=await Promise.all([r.length?Pt(t,r.map(g=>g.finding.dependent.id)):Promise.resolve([]),s.length?qt(t,s.map(g=>g.finding.dependent.id)):Promise.resolve([])]),v=[];for(const g of r){const k=o.find(x=>x.id===g.finding.dependent.id);if(!k){i.push({name:g.finding.dependent.name,reason:"form not found"});continue}const y=await a.protectedColumns(t,k.table);try{const x=Un(k.formxml,ct(g.finding,ne.Attribute),y,ct(g.finding,ne.Entity));x.removed.length?v.push({form:k,after:x.xml,removed:x.removed,kept:x.kept,warnings:x.warnings}):i.push({name:k.name,reason:`nothing to strip${x.kept.length?`: kept ${x.kept.map(z=>`${z.name} (${z.reason})`).join(", ")}`:""}`})}catch(x){i.push({name:k.name,reason:x.message})}}const _=[];for(const g of s){const k=u.find(y=>y.id===g.finding.dependent.id);if(!k){i.push({name:g.finding.dependent.name,reason:"view not found"});continue}try{const y=Mn(k.fetchxml,k.layoutxml,ct(g.finding,ne.Attribute),ct(g.finding,ne.Entity));y.removed.length?_.push({view:k,after:{fetchxml:y.fetchxml,layoutxml:y.layoutxml},removed:y.removed,warnings:y.warnings}):i.push({name:k.name,reason:"nothing to strip"})}catch(y){i.push({name:k.name,reason:y.message})}}const w=new Set([...v.map(g=>g.form.id),..._.map(g=>g.view.id)]),C=e.solution.prefix?`${e.solution.prefix}_`:null,f=[];for(const g of d.filter(k=>k.fix==="shell")){const k=(p=g.finding.fixes.find(I=>I.kind==="shell"))==null?void 0:p.root;if(!k||f.some(I=>I.root.id===k.id))continue;const y=e.components.find(I=>I.type===ne.Entity&&I.objectId===k.id),x=new Set(e.findings.filter(I=>I.dependent.selfOwned).map(I=>I.dependent.id)),z=e.components.filter(I=>y&&I.rootRowId===y.rowId&&I.rowId!==y.rowId).map(I=>{const F=(I.name??"").toLowerCase();if(x.has(I.objectId))return{component:I,keep:!1,why:"belongs to a managed solution in scope"};if(w.has(I.objectId))return{component:I,keep:!0,why:"edited in this plan"};if(C&&F.startsWith(C))return{component:I,keep:!0,why:`your prefix ${C}`};if(I.type===ne.Form||I.type===ne.View||I.type===ne.Chart){if(I.filteredOwner)return{component:I,keep:!1,why:`owned by ${I.filteredOwner}`};if(I.filteredOwner===null)return{component:I,keep:!0,why:"yours: not owned by a filtered managed solution"}}return{component:I,keep:!1,why:"not yours"}}).sort((I,F)=>Number(F.keep)-Number(I.keep)||I.component.type-F.component.type||(I.component.name??"").localeCompare(F.component.name??""));f.push({root:{...k,behavior:0},leaving:z})}const m=d.filter(g=>g.fix==="remove"&&g.finding.dependent.type===ne.Entity).map(g=>f.find(k=>k.root.id===g.finding.dependent.id)).filter(g=>!!g);if(m.length)throw new Error(`Conflicting fixes on table ${m.map(g=>g.root.name).join(", ")}: one finding converts it to a shell, another removes it from the solution. Pick one of the two and preview again.`);const l=new Set(f.map(g=>{var k;return(k=e.components.find(y=>y.type===ne.Entity&&y.objectId===g.root.id))==null?void 0:k.rowId})),h=[];for(const g of d.filter(k=>k.fix==="remove")){const k=e.components.find(y=>y.objectId===g.finding.dependent.id&&y.type===g.finding.dependent.type);if(k!=null&&k.rootRowId&&l.has(k.rootRowId)){i.push({name:g.finding.dependent.name,reason:"leaves with the shell conversion of its table"});continue}h.some(y=>y.id===g.finding.dependent.id)||h.push(g.finding.dependent)}for(const g of d.filter(k=>k.fix==="report"))i.push({name:g.finding.dependent.name,reason:"report only"});return{diagnosis:e,shells:f,removes:h,forms:v,views:_,skipped:i}}function Ut(t){const a=[];for(const i of t.shells){a.push({kind:"remove",component:i.root,reason:`convert ${i.root.name} to a shell`}),a.push({kind:"add",component:i.root,doNotIncludeSubcomponents:!0,reason:"re-add as shell (no subcomponents)"});for(const r of i.leaving.filter(s=>s.keep))a.push({kind:"add",component:Wn(r.component),doNotIncludeSubcomponents:!1,reason:`keep: ${r.why}`})}for(const i of t.removes)a.push({kind:"remove",component:i,reason:`remove ${_e(i.type).toLowerCase()}`});for(const i of t.forms)a.push({kind:"update-form",edit:i});for(const i of t.views)a.push({kind:"update-view",edit:i});const e=[...new Set([...t.forms.map(i=>i.form.table),...t.views.map(i=>i.view.table)].filter(Boolean))].sort();e.length&&a.push({kind:"publish",tables:e});const d=new Set;return a.filter(i=>{if(i.kind!=="remove"&&i.kind!=="add")return!0;const r=`${i.kind}:${i.component.type}:${i.component.id}:${i.kind==="add"?i.doNotIncludeSubcomponents:""}`;return d.has(r)?!1:(d.add(r),!0)})}function Hn(t){const a=e=>e.replace(/[<>&"']/g,d=>`&#${d.charCodeAt(0)};`);return`<importexportxml><entities>${t.map(e=>`<entity>${a(e)}</entity>`).join("")}</entities></importexportxml>`}const Gn=(t,a)=>({operationName:"RemoveSolutionComponent",operationType:"action",parameters:{ComponentId:t.id,ComponentType:t.type,SolutionUniqueName:a}}),Kn=(t,a,e)=>({operationName:"AddSolutionComponent",operationType:"action",parameters:{ComponentId:t.id,ComponentType:t.type,SolutionUniqueName:a,DoNotIncludeSubcomponents:e,AddRequiredComponents:!1}});async function Mt(t,a,e,d){const i=[];let r=!1,s=!1;for(let o=0;o<a.length;o++){const u=a[o];if(d==null||d(o,a.length),r&&!(u.kind==="publish"&&s)){i.push({op:u,ok:!1,skipped:!0,error:"not run: an earlier step failed"});continue}try{u.kind==="remove"?await t.execute(Gn(u.component,e)):u.kind==="add"?await t.execute(Kn(u.component,e,u.doNotIncludeSubcomponents)):u.kind==="update-form"?(await t.update("systemform",u.edit.form.id,{formxml:u.edit.after}),s=!0):u.kind==="update-view"?(await t.update("savedquery",u.edit.view.id,{fetchxml:u.edit.after.fetchxml,layoutxml:u.edit.after.layoutxml}),s=!0):u.kind==="publish"&&await t.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:Hn(u.tables)}}),i.push({op:u,ok:!0})}catch(v){r=!0,i.push({op:u,ok:!1,error:v.message??String(v)})}}return d==null||d(a.length,a.length),i}function St(t){switch(t.kind){case"remove":return`RemoveSolutionComponent ${_e(t.component.type)} ${t.component.name}`;case"add":return`AddSolutionComponent ${_e(t.component.type)} ${t.component.name}${t.doNotIncludeSubcomponents?" (DoNotIncludeSubcomponents)":""}`;case"update-form":return`Update form ${t.edit.form.name} (${t.edit.form.table}): formxml`;case"update-view":return`Update view ${t.edit.view.name} (${t.edit.view.table}): fetchxml + layoutxml`;case"publish":return`PublishXml ${t.tables.join(", ")}`}}const Wt=t=>t.replace(/>\s*</g,`>
2
+ <`).split(`
3
+ `);function Vn(t,a,e=2){const d=Wt(t),i=Wt(a);let r=0;for(;r<d.length&&r<i.length&&d[r]===i[r];)r++;let s=0;for(;s<d.length-r&&s<i.length-r&&d[d.length-1-s]===i[i.length-1-s];)s++;const o=d.slice(r,d.length-s),u=i.slice(r,i.length-s),v=[];if(o.length*u.length>4e6)v.push(...o.map(f=>({t:"-",s:f})),...u.map(f=>({t:"+",s:f})));else{const f=o.length,m=u.length,l=Array.from({length:f+1},()=>new Uint32Array(m+1));for(let g=f-1;g>=0;g--)for(let k=m-1;k>=0;k--)l[g][k]=o[g]===u[k]?l[g+1][k+1]+1:Math.max(l[g+1][k],l[g][k+1]);let h=0,p=0;for(;h<f||p<m;)h<f&&p<m&&o[h]===u[p]?(v.push({t:" ",s:o[h++]}),p++):p<m&&(h>=f||l[h][p+1]>=l[h+1][p])?v.push({t:"+",s:u[p++]}):v.push({t:"-",s:o[h++]})}const _=[...d.slice(0,r).map(f=>({t:" ",s:f})),...v,...d.slice(d.length-s).map(f=>({t:" ",s:f}))],w=_.map(()=>!1);_.forEach((f,m)=>{if(f.t!==" ")for(let l=-e;l<=e;l++)_[m+l]&&(w[m+l]=!0)});const C=[];return _.forEach((f,m)=>{w[m]?C.push(f):(C.length===0||C[C.length-1].t!=="…")&&C.push({t:"…",s:""})}),C}const Zt="sss-dependency-cleaner-backup";function Yn(t,a,e){const d=new Map(t.components.map(i=>[i.rowId,i]));return{kind:Zt,version:1,takenAt:new Date().toISOString(),environment:{name:t.environment.name,url:t.environment.url},solution:{id:t.solution.id,uniqueName:t.solution.uniqueName,friendlyName:t.solution.friendlyName},membership:t.components.map(i=>{var r;return{objectId:i.objectId,type:i.type,behavior:i.behavior,rootObjectId:i.rootRowId?((r=d.get(i.rootRowId))==null?void 0:r.objectId)??null:null,name:i.name??i.objectId}}),forms:a.forms.map(i=>i.form),views:a.views.map(i=>i.view),operations:e.map(St)}}function Xn(t,a=new Date){const e=a.toISOString().replace(/[:.]/g,"-").slice(0,19);return`dependency-cleaner-backup-${t.replace(/[^a-z0-9._-]+/gi,"_")}-${e}.json`}function Jn(t){var e;let a;try{a=JSON.parse(t)}catch(d){throw new Error(`not JSON: ${d.message}`)}if((a==null?void 0:a.kind)!==Zt)throw new Error("not a Dependency Cleaner backup");if(a.version!==1)throw new Error(`unsupported backup version ${String(a.version)}`);if(!((e=a.solution)!=null&&e.uniqueName)||!Array.isArray(a.membership)||!Array.isArray(a.forms)||!Array.isArray(a.views))throw new Error("backup is incomplete");return a}async function Qn(t,a,e,d){var l;const i=e.find(h=>h.uniqueName.toLowerCase()===a.solution.uniqueName.toLowerCase());if(!i)throw new Error(`solution ${a.solution.uniqueName} is not in this environment`);if(i.isManaged)throw new Error(`solution ${i.uniqueName} is managed: writes are refused`);const r=[],s=h=>(h??"").replace(/\/+$/,"").toLowerCase();if(!s((l=a.environment)==null?void 0:l.url))throw new Error("backup does not record its environment url");if(s(a.environment.url)!==s(d))throw new Error(`backup was taken in ${a.environment.name} (${a.environment.url}), not this environment (${d}): restore refused`);const o=await jt(t,i.id),u=(h,p)=>`${h}:${p}`,v=new Map(o.map(h=>[u(h.type,h.objectId),h])),_=[],w=new Set;for(const h of a.membership.filter(p=>!p.rootObjectId||p.rootObjectId===p.objectId)){const p=v.get(u(h.type,h.objectId)),g={type:h.type,id:h.objectId,name:h.name};p?h.type===ne.Entity&&h.behavior===0&&p.behavior!==0&&(_.push({kind:"remove",component:g,reason:"shell → back to all assets"}),_.push({kind:"add",component:g,doNotIncludeSubcomponents:!1,reason:"re-add with all subcomponents"}),w.add(h.objectId)):(_.push({kind:"add",component:g,doNotIncludeSubcomponents:h.behavior!==0,reason:"re-add removed component"}),h.type===ne.Entity&&h.behavior===0&&w.add(h.objectId))}for(const h of a.membership.filter(p=>p.rootObjectId&&p.rootObjectId!==p.objectId))v.has(u(h.type,h.objectId))||w.has(h.rootObjectId)||_.push({kind:"add",component:{type:h.type,id:h.objectId,name:h.name},doNotIncludeSubcomponents:!1,reason:"re-add removed subcomponent"});const[C,f]=await Promise.all([a.forms.length?Pt(t,a.forms.map(h=>h.id)):Promise.resolve([]),a.views.length?qt(t,a.views.map(h=>h.id)):Promise.resolve([])]),m=new Set;for(const h of a.forms){const p=C.find(g=>g.id===h.id);if(!p){r.push(`Form ${h.name} no longer exists; not restored.`);continue}p.formxml!==h.formxml&&(_.push({kind:"update-form",edit:{form:p,after:h.formxml,removed:[],kept:[],warnings:[]}}),m.add(p.table||h.table))}for(const h of a.views){const p=f.find(g=>g.id===h.id);if(!p){r.push(`View ${h.name} no longer exists; not restored.`);continue}p.fetchxml===h.fetchxml&&p.layoutxml===h.layoutxml||(_.push({kind:"update-view",edit:{view:p,after:{fetchxml:h.fetchxml,layoutxml:h.layoutxml},removed:[],warnings:[]}}),m.add(p.table||h.table))}return m.size&&_.push({kind:"publish",tables:[...m].filter(Boolean).sort()}),{solution:i,ops:_,notes:r}}function er(t){return[...new Set(t.split(/[\s,;]+/).map(a=>a.trim().toLowerCase()).filter(Boolean))]}function Pe(t,a,e){const d=e.toLowerCase();return t.some(i=>a?a.prefix.toLowerCase()===i||a.uniqueName.toLowerCase().startsWith(i):d.startsWith(`${i}_`))}const qe=t=>[...new Set(t.map(a=>a.name))].slice(0,4).join(", ")+(t.length>4?"…":"");function tr(t,a,e,d){var w,C;const i=(f,m)=>({cause:f,fixes:[{kind:"report",label:"Report only: open in maker portal",link:d,note:m}]}),r=t.root&&t.root.behavior===0?t.root:null,s=()=>r?{kind:"shell",label:`Convert table ${r.name} to a shell (remove + add without subcomponents)`,root:r}:null,o={kind:"remove",label:`Remove this ${_e(t.type).toLowerCase()} from the solution`},u=Pe(e,null,t.name),v=(f,...m)=>({cause:f,fixes:m.filter(l=>!!l)}),_=((C=(w=a.find(f=>f.id===t.id))==null?void 0:w.solution)==null?void 0:C.uniqueName)??"a managed solution";if(t.selfOwned&&t.type===ne.Entity)return v(`Table ${t.name} belongs to ${_}. Shipping it, even as a shell, needs that solution in the target.`,o,{kind:"report",label:"Report only: open in maker portal",link:d});if(t.selfOwned)return v(r?`${_e(t.type)} ${t.name} belongs to ${_} and came in with table ${r.name}, which is in the solution with all assets.`:`${_e(t.type)} ${t.name} belongs to ${_} and is included directly.`,s(),r?null:o);switch(t.type){case ne.Entity:return t.behavior===0?v(`Table added with all assets: its columns, forms and views come along, including ones that need ${qe(a)}.`,s()??{kind:"shell",label:`Convert table ${t.name} to a shell`,root:{...t,behavior:0}},o):v(`The table itself requires ${qe(a)}.`,o,{kind:"report",label:"Report only: open in maker portal",link:d});case ne.Attribute:return u?v(r?`Column ${t.name} comes with table ${r.name}, which is in the solution with all assets.`:`Column ${t.name} is included directly.`,s(),r?null:o):i(`Your column needs ${qe(a)} (for example a lookup to that table). This is a real dependency: the target needs the app, or the column has to be changed by hand.`);case ne.Relationship:case ne.EntityRelationship:return i(`Relationship to ${qe(a)}. This is a real dependency: the target needs the app, or the relationship has to be deleted by hand.`);case ne.Form:return v(`Form uses ${qe(a)} (a field, subgrid, quick view or library).`,{kind:"edit-form",label:"Edit form: remove those fields (backup first)"},s(),r?null:o);case ne.View:return v(`View uses ${qe(a)} (a column, condition or link-entity).`,{kind:"edit-view",label:"Edit view: strip those columns and link-entities (backup first)"},s(),r?null:o);default:return i(`${_e(t.type)} references ${qe(a)}. Not edited automatically in v1.`,"Sitemap, app, ribbon, chart, process, web resource and plugin step references are fixed by hand.")}}const nr=4,Ht=new Set(["default","active","basic"]),rr=new Set([ne.Entity,ne.Attribute,ne.OptionSet,ne.Relationship,ne.EntityRelationship,ne.WebResource]);class Gt extends Error{constructor(){super("Diagnosis cancelled")}}const Ae=(t,a)=>`${t}:${a}`;async function ir(t){var F;const a=t.cancelled??(()=>!1),e=await jt(t.api,t.solution.id),d=new Set(e.map(A=>A.objectId)),i=new Map(e.map(A=>[A.rowId,A])),r=[],s=new Map;let o=0;if((F=t.onProgress)==null||F.call(t,0,e.length),await Tn(e,nr,async A=>{var E;const B=Ae(A.type,A.objectId);let K=t.reqCache.get(B);if(!K)try{K=await jn(t.api,A.objectId,A.type),t.reqCache.set(B,K)}catch(T){r.push({component:B,error:T.message??String(T)}),K=[]}s.set(A,K.filter(T=>T.requiredId&&T.requiredId!==A.objectId)),(E=t.onProgress)==null||E.call(t,++o,e.length)},a),a())throw new Gt;const u=[...new Set([...s.values()].flat().map(A=>A.requiredId).concat(e.map(A=>A.objectId)))],v=u.length?await Dn(t.api,u):new Map,_=new Map(t.allSolutions.map(A=>[A.id,A])),w=A=>({uniqueName:A.uniqueName,friendlyName:A.friendlyName,prefix:A.prefix,isManaged:A.isManaged}),C=A=>(v.get(A)??[]).map(B=>_.get(B)).filter(B=>!!B&&B.isManaged&&B.id!==t.solution.id&&!Ht.has(B.uniqueName.toLowerCase())),f=A=>A.uniqueName.toLowerCase()==="system",m=t.allSolutions.find(f)??{id:"",uniqueName:"System",friendlyName:"System",version:"",isManaged:!0,publisherId:null,prefix:""},l=new Map;for(const A of s.values())for(const B of A)B.requiredBaseSolutionId&&!l.has(B.requiredId)&&l.set(B.requiredId,B.requiredBaseSolutionId);const h=e.map(A=>{const B=A.rootRowId?i.get(A.rootRowId):void 0;return{type:A.type,id:A.objectId,parentId:(B==null?void 0:B.type)===ne.Entity?B.objectId:null}});for(const A of s.values())for(const B of A)h.push({type:B.requiredType,id:B.requiredId,parentId:B.requiredParentId});const p=new Map,g=await Ln(t.api,t.meta,h,p),k=[];p.size&&k.push(`Name lookup failed for ${p.size} component(s) (${[...new Set(p.values())].slice(0,2).join("; ")}). Findings that involve them are report only: an edit keyed on an unresolved name would change nothing. Run Diagnose again.`);const y=(A,B)=>g.get(Ae(A,B))??{type:A,id:B,name:B},x=A=>{var B,K,E,T;return A.type===ne.Entity?((K=(B=t.meta.entities)==null?void 0:B.get(A.id))==null?void 0:K.isCustom)??null:A.type===ne.Attribute&&A.table?((T=(E=t.meta.attributes.get(A.table))==null?void 0:E.find(c=>c.id===A.id))==null?void 0:T.isCustom)??null:null},z=(A,B)=>{var R,O;const K=C(A.id),E=_.get(B??l.get(A.id)??""),T=x(A),c=(J=m)=>({owner:J,candidates:K,platform:!0});if(E!=null&&E.isManaged&&!Ht.has(E.uniqueName.toLowerCase()))return f(E)?c(E):{owner:E,candidates:K,platform:!1};if(T===!1)return c();const D=K.find(f);if(D&&T===null)return c(D);const Q=K.filter(J=>!f(J));if(Q.length<=1)return{owner:Q[0]??null,candidates:K,platform:!1};const q=rr.has(A.type)?(O=(R=/^([a-z0-9]+)_/i.exec(A.name))==null?void 0:R[1])==null?void 0:O.toLowerCase():void 0,re=q?Q.find(J=>J.prefix===q):void 0,M=Q.filter(J=>Pe(t.filter,J,A.name));return{owner:re??(M.length===Q.length?Q[0]:Q.find(J=>!Pe(t.filter,J,A.name))),candidates:K,platform:!1}};for(const A of e){const B=y(A.type,A.objectId);A.name=B.name,A.table=B.table;const K=z(B,null).owner;A.filteredOwner=K&&Pe(t.filter,K,B.name)?K.uniqueName:null}const I=[];for(const[A,B]of s){const K=[],E=new Set,T={requiredId:A.objectId,requiredType:A.type,requiredParentId:null,requiredBaseSolutionId:null},c=[T,...B];let D=!1;for(const R of c){const O=Ae(R.requiredType,R.requiredId);if(E.has(O))continue;E.add(O);const J=y(R.requiredType,R.requiredId),{owner:V,candidates:G,platform:fe}=z(J,R.requiredBaseSolutionId);if(!V&&d.has(R.requiredId)||R===T&&!V)continue;const we=!fe&&Pe(t.filter,V,J.name),oe=de=>{var ke;return!!((ke=t.targetSolutions)!=null&&ke.has(de.uniqueName.toLowerCase()))},ae=!!V&&(fe||oe(V)||G.some(oe)),ge=!!t.targetSolutions&&!!V&&!ae;!we&&!ge||(R===T&&(D=!0),K.push({...J,solution:V?w(V):null,solutions:G.map(de=>de.uniqueName),blocker:!ae}))}if(!K.length)continue;const Q=y(A.type,A.objectId),q=A.type===ne.Entity?A:A.rootRowId?i.get(A.rootRowId):void 0,re=q&&q.type===ne.Entity?{...y(q.type,q.objectId),behavior:q.behavior??0}:null,M=[...new Set([Ae(A.type,A.objectId),...K.map(R=>Ae(R.type,R.id))].map(R=>p.get(R)).filter(R=>!!R))],te=M.length?{cause:`Some names could not be read (${M.join("; ")}), so this cannot be fixed automatically. Run Diagnose again.`,fixes:[{kind:"report",label:"Report only: open in maker portal",link:t.link(Q),note:"Name lookup failed: not edited automatically."}]}:tr({...Q,behavior:A.behavior,root:re,selfOwned:D},K,t.filter,t.link(Q));I.push({key:Ae(A.type,A.objectId),dependent:{...Q,rootBehavior:(re==null?void 0:re.behavior)??null,rootTable:re==null?void 0:re.name,selfOwned:D},required:K.map(({blocker:R,...O})=>O),cause:te.cause,fixes:te.fixes,status:K.some(R=>R.blocker)?"blocker":"safe"})}return I.sort((A,B)=>(A.status===B.status?0:A.status==="blocker"?-1:1)||A.dependent.type-B.dependent.type||A.dependent.name.localeCompare(B.dependent.name)),{solution:t.solution,environment:t.environment,target:t.target,filter:t.filter,components:e,findings:I,errors:r,warnings:k,takenAt:new Date().toISOString()}}function Kt(t){let a=t==null?"":String(t);return/^[=+\-@\t\r]/.test(a)&&(a=`'${a}`),/[",\r\n]/.test(a)?`"${a.replace(/"/g,'""')}"`:a}function or(t){var e;const a=[["status","dependent type","dependent","table","cause","required type","required","required solution","fixes"].map(Kt).join(",")];for(const d of t.findings)for(const i of d.required)a.push([d.status,_e(d.dependent.type),d.dependent.name,d.dependent.table??d.dependent.rootTable??"",d.cause,_e(i.type),i.name,((e=i.solution)==null?void 0:e.uniqueName)??"",d.fixes.map(r=>r.kind).join(" | ")].map(Kt).join(","));return a.join(`
4
+ `)+`
5
+ `}function sr(t){return JSON.stringify({kind:"sss-dependency-cleaner-findings",version:1,takenAt:t.takenAt,environment:t.environment,target:t.target,solution:{uniqueName:t.solution.uniqueName,friendlyName:t.solution.friendlyName,version:t.solution.version},filter:t.filter,findings:t.findings,errors:t.errors,warnings:t.warnings},null,2)}const Vt=t=>t.replace(/[^a-z0-9._-]+/gi,"_").replace(/^_+|_+$/g,"")||"solution";var ut=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ar(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function dt(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Yt={exports:{}};/*!
6
+
7
+ JSZip v3.10.2 - A JavaScript class for generating and reading zip files
8
+ <http://stuartk.com/jszip>
9
+
10
+ (c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
11
+ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
12
+
13
+ JSZip uses the library pako released under the MIT license :
14
+ https://github.com/nodeca/pako/blob/main/LICENSE
15
+ */(function(t,a){(function(e){t.exports=e()})(function(){return function e(d,i,r){function s(v,_){if(!i[v]){if(!d[v]){var w=typeof dt=="function"&&dt;if(!_&&w)return w(v,!0);if(o)return o(v,!0);var C=new Error("Cannot find module '"+v+"'");throw C.code="MODULE_NOT_FOUND",C}var f=i[v]={exports:{}};d[v][0].call(f.exports,function(m){var l=d[v][1][m];return s(l||m)},f,f.exports,e,d,i,r)}return i[v].exports}for(var o=typeof dt=="function"&&dt,u=0;u<r.length;u++)s(r[u]);return s}({1:[function(e,d,i){var r=e("./utils"),s=e("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(u){for(var v,_,w,C,f,m,l,h=[],p=0,g=u.length,k=g,y=r.getTypeOf(u)!=="string";p<u.length;)k=g-p,w=y?(v=u[p++],_=p<g?u[p++]:0,p<g?u[p++]:0):(v=u.charCodeAt(p++),_=p<g?u.charCodeAt(p++):0,p<g?u.charCodeAt(p++):0),C=v>>2,f=(3&v)<<4|_>>4,m=1<k?(15&_)<<2|w>>6:64,l=2<k?63&w:64,h.push(o.charAt(C)+o.charAt(f)+o.charAt(m)+o.charAt(l));return h.join("")},i.decode=function(u){var v,_,w,C,f,m,l=0,h=0,p="data:";if(u.substr(0,p.length)===p)throw new Error("Invalid base64 input, it looks like a data url.");var g,k=3*(u=u.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(u.charAt(u.length-1)===o.charAt(64)&&k--,u.charAt(u.length-2)===o.charAt(64)&&k--,k%1!=0)throw new Error("Invalid base64 input, bad content length.");for(g=s.uint8array?new Uint8Array(0|k):new Array(0|k);l<u.length;)v=o.indexOf(u.charAt(l++))<<2|(C=o.indexOf(u.charAt(l++)))>>4,_=(15&C)<<4|(f=o.indexOf(u.charAt(l++)))>>2,w=(3&f)<<6|(m=o.indexOf(u.charAt(l++))),g[h++]=v,f!==64&&(g[h++]=_),m!==64&&(g[h++]=w);return g}},{"./support":30,"./utils":32}],2:[function(e,d,i){var r=e("./external"),s=e("./stream/DataWorker"),o=e("./stream/Crc32Probe"),u=e("./stream/DataLengthProbe");function v(_,w,C,f,m){this.compressedSize=_,this.uncompressedSize=w,this.crc32=C,this.compression=f,this.compressedContent=m}v.prototype={getContentWorker:function(){var _=new s(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new u("data_length")),w=this;return _.on("end",function(){if(this.streamInfo.data_length!==w.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),_},getCompressedWorker:function(){return new s(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},v.createWorkerFrom=function(_,w,C){return _.pipe(new o).pipe(new u("uncompressedSize")).pipe(w.compressWorker(C)).pipe(new u("compressedSize")).withStreamInfo("compression",w)},d.exports=v},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,d,i){var r=e("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},i.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,d,i){var r=e("./utils"),s=function(){for(var o,u=[],v=0;v<256;v++){o=v;for(var _=0;_<8;_++)o=1&o?3988292384^o>>>1:o>>>1;u[v]=o}return u}();d.exports=function(o,u){return o!==void 0&&o.length?r.getTypeOf(o)!=="string"?function(v,_,w,C){var f=s,m=C+w;v^=-1;for(var l=C;l<m;l++)v=v>>>8^f[255&(v^_[l])];return-1^v}(0|u,o,o.length,0):function(v,_,w,C){var f=s,m=C+w;v^=-1;for(var l=C;l<m;l++)v=v>>>8^f[255&(v^_.charCodeAt(l))];return-1^v}(0|u,o,o.length,0):0}},{"./utils":32}],5:[function(e,d,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(e,d,i){var r=null;r=typeof Promise<"u"?Promise:e("lie"),d.exports={Promise:r}},{lie:37}],7:[function(e,d,i){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=e("pako"),o=e("./utils"),u=e("./stream/GenericWorker"),v=r?"uint8array":"array";function _(w,C){u.call(this,"FlateWorker/"+w),this._pako=null,this._pakoAction=w,this._pakoOptions=C,this.meta={}}i.magic="\b\0",o.inherits(_,u),_.prototype.processChunk=function(w){this.meta=w.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(v,w.data),!1)},_.prototype.flush=function(){u.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},_.prototype.cleanUp=function(){u.prototype.cleanUp.call(this),this._pako=null},_.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var w=this;this._pako.onData=function(C){w.push({data:C,meta:w.meta})}},i.compressWorker=function(w){return new _("Deflate",w)},i.uncompressWorker=function(){return new _("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,d,i){function r(f,m){var l,h="";for(l=0;l<m;l++)h+=String.fromCharCode(255&f),f>>>=8;return h}function s(f,m,l,h,p,g){var k,y,x=f.file,z=f.compression,I=g!==v.utf8encode,F=o.transformTo("string",g(x.name)),A=o.transformTo("string",v.utf8encode(x.name)),B=x.comment,K=o.transformTo("string",g(B)),E=o.transformTo("string",v.utf8encode(B)),T=A.length!==x.name.length,c=E.length!==B.length,D="",Q="",q="",re=x.dir,M=x.date,te={crc32:0,compressedSize:0,uncompressedSize:0};m&&!l||(te.crc32=f.crc32,te.compressedSize=f.compressedSize,te.uncompressedSize=f.uncompressedSize);var R=0;m&&(R|=8),I||!T&&!c||(R|=2048);var O=0,J=0;re&&(O|=16),p==="UNIX"?(J=798,O|=function(G,fe){var we=G;return G||(we=fe?16893:33204),(65535&we)<<16}(x.unixPermissions,re)):(J=20,O|=function(G){return 63&(G||0)}(x.dosPermissions)),k=M.getUTCHours(),k<<=6,k|=M.getUTCMinutes(),k<<=5,k|=M.getUTCSeconds()/2,y=M.getUTCFullYear()-1980,y<<=4,y|=M.getUTCMonth()+1,y<<=5,y|=M.getUTCDate(),T&&(Q=r(1,1)+r(_(F),4)+A,D+="up"+r(Q.length,2)+Q),c&&(q=r(1,1)+r(_(K),4)+E,D+="uc"+r(q.length,2)+q);var V="";return V+=`
16
+ \0`,V+=r(R,2),V+=z.magic,V+=r(k,2),V+=r(y,2),V+=r(te.crc32,4),V+=r(te.compressedSize,4),V+=r(te.uncompressedSize,4),V+=r(F.length,2),V+=r(D.length,2),{fileRecord:w.LOCAL_FILE_HEADER+V+F+D,dirRecord:w.CENTRAL_FILE_HEADER+r(J,2)+V+r(K.length,2)+"\0\0\0\0"+r(O,4)+r(h,4)+F+D+K}}var o=e("../utils"),u=e("../stream/GenericWorker"),v=e("../utf8"),_=e("../crc32"),w=e("../signature");function C(f,m,l,h){u.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=l,this.encodeFileName=h,this.streamFiles=f,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(C,u),C.prototype.push=function(f){var m=f.meta.percent||0,l=this.entriesCount,h=this._sources.length;this.accumulate?this.contentBuffer.push(f):(this.bytesWritten+=f.data.length,u.prototype.push.call(this,{data:f.data,meta:{currentFile:this.currentFile,percent:l?(m+100*(l-h-1))/l:100}}))},C.prototype.openedSource=function(f){this.currentSourceOffset=this.bytesWritten,this.currentFile=f.file.name;var m=this.streamFiles&&!f.file.dir;if(m){var l=s(f,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:l.fileRecord,meta:{percent:0}})}else this.accumulate=!0},C.prototype.closedSource=function(f){this.accumulate=!1;var m=this.streamFiles&&!f.file.dir,l=s(f,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(l.dirRecord),m)this.push({data:function(h){return w.DATA_DESCRIPTOR+r(h.crc32,4)+r(h.compressedSize,4)+r(h.uncompressedSize,4)}(f),meta:{percent:100}});else for(this.push({data:l.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},C.prototype.flush=function(){for(var f=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var l=this.bytesWritten-f,h=function(p,g,k,y,x){var z=o.transformTo("string",x(y));return w.CENTRAL_DIRECTORY_END+"\0\0\0\0"+r(p,2)+r(p,2)+r(g,4)+r(k,4)+r(z.length,2)+z}(this.dirRecords.length,l,f,this.zipComment,this.encodeFileName);this.push({data:h,meta:{percent:100}})},C.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},C.prototype.registerPrevious=function(f){this._sources.push(f);var m=this;return f.on("data",function(l){m.processChunk(l)}),f.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),f.on("error",function(l){m.error(l)}),this},C.prototype.resume=function(){return!!u.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},C.prototype.error=function(f){var m=this._sources;if(!u.prototype.error.call(this,f))return!1;for(var l=0;l<m.length;l++)try{m[l].error(f)}catch{}return!0},C.prototype.lock=function(){u.prototype.lock.call(this);for(var f=this._sources,m=0;m<f.length;m++)f[m].lock()},d.exports=C},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,d,i){var r=e("../compressions"),s=e("./ZipFileWorker");i.generateWorker=function(o,u,v){var _=new s(u.streamFiles,v,u.platform,u.encodeFileName),w=0;try{o.forEach(function(C,f){w++;var m=function(g,k){var y=g||k,x=r[y];if(!x)throw new Error(y+" is not a valid compression method !");return x}(f.options.compression,u.compression),l=f.options.compressionOptions||u.compressionOptions||{},h=f.dir,p=f.date;f._compressWorker(m,l).withStreamInfo("file",{name:C,dir:h,date:p,comment:f.comment||"",unixPermissions:f.unixPermissions,dosPermissions:f.dosPermissions}).pipe(_)}),_.entriesCount=w}catch(C){_.error(C)}return _}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,d,i){function r(){if(!(this instanceof r))return new r;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new r;for(var o in this)typeof this[o]!="function"&&(s[o]=this[o]);return s}}(r.prototype=e("./object")).loadAsync=e("./load"),r.support=e("./support"),r.defaults=e("./defaults"),r.version="3.10.2",r.loadAsync=function(s,o){return new r().loadAsync(s,o)},r.external=e("./external"),d.exports=r},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,d,i){var r=e("./utils"),s=e("./external"),o=e("./utf8"),u=e("./zipEntries"),v=e("./stream/Crc32Probe"),_=e("./nodejsUtils");function w(C){return new s.Promise(function(f,m){var l=C.decompressed.getContentWorker().pipe(new v);l.on("error",function(h){m(h)}).on("end",function(){l.streamInfo.crc32!==C.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):f()}).resume()})}d.exports=function(C,f){var m=this;return f=r.extend(f||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),_.isNode&&_.isStream(C)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):r.prepareContent("the loaded zip file",C,!0,f.optimizedBinaryString,f.base64).then(function(l){var h=new u(f);return h.load(l),h}).then(function(l){var h=[s.Promise.resolve(l)],p=l.files;if(f.checkCRC32)for(var g=0;g<p.length;g++)h.push(w(p[g]));return s.Promise.all(h)}).then(function(l){for(var h=l.shift(),p=h.files,g=0;g<p.length;g++){var k=p[g],y=k.fileNameStr,x=r.resolve(k.fileNameStr);m.file(x,k.decompressed,{binary:!0,optimizedBinaryString:!0,date:k.date,dir:k.dir,comment:k.fileCommentStr.length?k.fileCommentStr:null,unixPermissions:k.unixPermissions,dosPermissions:k.dosPermissions,createFolders:f.createFolders}),k.dir||(m.file(x).unsafeOriginalName=y)}return h.zipComment.length&&(m.comment=h.zipComment),m})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,d,i){var r=e("../utils"),s=e("../stream/GenericWorker");function o(u,v){s.call(this,"Nodejs stream input adapter for "+u),this._upstreamEnded=!1,this._bindStream(v)}r.inherits(o,s),o.prototype._bindStream=function(u){var v=this;(this._stream=u).pause(),u.on("data",function(_){v.push({data:_,meta:{percent:0}})}).on("error",function(_){v.isPaused?this.generatedError=_:v.error(_)}).on("end",function(){v.isPaused?v._upstreamEnded=!0:v.end()})},o.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},d.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,d,i){var r=e("readable-stream").Readable;function s(o,u,v){r.call(this,u),this._helper=o;var _=this;o.on("data",function(w,C){_.push(w)||_._helper.pause(),v&&v(C)}).on("error",function(w){_.emit("error",w)}).on("end",function(){_.push(null)})}e("../utils").inherits(s,r),s.prototype._read=function(){this._helper.resume()},d.exports=s},{"../utils":32,"readable-stream":16}],14:[function(e,d,i){d.exports={isNode:typeof Buffer<"u",newBufferFrom:function(r,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(r,s);if(typeof r=="number")throw new Error('The "data" argument must not be a number');return new Buffer(r,s)},allocBuffer:function(r){if(Buffer.alloc)return Buffer.alloc(r);var s=new Buffer(r);return s.fill(0),s},isBuffer:function(r){return Buffer.isBuffer(r)},isStream:function(r){return r&&typeof r.on=="function"&&typeof r.pause=="function"&&typeof r.resume=="function"}}},{}],15:[function(e,d,i){function r(x,z,I){var F,A=o.getTypeOf(z),B=o.extend(I||{},_);B.date=B.date||new Date,B.compression!==null&&(B.compression=B.compression.toUpperCase()),typeof B.unixPermissions=="string"&&(B.unixPermissions=parseInt(B.unixPermissions,8)),B.unixPermissions&&16384&B.unixPermissions&&(B.dir=!0),B.dosPermissions&&16&B.dosPermissions&&(B.dir=!0),B.dir&&(x=p(x)),B.createFolders&&(F=h(x))&&g.call(this,F,!0);var K=A==="string"&&B.binary===!1&&B.base64===!1;I&&I.binary!==void 0||(B.binary=!K),(z instanceof w&&z.uncompressedSize===0||B.dir||!z||z.length===0)&&(B.base64=!1,B.binary=!0,z="",B.compression="STORE",A="string");var E=null;E=z instanceof w||z instanceof u?z:m.isNode&&m.isStream(z)?new l(x,z):o.prepareContent(x,z,B.binary,B.optimizedBinaryString,B.base64);var T=new C(x,E,B);this.files[x]=T}var s=e("./utf8"),o=e("./utils"),u=e("./stream/GenericWorker"),v=e("./stream/StreamHelper"),_=e("./defaults"),w=e("./compressedObject"),C=e("./zipObject"),f=e("./generate"),m=e("./nodejsUtils"),l=e("./nodejs/NodejsStreamInputAdapter"),h=function(x){x.slice(-1)==="/"&&(x=x.substring(0,x.length-1));var z=x.lastIndexOf("/");return 0<z?x.substring(0,z):""},p=function(x){return x.slice(-1)!=="/"&&(x+="/"),x},g=function(x,z){return z=z!==void 0?z:_.createFolders,x=p(x),this.files[x]||r.call(this,x,null,{dir:!0,createFolders:z}),this.files[x]};function k(x){return Object.prototype.toString.call(x)==="[object RegExp]"}var y={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(x){var z,I,F;for(z in this.files)F=this.files[z],(I=z.slice(this.root.length,z.length))&&z.slice(0,this.root.length)===this.root&&x(I,F)},filter:function(x){var z=[];return this.forEach(function(I,F){x(I,F)&&z.push(F)}),z},file:function(x,z,I){if(arguments.length!==1)return x=this.root+x,r.call(this,x,z,I),this;if(k(x)){var F=x;return this.filter(function(B,K){return!K.dir&&F.test(B)})}var A=this.files[this.root+x];return A&&!A.dir?A:null},folder:function(x){if(!x)return this;if(k(x))return this.filter(function(A,B){return B.dir&&x.test(A)});var z=this.root+x,I=g.call(this,z),F=this.clone();return F.root=I.name,F},remove:function(x){x=this.root+x;var z=this.files[x];if(z||(x.slice(-1)!=="/"&&(x+="/"),z=this.files[x]),z&&!z.dir)delete this.files[x];else for(var I=this.filter(function(A,B){return B.name.slice(0,x.length)===x}),F=0;F<I.length;F++)delete this.files[I[F].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(x){var z,I={};try{if((I=o.extend(x||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=I.type.toLowerCase(),I.compression=I.compression.toUpperCase(),I.type==="binarystring"&&(I.type="string"),!I.type)throw new Error("No output type specified.");o.checkSupport(I.type),I.platform!=="darwin"&&I.platform!=="freebsd"&&I.platform!=="linux"&&I.platform!=="sunos"||(I.platform="UNIX"),I.platform==="win32"&&(I.platform="DOS");var F=I.comment||this.comment||"";z=f.generateWorker(this,I,F)}catch(A){(z=new u("error")).error(A)}return new v(z,I.type||"string",I.mimeType)},generateAsync:function(x,z){return this.generateInternalStream(x).accumulate(z)},generateNodeStream:function(x,z){return(x=x||{}).type||(x.type="nodebuffer"),this.generateInternalStream(x).toNodejsStream(z)}};d.exports=y},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,d,i){d.exports=e("stream")},{stream:void 0}],17:[function(e,d,i){var r=e("./DataReader");function s(o){r.call(this,o);for(var u=0;u<this.data.length;u++)o[u]=255&o[u]}e("../utils").inherits(s,r),s.prototype.byteAt=function(o){return this.data[this.zero+o]},s.prototype.lastIndexOfSignature=function(o){for(var u=o.charCodeAt(0),v=o.charCodeAt(1),_=o.charCodeAt(2),w=o.charCodeAt(3),C=this.length-4;0<=C;--C)if(this.data[C]===u&&this.data[C+1]===v&&this.data[C+2]===_&&this.data[C+3]===w)return C-this.zero;return-1},s.prototype.readAndCheckSignature=function(o){var u=o.charCodeAt(0),v=o.charCodeAt(1),_=o.charCodeAt(2),w=o.charCodeAt(3),C=this.readData(4);return u===C[0]&&v===C[1]&&_===C[2]&&w===C[3]},s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var u=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,u},d.exports=s},{"../utils":32,"./DataReader":18}],18:[function(e,d,i){var r=e("../utils");function s(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var u,v=0;for(this.checkOffset(o),u=this.index+o-1;u>=this.index;u--)v=(v<<8)+this.byteAt(u);return this.index+=o,v},readString:function(o){return r.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},d.exports=s},{"../utils":32}],19:[function(e,d,i){var r=e("./Uint8ArrayReader");function s(o){r.call(this,o)}e("../utils").inherits(s,r),s.prototype.readData=function(o){this.checkOffset(o);var u=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,u},d.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,d,i){var r=e("./DataReader");function s(o){r.call(this,o)}e("../utils").inherits(s,r),s.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},s.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},s.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},s.prototype.readData=function(o){this.checkOffset(o);var u=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,u},d.exports=s},{"../utils":32,"./DataReader":18}],21:[function(e,d,i){var r=e("./ArrayReader");function s(o){r.call(this,o)}e("../utils").inherits(s,r),s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var u=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,u},d.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(e,d,i){var r=e("../utils"),s=e("../support"),o=e("./ArrayReader"),u=e("./StringReader"),v=e("./NodeBufferReader"),_=e("./Uint8ArrayReader");d.exports=function(w){var C=r.getTypeOf(w);return r.checkSupport(C),C!=="string"||s.uint8array?C==="nodebuffer"?new v(w):s.uint8array?new _(r.transformTo("uint8array",w)):new o(r.transformTo("array",w)):new u(w)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,d,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,d,i){var r=e("./GenericWorker"),s=e("../utils");function o(u){r.call(this,"ConvertWorker to "+u),this.destType=u}s.inherits(o,r),o.prototype.processChunk=function(u){this.push({data:s.transformTo(this.destType,u.data),meta:u.meta})},d.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,d,i){var r=e("./GenericWorker"),s=e("../crc32");function o(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,r),o.prototype.processChunk=function(u){this.streamInfo.crc32=s(u.data,this.streamInfo.crc32||0),this.push(u)},d.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,d,i){var r=e("../utils"),s=e("./GenericWorker");function o(u){s.call(this,"DataLengthProbe for "+u),this.propName=u,this.withStreamInfo(u,0)}r.inherits(o,s),o.prototype.processChunk=function(u){if(u){var v=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=v+u.data.length}s.prototype.processChunk.call(this,u)},d.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,d,i){var r=e("../utils"),s=e("./GenericWorker");function o(u){s.call(this,"DataWorker");var v=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,u.then(function(_){v.dataIsReady=!0,v.data=_,v.max=_&&_.length||0,v.type=r.getTypeOf(_),v.isPaused||v._tickAndRepeat()},function(_){v.error(_)})}r.inherits(o,s),o.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var u=null,v=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":u=this.data.substring(this.index,v);break;case"uint8array":u=this.data.subarray(this.index,v);break;case"array":case"nodebuffer":u=this.data.slice(this.index,v)}return this.index=v,this.push({data:u,meta:{percent:this.max?this.index/this.max*100:0}})},d.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,d,i){function r(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,o){return this._listeners[s].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,o){if(this._listeners[s])for(var u=0;u<this._listeners[s].length;u++)this._listeners[s][u].call(this,o)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var o=this;return s.on("data",function(u){o.processChunk(u)}),s.on("end",function(){o.end()}),s.on("error",function(u){o.error(u)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,o){return this.extraStreamInfo[s]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},d.exports=r},{}],29:[function(e,d,i){var r=e("../utils"),s=e("./ConvertWorker"),o=e("./GenericWorker"),u=e("../base64"),v=e("../support"),_=e("../external"),w=null;if(v.nodestream)try{w=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function C(m,l){return new _.Promise(function(h,p){var g=[],k=m._internalType,y=m._outputType,x=m._mimeType;m.on("data",function(z,I){g.push(z),l&&l(I)}).on("error",function(z){g=[],p(z)}).on("end",function(){try{var z=function(I,F,A){switch(I){case"blob":return r.newBlob(r.transformTo("arraybuffer",F),A);case"base64":return u.encode(F);default:return r.transformTo(I,F)}}(y,function(I,F){var A,B=0,K=null,E=0;for(A=0;A<F.length;A++)E+=F[A].length;switch(I){case"string":return F.join("");case"array":return Array.prototype.concat.apply([],F);case"uint8array":for(K=new Uint8Array(E),A=0;A<F.length;A++)K.set(F[A],B),B+=F[A].length;return K;case"nodebuffer":return Buffer.concat(F);default:throw new Error("concat : unsupported type '"+I+"'")}}(k,g),x);h(z)}catch(I){p(I)}g=[]}).resume()})}function f(m,l,h){var p=l;switch(l){case"blob":case"arraybuffer":p="uint8array";break;case"base64":p="string"}try{this._internalType=p,this._outputType=l,this._mimeType=h,r.checkSupport(p),this._worker=m.pipe(new s(p)),m.lock()}catch(g){this._worker=new o("error"),this._worker.error(g)}}f.prototype={accumulate:function(m){return C(this,m)},on:function(m,l){var h=this;return m==="data"?this._worker.on(m,function(p){l.call(h,p.data,p.meta)}):this._worker.on(m,function(){r.delay(l,arguments,h)}),this},resume:function(){return r.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(m){if(r.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new w(this,{objectMode:this._outputType!=="nodebuffer"},m)}},d.exports=f},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,d,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var r=new ArrayBuffer(0);try{i.blob=new Blob([r],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(r),i.blob=s.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!e("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(e,d,i){for(var r=e("./utils"),s=e("./support"),o=e("./nodejsUtils"),u=e("./stream/GenericWorker"),v=new Array(256),_=0;_<256;_++)v[_]=252<=_?6:248<=_?5:240<=_?4:224<=_?3:192<=_?2:1;v[254]=v[254]=1;function w(){u.call(this,"utf-8 decode"),this.leftOver=null}function C(){u.call(this,"utf-8 encode")}i.utf8encode=function(f){return s.nodebuffer?o.newBufferFrom(f,"utf-8"):function(m){var l,h,p,g,k,y=m.length,x=0;for(g=0;g<y;g++)(64512&(h=m.charCodeAt(g)))==55296&&g+1<y&&(64512&(p=m.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),g++),x+=h<128?1:h<2048?2:h<65536?3:4;for(l=s.uint8array?new Uint8Array(x):new Array(x),g=k=0;k<x;g++)(64512&(h=m.charCodeAt(g)))==55296&&g+1<y&&(64512&(p=m.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),g++),h<128?l[k++]=h:(h<2048?l[k++]=192|h>>>6:(h<65536?l[k++]=224|h>>>12:(l[k++]=240|h>>>18,l[k++]=128|h>>>12&63),l[k++]=128|h>>>6&63),l[k++]=128|63&h);return l}(f)},i.utf8decode=function(f){return s.nodebuffer?r.transformTo("nodebuffer",f).toString("utf-8"):function(m){var l,h,p,g,k=m.length,y=new Array(2*k);for(l=h=0;l<k;)if((p=m[l++])<128)y[h++]=p;else if(4<(g=v[p]))y[h++]=65533,l+=g-1;else{for(p&=g===2?31:g===3?15:7;1<g&&l<k;)p=p<<6|63&m[l++],g--;1<g?y[h++]=65533:p<65536?y[h++]=p:(p-=65536,y[h++]=55296|p>>10&1023,y[h++]=56320|1023&p)}return y.length!==h&&(y.subarray?y=y.subarray(0,h):y.length=h),r.applyFromCharCode(y)}(f=r.transformTo(s.uint8array?"uint8array":"array",f))},r.inherits(w,u),w.prototype.processChunk=function(f){var m=r.transformTo(s.uint8array?"uint8array":"array",f.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var l=m;(m=new Uint8Array(l.length+this.leftOver.length)).set(this.leftOver,0),m.set(l,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var h=function(g,k){var y;for((k=k||g.length)>g.length&&(k=g.length),y=k-1;0<=y&&(192&g[y])==128;)y--;return y<0||y===0?k:y+v[g[y]]>k?y:k}(m),p=m;h!==m.length&&(s.uint8array?(p=m.subarray(0,h),this.leftOver=m.subarray(h,m.length)):(p=m.slice(0,h),this.leftOver=m.slice(h,m.length))),this.push({data:i.utf8decode(p),meta:f.meta})},w.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=w,r.inherits(C,u),C.prototype.processChunk=function(f){this.push({data:i.utf8encode(f.data),meta:f.meta})},i.Utf8EncodeWorker=C},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,d,i){var r=e("./support"),s=e("./base64"),o=e("./nodejsUtils"),u=e("./external");function v(l){return l}function _(l,h){for(var p=0;p<l.length;++p)h[p]=255&l.charCodeAt(p);return h}e("setimmediate"),i.newBlob=function(l,h){i.checkSupport("blob");try{return new Blob([l],{type:h})}catch{try{var p=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return p.append(l),p.getBlob(h)}catch{throw new Error("Bug : can't construct the Blob.")}}};var w={stringifyByChunk:function(l,h,p){var g=[],k=0,y=l.length;if(y<=p)return String.fromCharCode.apply(null,l);for(;k<y;)h==="array"||h==="nodebuffer"?g.push(String.fromCharCode.apply(null,l.slice(k,Math.min(k+p,y)))):g.push(String.fromCharCode.apply(null,l.subarray(k,Math.min(k+p,y)))),k+=p;return g.join("")},stringifyByChar:function(l){for(var h="",p=0;p<l.length;p++)h+=String.fromCharCode(l[p]);return h},applyCanBeUsed:{uint8array:function(){try{return r.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return r.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}}()}};function C(l){var h=65536,p=i.getTypeOf(l),g=!0;if(p==="uint8array"?g=w.applyCanBeUsed.uint8array:p==="nodebuffer"&&(g=w.applyCanBeUsed.nodebuffer),g)for(;1<h;)try{return w.stringifyByChunk(l,p,h)}catch{h=Math.floor(h/2)}return w.stringifyByChar(l)}function f(l,h){for(var p=0;p<l.length;p++)h[p]=l[p];return h}i.applyFromCharCode=C;var m={};m.string={string:v,array:function(l){return _(l,new Array(l.length))},arraybuffer:function(l){return m.string.uint8array(l).buffer},uint8array:function(l){return _(l,new Uint8Array(l.length))},nodebuffer:function(l){return _(l,o.allocBuffer(l.length))}},m.array={string:C,array:v,arraybuffer:function(l){return new Uint8Array(l).buffer},uint8array:function(l){return new Uint8Array(l)},nodebuffer:function(l){return o.newBufferFrom(l)}},m.arraybuffer={string:function(l){return C(new Uint8Array(l))},array:function(l){return f(new Uint8Array(l),new Array(l.byteLength))},arraybuffer:v,uint8array:function(l){return new Uint8Array(l)},nodebuffer:function(l){return o.newBufferFrom(new Uint8Array(l))}},m.uint8array={string:C,array:function(l){return f(l,new Array(l.length))},arraybuffer:function(l){return l.buffer},uint8array:v,nodebuffer:function(l){return o.newBufferFrom(l)}},m.nodebuffer={string:C,array:function(l){return f(l,new Array(l.length))},arraybuffer:function(l){return m.nodebuffer.uint8array(l).buffer},uint8array:function(l){return f(l,new Uint8Array(l.length))},nodebuffer:v},i.transformTo=function(l,h){if(h=h||"",!l)return h;i.checkSupport(l);var p=i.getTypeOf(h);return m[p][l](h)},i.resolve=function(l){for(var h=l.split("/"),p=[],g=0;g<h.length;g++){var k=h[g];k==="."||k===""&&g!==0&&g!==h.length-1||(k===".."?p.pop():p.push(k))}return p.join("/")},i.getTypeOf=function(l){if(typeof l=="string")return"string";var h=Object.prototype.toString.call(l);return h==="[object Array]"?"array":r.nodebuffer&&o.isBuffer(l)?"nodebuffer":r.uint8array&&h==="[object Uint8Array]"?"uint8array":r.arraybuffer&&h==="[object ArrayBuffer]"?"arraybuffer":void 0},i.checkSupport=function(l){if(!r[l.toLowerCase()])throw new Error(l+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(l){var h,p,g="";for(p=0;p<(l||"").length;p++)g+="\\x"+((h=l.charCodeAt(p))<16?"0":"")+h.toString(16).toUpperCase();return g},i.delay=function(l,h,p){setImmediate(function(){l.apply(p||null,h||[])})},i.inherits=function(l,h){function p(){}p.prototype=h.prototype,l.prototype=new p},i.extend=function(){var l,h,p={};for(l=0;l<arguments.length;l++)for(h in arguments[l])Object.prototype.hasOwnProperty.call(arguments[l],h)&&p[h]===void 0&&(p[h]=arguments[l][h]);return p},i.prepareContent=function(l,h,p,g,k){return u.Promise.resolve(h).then(function(y){return r.blob&&(y instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(y))!==-1)?Blob.prototype.arrayBuffer!==void 0?y.arrayBuffer():typeof FileReader<"u"?new u.Promise(function(x,z){var I=new FileReader;I.onload=function(F){x(F.target.result)},I.onerror=function(F){z(F.target.error)},I.readAsArrayBuffer(y)}):u.Promise.reject(new Error(l+" is a Blob, but we have no way of reading it.")):y}).then(function(y){var x=i.getTypeOf(y);return x?(x==="arraybuffer"?y=i.transformTo("uint8array",y):x==="string"&&(k?y=s.decode(y):p&&g!==!0&&(y=function(z){return _(z,r.uint8array?new Uint8Array(z.length):new Array(z.length))}(y))),y):u.Promise.reject(new Error("Can't read the data of '"+l+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,d,i){var r=e("./reader/readerFor"),s=e("./utils"),o=e("./signature"),u=e("./zipEntry"),v=e("./support");function _(w){this.files=[],this.loadOptions=w}_.prototype={checkSignature:function(w){if(!this.reader.readAndCheckSignature(w)){this.reader.index-=4;var C=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(C)+", expected "+s.pretty(w)+")")}},isSignature:function(w,C){var f=this.reader.index;this.reader.setIndex(w);var m=this.reader.readString(4)===C;return this.reader.setIndex(f),m},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var w=this.reader.readData(this.zipCommentLength),C=v.uint8array?"uint8array":"array",f=s.transformTo(C,w);this.zipComment=this.loadOptions.decodeFileName(f)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var w,C,f,m=this.zip64EndOfCentralSize-44;0<m;)w=this.reader.readInt(2),C=this.reader.readInt(4),f=this.reader.readData(C),this.zip64ExtensibleData[w]={id:w,length:C,value:f}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var w,C;for(w=0;w<this.files.length;w++)C=this.files[w],this.reader.setIndex(C.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),C.readLocalPart(this.reader),C.handleUTF8(),C.processAttributes()},readCentralDir:function(){var w;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(w=new u({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(w);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var w=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(w<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(w);var C=w;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(w=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(w),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var f=this.centralDirOffset+this.centralDirSize;this.zip64&&(f+=20,f+=12+this.zip64EndOfCentralSize);var m=C-f;if(0<m)this.isSignature(C,o.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(w){this.reader=r(w)},load:function(w){this.prepareReader(w),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},d.exports=_},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,d,i){var r=e("./reader/readerFor"),s=e("./utils"),o=e("./compressedObject"),u=e("./crc32"),v=e("./utf8"),_=e("./compressions"),w=e("./support");function C(f,m){this.options=f,this.loadOptions=m}C.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(f){var m,l;if(f.skip(22),this.fileNameLength=f.readInt(2),l=f.readInt(2),this.fileName=f.readData(this.fileNameLength),f.skip(l),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((m=function(h){for(var p in _)if(Object.prototype.hasOwnProperty.call(_,p)&&_[p].magic===h)return _[p];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,m,f.readData(this.compressedSize))},readCentralPart:function(f){this.versionMadeBy=f.readInt(2),f.skip(2),this.bitFlag=f.readInt(2),this.compressionMethod=f.readString(2),this.date=f.readDate(),this.crc32=f.readInt(4),this.compressedSize=f.readInt(4),this.uncompressedSize=f.readInt(4);var m=f.readInt(2);if(this.extraFieldsLength=f.readInt(2),this.fileCommentLength=f.readInt(2),this.diskNumberStart=f.readInt(2),this.internalFileAttributes=f.readInt(2),this.externalFileAttributes=f.readInt(4),this.localHeaderOffset=f.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");f.skip(m),this.readExtraFields(f),this.parseZIP64ExtraField(f),this.fileComment=f.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var f=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),f==0&&(this.dosPermissions=63&this.externalFileAttributes),f==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var f=r(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=f.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=f.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=f.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=f.readInt(4))}},readExtraFields:function(f){var m,l,h,p=f.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});f.index+4<p;)m=f.readInt(2),l=f.readInt(2),h=f.readData(l),this.extraFields[m]={id:m,length:l,value:h};f.setIndex(p)},handleUTF8:function(){var f=w.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=v.utf8decode(this.fileName),this.fileCommentStr=v.utf8decode(this.fileComment);else{var m=this.findExtraFieldUnicodePath();if(m!==null)this.fileNameStr=m;else{var l=s.transformTo(f,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(l)}var h=this.findExtraFieldUnicodeComment();if(h!==null)this.fileCommentStr=h;else{var p=s.transformTo(f,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(p)}}},findExtraFieldUnicodePath:function(){var f=this.extraFields[28789];if(f){var m=r(f.value);return m.readInt(1)!==1||u(this.fileName)!==m.readInt(4)?null:v.utf8decode(m.readData(f.length-5))}return null},findExtraFieldUnicodeComment:function(){var f=this.extraFields[25461];if(f){var m=r(f.value);return m.readInt(1)!==1||u(this.fileComment)!==m.readInt(4)?null:v.utf8decode(m.readData(f.length-5))}return null}},d.exports=C},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,d,i){function r(m,l,h){this.name=m,this.dir=h.dir,this.date=h.date,this.comment=h.comment,this.unixPermissions=h.unixPermissions,this.dosPermissions=h.dosPermissions,this._data=l,this._dataBinary=h.binary,this.options={compression:h.compression,compressionOptions:h.compressionOptions}}var s=e("./stream/StreamHelper"),o=e("./stream/DataWorker"),u=e("./utf8"),v=e("./compressedObject"),_=e("./stream/GenericWorker");r.prototype={internalStream:function(m){var l=null,h="string";try{if(!m)throw new Error("No output type specified.");var p=(h=m.toLowerCase())==="string"||h==="text";h!=="binarystring"&&h!=="text"||(h="string"),l=this._decompressWorker();var g=!this._dataBinary;g&&!p&&(l=l.pipe(new u.Utf8EncodeWorker)),!g&&p&&(l=l.pipe(new u.Utf8DecodeWorker))}catch(k){(l=new _("error")).error(k)}return new s(l,h,"")},async:function(m,l){return this.internalStream(m).accumulate(l)},nodeStream:function(m,l){return this.internalStream(m||"nodebuffer").toNodejsStream(l)},_compressWorker:function(m,l){if(this._data instanceof v&&this._data.compression.magic===m.magic)return this._data.getCompressedWorker();var h=this._decompressWorker();return this._dataBinary||(h=h.pipe(new u.Utf8EncodeWorker)),v.createWorkerFrom(h,m,l)},_decompressWorker:function(){return this._data instanceof v?this._data.getContentWorker():this._data instanceof _?this._data:new o(this._data)}};for(var w=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],C=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},f=0;f<w.length;f++)r.prototype[w[f]]=C;d.exports=r},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,d,i){(function(r){var s,o,u=r.MutationObserver||r.WebKitMutationObserver;if(u){var v=0,_=new u(m),w=r.document.createTextNode("");_.observe(w,{characterData:!0}),s=function(){w.data=v=++v%2}}else if(r.setImmediate||r.MessageChannel===void 0)s="document"in r&&"onreadystatechange"in r.document.createElement("script")?function(){var l=r.document.createElement("script");l.onreadystatechange=function(){m(),l.onreadystatechange=null,l.parentNode.removeChild(l),l=null},r.document.documentElement.appendChild(l)}:function(){setTimeout(m,0)};else{var C=new r.MessageChannel;C.port1.onmessage=m,s=function(){C.port2.postMessage(0)}}var f=[];function m(){var l,h;o=!0;for(var p=f.length;p;){for(h=f,f=[],l=-1;++l<p;)h[l]();p=f.length}o=!1}d.exports=function(l){f.push(l)!==1||o||s()}}).call(this,typeof ut<"u"?ut:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(e,d,i){var r=e("immediate");function s(){}var o={},u=["REJECTED"],v=["FULFILLED"],_=["PENDING"];function w(p){if(typeof p!="function")throw new TypeError("resolver must be a function");this.state=_,this.queue=[],this.outcome=void 0,p!==s&&l(this,p)}function C(p,g,k){this.promise=p,typeof g=="function"&&(this.onFulfilled=g,this.callFulfilled=this.otherCallFulfilled),typeof k=="function"&&(this.onRejected=k,this.callRejected=this.otherCallRejected)}function f(p,g,k){r(function(){var y;try{y=g(k)}catch(x){return o.reject(p,x)}y===p?o.reject(p,new TypeError("Cannot resolve promise with itself")):o.resolve(p,y)})}function m(p){var g=p&&p.then;if(p&&(typeof p=="object"||typeof p=="function")&&typeof g=="function")return function(){g.apply(p,arguments)}}function l(p,g){var k=!1;function y(I){k||(k=!0,o.reject(p,I))}function x(I){k||(k=!0,o.resolve(p,I))}var z=h(function(){g(x,y)});z.status==="error"&&y(z.value)}function h(p,g){var k={};try{k.value=p(g),k.status="success"}catch(y){k.status="error",k.value=y}return k}(d.exports=w).prototype.finally=function(p){if(typeof p!="function")return this;var g=this.constructor;return this.then(function(k){return g.resolve(p()).then(function(){return k})},function(k){return g.resolve(p()).then(function(){throw k})})},w.prototype.catch=function(p){return this.then(null,p)},w.prototype.then=function(p,g){if(typeof p!="function"&&this.state===v||typeof g!="function"&&this.state===u)return this;var k=new this.constructor(s);return this.state!==_?f(k,this.state===v?p:g,this.outcome):this.queue.push(new C(k,p,g)),k},C.prototype.callFulfilled=function(p){o.resolve(this.promise,p)},C.prototype.otherCallFulfilled=function(p){f(this.promise,this.onFulfilled,p)},C.prototype.callRejected=function(p){o.reject(this.promise,p)},C.prototype.otherCallRejected=function(p){f(this.promise,this.onRejected,p)},o.resolve=function(p,g){var k=h(m,g);if(k.status==="error")return o.reject(p,k.value);var y=k.value;if(y)l(p,y);else{p.state=v,p.outcome=g;for(var x=-1,z=p.queue.length;++x<z;)p.queue[x].callFulfilled(g)}return p},o.reject=function(p,g){p.state=u,p.outcome=g;for(var k=-1,y=p.queue.length;++k<y;)p.queue[k].callRejected(g);return p},w.resolve=function(p){return p instanceof this?p:o.resolve(new this(s),p)},w.reject=function(p){var g=new this(s);return o.reject(g,p)},w.all=function(p){var g=this;if(Object.prototype.toString.call(p)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=p.length,y=!1;if(!k)return this.resolve([]);for(var x=new Array(k),z=0,I=-1,F=new this(s);++I<k;)A(p[I],I);return F;function A(B,K){g.resolve(B).then(function(E){x[K]=E,++z!==k||y||(y=!0,o.resolve(F,x))},function(E){y||(y=!0,o.reject(F,E))})}},w.race=function(p){var g=this;if(Object.prototype.toString.call(p)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=p.length,y=!1;if(!k)return this.resolve([]);for(var x=-1,z=new this(s);++x<k;)I=p[x],g.resolve(I).then(function(F){y||(y=!0,o.resolve(z,F))},function(F){y||(y=!0,o.reject(z,F))});var I;return z}},{immediate:36}],38:[function(e,d,i){var r={};(0,e("./lib/utils/common").assign)(r,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),d.exports=r},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,d,i){var r=e("./zlib/deflate"),s=e("./utils/common"),o=e("./utils/strings"),u=e("./zlib/messages"),v=e("./zlib/zstream"),_=Object.prototype.toString,w=0,C=-1,f=0,m=8;function l(p){if(!(this instanceof l))return new l(p);this.options=s.assign({level:C,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:f,to:""},p||{});var g=this.options;g.raw&&0<g.windowBits?g.windowBits=-g.windowBits:g.gzip&&0<g.windowBits&&g.windowBits<16&&(g.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new v,this.strm.avail_out=0;var k=r.deflateInit2(this.strm,g.level,g.method,g.windowBits,g.memLevel,g.strategy);if(k!==w)throw new Error(u[k]);if(g.header&&r.deflateSetHeader(this.strm,g.header),g.dictionary){var y;if(y=typeof g.dictionary=="string"?o.string2buf(g.dictionary):_.call(g.dictionary)==="[object ArrayBuffer]"?new Uint8Array(g.dictionary):g.dictionary,(k=r.deflateSetDictionary(this.strm,y))!==w)throw new Error(u[k]);this._dict_set=!0}}function h(p,g){var k=new l(g);if(k.push(p,!0),k.err)throw k.msg||u[k.err];return k.result}l.prototype.push=function(p,g){var k,y,x=this.strm,z=this.options.chunkSize;if(this.ended)return!1;y=g===~~g?g:g===!0?4:0,typeof p=="string"?x.input=o.string2buf(p):_.call(p)==="[object ArrayBuffer]"?x.input=new Uint8Array(p):x.input=p,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new s.Buf8(z),x.next_out=0,x.avail_out=z),(k=r.deflate(x,y))!==1&&k!==w)return this.onEnd(k),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||y!==4&&y!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(s.shrinkBuf(x.output,x.next_out))):this.onData(s.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&k!==1);return y===4?(k=r.deflateEnd(this.strm),this.onEnd(k),this.ended=!0,k===w):y!==2||(this.onEnd(w),!(x.avail_out=0))},l.prototype.onData=function(p){this.chunks.push(p)},l.prototype.onEnd=function(p){p===w&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=p,this.msg=this.strm.msg},i.Deflate=l,i.deflate=h,i.deflateRaw=function(p,g){return(g=g||{}).raw=!0,h(p,g)},i.gzip=function(p,g){return(g=g||{}).gzip=!0,h(p,g)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,d,i){var r=e("./zlib/inflate"),s=e("./utils/common"),o=e("./utils/strings"),u=e("./zlib/constants"),v=e("./zlib/messages"),_=e("./zlib/zstream"),w=e("./zlib/gzheader"),C=Object.prototype.toString;function f(l){if(!(this instanceof f))return new f(l);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},l||{});var h=this.options;h.raw&&0<=h.windowBits&&h.windowBits<16&&(h.windowBits=-h.windowBits,h.windowBits===0&&(h.windowBits=-15)),!(0<=h.windowBits&&h.windowBits<16)||l&&l.windowBits||(h.windowBits+=32),15<h.windowBits&&h.windowBits<48&&!(15&h.windowBits)&&(h.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new _,this.strm.avail_out=0;var p=r.inflateInit2(this.strm,h.windowBits);if(p!==u.Z_OK)throw new Error(v[p]);this.header=new w,r.inflateGetHeader(this.strm,this.header)}function m(l,h){var p=new f(h);if(p.push(l,!0),p.err)throw p.msg||v[p.err];return p.result}f.prototype.push=function(l,h){var p,g,k,y,x,z,I=this.strm,F=this.options.chunkSize,A=this.options.dictionary,B=!1;if(this.ended)return!1;g=h===~~h?h:h===!0?u.Z_FINISH:u.Z_NO_FLUSH,typeof l=="string"?I.input=o.binstring2buf(l):C.call(l)==="[object ArrayBuffer]"?I.input=new Uint8Array(l):I.input=l,I.next_in=0,I.avail_in=I.input.length;do{if(I.avail_out===0&&(I.output=new s.Buf8(F),I.next_out=0,I.avail_out=F),(p=r.inflate(I,u.Z_NO_FLUSH))===u.Z_NEED_DICT&&A&&(z=typeof A=="string"?o.string2buf(A):C.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,p=r.inflateSetDictionary(this.strm,z)),p===u.Z_BUF_ERROR&&B===!0&&(p=u.Z_OK,B=!1),p!==u.Z_STREAM_END&&p!==u.Z_OK)return this.onEnd(p),!(this.ended=!0);I.next_out&&(I.avail_out!==0&&p!==u.Z_STREAM_END&&(I.avail_in!==0||g!==u.Z_FINISH&&g!==u.Z_SYNC_FLUSH)||(this.options.to==="string"?(k=o.utf8border(I.output,I.next_out),y=I.next_out-k,x=o.buf2string(I.output,k),I.next_out=y,I.avail_out=F-y,y&&s.arraySet(I.output,I.output,k,y,0),this.onData(x)):this.onData(s.shrinkBuf(I.output,I.next_out)))),I.avail_in===0&&I.avail_out===0&&(B=!0)}while((0<I.avail_in||I.avail_out===0)&&p!==u.Z_STREAM_END);return p===u.Z_STREAM_END&&(g=u.Z_FINISH),g===u.Z_FINISH?(p=r.inflateEnd(this.strm),this.onEnd(p),this.ended=!0,p===u.Z_OK):g!==u.Z_SYNC_FLUSH||(this.onEnd(u.Z_OK),!(I.avail_out=0))},f.prototype.onData=function(l){this.chunks.push(l)},f.prototype.onEnd=function(l){l===u.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=l,this.msg=this.strm.msg},i.Inflate=f,i.inflate=m,i.inflateRaw=function(l,h){return(h=h||{}).raw=!0,m(l,h)},i.ungzip=m},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,d,i){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(u){for(var v=Array.prototype.slice.call(arguments,1);v.length;){var _=v.shift();if(_){if(typeof _!="object")throw new TypeError(_+"must be non-object");for(var w in _)_.hasOwnProperty(w)&&(u[w]=_[w])}}return u},i.shrinkBuf=function(u,v){return u.length===v?u:u.subarray?u.subarray(0,v):(u.length=v,u)};var s={arraySet:function(u,v,_,w,C){if(v.subarray&&u.subarray)u.set(v.subarray(_,_+w),C);else for(var f=0;f<w;f++)u[C+f]=v[_+f]},flattenChunks:function(u){var v,_,w,C,f,m;for(v=w=0,_=u.length;v<_;v++)w+=u[v].length;for(m=new Uint8Array(w),v=C=0,_=u.length;v<_;v++)f=u[v],m.set(f,C),C+=f.length;return m}},o={arraySet:function(u,v,_,w,C){for(var f=0;f<w;f++)u[C+f]=v[_+f]},flattenChunks:function(u){return[].concat.apply([],u)}};i.setTyped=function(u){u?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,s)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,o))},i.setTyped(r)},{}],42:[function(e,d,i){var r=e("./common"),s=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var u=new r.Buf8(256),v=0;v<256;v++)u[v]=252<=v?6:248<=v?5:240<=v?4:224<=v?3:192<=v?2:1;function _(w,C){if(C<65537&&(w.subarray&&o||!w.subarray&&s))return String.fromCharCode.apply(null,r.shrinkBuf(w,C));for(var f="",m=0;m<C;m++)f+=String.fromCharCode(w[m]);return f}u[254]=u[254]=1,i.string2buf=function(w){var C,f,m,l,h,p=w.length,g=0;for(l=0;l<p;l++)(64512&(f=w.charCodeAt(l)))==55296&&l+1<p&&(64512&(m=w.charCodeAt(l+1)))==56320&&(f=65536+(f-55296<<10)+(m-56320),l++),g+=f<128?1:f<2048?2:f<65536?3:4;for(C=new r.Buf8(g),l=h=0;h<g;l++)(64512&(f=w.charCodeAt(l)))==55296&&l+1<p&&(64512&(m=w.charCodeAt(l+1)))==56320&&(f=65536+(f-55296<<10)+(m-56320),l++),f<128?C[h++]=f:(f<2048?C[h++]=192|f>>>6:(f<65536?C[h++]=224|f>>>12:(C[h++]=240|f>>>18,C[h++]=128|f>>>12&63),C[h++]=128|f>>>6&63),C[h++]=128|63&f);return C},i.buf2binstring=function(w){return _(w,w.length)},i.binstring2buf=function(w){for(var C=new r.Buf8(w.length),f=0,m=C.length;f<m;f++)C[f]=w.charCodeAt(f);return C},i.buf2string=function(w,C){var f,m,l,h,p=C||w.length,g=new Array(2*p);for(f=m=0;f<p;)if((l=w[f++])<128)g[m++]=l;else if(4<(h=u[l]))g[m++]=65533,f+=h-1;else{for(l&=h===2?31:h===3?15:7;1<h&&f<p;)l=l<<6|63&w[f++],h--;1<h?g[m++]=65533:l<65536?g[m++]=l:(l-=65536,g[m++]=55296|l>>10&1023,g[m++]=56320|1023&l)}return _(g,m)},i.utf8border=function(w,C){var f;for((C=C||w.length)>w.length&&(C=w.length),f=C-1;0<=f&&(192&w[f])==128;)f--;return f<0||f===0?C:f+u[w[f]]>C?f:C}},{"./common":41}],43:[function(e,d,i){d.exports=function(r,s,o,u){for(var v=65535&r|0,_=r>>>16&65535|0,w=0;o!==0;){for(o-=w=2e3<o?2e3:o;_=_+(v=v+s[u++]|0)|0,--w;);v%=65521,_%=65521}return v|_<<16|0}},{}],44:[function(e,d,i){d.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,d,i){var r=function(){for(var s,o=[],u=0;u<256;u++){s=u;for(var v=0;v<8;v++)s=1&s?3988292384^s>>>1:s>>>1;o[u]=s}return o}();d.exports=function(s,o,u,v){var _=r,w=v+u;s^=-1;for(var C=v;C<w;C++)s=s>>>8^_[255&(s^o[C])];return-1^s}},{}],46:[function(e,d,i){var r,s=e("../utils/common"),o=e("./trees"),u=e("./adler32"),v=e("./crc32"),_=e("./messages"),w=0,C=4,f=0,m=-2,l=-1,h=4,p=2,g=8,k=9,y=286,x=30,z=19,I=2*y+1,F=15,A=3,B=258,K=B+A+1,E=42,T=113,c=1,D=2,Q=3,q=4;function re(n,L){return n.msg=_[L],L}function M(n){return(n<<1)-(4<n?9:0)}function te(n){for(var L=n.length;0<=--L;)n[L]=0}function R(n){var L=n.state,j=L.pending;j>n.avail_out&&(j=n.avail_out),j!==0&&(s.arraySet(n.output,L.pending_buf,L.pending_out,j,n.next_out),n.next_out+=j,L.pending_out+=j,n.total_out+=j,n.avail_out-=j,L.pending-=j,L.pending===0&&(L.pending_out=0))}function O(n,L){o._tr_flush_block(n,0<=n.block_start?n.block_start:-1,n.strstart-n.block_start,L),n.block_start=n.strstart,R(n.strm)}function J(n,L){n.pending_buf[n.pending++]=L}function V(n,L){n.pending_buf[n.pending++]=L>>>8&255,n.pending_buf[n.pending++]=255&L}function G(n,L){var j,S,b=n.max_chain_length,N=n.strstart,P=n.prev_length,U=n.nice_match,$=n.strstart>n.w_size-K?n.strstart-(n.w_size-K):0,Z=n.window,X=n.w_mask,H=n.prev,ee=n.strstart+B,ue=Z[N+P-1],se=Z[N+P];n.prev_length>=n.good_match&&(b>>=2),U>n.lookahead&&(U=n.lookahead);do if(Z[(j=L)+P]===se&&Z[j+P-1]===ue&&Z[j]===Z[N]&&Z[++j]===Z[N+1]){N+=2,j++;do;while(Z[++N]===Z[++j]&&Z[++N]===Z[++j]&&Z[++N]===Z[++j]&&Z[++N]===Z[++j]&&Z[++N]===Z[++j]&&Z[++N]===Z[++j]&&Z[++N]===Z[++j]&&Z[++N]===Z[++j]&&N<ee);if(S=B-(ee-N),N=ee-B,P<S){if(n.match_start=L,U<=(P=S))break;ue=Z[N+P-1],se=Z[N+P]}}while((L=H[L&X])>$&&--b!=0);return P<=n.lookahead?P:n.lookahead}function fe(n){var L,j,S,b,N,P,U,$,Z,X,H=n.w_size;do{if(b=n.window_size-n.lookahead-n.strstart,n.strstart>=H+(H-K)){for(s.arraySet(n.window,n.window,H,H,0),n.match_start-=H,n.strstart-=H,n.block_start-=H,L=j=n.hash_size;S=n.head[--L],n.head[L]=H<=S?S-H:0,--j;);for(L=j=H;S=n.prev[--L],n.prev[L]=H<=S?S-H:0,--j;);b+=H}if(n.strm.avail_in===0)break;if(P=n.strm,U=n.window,$=n.strstart+n.lookahead,Z=b,X=void 0,X=P.avail_in,Z<X&&(X=Z),j=X===0?0:(P.avail_in-=X,s.arraySet(U,P.input,P.next_in,X,$),P.state.wrap===1?P.adler=u(P.adler,U,X,$):P.state.wrap===2&&(P.adler=v(P.adler,U,X,$)),P.next_in+=X,P.total_in+=X,X),n.lookahead+=j,n.lookahead+n.insert>=A)for(N=n.strstart-n.insert,n.ins_h=n.window[N],n.ins_h=(n.ins_h<<n.hash_shift^n.window[N+1])&n.hash_mask;n.insert&&(n.ins_h=(n.ins_h<<n.hash_shift^n.window[N+A-1])&n.hash_mask,n.prev[N&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=N,N++,n.insert--,!(n.lookahead+n.insert<A)););}while(n.lookahead<K&&n.strm.avail_in!==0)}function we(n,L){for(var j,S;;){if(n.lookahead<K){if(fe(n),n.lookahead<K&&L===w)return c;if(n.lookahead===0)break}if(j=0,n.lookahead>=A&&(n.ins_h=(n.ins_h<<n.hash_shift^n.window[n.strstart+A-1])&n.hash_mask,j=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),j!==0&&n.strstart-j<=n.w_size-K&&(n.match_length=G(n,j)),n.match_length>=A)if(S=o._tr_tally(n,n.strstart-n.match_start,n.match_length-A),n.lookahead-=n.match_length,n.match_length<=n.max_lazy_match&&n.lookahead>=A){for(n.match_length--;n.strstart++,n.ins_h=(n.ins_h<<n.hash_shift^n.window[n.strstart+A-1])&n.hash_mask,j=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart,--n.match_length!=0;);n.strstart++}else n.strstart+=n.match_length,n.match_length=0,n.ins_h=n.window[n.strstart],n.ins_h=(n.ins_h<<n.hash_shift^n.window[n.strstart+1])&n.hash_mask;else S=o._tr_tally(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++;if(S&&(O(n,!1),n.strm.avail_out===0))return c}return n.insert=n.strstart<A-1?n.strstart:A-1,L===C?(O(n,!0),n.strm.avail_out===0?Q:q):n.last_lit&&(O(n,!1),n.strm.avail_out===0)?c:D}function oe(n,L){for(var j,S,b;;){if(n.lookahead<K){if(fe(n),n.lookahead<K&&L===w)return c;if(n.lookahead===0)break}if(j=0,n.lookahead>=A&&(n.ins_h=(n.ins_h<<n.hash_shift^n.window[n.strstart+A-1])&n.hash_mask,j=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),n.prev_length=n.match_length,n.prev_match=n.match_start,n.match_length=A-1,j!==0&&n.prev_length<n.max_lazy_match&&n.strstart-j<=n.w_size-K&&(n.match_length=G(n,j),n.match_length<=5&&(n.strategy===1||n.match_length===A&&4096<n.strstart-n.match_start)&&(n.match_length=A-1)),n.prev_length>=A&&n.match_length<=n.prev_length){for(b=n.strstart+n.lookahead-A,S=o._tr_tally(n,n.strstart-1-n.prev_match,n.prev_length-A),n.lookahead-=n.prev_length-1,n.prev_length-=2;++n.strstart<=b&&(n.ins_h=(n.ins_h<<n.hash_shift^n.window[n.strstart+A-1])&n.hash_mask,j=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),--n.prev_length!=0;);if(n.match_available=0,n.match_length=A-1,n.strstart++,S&&(O(n,!1),n.strm.avail_out===0))return c}else if(n.match_available){if((S=o._tr_tally(n,0,n.window[n.strstart-1]))&&O(n,!1),n.strstart++,n.lookahead--,n.strm.avail_out===0)return c}else n.match_available=1,n.strstart++,n.lookahead--}return n.match_available&&(S=o._tr_tally(n,0,n.window[n.strstart-1]),n.match_available=0),n.insert=n.strstart<A-1?n.strstart:A-1,L===C?(O(n,!0),n.strm.avail_out===0?Q:q):n.last_lit&&(O(n,!1),n.strm.avail_out===0)?c:D}function ae(n,L,j,S,b){this.good_length=n,this.max_lazy=L,this.nice_length=j,this.max_chain=S,this.func=b}function ge(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=g,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*I),this.dyn_dtree=new s.Buf16(2*(2*x+1)),this.bl_tree=new s.Buf16(2*(2*z+1)),te(this.dyn_ltree),te(this.dyn_dtree),te(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(F+1),this.heap=new s.Buf16(2*y+1),te(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*y+1),te(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function de(n){var L;return n&&n.state?(n.total_in=n.total_out=0,n.data_type=p,(L=n.state).pending=0,L.pending_out=0,L.wrap<0&&(L.wrap=-L.wrap),L.status=L.wrap?E:T,n.adler=L.wrap===2?0:1,L.last_flush=w,o._tr_init(L),f):re(n,m)}function ke(n){var L=de(n);return L===f&&function(j){j.window_size=2*j.w_size,te(j.head),j.max_lazy_match=r[j.level].max_lazy,j.good_match=r[j.level].good_length,j.nice_match=r[j.level].nice_length,j.max_chain_length=r[j.level].max_chain,j.strstart=0,j.block_start=0,j.lookahead=0,j.insert=0,j.match_length=j.prev_length=A-1,j.match_available=0,j.ins_h=0}(n.state),L}function Ne(n,L,j,S,b,N){if(!n)return m;var P=1;if(L===l&&(L=6),S<0?(P=0,S=-S):15<S&&(P=2,S-=16),b<1||k<b||j!==g||S<8||15<S||L<0||9<L||N<0||h<N)return re(n,m);S===8&&(S=9);var U=new ge;return(n.state=U).strm=n,U.wrap=P,U.gzhead=null,U.w_bits=S,U.w_size=1<<U.w_bits,U.w_mask=U.w_size-1,U.hash_bits=b+7,U.hash_size=1<<U.hash_bits,U.hash_mask=U.hash_size-1,U.hash_shift=~~((U.hash_bits+A-1)/A),U.window=new s.Buf8(2*U.w_size),U.head=new s.Buf16(U.hash_size),U.prev=new s.Buf16(U.w_size),U.lit_bufsize=1<<b+6,U.pending_buf_size=4*U.lit_bufsize,U.pending_buf=new s.Buf8(U.pending_buf_size),U.d_buf=1*U.lit_bufsize,U.l_buf=3*U.lit_bufsize,U.level=L,U.strategy=N,U.method=j,ke(n)}r=[new ae(0,0,0,0,function(n,L){var j=65535;for(j>n.pending_buf_size-5&&(j=n.pending_buf_size-5);;){if(n.lookahead<=1){if(fe(n),n.lookahead===0&&L===w)return c;if(n.lookahead===0)break}n.strstart+=n.lookahead,n.lookahead=0;var S=n.block_start+j;if((n.strstart===0||n.strstart>=S)&&(n.lookahead=n.strstart-S,n.strstart=S,O(n,!1),n.strm.avail_out===0)||n.strstart-n.block_start>=n.w_size-K&&(O(n,!1),n.strm.avail_out===0))return c}return n.insert=0,L===C?(O(n,!0),n.strm.avail_out===0?Q:q):(n.strstart>n.block_start&&(O(n,!1),n.strm.avail_out),c)}),new ae(4,4,8,4,we),new ae(4,5,16,8,we),new ae(4,6,32,32,we),new ae(4,4,16,16,oe),new ae(8,16,32,32,oe),new ae(8,16,128,128,oe),new ae(8,32,128,256,oe),new ae(32,128,258,1024,oe),new ae(32,258,258,4096,oe)],i.deflateInit=function(n,L){return Ne(n,L,g,15,8,0)},i.deflateInit2=Ne,i.deflateReset=ke,i.deflateResetKeep=de,i.deflateSetHeader=function(n,L){return n&&n.state?n.state.wrap!==2?m:(n.state.gzhead=L,f):m},i.deflate=function(n,L){var j,S,b,N;if(!n||!n.state||5<L||L<0)return n?re(n,m):m;if(S=n.state,!n.output||!n.input&&n.avail_in!==0||S.status===666&&L!==C)return re(n,n.avail_out===0?-5:m);if(S.strm=n,j=S.last_flush,S.last_flush=L,S.status===E)if(S.wrap===2)n.adler=0,J(S,31),J(S,139),J(S,8),S.gzhead?(J(S,(S.gzhead.text?1:0)+(S.gzhead.hcrc?2:0)+(S.gzhead.extra?4:0)+(S.gzhead.name?8:0)+(S.gzhead.comment?16:0)),J(S,255&S.gzhead.time),J(S,S.gzhead.time>>8&255),J(S,S.gzhead.time>>16&255),J(S,S.gzhead.time>>24&255),J(S,S.level===9?2:2<=S.strategy||S.level<2?4:0),J(S,255&S.gzhead.os),S.gzhead.extra&&S.gzhead.extra.length&&(J(S,255&S.gzhead.extra.length),J(S,S.gzhead.extra.length>>8&255)),S.gzhead.hcrc&&(n.adler=v(n.adler,S.pending_buf,S.pending,0)),S.gzindex=0,S.status=69):(J(S,0),J(S,0),J(S,0),J(S,0),J(S,0),J(S,S.level===9?2:2<=S.strategy||S.level<2?4:0),J(S,3),S.status=T);else{var P=g+(S.w_bits-8<<4)<<8;P|=(2<=S.strategy||S.level<2?0:S.level<6?1:S.level===6?2:3)<<6,S.strstart!==0&&(P|=32),P+=31-P%31,S.status=T,V(S,P),S.strstart!==0&&(V(S,n.adler>>>16),V(S,65535&n.adler)),n.adler=1}if(S.status===69)if(S.gzhead.extra){for(b=S.pending;S.gzindex<(65535&S.gzhead.extra.length)&&(S.pending!==S.pending_buf_size||(S.gzhead.hcrc&&S.pending>b&&(n.adler=v(n.adler,S.pending_buf,S.pending-b,b)),R(n),b=S.pending,S.pending!==S.pending_buf_size));)J(S,255&S.gzhead.extra[S.gzindex]),S.gzindex++;S.gzhead.hcrc&&S.pending>b&&(n.adler=v(n.adler,S.pending_buf,S.pending-b,b)),S.gzindex===S.gzhead.extra.length&&(S.gzindex=0,S.status=73)}else S.status=73;if(S.status===73)if(S.gzhead.name){b=S.pending;do{if(S.pending===S.pending_buf_size&&(S.gzhead.hcrc&&S.pending>b&&(n.adler=v(n.adler,S.pending_buf,S.pending-b,b)),R(n),b=S.pending,S.pending===S.pending_buf_size)){N=1;break}N=S.gzindex<S.gzhead.name.length?255&S.gzhead.name.charCodeAt(S.gzindex++):0,J(S,N)}while(N!==0);S.gzhead.hcrc&&S.pending>b&&(n.adler=v(n.adler,S.pending_buf,S.pending-b,b)),N===0&&(S.gzindex=0,S.status=91)}else S.status=91;if(S.status===91)if(S.gzhead.comment){b=S.pending;do{if(S.pending===S.pending_buf_size&&(S.gzhead.hcrc&&S.pending>b&&(n.adler=v(n.adler,S.pending_buf,S.pending-b,b)),R(n),b=S.pending,S.pending===S.pending_buf_size)){N=1;break}N=S.gzindex<S.gzhead.comment.length?255&S.gzhead.comment.charCodeAt(S.gzindex++):0,J(S,N)}while(N!==0);S.gzhead.hcrc&&S.pending>b&&(n.adler=v(n.adler,S.pending_buf,S.pending-b,b)),N===0&&(S.status=103)}else S.status=103;if(S.status===103&&(S.gzhead.hcrc?(S.pending+2>S.pending_buf_size&&R(n),S.pending+2<=S.pending_buf_size&&(J(S,255&n.adler),J(S,n.adler>>8&255),n.adler=0,S.status=T)):S.status=T),S.pending!==0){if(R(n),n.avail_out===0)return S.last_flush=-1,f}else if(n.avail_in===0&&M(L)<=M(j)&&L!==C)return re(n,-5);if(S.status===666&&n.avail_in!==0)return re(n,-5);if(n.avail_in!==0||S.lookahead!==0||L!==w&&S.status!==666){var U=S.strategy===2?function($,Z){for(var X;;){if($.lookahead===0&&(fe($),$.lookahead===0)){if(Z===w)return c;break}if($.match_length=0,X=o._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++,X&&(O($,!1),$.strm.avail_out===0))return c}return $.insert=0,Z===C?(O($,!0),$.strm.avail_out===0?Q:q):$.last_lit&&(O($,!1),$.strm.avail_out===0)?c:D}(S,L):S.strategy===3?function($,Z){for(var X,H,ee,ue,se=$.window;;){if($.lookahead<=B){if(fe($),$.lookahead<=B&&Z===w)return c;if($.lookahead===0)break}if($.match_length=0,$.lookahead>=A&&0<$.strstart&&(H=se[ee=$.strstart-1])===se[++ee]&&H===se[++ee]&&H===se[++ee]){ue=$.strstart+B;do;while(H===se[++ee]&&H===se[++ee]&&H===se[++ee]&&H===se[++ee]&&H===se[++ee]&&H===se[++ee]&&H===se[++ee]&&H===se[++ee]&&ee<ue);$.match_length=B-(ue-ee),$.match_length>$.lookahead&&($.match_length=$.lookahead)}if($.match_length>=A?(X=o._tr_tally($,1,$.match_length-A),$.lookahead-=$.match_length,$.strstart+=$.match_length,$.match_length=0):(X=o._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++),X&&(O($,!1),$.strm.avail_out===0))return c}return $.insert=0,Z===C?(O($,!0),$.strm.avail_out===0?Q:q):$.last_lit&&(O($,!1),$.strm.avail_out===0)?c:D}(S,L):r[S.level].func(S,L);if(U!==Q&&U!==q||(S.status=666),U===c||U===Q)return n.avail_out===0&&(S.last_flush=-1),f;if(U===D&&(L===1?o._tr_align(S):L!==5&&(o._tr_stored_block(S,0,0,!1),L===3&&(te(S.head),S.lookahead===0&&(S.strstart=0,S.block_start=0,S.insert=0))),R(n),n.avail_out===0))return S.last_flush=-1,f}return L!==C?f:S.wrap<=0?1:(S.wrap===2?(J(S,255&n.adler),J(S,n.adler>>8&255),J(S,n.adler>>16&255),J(S,n.adler>>24&255),J(S,255&n.total_in),J(S,n.total_in>>8&255),J(S,n.total_in>>16&255),J(S,n.total_in>>24&255)):(V(S,n.adler>>>16),V(S,65535&n.adler)),R(n),0<S.wrap&&(S.wrap=-S.wrap),S.pending!==0?f:1)},i.deflateEnd=function(n){var L;return n&&n.state?(L=n.state.status)!==E&&L!==69&&L!==73&&L!==91&&L!==103&&L!==T&&L!==666?re(n,m):(n.state=null,L===T?re(n,-3):f):m},i.deflateSetDictionary=function(n,L){var j,S,b,N,P,U,$,Z,X=L.length;if(!n||!n.state||(N=(j=n.state).wrap)===2||N===1&&j.status!==E||j.lookahead)return m;for(N===1&&(n.adler=u(n.adler,L,X,0)),j.wrap=0,X>=j.w_size&&(N===0&&(te(j.head),j.strstart=0,j.block_start=0,j.insert=0),Z=new s.Buf8(j.w_size),s.arraySet(Z,L,X-j.w_size,j.w_size,0),L=Z,X=j.w_size),P=n.avail_in,U=n.next_in,$=n.input,n.avail_in=X,n.next_in=0,n.input=L,fe(j);j.lookahead>=A;){for(S=j.strstart,b=j.lookahead-(A-1);j.ins_h=(j.ins_h<<j.hash_shift^j.window[S+A-1])&j.hash_mask,j.prev[S&j.w_mask]=j.head[j.ins_h],j.head[j.ins_h]=S,S++,--b;);j.strstart=S,j.lookahead=A-1,fe(j)}return j.strstart+=j.lookahead,j.block_start=j.strstart,j.insert=j.lookahead,j.lookahead=0,j.match_length=j.prev_length=A-1,j.match_available=0,n.next_in=U,n.input=$,n.avail_in=P,j.wrap=N,f},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,d,i){d.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,d,i){d.exports=function(r,s){var o,u,v,_,w,C,f,m,l,h,p,g,k,y,x,z,I,F,A,B,K,E,T,c,D;o=r.state,u=r.next_in,c=r.input,v=u+(r.avail_in-5),_=r.next_out,D=r.output,w=_-(s-r.avail_out),C=_+(r.avail_out-257),f=o.dmax,m=o.wsize,l=o.whave,h=o.wnext,p=o.window,g=o.hold,k=o.bits,y=o.lencode,x=o.distcode,z=(1<<o.lenbits)-1,I=(1<<o.distbits)-1;e:do{k<15&&(g+=c[u++]<<k,k+=8,g+=c[u++]<<k,k+=8),F=y[g&z];t:for(;;){if(g>>>=A=F>>>24,k-=A,(A=F>>>16&255)===0)D[_++]=65535&F;else{if(!(16&A)){if(!(64&A)){F=y[(65535&F)+(g&(1<<A)-1)];continue t}if(32&A){o.mode=12;break e}r.msg="invalid literal/length code",o.mode=30;break e}B=65535&F,(A&=15)&&(k<A&&(g+=c[u++]<<k,k+=8),B+=g&(1<<A)-1,g>>>=A,k-=A),k<15&&(g+=c[u++]<<k,k+=8,g+=c[u++]<<k,k+=8),F=x[g&I];n:for(;;){if(g>>>=A=F>>>24,k-=A,!(16&(A=F>>>16&255))){if(!(64&A)){F=x[(65535&F)+(g&(1<<A)-1)];continue n}r.msg="invalid distance code",o.mode=30;break e}if(K=65535&F,k<(A&=15)&&(g+=c[u++]<<k,(k+=8)<A&&(g+=c[u++]<<k,k+=8)),f<(K+=g&(1<<A)-1)){r.msg="invalid distance too far back",o.mode=30;break e}if(g>>>=A,k-=A,(A=_-w)<K){if(l<(A=K-A)&&o.sane){r.msg="invalid distance too far back",o.mode=30;break e}if(T=p,(E=0)===h){if(E+=m-A,A<B){for(B-=A;D[_++]=p[E++],--A;);E=_-K,T=D}}else if(h<A){if(E+=m+h-A,(A-=h)<B){for(B-=A;D[_++]=p[E++],--A;);if(E=0,h<B){for(B-=A=h;D[_++]=p[E++],--A;);E=_-K,T=D}}}else if(E+=h-A,A<B){for(B-=A;D[_++]=p[E++],--A;);E=_-K,T=D}for(;2<B;)D[_++]=T[E++],D[_++]=T[E++],D[_++]=T[E++],B-=3;B&&(D[_++]=T[E++],1<B&&(D[_++]=T[E++]))}else{for(E=_-K;D[_++]=D[E++],D[_++]=D[E++],D[_++]=D[E++],2<(B-=3););B&&(D[_++]=D[E++],1<B&&(D[_++]=D[E++]))}break}}break}}while(u<v&&_<C);u-=B=k>>3,g&=(1<<(k-=B<<3))-1,r.next_in=u,r.next_out=_,r.avail_in=u<v?v-u+5:5-(u-v),r.avail_out=_<C?C-_+257:257-(_-C),o.hold=g,o.bits=k}},{}],49:[function(e,d,i){var r=e("../utils/common"),s=e("./adler32"),o=e("./crc32"),u=e("./inffast"),v=e("./inftrees"),_=1,w=2,C=0,f=-2,m=1,l=852,h=592;function p(E){return(E>>>24&255)+(E>>>8&65280)+((65280&E)<<8)+((255&E)<<24)}function g(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function k(E){var T;return E&&E.state?(T=E.state,E.total_in=E.total_out=T.total=0,E.msg="",T.wrap&&(E.adler=1&T.wrap),T.mode=m,T.last=0,T.havedict=0,T.dmax=32768,T.head=null,T.hold=0,T.bits=0,T.lencode=T.lendyn=new r.Buf32(l),T.distcode=T.distdyn=new r.Buf32(h),T.sane=1,T.back=-1,C):f}function y(E){var T;return E&&E.state?((T=E.state).wsize=0,T.whave=0,T.wnext=0,k(E)):f}function x(E,T){var c,D;return E&&E.state?(D=E.state,T<0?(c=0,T=-T):(c=1+(T>>4),T<48&&(T&=15)),T&&(T<8||15<T)?f:(D.window!==null&&D.wbits!==T&&(D.window=null),D.wrap=c,D.wbits=T,y(E))):f}function z(E,T){var c,D;return E?(D=new g,(E.state=D).window=null,(c=x(E,T))!==C&&(E.state=null),c):f}var I,F,A=!0;function B(E){if(A){var T;for(I=new r.Buf32(512),F=new r.Buf32(32),T=0;T<144;)E.lens[T++]=8;for(;T<256;)E.lens[T++]=9;for(;T<280;)E.lens[T++]=7;for(;T<288;)E.lens[T++]=8;for(v(_,E.lens,0,288,I,0,E.work,{bits:9}),T=0;T<32;)E.lens[T++]=5;v(w,E.lens,0,32,F,0,E.work,{bits:5}),A=!1}E.lencode=I,E.lenbits=9,E.distcode=F,E.distbits=5}function K(E,T,c,D){var Q,q=E.state;return q.window===null&&(q.wsize=1<<q.wbits,q.wnext=0,q.whave=0,q.window=new r.Buf8(q.wsize)),D>=q.wsize?(r.arraySet(q.window,T,c-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(D<(Q=q.wsize-q.wnext)&&(Q=D),r.arraySet(q.window,T,c-D,Q,q.wnext),(D-=Q)?(r.arraySet(q.window,T,c-D,D,0),q.wnext=D,q.whave=q.wsize):(q.wnext+=Q,q.wnext===q.wsize&&(q.wnext=0),q.whave<q.wsize&&(q.whave+=Q))),0}i.inflateReset=y,i.inflateReset2=x,i.inflateResetKeep=k,i.inflateInit=function(E){return z(E,15)},i.inflateInit2=z,i.inflate=function(E,T){var c,D,Q,q,re,M,te,R,O,J,V,G,fe,we,oe,ae,ge,de,ke,Ne,n,L,j,S,b=0,N=new r.Buf8(4),P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!E||!E.state||!E.output||!E.input&&E.avail_in!==0)return f;(c=E.state).mode===12&&(c.mode=13),re=E.next_out,Q=E.output,te=E.avail_out,q=E.next_in,D=E.input,M=E.avail_in,R=c.hold,O=c.bits,J=M,V=te,L=C;e:for(;;)switch(c.mode){case m:if(c.wrap===0){c.mode=13;break}for(;O<16;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}if(2&c.wrap&&R===35615){N[c.check=0]=255&R,N[1]=R>>>8&255,c.check=o(c.check,N,2,0),O=R=0,c.mode=2;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&R)<<8)+(R>>8))%31){E.msg="incorrect header check",c.mode=30;break}if((15&R)!=8){E.msg="unknown compression method",c.mode=30;break}if(O-=4,n=8+(15&(R>>>=4)),c.wbits===0)c.wbits=n;else if(n>c.wbits){E.msg="invalid window size",c.mode=30;break}c.dmax=1<<n,E.adler=c.check=1,c.mode=512&R?10:12,O=R=0;break;case 2:for(;O<16;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}if(c.flags=R,(255&c.flags)!=8){E.msg="unknown compression method",c.mode=30;break}if(57344&c.flags){E.msg="unknown header flags set",c.mode=30;break}c.head&&(c.head.text=R>>8&1),512&c.flags&&(N[0]=255&R,N[1]=R>>>8&255,c.check=o(c.check,N,2,0)),O=R=0,c.mode=3;case 3:for(;O<32;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}c.head&&(c.head.time=R),512&c.flags&&(N[0]=255&R,N[1]=R>>>8&255,N[2]=R>>>16&255,N[3]=R>>>24&255,c.check=o(c.check,N,4,0)),O=R=0,c.mode=4;case 4:for(;O<16;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}c.head&&(c.head.xflags=255&R,c.head.os=R>>8),512&c.flags&&(N[0]=255&R,N[1]=R>>>8&255,c.check=o(c.check,N,2,0)),O=R=0,c.mode=5;case 5:if(1024&c.flags){for(;O<16;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}c.length=R,c.head&&(c.head.extra_len=R),512&c.flags&&(N[0]=255&R,N[1]=R>>>8&255,c.check=o(c.check,N,2,0)),O=R=0}else c.head&&(c.head.extra=null);c.mode=6;case 6:if(1024&c.flags&&(M<(G=c.length)&&(G=M),G&&(c.head&&(n=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),r.arraySet(c.head.extra,D,q,G,n)),512&c.flags&&(c.check=o(c.check,D,G,q)),M-=G,q+=G,c.length-=G),c.length))break e;c.length=0,c.mode=7;case 7:if(2048&c.flags){if(M===0)break e;for(G=0;n=D[q+G++],c.head&&n&&c.length<65536&&(c.head.name+=String.fromCharCode(n)),n&&G<M;);if(512&c.flags&&(c.check=o(c.check,D,G,q)),M-=G,q+=G,n)break e}else c.head&&(c.head.name=null);c.length=0,c.mode=8;case 8:if(4096&c.flags){if(M===0)break e;for(G=0;n=D[q+G++],c.head&&n&&c.length<65536&&(c.head.comment+=String.fromCharCode(n)),n&&G<M;);if(512&c.flags&&(c.check=o(c.check,D,G,q)),M-=G,q+=G,n)break e}else c.head&&(c.head.comment=null);c.mode=9;case 9:if(512&c.flags){for(;O<16;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}if(R!==(65535&c.check)){E.msg="header crc mismatch",c.mode=30;break}O=R=0}c.head&&(c.head.hcrc=c.flags>>9&1,c.head.done=!0),E.adler=c.check=0,c.mode=12;break;case 10:for(;O<32;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}E.adler=c.check=p(R),O=R=0,c.mode=11;case 11:if(c.havedict===0)return E.next_out=re,E.avail_out=te,E.next_in=q,E.avail_in=M,c.hold=R,c.bits=O,2;E.adler=c.check=1,c.mode=12;case 12:if(T===5||T===6)break e;case 13:if(c.last){R>>>=7&O,O-=7&O,c.mode=27;break}for(;O<3;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}switch(c.last=1&R,O-=1,3&(R>>>=1)){case 0:c.mode=14;break;case 1:if(B(c),c.mode=20,T!==6)break;R>>>=2,O-=2;break e;case 2:c.mode=17;break;case 3:E.msg="invalid block type",c.mode=30}R>>>=2,O-=2;break;case 14:for(R>>>=7&O,O-=7&O;O<32;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}if((65535&R)!=(R>>>16^65535)){E.msg="invalid stored block lengths",c.mode=30;break}if(c.length=65535&R,O=R=0,c.mode=15,T===6)break e;case 15:c.mode=16;case 16:if(G=c.length){if(M<G&&(G=M),te<G&&(G=te),G===0)break e;r.arraySet(Q,D,q,G,re),M-=G,q+=G,te-=G,re+=G,c.length-=G;break}c.mode=12;break;case 17:for(;O<14;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}if(c.nlen=257+(31&R),R>>>=5,O-=5,c.ndist=1+(31&R),R>>>=5,O-=5,c.ncode=4+(15&R),R>>>=4,O-=4,286<c.nlen||30<c.ndist){E.msg="too many length or distance symbols",c.mode=30;break}c.have=0,c.mode=18;case 18:for(;c.have<c.ncode;){for(;O<3;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}c.lens[P[c.have++]]=7&R,R>>>=3,O-=3}for(;c.have<19;)c.lens[P[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,j={bits:c.lenbits},L=v(0,c.lens,0,19,c.lencode,0,c.work,j),c.lenbits=j.bits,L){E.msg="invalid code lengths set",c.mode=30;break}c.have=0,c.mode=19;case 19:for(;c.have<c.nlen+c.ndist;){for(;ae=(b=c.lencode[R&(1<<c.lenbits)-1])>>>16&255,ge=65535&b,!((oe=b>>>24)<=O);){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}if(ge<16)R>>>=oe,O-=oe,c.lens[c.have++]=ge;else{if(ge===16){for(S=oe+2;O<S;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}if(R>>>=oe,O-=oe,c.have===0){E.msg="invalid bit length repeat",c.mode=30;break}n=c.lens[c.have-1],G=3+(3&R),R>>>=2,O-=2}else if(ge===17){for(S=oe+3;O<S;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}O-=oe,n=0,G=3+(7&(R>>>=oe)),R>>>=3,O-=3}else{for(S=oe+7;O<S;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}O-=oe,n=0,G=11+(127&(R>>>=oe)),R>>>=7,O-=7}if(c.have+G>c.nlen+c.ndist){E.msg="invalid bit length repeat",c.mode=30;break}for(;G--;)c.lens[c.have++]=n}}if(c.mode===30)break;if(c.lens[256]===0){E.msg="invalid code -- missing end-of-block",c.mode=30;break}if(c.lenbits=9,j={bits:c.lenbits},L=v(_,c.lens,0,c.nlen,c.lencode,0,c.work,j),c.lenbits=j.bits,L){E.msg="invalid literal/lengths set",c.mode=30;break}if(c.distbits=6,c.distcode=c.distdyn,j={bits:c.distbits},L=v(w,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,j),c.distbits=j.bits,L){E.msg="invalid distances set",c.mode=30;break}if(c.mode=20,T===6)break e;case 20:c.mode=21;case 21:if(6<=M&&258<=te){E.next_out=re,E.avail_out=te,E.next_in=q,E.avail_in=M,c.hold=R,c.bits=O,u(E,V),re=E.next_out,Q=E.output,te=E.avail_out,q=E.next_in,D=E.input,M=E.avail_in,R=c.hold,O=c.bits,c.mode===12&&(c.back=-1);break}for(c.back=0;ae=(b=c.lencode[R&(1<<c.lenbits)-1])>>>16&255,ge=65535&b,!((oe=b>>>24)<=O);){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}if(ae&&!(240&ae)){for(de=oe,ke=ae,Ne=ge;ae=(b=c.lencode[Ne+((R&(1<<de+ke)-1)>>de)])>>>16&255,ge=65535&b,!(de+(oe=b>>>24)<=O);){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}R>>>=de,O-=de,c.back+=de}if(R>>>=oe,O-=oe,c.back+=oe,c.length=ge,ae===0){c.mode=26;break}if(32&ae){c.back=-1,c.mode=12;break}if(64&ae){E.msg="invalid literal/length code",c.mode=30;break}c.extra=15&ae,c.mode=22;case 22:if(c.extra){for(S=c.extra;O<S;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}c.length+=R&(1<<c.extra)-1,R>>>=c.extra,O-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=23;case 23:for(;ae=(b=c.distcode[R&(1<<c.distbits)-1])>>>16&255,ge=65535&b,!((oe=b>>>24)<=O);){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}if(!(240&ae)){for(de=oe,ke=ae,Ne=ge;ae=(b=c.distcode[Ne+((R&(1<<de+ke)-1)>>de)])>>>16&255,ge=65535&b,!(de+(oe=b>>>24)<=O);){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}R>>>=de,O-=de,c.back+=de}if(R>>>=oe,O-=oe,c.back+=oe,64&ae){E.msg="invalid distance code",c.mode=30;break}c.offset=ge,c.extra=15&ae,c.mode=24;case 24:if(c.extra){for(S=c.extra;O<S;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}c.offset+=R&(1<<c.extra)-1,R>>>=c.extra,O-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){E.msg="invalid distance too far back",c.mode=30;break}c.mode=25;case 25:if(te===0)break e;if(G=V-te,c.offset>G){if((G=c.offset-G)>c.whave&&c.sane){E.msg="invalid distance too far back",c.mode=30;break}fe=G>c.wnext?(G-=c.wnext,c.wsize-G):c.wnext-G,G>c.length&&(G=c.length),we=c.window}else we=Q,fe=re-c.offset,G=c.length;for(te<G&&(G=te),te-=G,c.length-=G;Q[re++]=we[fe++],--G;);c.length===0&&(c.mode=21);break;case 26:if(te===0)break e;Q[re++]=c.length,te--,c.mode=21;break;case 27:if(c.wrap){for(;O<32;){if(M===0)break e;M--,R|=D[q++]<<O,O+=8}if(V-=te,E.total_out+=V,c.total+=V,V&&(E.adler=c.check=c.flags?o(c.check,Q,V,re-V):s(c.check,Q,V,re-V)),V=te,(c.flags?R:p(R))!==c.check){E.msg="incorrect data check",c.mode=30;break}O=R=0}c.mode=28;case 28:if(c.wrap&&c.flags){for(;O<32;){if(M===0)break e;M--,R+=D[q++]<<O,O+=8}if(R!==(4294967295&c.total)){E.msg="incorrect length check",c.mode=30;break}O=R=0}c.mode=29;case 29:L=1;break e;case 30:L=-3;break e;case 31:return-4;case 32:default:return f}return E.next_out=re,E.avail_out=te,E.next_in=q,E.avail_in=M,c.hold=R,c.bits=O,(c.wsize||V!==E.avail_out&&c.mode<30&&(c.mode<27||T!==4))&&K(E,E.output,E.next_out,V-E.avail_out)?(c.mode=31,-4):(J-=E.avail_in,V-=E.avail_out,E.total_in+=J,E.total_out+=V,c.total+=V,c.wrap&&V&&(E.adler=c.check=c.flags?o(c.check,Q,V,E.next_out-V):s(c.check,Q,V,E.next_out-V)),E.data_type=c.bits+(c.last?64:0)+(c.mode===12?128:0)+(c.mode===20||c.mode===15?256:0),(J==0&&V===0||T===4)&&L===C&&(L=-5),L)},i.inflateEnd=function(E){if(!E||!E.state)return f;var T=E.state;return T.window&&(T.window=null),E.state=null,C},i.inflateGetHeader=function(E,T){var c;return E&&E.state&&2&(c=E.state).wrap?((c.head=T).done=!1,C):f},i.inflateSetDictionary=function(E,T){var c,D=T.length;return E&&E.state?(c=E.state).wrap!==0&&c.mode!==11?f:c.mode===11&&s(1,T,D,0)!==c.check?-3:K(E,T,D,D)?(c.mode=31,-4):(c.havedict=1,C):f},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,d,i){var r=e("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],u=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],v=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];d.exports=function(_,w,C,f,m,l,h,p){var g,k,y,x,z,I,F,A,B,K=p.bits,E=0,T=0,c=0,D=0,Q=0,q=0,re=0,M=0,te=0,R=0,O=null,J=0,V=new r.Buf16(16),G=new r.Buf16(16),fe=null,we=0;for(E=0;E<=15;E++)V[E]=0;for(T=0;T<f;T++)V[w[C+T]]++;for(Q=K,D=15;1<=D&&V[D]===0;D--);if(D<Q&&(Q=D),D===0)return m[l++]=20971520,m[l++]=20971520,p.bits=1,0;for(c=1;c<D&&V[c]===0;c++);for(Q<c&&(Q=c),E=M=1;E<=15;E++)if(M<<=1,(M-=V[E])<0)return-1;if(0<M&&(_===0||D!==1))return-1;for(G[1]=0,E=1;E<15;E++)G[E+1]=G[E]+V[E];for(T=0;T<f;T++)w[C+T]!==0&&(h[G[w[C+T]]++]=T);if(I=_===0?(O=fe=h,19):_===1?(O=s,J-=257,fe=o,we-=257,256):(O=u,fe=v,-1),E=c,z=l,re=T=R=0,y=-1,x=(te=1<<(q=Q))-1,_===1&&852<te||_===2&&592<te)return 1;for(;;){for(F=E-re,B=h[T]<I?(A=0,h[T]):h[T]>I?(A=fe[we+h[T]],O[J+h[T]]):(A=96,0),g=1<<E-re,c=k=1<<q;m[z+(R>>re)+(k-=g)]=F<<24|A<<16|B|0,k!==0;);for(g=1<<E-1;R&g;)g>>=1;if(g!==0?(R&=g-1,R+=g):R=0,T++,--V[E]==0){if(E===D)break;E=w[C+h[T]]}if(Q<E&&(R&x)!==y){for(re===0&&(re=Q),z+=c,M=1<<(q=E-re);q+re<D&&!((M-=V[q+re])<=0);)q++,M<<=1;if(te+=1<<q,_===1&&852<te||_===2&&592<te)return 1;m[y=R&x]=Q<<24|q<<16|z-l|0}}return R!==0&&(m[z+R]=E-re<<24|64<<16|0),p.bits=Q,0}},{"../utils/common":41}],51:[function(e,d,i){d.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,d,i){var r=e("../utils/common"),s=0,o=1;function u(b){for(var N=b.length;0<=--N;)b[N]=0}var v=0,_=29,w=256,C=w+1+_,f=30,m=19,l=2*C+1,h=15,p=16,g=7,k=256,y=16,x=17,z=18,I=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],F=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],B=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],K=new Array(2*(C+2));u(K);var E=new Array(2*f);u(E);var T=new Array(512);u(T);var c=new Array(256);u(c);var D=new Array(_);u(D);var Q,q,re,M=new Array(f);function te(b,N,P,U,$){this.static_tree=b,this.extra_bits=N,this.extra_base=P,this.elems=U,this.max_length=$,this.has_stree=b&&b.length}function R(b,N){this.dyn_tree=b,this.max_code=0,this.stat_desc=N}function O(b){return b<256?T[b]:T[256+(b>>>7)]}function J(b,N){b.pending_buf[b.pending++]=255&N,b.pending_buf[b.pending++]=N>>>8&255}function V(b,N,P){b.bi_valid>p-P?(b.bi_buf|=N<<b.bi_valid&65535,J(b,b.bi_buf),b.bi_buf=N>>p-b.bi_valid,b.bi_valid+=P-p):(b.bi_buf|=N<<b.bi_valid&65535,b.bi_valid+=P)}function G(b,N,P){V(b,P[2*N],P[2*N+1])}function fe(b,N){for(var P=0;P|=1&b,b>>>=1,P<<=1,0<--N;);return P>>>1}function we(b,N,P){var U,$,Z=new Array(h+1),X=0;for(U=1;U<=h;U++)Z[U]=X=X+P[U-1]<<1;for($=0;$<=N;$++){var H=b[2*$+1];H!==0&&(b[2*$]=fe(Z[H]++,H))}}function oe(b){var N;for(N=0;N<C;N++)b.dyn_ltree[2*N]=0;for(N=0;N<f;N++)b.dyn_dtree[2*N]=0;for(N=0;N<m;N++)b.bl_tree[2*N]=0;b.dyn_ltree[2*k]=1,b.opt_len=b.static_len=0,b.last_lit=b.matches=0}function ae(b){8<b.bi_valid?J(b,b.bi_buf):0<b.bi_valid&&(b.pending_buf[b.pending++]=b.bi_buf),b.bi_buf=0,b.bi_valid=0}function ge(b,N,P,U){var $=2*N,Z=2*P;return b[$]<b[Z]||b[$]===b[Z]&&U[N]<=U[P]}function de(b,N,P){for(var U=b.heap[P],$=P<<1;$<=b.heap_len&&($<b.heap_len&&ge(N,b.heap[$+1],b.heap[$],b.depth)&&$++,!ge(N,U,b.heap[$],b.depth));)b.heap[P]=b.heap[$],P=$,$<<=1;b.heap[P]=U}function ke(b,N,P){var U,$,Z,X,H=0;if(b.last_lit!==0)for(;U=b.pending_buf[b.d_buf+2*H]<<8|b.pending_buf[b.d_buf+2*H+1],$=b.pending_buf[b.l_buf+H],H++,U===0?G(b,$,N):(G(b,(Z=c[$])+w+1,N),(X=I[Z])!==0&&V(b,$-=D[Z],X),G(b,Z=O(--U),P),(X=F[Z])!==0&&V(b,U-=M[Z],X)),H<b.last_lit;);G(b,k,N)}function Ne(b,N){var P,U,$,Z=N.dyn_tree,X=N.stat_desc.static_tree,H=N.stat_desc.has_stree,ee=N.stat_desc.elems,ue=-1;for(b.heap_len=0,b.heap_max=l,P=0;P<ee;P++)Z[2*P]!==0?(b.heap[++b.heap_len]=ue=P,b.depth[P]=0):Z[2*P+1]=0;for(;b.heap_len<2;)Z[2*($=b.heap[++b.heap_len]=ue<2?++ue:0)]=1,b.depth[$]=0,b.opt_len--,H&&(b.static_len-=X[2*$+1]);for(N.max_code=ue,P=b.heap_len>>1;1<=P;P--)de(b,Z,P);for($=ee;P=b.heap[1],b.heap[1]=b.heap[b.heap_len--],de(b,Z,1),U=b.heap[1],b.heap[--b.heap_max]=P,b.heap[--b.heap_max]=U,Z[2*$]=Z[2*P]+Z[2*U],b.depth[$]=(b.depth[P]>=b.depth[U]?b.depth[P]:b.depth[U])+1,Z[2*P+1]=Z[2*U+1]=$,b.heap[1]=$++,de(b,Z,1),2<=b.heap_len;);b.heap[--b.heap_max]=b.heap[1],function(se,Ee){var nt,Oe,rt,pe,gt,Rt,Te=Ee.dyn_tree,vn=Ee.max_code,Nr=Ee.stat_desc.static_tree,zr=Ee.stat_desc.has_stree,Rr=Ee.stat_desc.extra_bits,_n=Ee.stat_desc.extra_base,it=Ee.stat_desc.max_length,yt=0;for(pe=0;pe<=h;pe++)se.bl_count[pe]=0;for(Te[2*se.heap[se.heap_max]+1]=0,nt=se.heap_max+1;nt<l;nt++)it<(pe=Te[2*Te[2*(Oe=se.heap[nt])+1]+1]+1)&&(pe=it,yt++),Te[2*Oe+1]=pe,vn<Oe||(se.bl_count[pe]++,gt=0,_n<=Oe&&(gt=Rr[Oe-_n]),Rt=Te[2*Oe],se.opt_len+=Rt*(pe+gt),zr&&(se.static_len+=Rt*(Nr[2*Oe+1]+gt)));if(yt!==0){do{for(pe=it-1;se.bl_count[pe]===0;)pe--;se.bl_count[pe]--,se.bl_count[pe+1]+=2,se.bl_count[it]--,yt-=2}while(0<yt);for(pe=it;pe!==0;pe--)for(Oe=se.bl_count[pe];Oe!==0;)vn<(rt=se.heap[--nt])||(Te[2*rt+1]!==pe&&(se.opt_len+=(pe-Te[2*rt+1])*Te[2*rt],Te[2*rt+1]=pe),Oe--)}}(b,N),we(Z,ue,b.bl_count)}function n(b,N,P){var U,$,Z=-1,X=N[1],H=0,ee=7,ue=4;for(X===0&&(ee=138,ue=3),N[2*(P+1)+1]=65535,U=0;U<=P;U++)$=X,X=N[2*(U+1)+1],++H<ee&&$===X||(H<ue?b.bl_tree[2*$]+=H:$!==0?($!==Z&&b.bl_tree[2*$]++,b.bl_tree[2*y]++):H<=10?b.bl_tree[2*x]++:b.bl_tree[2*z]++,Z=$,ue=(H=0)===X?(ee=138,3):$===X?(ee=6,3):(ee=7,4))}function L(b,N,P){var U,$,Z=-1,X=N[1],H=0,ee=7,ue=4;for(X===0&&(ee=138,ue=3),U=0;U<=P;U++)if($=X,X=N[2*(U+1)+1],!(++H<ee&&$===X)){if(H<ue)for(;G(b,$,b.bl_tree),--H!=0;);else $!==0?($!==Z&&(G(b,$,b.bl_tree),H--),G(b,y,b.bl_tree),V(b,H-3,2)):H<=10?(G(b,x,b.bl_tree),V(b,H-3,3)):(G(b,z,b.bl_tree),V(b,H-11,7));Z=$,ue=(H=0)===X?(ee=138,3):$===X?(ee=6,3):(ee=7,4)}}u(M);var j=!1;function S(b,N,P,U){V(b,(v<<1)+(U?1:0),3),function($,Z,X,H){ae($),J($,X),J($,~X),r.arraySet($.pending_buf,$.window,Z,X,$.pending),$.pending+=X}(b,N,P)}i._tr_init=function(b){j||(function(){var N,P,U,$,Z,X=new Array(h+1);for($=U=0;$<_-1;$++)for(D[$]=U,N=0;N<1<<I[$];N++)c[U++]=$;for(c[U-1]=$,$=Z=0;$<16;$++)for(M[$]=Z,N=0;N<1<<F[$];N++)T[Z++]=$;for(Z>>=7;$<f;$++)for(M[$]=Z<<7,N=0;N<1<<F[$]-7;N++)T[256+Z++]=$;for(P=0;P<=h;P++)X[P]=0;for(N=0;N<=143;)K[2*N+1]=8,N++,X[8]++;for(;N<=255;)K[2*N+1]=9,N++,X[9]++;for(;N<=279;)K[2*N+1]=7,N++,X[7]++;for(;N<=287;)K[2*N+1]=8,N++,X[8]++;for(we(K,C+1,X),N=0;N<f;N++)E[2*N+1]=5,E[2*N]=fe(N,5);Q=new te(K,I,w+1,C,h),q=new te(E,F,0,f,h),re=new te(new Array(0),A,0,m,g)}(),j=!0),b.l_desc=new R(b.dyn_ltree,Q),b.d_desc=new R(b.dyn_dtree,q),b.bl_desc=new R(b.bl_tree,re),b.bi_buf=0,b.bi_valid=0,oe(b)},i._tr_stored_block=S,i._tr_flush_block=function(b,N,P,U){var $,Z,X=0;0<b.level?(b.strm.data_type===2&&(b.strm.data_type=function(H){var ee,ue=4093624447;for(ee=0;ee<=31;ee++,ue>>>=1)if(1&ue&&H.dyn_ltree[2*ee]!==0)return s;if(H.dyn_ltree[18]!==0||H.dyn_ltree[20]!==0||H.dyn_ltree[26]!==0)return o;for(ee=32;ee<w;ee++)if(H.dyn_ltree[2*ee]!==0)return o;return s}(b)),Ne(b,b.l_desc),Ne(b,b.d_desc),X=function(H){var ee;for(n(H,H.dyn_ltree,H.l_desc.max_code),n(H,H.dyn_dtree,H.d_desc.max_code),Ne(H,H.bl_desc),ee=m-1;3<=ee&&H.bl_tree[2*B[ee]+1]===0;ee--);return H.opt_len+=3*(ee+1)+5+5+4,ee}(b),$=b.opt_len+3+7>>>3,(Z=b.static_len+3+7>>>3)<=$&&($=Z)):$=Z=P+5,P+4<=$&&N!==-1?S(b,N,P,U):b.strategy===4||Z===$?(V(b,2+(U?1:0),3),ke(b,K,E)):(V(b,4+(U?1:0),3),function(H,ee,ue,se){var Ee;for(V(H,ee-257,5),V(H,ue-1,5),V(H,se-4,4),Ee=0;Ee<se;Ee++)V(H,H.bl_tree[2*B[Ee]+1],3);L(H,H.dyn_ltree,ee-1),L(H,H.dyn_dtree,ue-1)}(b,b.l_desc.max_code+1,b.d_desc.max_code+1,X+1),ke(b,b.dyn_ltree,b.dyn_dtree)),oe(b),U&&ae(b)},i._tr_tally=function(b,N,P){return b.pending_buf[b.d_buf+2*b.last_lit]=N>>>8&255,b.pending_buf[b.d_buf+2*b.last_lit+1]=255&N,b.pending_buf[b.l_buf+b.last_lit]=255&P,b.last_lit++,N===0?b.dyn_ltree[2*P]++:(b.matches++,N--,b.dyn_ltree[2*(c[P]+w+1)]++,b.dyn_dtree[2*O(N)]++),b.last_lit===b.lit_bufsize-1},i._tr_align=function(b){V(b,2,3),G(b,k,K),function(N){N.bi_valid===16?(J(N,N.bi_buf),N.bi_buf=0,N.bi_valid=0):8<=N.bi_valid&&(N.pending_buf[N.pending++]=255&N.bi_buf,N.bi_buf>>=8,N.bi_valid-=8)}(b)}},{"../utils/common":41}],53:[function(e,d,i){d.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,d,i){(function(r){(function(s,o){if(!s.setImmediate){var u,v,_,w,C=1,f={},m=!1,l=s.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(s);h=h&&h.setTimeout?h:s,u={}.toString.call(s.process)==="[object process]"?function(y){process.nextTick(function(){g(y)})}:function(){if(s.postMessage&&!s.importScripts){var y=!0,x=s.onmessage;return s.onmessage=function(){y=!1},s.postMessage("","*"),s.onmessage=x,y}}()?(w="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",k,!1):s.attachEvent("onmessage",k),function(y){s.postMessage(w+y,"*")}):s.MessageChannel?((_=new MessageChannel).port1.onmessage=function(y){g(y.data)},function(y){_.port2.postMessage(y)}):l&&"onreadystatechange"in l.createElement("script")?(v=l.documentElement,function(y){var x=l.createElement("script");x.onreadystatechange=function(){g(y),x.onreadystatechange=null,v.removeChild(x),x=null},v.appendChild(x)}):function(y){setTimeout(g,0,y)},h.setImmediate=function(y){typeof y!="function"&&(y=new Function(""+y));for(var x=new Array(arguments.length-1),z=0;z<x.length;z++)x[z]=arguments[z+1];var I={callback:y,args:x};return f[C]=I,u(C),C++},h.clearImmediate=p}function p(y){delete f[y]}function g(y){if(m)setTimeout(g,0,y);else{var x=f[y];if(x){m=!0;try{(function(z){var I=z.callback,F=z.args;switch(F.length){case 0:I();break;case 1:I(F[0]);break;case 2:I(F[0],F[1]);break;case 3:I(F[0],F[1],F[2]);break;default:I.apply(o,F)}})(x)}finally{p(y),m=!1}}}}function k(y){y.source===s&&typeof y.data=="string"&&y.data.indexOf(w)===0&&g(+y.data.slice(w.length))}})(typeof self>"u"?r===void 0?this:r:self)}).call(this,typeof ut<"u"?ut:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Yt);var lr=Yt.exports;const cr=ar(lr),He=(t,a)=>{const e=t==null?void 0:t.getAttribute(a);return e==null||e===""?null:e};function Xt(t){const a=Number(He(t,"type")??0),e=He(t,"solution");return{type:a,typeName:_e(a),schemaName:He(t,"schemaName"),displayName:He(t,"displayName"),id:He(t,"id"),solution:e&&e.replace(/\s*\([\d.]+\)\s*$/,"").trim()||null,parentSchemaName:He(t,"parentSchemaName")}}const $e=t=>t.schemaName??t.displayName??t.id??"(unnamed)";function ur(t){const a=new DOMParser().parseFromString(t,"application/xml");if(a.getElementsByTagName("parsererror").length)throw new Error("solution.xml: invalid XML");const e=a.querySelector("ImportExportXml > SolutionManifest");if(!e)throw new Error("solution.xml: SolutionManifest not found");const d=r=>{var s,o;return((o=(s=e.querySelector(r))==null?void 0:s.textContent)==null?void 0:o.trim())??""},i=Array.from(e.querySelectorAll(":scope > MissingDependencies > MissingDependency")).map(r=>({required:Xt(r.querySelector(":scope > Required")),dependent:Xt(r.querySelector(":scope > Dependent"))}));return{uniqueName:d(":scope > UniqueName"),version:d(":scope > Version"),managed:d(":scope > Managed")!=="0"&&d(":scope > Managed")!=="",missing:i}}function dr(t,a,e){const d=new Map;for(const i of t){const r=i.required,s=Pe(a,null,$e(r))||!!r.solution&&Pe(a,{uniqueName:r.solution,prefix:""},$e(r)),o=!!r.solution&&!!(e!=null&&e.has(r.solution.toLowerCase()));if(!s&&!(e&&r.solution&&!o))continue;const u=i.dependent,v=`${u.type}:${(u.id??$e(u)).toLowerCase()}:${u.parentSchemaName??""}`,_=d.get(v)??{key:v,dependent:u,required:[],status:"safe"};_.required.some(w=>w.type===r.type&&$e(w)===$e(r))||_.required.push({...r,safe:o}),o||(_.status="blocker"),d.set(v,_)}return[...d.values()].sort((i,r)=>(i.status===r.status?0:i.status==="blocker"?-1:1)||i.dependent.type-r.dependent.type||$e(i.dependent).localeCompare($e(r.dependent)))}async function fr(t,a,e,d){let i;try{i=await cr.loadAsync(a)}catch{throw new Error(`${t}: not a zip file`)}const r=i.file(/^solution\.xml$/i)[0];if(!r)throw new Error(`${t}: solution.xml not found (is this a solution export?)`);const s=ur(await r.async("string"));return{fileName:t,uniqueName:s.uniqueName,version:s.version,managed:s.managed,total:s.missing.length,groups:dr(s.missing,e,d)}}const Jt=()=>window,je=()=>Jt().toolboxAPI,Qt=()=>Jt().dataverseAPI,en=()=>{var t;return!!((t=je())!=null&&t.connections)&&!!Qt()};async function tn(){var i,r;const t=je();if(!(t!=null&&t.connections))return[];const a=[],e=await t.connections.getActiveConnection().catch(()=>null);e&&a.push({target:"primary",conn:e});const d=await((r=(i=t.connections).getSecondaryConnection)==null?void 0:r.call(i).catch(()=>null));return d&&a.push({target:"secondary",conn:d}),a}function hr(t){var a,e;try{(e=(a=je())==null?void 0:a.events)==null||e.on((d,i)=>{typeof(i==null?void 0:i.event)=="string"&&i.event.startsWith("connection:")&&t()})}catch{}}async function pr(t){var d,i,r,s;const a=je();let e=(d=window.matchMedia)!=null&&d.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light";if((i=a==null?void 0:a.utils)!=null&&i.getCurrentTheme)try{e=await a.utils.getCurrentTheme()}catch{}t(e);try{(r=a==null?void 0:a.events)==null||r.on((o,u)=>{var v;if((u==null?void 0:u.event)==="settings:updated"){const _=(v=u.data)==null?void 0:v.theme;(_==="light"||_==="dark")&&t(_)}})}catch{}a||(s=window.matchMedia)==null||s.call(window,"(prefers-color-scheme: dark)").addEventListener("change",o=>t(o.matches?"dark":"light"))}async function be(t,a,e="info"){var i;const d=je();if((i=d==null?void 0:d.utils)!=null&&i.showNotification)try{await d.utils.showNotification({title:t,body:a,type:e,duration:4e3});return}catch{}console[e==="error"?"error":"log"](`${t}: ${a}`)}async function nn(t,a,e="application/json"){var s;const d=je();if((s=d==null?void 0:d.fileSystem)!=null&&s.saveFile)return!!await d.fileSystem.saveFile(t,a);const i=URL.createObjectURL(new Blob([a],{type:e})),r=document.createElement("a");return r.href=i,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e3),!0}function mr(t){if(t instanceof Uint8Array)return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);const a=t;if(a&&a.type==="Buffer"&&Array.isArray(a.data))return Uint8Array.from(a.data);if(Array.isArray(t))return Uint8Array.from(t);throw new Error("Unsupported binary payload from host")}function rn(t,a){return new Promise(e=>{const d=document.createElement("input");d.type="file",d.accept=t,d.multiple=a,d.addEventListener("change",()=>e(Array.from(d.files??[]))),d.addEventListener("cancel",()=>e([])),d.click()})}async function gr(t){var d;const a=je();if((d=a==null?void 0:a.fileSystem)!=null&&d.selectPath){const i=await a.fileSystem.selectPath({type:"file",title:t.title,filters:[{name:t.extensions.map(s=>s.toUpperCase()).join(" / "),extensions:t.extensions},{name:"All files",extensions:["*"]}]});if(!i)return[];const r=await a.fileSystem.readBinary(i);return[{name:i.split(/[\\/]/).pop()??i,data:mr(r)}]}const e=await rn(t.extensions.map(i=>`.${i}`).join(","),!!t.multiple);return Promise.all(e.map(async i=>({name:i.name,data:new Uint8Array(await i.arrayBuffer())})))}async function yr(t){var d;const a=je();if((d=a==null?void 0:a.fileSystem)!=null&&d.selectPath){const i=await a.fileSystem.selectPath({type:"file",title:t.title,filters:[{name:t.extensions.join("/"),extensions:t.extensions}]});return i?{name:i.split(/[\\/]/).pop()??i,text:await a.fileSystem.readText(i)}:null}const[e]=await rn(t.extensions.map(i=>`.${i}`).join(","),!1);return e?{name:e.name,text:await e.text()}:null}let Ve=[],Ue=[],De=null,Ct=new Lt;const on=new Map;let Ye,ie=null;const Re=new Map;let Se=null,Ce=[],Xe=!1,Je=null,Le=null,Et=0,At=!1,It=!1,ft=!1,ce=null;const Ge=()=>Qt(),ve=()=>Ve.find(t=>t.target==="primary"),sn=()=>Ve.find(t=>t.target==="secondary"),Qe=t=>!!t&&(t.conn.environment==="Production"||/\bprod/i.test(t.conn.name)),ht=()=>{var e;const t=((e=ve())==null?void 0:e.conn.url)??"";let a=on.get(t);return a||on.set(t,a=new Map),a},pt=(t,a)=>!!t&&!!a&&t.replace(/\/+$/,"").toLowerCase()===a.replace(/\/+$/,"").toLowerCase(),an=t=>t.map(a=>`${a.target}:${a.conn.id}:${a.conn.url}`).join("|"),ln=async()=>(await tn().catch(()=>[])).find(t=>t.target==="primary"),et=()=>{Se=null,Ce=[],Xe=!1,Je=null,Le=null},Nt=()=>{const t=er(Y("#filter").value);return t.length?t:Cn};function Ie(t){const a=Y("#status");a.hidden=!t,a.textContent=t??""}function cn(t,a){const e=W("span",{class:"dot"});return t.conn.environmentColor&&(e.style.background=t.conn.environmentColor),W("span",{class:"connchip",title:t.conn.url},e,W("span",{class:"env"},t.conn.name),W("span",{class:"kind"},`${a} · ${t.conn.environment}`))}function un(){const t=ve(),a=ie==null?void 0:ie.solution;return!t||!a?"https://make.powerapps.com/":Ye?`https://make.powerapps.com/environments/${Ye}/solutions/${a.id}`:`${t.conn.url.replace(/\/+$/,"")}/tools/solution/edit.aspx?id=${a.id}`}async function dn(){const t=an(Ve);Ve=await tn(),Ct=new Lt,Ye=void 0,an(Ve)!==t&&(Et++,ie=null,Re.clear(),et(),ce=null,Y("#fix-results").replaceChildren(),Y("#restore-results").replaceChildren(),Y("#restore-file").textContent="",Ke(),Me());const a=Y("#conn");a.replaceChildren();const e=ve(),d=sn();e&&a.append(cn(e,"dev")),d&&a.append(cn(d,"target")),e||a.append(W("span",{class:"caption"},en()?"No connection. Pick a primary (dev) connection in ToolBox.":"Standalone: Offline tab only."));const i=Ge();if(Ue=[],De=null,i&&e){Ie("Loading solutions…");try{Ue=await vt(i,"primary")}catch(u){await be("Load failed",u.message,"error")}if(d)try{De=new Set((await vt(i,"secondary")).map(u=>u.uniqueName.toLowerCase()))}catch(u){await be("Target load failed",`${d.conn.name}: ${u.message}`,"warning")}Ie(null)}const r=Y("#solution"),s=r.value,o=Ue.filter(u=>!u.isManaged&&!["default","active","basic"].includes(u.uniqueName.toLowerCase()));r.replaceChildren(...o.length?o.map(u=>W("option",{value:u.id},`${u.friendlyName} (${u.uniqueName}) ${u.version}`)):[W("option",{value:""},e?"No unmanaged solutions":"No connection")]),[...r.options].some(u=>u.value===s)&&(r.value=s),Y("#btn-run").disabled=!o.length}async function fn(t){const a=Ge(),e=ve(),d=Ue.find(s=>s.id===(t??Y("#solution").value));if(!a||!e||!d||It)return;It=!0,At=!1;const i=Et;Y("#btn-cancel").hidden=!1,Y("#btn-run").disabled=!0,Y("#progress").hidden=!1;const r=Y("#progress-bar");try{Ye===void 0&&(Ye=await Fn(a));const s=sn(),o=await ir({api:a,meta:Ct,reqCache:ht(),solution:d,allSolutions:Ue,targetSolutions:De,filter:Nt(),environment:{name:e.conn.name,url:e.conn.url,environment:e.conn.environment},target:s&&De?{name:s.conn.name,url:s.conn.url}:null,link:()=>un(),onProgress:(u,v)=>{r.max=Math.max(v,1),r.value=u,Y("#progress-text").textContent=`RetrieveRequiredComponents ${u} / ${v}`},cancelled:()=>At});if(i!==Et)return;ie=o;for(const u of ie.findings)for(const v of u.fixes)v.kind==="report"&&(v.link=un());for(const[u,v]of[...Re])ie.findings.some(_=>_.key===u&&_.fixes.some(w=>w.kind===v))||Re.delete(u)}catch(s){s instanceof Gt?await be("Cancelled","Diagnosis cancelled. Finished calls stay cached.","info"):await be("Diagnosis failed",s.message,"error")}finally{It=!1,Y("#btn-cancel").hidden=!0,Y("#btn-run").disabled=!1,Y("#progress").hidden=!0}mt()}function wr(t){var e;const a=!!t.solution&&!!(De!=null&&De.has(t.solution.uniqueName.toLowerCase()));return W("span",{class:`req${a?" is-safe":""}`,title:t.solutions.join(", ")},W("span",{class:"sol"},((e=t.solution)==null?void 0:e.uniqueName)??"unknown solution"),`${_e(t.type)} ${t.name}`,a?" · in target":"")}function br(t){const a=W("select",{class:"fix","aria-label":`Fix for ${t.dependent.name}`});a.append(W("option",{value:""},"No action"),...t.fixes.map(d=>W("option",{value:d.kind},d.label))),a.value=Re.get(t.key)??"",a.addEventListener("change",()=>{a.value?Re.set(t.key,a.value):Re.delete(t.key),hn()});const e=t.fixes.find(d=>d.kind==="report");return W("li",{class:`finding${t.status==="safe"?" is-safe":""}`,"data-key":t.key},W("div",{class:"head"},me(_e(t.dependent.type),"neutral"),W("span",{class:"name mono"},t.dependent.name),t.dependent.table||t.dependent.rootTable?W("span",{class:"caption"},t.dependent.table??t.dependent.rootTable??""):null,t.dependent.rootBehavior===0?me("table: all assets","warn"):null,me(t.status==="blocker"?"blocker":"present in target",t.status==="blocker"?"bad":"ok"),a),W("div",{class:"cause"},t.cause),W("div",{class:"chips"},...t.required.map(wr)),e!=null&&e.link?W("div",{class:"caption"},e.note??""," ",W("a",{href:e.link,target:"_blank",rel:"noopener"},"Open solution in maker portal")):null)}function hn(){Y("#sel-count").textContent=`${Re.size} selected`,Y("#btn-to-fix").disabled=Re.size===0}function mt(){const t=Y("#findings"),a=Y("#diag-summary");t.replaceChildren(),a.replaceChildren(),Y("#diag-actions").hidden=!ie;for(const o of["#btn-export-json","#btn-export-csv"])Y(o).toggleAttribute("disabled",!ie);if(!ie){t.append(Be("No diagnosis yet",ve()?"Pick an unmanaged solution and run Diagnose.":"Connect a dev environment in ToolBox, or use the Offline tab."));return}const e=ie,d=e.findings.filter(o=>o.status==="blocker"),i=e.findings.length-d.length,r=Y("#show-safe").checked;a.append(W("div",{class:"summary"},W("strong",{},`${e.solution.friendlyName}`),`${e.components.length} components ·`,me(`${d.length} blocker${d.length===1?"":"s"}`,d.length?"bad":"ok"),e.target?me(`${i} present in target`,"ok"):W("span",{class:"caption"},"No target connection: every dependency matching the filter counts."),e.errors.length?me(`${e.errors.length} lookups failed`,"warn"):null));for(const o of e.warnings??[])a.append(W("div",{class:"warnings"},o));e.errors.length&&a.append(W("div",{class:"warnings"},`RetrieveRequiredComponents failed for ${e.errors.length} component(s): ${e.errors.slice(0,3).map(o=>`${o.component} (${o.error})`).join("; ")}`));const s=e.findings.filter(o=>r||o.status==="blocker");s.length?t.append(W("ul",{class:"findings"},...s.map(br))):t.append(Be("No blocking dependencies",e.findings.length?"Everything found is present in the target. Tick “Show present in target” to see it.":"Nothing in this solution depends on the filtered solutions.")),hn()}function zt(t,a,e){const d=W("pre",{class:"diff","aria-label":e});for(const i of Vn(t,a))d.append(W("span",{class:i.t==="-"?"del":i.t==="+"?"add":i.t==="…"?"gap":"ctx"},i.t==="…"?"…":`${i.t} ${i.s}`));return d}function pn(t){const a=W("li",{class:"op","data-kind":t.kind},W("span",{class:"mono"},St(t)));if((t.kind==="remove"||t.kind==="add")&&a.append(" ",W("span",{class:"why"},t.reason)),t.kind==="update-form"){const e=t.edit;ze(a,e.removed.length?W("div",{class:"caption"},`Removes: ${e.removed.join(", ")}`):null,e.kept.length?W("div",{class:"caption"},`Kept: ${e.kept.map(d=>`${d.name} (${d.reason})`).join(", ")}`):null,e.warnings.length?W("div",{class:"warnings"},e.warnings.join(" ")):null,zt(e.form.formxml,e.after,`formxml diff ${e.form.name}`))}if(t.kind==="update-view"){const e=t.edit;ze(a,e.removed.length?W("div",{class:"caption"},`Removes: ${e.removed.join(", ")}`):null,e.warnings.length?W("div",{class:"warnings"},e.warnings.join(" ")):null,zt(e.view.fetchxml,e.after.fetchxml,`fetchxml diff ${e.view.name}`),zt(e.view.layoutxml,e.after.layoutxml,`layoutxml diff ${e.view.name}`))}return a}function mn(){return!!(ie!=null&&ie.solution.isManaged)}function tt(){const t=!Qe(ve())||Y("#prod-ack").checked;Y("#btn-confirm").disabled=ft||!(Xe&&Ce.length&&Le&&t&&!mn()),Y("#btn-backup").textContent=Xe?"1. Backup saved ✓":"1. Download backup"}function Ke(){const t=Y("#fix-banners"),a=Y("#fix-body");if(t.replaceChildren(),a.replaceChildren(),Y("#fix-actions").hidden=!Se,tt(),Je){t.append(W("div",{class:"danger-banner",id:"preview-error"},Je)),a.append(Be("Preview refused","Change the selected fixes in Diagnose, then Preview fixes again."));return}if(!Se||!ie){a.append(Be("Nothing selected","Pick a fix on one or more findings in Diagnose, then Preview fixes."));return}mn()&&t.append(W("div",{class:"danger-banner"},`${ie.solution.uniqueName} is managed. Writes are refused: fix dependencies in the dev environment, in the unmanaged solution.`)),Qe(ve())&&t.append(W("div",{class:"danger-banner"},`This connection (${ve().conn.name}) looks like Production. Dependencies are fixed in dev.`)),Y("#prod-ack-wrap").hidden=!Qe(ve());for(const e of Se.shells){const d=e.leaving.map(i=>{const r=W("input",{type:"checkbox","aria-label":`Keep ${i.component.name}`});return r.checked=i.keep,r.addEventListener("change",()=>{i.keep=r.checked,Ce=Ut(Se),gn()}),W("label",{title:i.why},r,me(_e(i.component.type),"neutral"),W("span",{class:"mono"},i.component.name??i.component.objectId),W("span",{class:"caption"},i.why))});a.append(W("div",{class:"card"},W("div",{class:"card-head"},W("h3",{},`Shell conversion: ${e.root.name}`),me(`${e.leaving.filter(i=>!i.keep).length} leave`,"warn")),W("div",{class:"card-body"},W("p",{class:"caption"},"The table is removed and added back without subcomponents. Every subcomponent below leaves the solution unless ticked to re-add. Other developers may rely on them."),e.leaving.length?W("div",{class:"leaving"},...d):W("p",{class:"caption"},"No subcomponent rows."))))}Se.skipped.length&&a.append(W("div",{class:"warnings"},"Not changed: ",Se.skipped.map(e=>`${e.name} (${e.reason})`).join("; "))),a.append(W("div",{id:"ops-wrap"})),gn()}function gn(){const t=document.getElementById("ops-wrap");t&&(t.replaceChildren(W("h3",{},`${Ce.length} operation${Ce.length===1?"":"s"} on ${(ie==null?void 0:ie.solution.uniqueName)??""}`),Ce.length?W("ol",{class:"ops",id:"ops"},...Ce.map(pn)):Be("No operations","The selected fixes change nothing.")),tt())}async function vr(){const t=Ge(),a=ve();if(!t||!a||!ie)return;const e=[...Re].map(([d,i])=>({finding:ie.findings.find(r=>r.key===d),fix:i})).filter(d=>d.finding&&d.finding.fixes.some(i=>i.kind===d.fix));Ie("Preparing preview…"),et(),Y("#prod-ack").checked=!1,Y("#fix-results").replaceChildren();try{if(!pt(a.conn.url,ie.environment.url))throw new Error(`The diagnosis was run on ${ie.environment.url}, the connection is now ${a.conn.url}. Run Diagnose again.`);Se=await Zn(t,Ct,ie,e),Ce=Ut(Se),Le={id:a.conn.id,url:a.conn.url}}catch(d){et(),Je=d.message,await be("Preview failed",Je,"error")}finally{Ie(null)}document.querySelector('.tab[data-tab="fix"]').click(),Ke()}async function _r(){if(!ie||!Se)return;const t=Yn(ie,Se,Ce);await nn(Xn(ie.solution.uniqueName),JSON.stringify(t,null,2))&&(Xe=!0,await be("Backup saved","Keep it: the Restore tab reapplies it.","success")),tt()}function yn(t){return W("table",{},W("thead",{},W("tr",{},W("th",{},"Operation"),W("th",{},"Result"))),W("tbody",{},...t.map(a=>W("tr",{},W("td",{class:"mono"},St(a.op)),W("td",{},a.ok?me("ok","ok"):a.skipped?me(a.error??"skipped","neutral"):me(a.error??"failed","bad"))))))}async function kr(){const t=Ge();if(!(ft||!t||!ie||!Se||!Xe||!Ce.length||!Le)){ft=!0,Y("#btn-confirm").disabled=!0;try{await xr(t)}finally{ft=!1,tt()}}}async function xr(t){if(!ie||!Le)return;const a=ie.solution,e=await ln();if(!e||e.conn.id!==Le.id||!pt(e.conn.url,Le.url)){const w=Le.url;et(),Ke(),await be("Refused",`The plan was made on ${w}, the connection is now ${(e==null?void 0:e.conn.url)??"none"}. Nothing was written: run Diagnose and Preview again.`,"error");return}const d=await Bt(t,a.id).catch(()=>null);if(!d||d.isManaged||a.isManaged){ie={...ie,solution:{...ie.solution,isManaged:!0}},Ke(),await be("Refused",`${a.uniqueName} is managed (or could not be read). Nothing was written.`,"error");return}Y("#btn-confirm").disabled=!0;const i=ie.findings.filter(w=>w.status==="blocker").map(w=>w.key),r=new Set;for(const w of Ce)w.kind==="update-form"&&r.add(Ae(ne.Form,w.edit.form.id)),w.kind==="update-view"&&r.add(Ae(ne.View,w.edit.view.id)),(w.kind==="remove"||w.kind==="add")&&r.add(Ae(w.component.type,w.component.id));const s=await Mt(t,Ce,d.uniqueName,(w,C)=>Ie(w<C?`Applying ${w+1} / ${C}…`:null));Ie(null);const o=s.filter(w=>!w.ok&&!w.skipped).length;await be(o?"Some operations failed":"Applied",o?"Restore from the backup if needed.":`${s.length} operations done. Re-running diagnosis…`,o?"error":"success");for(const w of r)ht().delete(w);et(),Re.clear(),Ke();const u=Y("#fix-results");u.replaceChildren(W("h3",{},"Results"),yn(s)),await fn(a.id);const v=new Set(((ie==null?void 0:ie.findings)??[]).filter(w=>w.status==="blocker").map(w=>w.key)),_=i.filter(w=>!v.has(w)).length;u.append(W("div",{class:"summary",id:"rediag"},W("strong",{},"Re-diagnosis:"),me(`${_} fixed`,"ok"),me(`${i.length-_} still present`,i.length-_?"bad":"ok"),me(`${v.size} blockers now`,v.size?"bad":"ok")))}async function Sr(){const t=await yr({title:"Open Dependency Cleaner backup",extensions:["json"]});if(!t)return;Y("#restore-results").replaceChildren();try{ce={backup:Jn(t.text),plan:null,url:null},Y("#restore-file").textContent=t.name}catch(d){ce=null,await be("Backup rejected",`${t.name}: ${d.message}`,"error"),Me();return}const a=Ge(),e=ve();if(a&&e){Ie("Comparing backup to the environment…"),ce.url=e.conn.url;try{ce.plan=await Qn(a,ce.backup,Ue.length?Ue:await vt(a,"primary"),e.conn.url)}catch(d){await be("Restore refused",d.message,"error"),Me(d.message),Ie(null);return}Ie(null)}Me()}function Me(t){var d;const a=Y("#restore-body");if(a.replaceChildren(),Y("#restore-actions").hidden=!(ce!=null&&ce.plan),Y("#btn-restore-apply").disabled=!((d=ce==null?void 0:ce.plan)!=null&&d.ops.length),!ce){a.append(Be("No backup loaded","Load a dependency-cleaner-backup-*.json file saved before a fix."));return}const e=ce.backup;if(a.append(W("p",{class:"caption"},`Backup of ${e.solution.uniqueName} from ${e.environment.name}, ${e.takenAt}. ${e.membership.length} members, ${e.forms.length} forms, ${e.views.length} views.`)),t&&a.append(W("div",{class:"danger-banner",id:"restore-error"},t)),!!ce.plan){for(const i of ce.plan.notes)a.append(W("div",{class:"warnings"},i));Qe(ve())&&a.append(W("div",{class:"danger-banner"},`This connection (${ve().conn.name}) looks like Production.`)),a.append(ce.plan.ops.length?W("ol",{class:"ops",id:"restore-ops"},...ce.plan.ops.map(pn)):Be("Nothing to restore","The environment already matches the backup."))}}async function Cr(){var o,u,v;const t=Ge();if(!t||!(ce!=null&&ce.plan))return;const a=ce.plan,e=await ln();if(!e||!pt(e.conn.url,ce.url)||!pt(e.conn.url,(o=ce.backup.environment)==null?void 0:o.url)){ce.plan=null,Me(),await be("Refused",`The backup is from ${((u=ce.backup.environment)==null?void 0:u.url)??"an unknown environment"}, the connection is now ${(e==null?void 0:e.conn.url)??"none"}. Nothing was written: load the backup again on the right connection.`,"error");return}const d=await Bt(t,a.solution.id).catch(()=>null);if(!d||d.isManaged){await be("Refused",`${a.solution.uniqueName} is managed (or could not be read). Nothing was written.`,"error");return}if(!await kn({title:"Apply restore",body:W("p",{},`${a.ops.length} operations on ${a.solution.uniqueName} in ${((v=ve())==null?void 0:v.conn.name)??""}.`),okLabel:`Apply ${a.ops.length}`,danger:Qe(ve())}))return;const r=await Mt(t,a.ops,d.uniqueName,(_,w)=>Ie(_<w?`Restoring ${_+1} / ${w}…`:null));Ie(null);for(const _ of a.ops)_.kind==="update-form"&&ht().delete(Ae(ne.Form,_.edit.form.id)),_.kind==="update-view"&&ht().delete(Ae(ne.View,_.edit.view.id));const s=r.filter(_=>!_.ok&&!_.skipped).length;await be(s?"Restore incomplete":"Restored",`${r.length-s} ok, ${s} failed`,s?"error":"success"),ce.plan=null,Me(),Y("#restore-results").replaceChildren(W("h3",{},"Restore results"),yn(r))}async function wn(t,a){const e=Y("#offline-body");try{Er(await fr(t,a,Nt(),De))}catch(d){e.replaceChildren(W("div",{class:"danger-banner"},d.message))}}function Er(t){const a=t.groups.filter(i=>i.status==="blocker").length,e=i=>`${i.typeName} ${$e(i)}${i.parentSchemaName?` (${i.parentSchemaName})`:""}`,d=t.groups.map(i=>W("li",{class:`finding${i.status==="safe"?" is-safe":""}`},W("div",{class:"head"},me(i.dependent.typeName,"neutral"),W("span",{class:"name mono"},$e(i.dependent)),i.dependent.parentSchemaName?W("span",{class:"caption"},i.dependent.parentSchemaName):null,me(i.status==="blocker"?"blocker":"present in target",i.status==="blocker"?"bad":"ok")),W("div",{class:"chips"},...i.required.map(r=>W("span",{class:`req${r.safe?" is-safe":""}`},W("span",{class:"sol"},r.solution??"unknown solution"),e(r))))));Y("#offline-body").replaceChildren(W("div",{class:"summary",id:"offline-summary"},W("strong",{},`${t.uniqueName} ${t.version}`),t.managed?me("managed","neutral"):me("unmanaged","neutral"),`${t.total} missing dependencies in solution.xml ·`,me(`${t.groups.length} dependents in scope`,"neutral"),me(`${a} blocking`,a?"bad":"ok")),t.groups.length?W("ul",{class:"findings"},...d):Be("No missing dependencies in scope",`Filter: ${Nt().join(", ")}`))}function Ar(){const t=Y("#drop");t.addEventListener("dragover",a=>{a.preventDefault(),t.classList.add("is-over")}),t.addEventListener("dragleave",()=>t.classList.remove("is-over")),t.addEventListener("drop",async a=>{var d,i;a.preventDefault(),t.classList.remove("is-over");const e=(i=(d=a.dataTransfer)==null?void 0:d.files)==null?void 0:i[0];e&&await wn(e.name,new Uint8Array(await e.arrayBuffer()))}),Y("#btn-open-zip").addEventListener("click",async()=>{const[a]=await gr({title:"Open solution zip",extensions:["zip"]});a&&await wn(a.name,a.data)})}async function bn(t,a,e){await nn(t,a,e)&&await be("Exported",t,"success")}function Ir(){xn(),Y("#btn-run").addEventListener("click",()=>void fn()),Y("#btn-cancel").addEventListener("click",()=>{At=!0}),Y("#show-safe").addEventListener("change",mt),Y("#btn-to-fix").addEventListener("click",()=>void vr()),Y("#btn-backup").addEventListener("click",()=>void _r()),Y("#prod-ack").addEventListener("change",tt),Y("#btn-confirm").addEventListener("click",()=>void kr()),Y("#btn-load-backup").addEventListener("click",()=>void Sr()),Y("#btn-restore-apply").addEventListener("click",()=>void Cr()),Y("#btn-export-json").addEventListener("click",()=>{ie&&bn(`dependency-findings.${Vt(ie.solution.uniqueName)}.json`,sr(ie),"application/json")}),Y("#btn-export-csv").addEventListener("click",()=>{ie&&bn(`dependency-findings.${Vt(ie.solution.uniqueName)}.csv`,or(ie),"text/csv")}),Ar(),hr(()=>void dn().then(mt)),Y("#host-mode").textContent=en()?"Running inside Power Platform ToolBox":"Standalone mode (Offline tab only)"}pr(t=>document.documentElement.setAttribute("data-theme",t)),Ir(),mt(),Ke(),Me(),dn()})();
package/dist/index.html CHANGED
@@ -96,6 +96,6 @@
96
96
  </dialog>
97
97
 
98
98
 
99
- <script src="./assets/index-C81UYfrl.js"></script>
99
+ <script src="./assets/index-BPWxIlef.js"></script>
100
100
  </body>
101
101
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplesmoothsafe/pptb-dependency-cleaner",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "displayName": "SSS Dependency Cleaner",
5
5
  "description": "Why does my solution depend on msdyn_*? Find every dependency of an unmanaged solution on a managed solution the target environment lacks, see the component that causes it, and fix it in place: convert tables to shells, remove components, strip msdyn columns from forms and views. Preview, backup and restore.",
6
6
  "main": "index.html",
@@ -1,16 +0,0 @@
1
- var vr=Object.defineProperty;var _r=(K,Ie,M)=>Ie in K?vr(K,Ie,{enumerable:!0,configurable:!0,writable:!0,value:M}):K[Ie]=M;var yt=(K,Ie,M)=>_r(K,typeof Ie!="symbol"?Ie+"":Ie,M);(function(){"use strict";const K=t=>{const l=document.querySelector(t);if(!l)throw new Error(`missing ${t}`);return l};function Ie(t,...l){for(const e of l)e!=null&&e!==!1&&t.append(e)}function M(t,l={},...e){const u=document.createElement(t);for(const[i,r]of Object.entries(l))r===void 0||r===!1||(i==="class"?u.className=String(r):r===!0?u.setAttribute(i,""):u.setAttribute(i,r));for(const i of e)i!=null&&i!==!1&&u.append(typeof i=="string"?document.createTextNode(i):i);return u}const pe=(t,l="")=>M("span",{class:`badge${l?` badge-${l}`:""}`},t),Be=(t,l)=>M("div",{class:"empty-state"},M("strong",{},t),l);function wn(t){const l=K("#dlg");K("#dlg-title").textContent=t.title;const e=K("#dlg-target");e.replaceChildren(),t.target&&e.append(t.target),K("#dlg-body").replaceChildren(t.body);const u=K("#dlg-ok");return u.textContent=t.okLabel??"",u.className=`btn ${t.danger?"btn-danger":"btn-primary"}`,u.style.flex="none",u.hidden=!t.okLabel,new Promise(i=>{let r=!1;const a=o=>{r||(r=!0,u.onclick=null,K("#dlg-cancel").onclick=null,l.onclose=null,l.open?(l.addEventListener("close",()=>i(o),{once:!0}),l.close()):i(o))};u.onclick=()=>a(!0),K("#dlg-cancel").onclick=()=>a(!1),l.onclose=()=>a(!1),l.showModal()})}function vn(t){document.querySelectorAll(".tab").forEach(l=>l.addEventListener("click",()=>{const e=l.dataset.tab;document.querySelectorAll(".tab").forEach(u=>u.classList.toggle("is-active",u===l)),document.querySelectorAll(".panel[id^='tab-']").forEach(u=>u.hidden=u.id!==`tab-${e}`)}))}const ie={Entity:1,Attribute:2,Relationship:3,OptionSet:9,EntityRelationship:10,View:26,Workflow:29,Chart:59,Form:60,WebResource:61,SiteMap:62,AppModule:80,PluginStep:92},_n={1:"Table",2:"Column",3:"Relationship",9:"Choice",10:"Relationship",14:"Key",20:"Security role",24:"Form",26:"View",29:"Process",31:"Report",36:"Email template",48:"Ribbon command",50:"Ribbon",55:"Ribbon diff",59:"Chart",60:"Form",61:"Web resource",62:"Site map",63:"Connection role",65:"Hierarchy rule",66:"Custom control",70:"Field security profile",80:"Model-driven app",90:"Plugin type",91:"Plugin assembly",92:"Plugin step",300:"Canvas app",371:"Connector",372:"Connection reference",380:"Environment variable"},_e=t=>_n[t]??`Type ${t}`,kn=["msdyn","msdynce","mspp"],it=t=>t==null||t===""?null:String(t),ge=t=>String(t??"").toLowerCase(),Rt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ot(t,l="id"){if(!Rt.test(t))throw new Error(`${l} is not a guid: ${t}`);return t.toLowerCase()}function xn(t){const l=t.match(/\/api\/data\/v\d+(?:\.\d+)*\/(.*)$/i);return l?l[1]:t}const Ot=500;async function bt(t,l,e="primary"){const u=[],i=new Set;let r=l;for(let a=0;r&&a<Ot;a++){const o=await t.queryData(r,e);u.push(...o.value??[]);const c=o["@odata.nextLink"];if(r=typeof c=="string"&&c?xn(c):null,r&&i.has(r))throw new Error(`paging loop at ${r}`);r&&i.add(r)}if(r)throw new Error(`more than ${Ot} pages for ${l.split("?")[0]}`);return u}const $t=40;async function at(t,l,e,u,i="primary"){const r=[...new Set(l.map(c=>c.toLowerCase()))].filter(c=>Rt.test(c)),a=[];for(let c=0;c<r.length;c+=$t)a.push(r.slice(c,c+$t));return(await Promise.all(a.map(c=>bt(t,u(c.map(k=>`${e} eq ${k}`).join(" or ")),i)))).flat()}async function Sn(t,l,e,u=()=>!1){let i=0;const r=async()=>{for(;i<t.length&&!u();){const a=t[i++];await e(a)}};await Promise.all(Array.from({length:Math.min(l,t.length)},r))}async function wt(t,l="primary"){const[e,u]=await Promise.all([t.getSolutions(["solutionid","uniquename","friendlyname","version","ismanaged","_publisherid_value"],l),bt(t,"publishers?$select=publisherid,uniquename,customizationprefix",l).catch(()=>[])]),i=new Map(u.map(r=>[ge(r.publisherid),String(r.customizationprefix??"").toLowerCase()]));return e.value.map(r=>{const a=r._publisherid_value?ge(r._publisherid_value):null;return{id:ge(r.solutionid),uniqueName:String(r.uniquename??""),friendlyName:it(r.friendlyname)??String(r.uniquename??""),version:String(r.version??""),isManaged:!!r.ismanaged,publisherId:a,prefix:a?i.get(a)??"":""}}).sort((r,a)=>r.friendlyName.localeCompare(a.friendlyName))}async function Tt(t,l){const u=(await t.queryData(`solutions?$select=solutionid,uniquename,ismanaged&$filter=solutionid eq ${ot(l,"solution id")}`)).value[0];return u?{isManaged:!!u.ismanaged,uniqueName:String(u.uniquename??"")}:null}async function Bt(t,l){return(await bt(t,`solutioncomponents?$select=solutioncomponentid,objectid,componenttype,rootcomponentbehavior,_rootsolutioncomponentid_value&$filter=_solutionid_value eq ${ot(l,"solution id")}`)).map(u=>({rowId:ge(u.solutioncomponentid),objectId:ge(u.objectid),type:Number(u.componenttype??0),behavior:u.rootcomponentbehavior==null?null:Number(u.rootcomponentbehavior),rootRowId:u._rootsolutioncomponentid_value?ge(u._rootsolutioncomponentid_value):null}))}function Cn(t){const l=t;if(!l)return[];const e=l.EntityCollection;if(Array.isArray(e))return e;if(e&&typeof e=="object"){const u=e.Entities??e.value;if(Array.isArray(u))return u}return Array.isArray(l.value)?l.value:[]}const Ue=(t,l)=>t[l]??t[`_${l}_value`];async function En(t,l,e){const u=ot(l,"component id");if(!Number.isInteger(e))throw new Error(`bad component type ${e}`);const i=await t.queryData(`RetrieveRequiredComponents(ObjectId=${u},ComponentType=${e})`);return Cn(i).map(r=>({requiredId:ge(Ue(r,"requiredcomponentobjectid")),requiredType:Number(Ue(r,"requiredcomponenttype")??0),requiredParentId:Ue(r,"requiredcomponentparentid")?ge(Ue(r,"requiredcomponentparentid")):null,requiredBaseSolutionId:Ue(r,"requiredcomponentbasesolutionid")?ge(Ue(r,"requiredcomponentbasesolutionid")):null}))}async function An(t,l){const e=await at(t,l,"objectid",i=>`solutioncomponents?$select=objectid,componenttype,_solutionid_value&$filter=${i}`),u=new Map;for(const i of e){const r=ge(i.objectid),a=u.get(r)??[],o=ge(i._solutionid_value);o&&!a.includes(o)&&a.push(o),u.set(r,a)}return u}class jt{constructor(){yt(this,"entities",null);yt(this,"attributes",new Map);yt(this,"names",new Map)}async entitiesById(l){if(this.entities)return this.entities;const e=await l.getAllEntitiesMetadata(["LogicalName","MetadataId","PrimaryNameAttribute"]);return this.entities=new Map(e.value.map(u=>[ge(u.MetadataId),{id:ge(u.MetadataId),logicalName:String(u.LogicalName??""),primaryName:it(u.PrimaryNameAttribute)}])),this.entities}async entityByName(l,e){const u=await this.entitiesById(l);for(const i of u.values())if(i.logicalName===e)return i}async attributesOf(l,e){const u=this.attributes.get(e);if(u)return u;const r=(await l.getEntityRelatedMetadata(e,"Attributes",["LogicalName","MetadataId","RequiredLevel"])).value.map(a=>{var o;return{id:ge(a.MetadataId),logicalName:String(a.LogicalName??""),requiredLevel:String(((o=a.RequiredLevel)==null?void 0:o.Value)??a.RequiredLevel??"None")}});return this.attributes.set(e,r),r}async protectedColumns(l,e){const u=await this.entityByName(l,e),i=await this.attributesOf(l,e).catch(()=>[]),r=new Set;u!=null&&u.primaryName&&r.add(u.primaryName);for(const a of i)(a.requiredLevel==="ApplicationRequired"||a.requiredLevel==="SystemRequired")&&r.add(a.logicalName);return[...r]}}const Lt={[ie.View]:["savedqueries","savedqueryid","name","returnedtypecode"],[ie.Form]:["systemforms","formid","name","objecttypecode"],[ie.Chart]:["savedqueryvisualizations","savedqueryvisualizationid","name","primaryentitytypecode"],[ie.WebResource]:["webresourceset","webresourceid","name"],[ie.Workflow]:["workflows","workflowid","name","primaryentity"],[ie.SiteMap]:["sitemaps","sitemapid","sitemapname"],[ie.AppModule]:["appmodules","appmoduleid","name"],[ie.PluginStep]:["sdkmessageprocessingsteps","sdkmessageprocessingstepid","name"],20:["roles","roleid","name"],300:["canvasapps","canvasappid","name"],372:["connectionreferences","connectionreferenceid","connectionreferencelogicalname"],380:["environmentvariabledefinitions","environmentvariabledefinitionid","schemaname"]};async function In(t,l,e){var x;const u=(y,_)=>`${y}:${_}`,i=new Map,r=e.filter(y=>{const _=l.names.get(u(y.type,y.id));return _&&i.set(u(y.type,y.id),_),!_});if(!r.length)return i;const a=y=>{i.set(u(y.type,y.id),y),l.names.set(u(y.type,y.id),y)},o=await l.entitiesById(t).catch(()=>new Map);for(const y of r.filter(_=>_.type===ie.Entity)){const _=o.get(y.id);_&&a({type:y.type,id:y.id,name:_.logicalName,table:_.logicalName})}const c=new Map;for(const y of r.filter(_=>_.type===ie.Attribute)){const _=y.parentId??"";c.set(_,[...c.get(_)??[],y])}for(const[y,_]of c){const d=(x=o.get(y))==null?void 0:x.logicalName;if(!d)continue;const b=await l.attributesOf(t,d).catch(()=>[]);for(const f of _){const h=b.find(p=>p.id===f.id);h&&a({type:f.type,id:f.id,name:h.logicalName,table:d})}}const k=new Map;for(const y of r)Lt[y.type]&&k.set(y.type,[...k.get(y.type)??[],y.id]);await Promise.all([...k].map(async([y,_])=>{const[d,b,f,h]=Lt[y],p=await at(t,_,b,g=>`${d}?$select=${[b,f,h].filter(Boolean).join(",")}&$filter=${g}`).catch(()=>[]);for(const g of p)a({type:y,id:ge(g[b]),name:it(g[f])??ge(g[b]),table:h?it(g[h])??void 0:void 0})}));for(const y of r.filter(_=>_.type===ie.EntityRelationship||_.type===ie.Relationship))try{const _=await t.queryData(`RelationshipDefinitions(${ot(y.id)})?$select=SchemaName`);_!=null&&_.SchemaName&&a({type:y.type,id:y.id,name:String(_.SchemaName)})}catch{}for(const y of r)i.has(u(y.type,y.id))||i.set(u(y.type,y.id),{type:y.type,id:y.id,name:y.id});return i}async function Dt(t,l){return(await at(t,l,"formid",u=>`systemforms?$select=formid,name,objecttypecode,formxml&$filter=${u}`)).map(u=>({id:ge(u.formid),name:String(u.name??""),table:String(u.objecttypecode??""),formxml:String(u.formxml??"")}))}async function Pt(t,l){return(await at(t,l,"savedqueryid",u=>`savedqueries?$select=savedqueryid,name,returnedtypecode,fetchxml,layoutxml&$filter=${u}`)).map(u=>({id:ge(u.savedqueryid),name:String(u.name??""),table:String(u.returnedtypecode??""),fetchxml:String(u.fetchxml??""),layoutxml:String(u.layoutxml??"")}))}async function Nn(t){var l;try{const e=await t.execute({operationName:"RetrieveCurrentOrganization",operationType:"function",parameters:{AccessType:"Microsoft.Dynamics.CRM.EndpointAccessType'Default'"}}),u=(l=e==null?void 0:e.Detail)==null?void 0:l.EnvironmentId;return typeof u=="string"&&u?u:null}catch{return null}}const ue=t=>(t??"").trim().toLowerCase();function vt(t,l){const e=new DOMParser().parseFromString(t,"application/xml");if(e.getElementsByTagName("parsererror").length)throw new Error(`${l}: invalid XML`);return e}function _t(t,l){const e=/^?\s*<\?xml[^?]*\?>\s*/.exec(l),u=new XMLSerializer().serializeToString(t).replace(/^<\?xml[^?]*\?>\s*/,"");return(e?e[0]:"")+u}const me=(t,l)=>Array.from(t.getElementsByTagName(l)),Me=(t,l)=>Array.from(t.children).filter(e=>!l||e.localName===l);function Ce(t){var e,u;const l=t.previousSibling;l&&l.nodeType===3&&!(l.nodeValue??"").trim()&&((e=l.parentNode)==null||e.removeChild(l)),(u=t.parentNode)==null||u.removeChild(t)}function Ke(t){if(t.children.length===0&&!(t.textContent??"").trim())for(;t.firstChild;)t.removeChild(t.firstChild)}const st=(t,l)=>{for(let e=t.parentElement;e;e=e.parentElement)if(e.localName===l)return e;return null},kt=t=>{var e;return t&&(((e=t.getElementsByTagName("label")[0])==null?void 0:e.getAttribute("description"))||t.getAttribute("name")||t.getAttribute("id"))||""},zn=t=>new Set(t.map(l=>{var e;return(e=/^([a-z0-9]+_)/.exec(l))==null?void 0:e[1]}).filter(l=>!!l));function Rn(t,l,e,u=[]){var C;const i=new Set(l.map(ue)),r=new Set(e.map(ue)),a=new Set(u.map(ue)),o=[],c=[],k=[],x=m=>!o.includes(m)&&o.push(m),y=(m,v)=>!c.some(N=>N.name===m)&&c.push({name:m,reason:v}),_=vt(t,"formxml"),d=new Set,b=new Set,f=new Set,h=new Set;for(const m of me(_,"control")){if(!m.parentNode||!_.documentElement.contains(m))continue;const v=ue(m.getAttribute("datafieldname"));let N=null;if(v&&i.has(v)){if(r.has(v)){y(v,"protected: primary name or ApplicationRequired column");continue}N=v}else if(a.size){const T=m.getElementsByTagName("parameters")[0];if(T){const W=ue((C=T.getElementsByTagName("TargetEntityType")[0])==null?void 0:C.textContent),Y=me(T,"QuickFormId").map(E=>ue(E.getAttribute("entityname"))).find(E=>a.has(E));W&&a.has(W)?N=`subgrid ${m.getAttribute("id")??"?"} (${W})`:Y&&(N=`quickview ${m.getAttribute("id")??"?"} (${Y})`)}}if(!N)continue;const A=st(m,"cell"),L=A&&st(A,"row");for(const T of[m.getAttribute("id"),m.getAttribute("uniqueid")])T&&d.add(ue(T));v&&N===v&&b.add(v),x(N),A?(Ce(A),L&&f.add(L)):Ce(m)}for(const m of f){const v=st(m,"section");if(v&&h.add(v),Me(m,"cell").length===0){const N=m.parentElement;Ce(m),N&&Ke(N)}}const p=new Set;for(const m of h){const v=st(m,"tab");if(v&&p.add(v),!me(m,"row").some(A=>Me(A,"cell").some(L=>L.getElementsByTagName("control").length>0))){k.push(`Section "${kt(m)}"${v?` in tab "${kt(v)}"`:""} became empty and was removed.`);const A=m.parentElement;Ce(m),A&&Ke(A)}}for(const m of p)me(m,"control").length===0&&k.push(`Tab "${kt(m)}" is now empty (kept; remove or hide it by hand).`);for(const m of me(_,"controlDescription")){const v=ue(m.getAttribute("forControl"));if(v&&d.has(v)){const A=m.parentElement;Ce(m),A&&Ke(A);continue}const N=me(m,"*").filter(A=>A.children.length===0).map(A=>ue(A.textContent)).find(A=>b.has(A));N&&k.push(`Custom control (controlDescription for ${m.getAttribute("forControl")}) references removed column ${N}; review it by hand.`)}for(const m of me(_,"event")){const v=ue(m.getAttribute("attribute"));if(v&&b.has(v)){const N=me(m,"Handler").map(A=>`${A.getAttribute("libraryName")}:${A.getAttribute("functionName")}`);k.push(`Event "${m.getAttribute("name")}" on removed column ${v} still has handlers${N.length?` (${N.join(", ")})`:""}; review the form events.`)}}const g=zn([...b,...a]);if(o.length&&g.size){const m=new Set,v=[...me(_,"Library").map(N=>N.getAttribute("name")??""),...me(_,"Handler").map(N=>N.getAttribute("libraryName")??"")];for(const N of v){const A=ue(N);!A||m.has(A)||(m.add(A),[...g].some(L=>A.startsWith(L)||A.includes("/"+L))&&k.push(`Form library "${N}" belongs to the same publisher as removed components; it may still depend on them.`))}}return{xml:o.length?_t(_,t):t,removed:o,kept:c,warnings:k}}function On(t,l,e,u){const i=new Set(e.map(ue)),r=new Set(u.map(ue)),a=[],o=[],c=new Set,k=new Set;let x=!1,y=t;if(t.trim()){const d=vt(t,"fetchxml"),b=me(d,"entity")[0],f=b?Me(b,"order").length:0;for(const m of me(d,"link-entity")){if(!d.documentElement.contains(m))continue;const v=ue(m.getAttribute("name")),N=ue(m.getAttribute("alias"));if(r.has(v)){N&&c.add(N);for(const A of me(m,"link-entity"))A.getAttribute("alias")&&c.add(ue(A.getAttribute("alias")));a.push(`link-entity ${v}${N?` (${N})`:""}`),Ce(m),x=!0}else N&&k.add(N)}for(const m of me(d,"link-entity"))for(const v of["from","to"]){const N=ue(m.getAttribute(v));N&&i.has(N)&&o.push(`link-entity ${m.getAttribute("name")} joins ${v}="${N}", a removed column; the view will break until this join is fixed.`)}for(const m of me(d,"attribute")){const v=ue(m.getAttribute("name"));i.has(v)&&(a.push(`attribute ${v}`),Ce(m),x=!0)}let h=0;for(const m of me(d,"order")){const v=ue(m.getAttribute("attribute")),N=ue(m.getAttribute("entityname"));(i.has(v)||N&&c.has(N))&&(a.push(`order ${N?N+".":""}${v}`),Ce(m),h++,x=!0)}const p=new Set;let g=0;for(const m of me(d,"condition")){const v=ue(m.getAttribute("attribute")),N=ue(m.getAttribute("entityname"));if(i.has(v)||N&&c.has(N)){a.push(`condition ${N?N+".":""}${v} ${m.getAttribute("operator")??""}`.trim());const A=m.parentElement;Ce(m),(A==null?void 0:A.localName)==="filter"&&p.add(A),g++,x=!0}}const C=[...p];for(;C.length;){const m=C.shift();if(!m.parentNode||Me(m).some(N=>N.localName==="condition"||N.localName==="filter"))continue;const v=m.parentElement;Ce(m),v&&(Ke(v),v.localName==="filter"&&C.push(v))}g&&o.push(`${g} filter condition(s) removed: the view now returns a different (usually larger) set of rows. Review the filter.`),h&&f>0&&b&&Me(b,"order").length===0&&o.push("The view's only sort order was removed; it will fall back to the default order."),b&&x&&Me(b,"attribute").length===0&&!b.getElementsByTagName("all-attributes").length&&o.push("The root entity has no attributes left in the view."),x&&(y=_t(d,t))}let _=l;if(l.trim()){const d=vt(l,"layoutxml");let b=!1;for(const f of me(d,"cell")){const h=ue(f.getAttribute("name"));if(!h)continue;const p=h.indexOf("."),g=p>=0?h.slice(0,p):"",C=p>=0?h.slice(p+1):h;if(g?c.has(g)||k.has(g)&&i.has(C):i.has(C)){a.push(`cell ${h}`);const v=f.parentElement;Ce(f),v&&Ke(v),b=!0}}for(const f of me(d,"grid")){const h=ue(f.getAttribute("jump"));h&&i.has(h)&&o.push(`Layout jump column "${h}" was removed; set another primary column for the grid.`)}b&&(_=_t(d,l))}return{fetchxml:y,layoutxml:_,removed:a,warnings:o}}const $n=t=>({type:t.type,id:t.objectId,name:t.name??t.objectId,table:t.table}),lt=(t,l)=>[...new Set(t.required.filter(e=>e.type===l).map(e=>e.name))];async function Tn(t,l,e,u){var p;const i=[],r=u.filter(g=>g.fix==="edit-form"),a=u.filter(g=>g.fix==="edit-view"),[o,c]=await Promise.all([r.length?Dt(t,r.map(g=>g.finding.dependent.id)):Promise.resolve([]),a.length?Pt(t,a.map(g=>g.finding.dependent.id)):Promise.resolve([])]),k=[];for(const g of r){const C=o.find(v=>v.id===g.finding.dependent.id);if(!C){i.push({name:g.finding.dependent.name,reason:"form not found"});continue}const m=await l.protectedColumns(t,C.table);try{const v=Rn(C.formxml,lt(g.finding,ie.Attribute),m,lt(g.finding,ie.Entity));v.removed.length?k.push({form:C,after:v.xml,removed:v.removed,kept:v.kept,warnings:v.warnings}):i.push({name:C.name,reason:`nothing to strip${v.kept.length?`: kept ${v.kept.map(N=>`${N.name} (${N.reason})`).join(", ")}`:""}`})}catch(v){i.push({name:C.name,reason:v.message})}}const x=[];for(const g of a){const C=c.find(m=>m.id===g.finding.dependent.id);if(!C){i.push({name:g.finding.dependent.name,reason:"view not found"});continue}try{const m=On(C.fetchxml,C.layoutxml,lt(g.finding,ie.Attribute),lt(g.finding,ie.Entity));m.removed.length?x.push({view:C,after:{fetchxml:m.fetchxml,layoutxml:m.layoutxml},removed:m.removed,warnings:m.warnings}):i.push({name:C.name,reason:"nothing to strip"})}catch(m){i.push({name:C.name,reason:m.message})}}const y=new Set([...k.map(g=>g.form.id),...x.map(g=>g.view.id)]),_=e.solution.prefix?`${e.solution.prefix}_`:null,d=[];for(const g of u.filter(C=>C.fix==="shell")){const C=(p=g.finding.fixes.find(A=>A.kind==="shell"))==null?void 0:p.root;if(!C||d.some(A=>A.root.id===C.id))continue;const m=e.components.find(A=>A.type===ie.Entity&&A.objectId===C.id),v=new Set(e.findings.filter(A=>A.dependent.selfOwned).map(A=>A.dependent.id)),N=e.components.filter(A=>m&&A.rootRowId===m.rowId&&A.rowId!==m.rowId).map(A=>{const L=(A.name??"").toLowerCase();if(v.has(A.objectId))return{component:A,keep:!1,why:"belongs to a managed solution in scope"};if(y.has(A.objectId))return{component:A,keep:!0,why:"edited in this plan"};if(_&&L.startsWith(_))return{component:A,keep:!0,why:`your prefix ${_}`};if(A.type===ie.Form||A.type===ie.View||A.type===ie.Chart){if(A.filteredOwner)return{component:A,keep:!1,why:`owned by ${A.filteredOwner}`};if(A.filteredOwner===null)return{component:A,keep:!0,why:"yours: not owned by a filtered managed solution"}}return{component:A,keep:!1,why:"not yours"}}).sort((A,L)=>Number(L.keep)-Number(A.keep)||A.component.type-L.component.type||(A.component.name??"").localeCompare(L.component.name??""));d.push({root:{...C,behavior:0},leaving:N})}const b=u.filter(g=>g.fix==="remove"&&g.finding.dependent.type===ie.Entity).map(g=>d.find(C=>C.root.id===g.finding.dependent.id)).filter(g=>!!g);if(b.length)throw new Error(`Conflicting fixes on table ${b.map(g=>g.root.name).join(", ")}: one finding converts it to a shell, another removes it from the solution. Pick one of the two and preview again.`);const f=new Set(d.map(g=>{var C;return(C=e.components.find(m=>m.type===ie.Entity&&m.objectId===g.root.id))==null?void 0:C.rowId})),h=[];for(const g of u.filter(C=>C.fix==="remove")){const C=e.components.find(m=>m.objectId===g.finding.dependent.id&&m.type===g.finding.dependent.type);if(C!=null&&C.rootRowId&&f.has(C.rootRowId)){i.push({name:g.finding.dependent.name,reason:"leaves with the shell conversion of its table"});continue}h.some(m=>m.id===g.finding.dependent.id)||h.push(g.finding.dependent)}for(const g of u.filter(C=>C.fix==="report"))i.push({name:g.finding.dependent.name,reason:"report only"});return{diagnosis:e,shells:d,removes:h,forms:k,views:x,skipped:i}}function Ft(t){const l=[];for(const i of t.shells){l.push({kind:"remove",component:i.root,reason:`convert ${i.root.name} to a shell`}),l.push({kind:"add",component:i.root,doNotIncludeSubcomponents:!0,reason:"re-add as shell (no subcomponents)"});for(const r of i.leaving.filter(a=>a.keep))l.push({kind:"add",component:$n(r.component),doNotIncludeSubcomponents:!1,reason:`keep: ${r.why}`})}for(const i of t.removes)l.push({kind:"remove",component:i,reason:`remove ${_e(i.type).toLowerCase()}`});for(const i of t.forms)l.push({kind:"update-form",edit:i});for(const i of t.views)l.push({kind:"update-view",edit:i});const e=[...new Set([...t.forms.map(i=>i.form.table),...t.views.map(i=>i.view.table)].filter(Boolean))].sort();e.length&&l.push({kind:"publish",tables:e});const u=new Set;return l.filter(i=>{if(i.kind!=="remove"&&i.kind!=="add")return!0;const r=`${i.kind}:${i.component.type}:${i.component.id}:${i.kind==="add"?i.doNotIncludeSubcomponents:""}`;return u.has(r)?!1:(u.add(r),!0)})}function Bn(t){const l=e=>e.replace(/[<>&"']/g,u=>`&#${u.charCodeAt(0)};`);return`<importexportxml><entities>${t.map(e=>`<entity>${l(e)}</entity>`).join("")}</entities></importexportxml>`}const jn=(t,l)=>({operationName:"RemoveSolutionComponent",operationType:"action",parameters:{ComponentId:t.id,ComponentType:t.type,SolutionUniqueName:l}}),Ln=(t,l,e)=>({operationName:"AddSolutionComponent",operationType:"action",parameters:{ComponentId:t.id,ComponentType:t.type,SolutionUniqueName:l,DoNotIncludeSubcomponents:e,AddRequiredComponents:!1}});async function qt(t,l,e,u){const i=[];let r=!1,a=!1;for(let o=0;o<l.length;o++){const c=l[o];if(u==null||u(o,l.length),r&&!(c.kind==="publish"&&a)){i.push({op:c,ok:!1,skipped:!0,error:"not run: an earlier step failed"});continue}try{c.kind==="remove"?await t.execute(jn(c.component,e)):c.kind==="add"?await t.execute(Ln(c.component,e,c.doNotIncludeSubcomponents)):c.kind==="update-form"?(await t.update("systemform",c.edit.form.id,{formxml:c.edit.after}),a=!0):c.kind==="update-view"?(await t.update("savedquery",c.edit.view.id,{fetchxml:c.edit.after.fetchxml,layoutxml:c.edit.after.layoutxml}),a=!0):c.kind==="publish"&&await t.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:Bn(c.tables)}}),i.push({op:c,ok:!0})}catch(k){r=!0,i.push({op:c,ok:!1,error:k.message??String(k)})}}return u==null||u(l.length,l.length),i}function xt(t){switch(t.kind){case"remove":return`RemoveSolutionComponent ${_e(t.component.type)} ${t.component.name}`;case"add":return`AddSolutionComponent ${_e(t.component.type)} ${t.component.name}${t.doNotIncludeSubcomponents?" (DoNotIncludeSubcomponents)":""}`;case"update-form":return`Update form ${t.edit.form.name} (${t.edit.form.table}): formxml`;case"update-view":return`Update view ${t.edit.view.name} (${t.edit.view.table}): fetchxml + layoutxml`;case"publish":return`PublishXml ${t.tables.join(", ")}`}}const Ut=t=>t.replace(/>\s*</g,`>
2
- <`).split(`
3
- `);function Dn(t,l,e=2){const u=Ut(t),i=Ut(l);let r=0;for(;r<u.length&&r<i.length&&u[r]===i[r];)r++;let a=0;for(;a<u.length-r&&a<i.length-r&&u[u.length-1-a]===i[i.length-1-a];)a++;const o=u.slice(r,u.length-a),c=i.slice(r,i.length-a),k=[];if(o.length*c.length>4e6)k.push(...o.map(d=>({t:"-",s:d})),...c.map(d=>({t:"+",s:d})));else{const d=o.length,b=c.length,f=Array.from({length:d+1},()=>new Uint32Array(b+1));for(let g=d-1;g>=0;g--)for(let C=b-1;C>=0;C--)f[g][C]=o[g]===c[C]?f[g+1][C+1]+1:Math.max(f[g+1][C],f[g][C+1]);let h=0,p=0;for(;h<d||p<b;)h<d&&p<b&&o[h]===c[p]?(k.push({t:" ",s:o[h++]}),p++):p<b&&(h>=d||f[h][p+1]>=f[h+1][p])?k.push({t:"+",s:c[p++]}):k.push({t:"-",s:o[h++]})}const x=[...u.slice(0,r).map(d=>({t:" ",s:d})),...k,...u.slice(u.length-a).map(d=>({t:" ",s:d}))],y=x.map(()=>!1);x.forEach((d,b)=>{if(d.t!==" ")for(let f=-e;f<=e;f++)x[b+f]&&(y[b+f]=!0)});const _=[];return x.forEach((d,b)=>{y[b]?_.push(d):(_.length===0||_[_.length-1].t!=="…")&&_.push({t:"…",s:""})}),_}const Mt="sss-dependency-cleaner-backup";function Pn(t,l,e){const u=new Map(t.components.map(i=>[i.rowId,i]));return{kind:Mt,version:1,takenAt:new Date().toISOString(),environment:{name:t.environment.name,url:t.environment.url},solution:{id:t.solution.id,uniqueName:t.solution.uniqueName,friendlyName:t.solution.friendlyName},membership:t.components.map(i=>{var r;return{objectId:i.objectId,type:i.type,behavior:i.behavior,rootObjectId:i.rootRowId?((r=u.get(i.rootRowId))==null?void 0:r.objectId)??null:null,name:i.name??i.objectId}}),forms:l.forms.map(i=>i.form),views:l.views.map(i=>i.view),operations:e.map(xt)}}function Fn(t,l=new Date){const e=l.toISOString().replace(/[:.]/g,"-").slice(0,19);return`dependency-cleaner-backup-${t.replace(/[^a-z0-9._-]+/gi,"_")}-${e}.json`}function qn(t){var e;let l;try{l=JSON.parse(t)}catch(u){throw new Error(`not JSON: ${u.message}`)}if((l==null?void 0:l.kind)!==Mt)throw new Error("not a Dependency Cleaner backup");if(l.version!==1)throw new Error(`unsupported backup version ${String(l.version)}`);if(!((e=l.solution)!=null&&e.uniqueName)||!Array.isArray(l.membership)||!Array.isArray(l.forms)||!Array.isArray(l.views))throw new Error("backup is incomplete");return l}async function Un(t,l,e,u){var f;const i=e.find(h=>h.uniqueName.toLowerCase()===l.solution.uniqueName.toLowerCase());if(!i)throw new Error(`solution ${l.solution.uniqueName} is not in this environment`);if(i.isManaged)throw new Error(`solution ${i.uniqueName} is managed: writes are refused`);const r=[],a=h=>(h??"").replace(/\/+$/,"").toLowerCase();if(!a((f=l.environment)==null?void 0:f.url))throw new Error("backup does not record its environment url");if(a(l.environment.url)!==a(u))throw new Error(`backup was taken in ${l.environment.name} (${l.environment.url}), not this environment (${u}): restore refused`);const o=await Bt(t,i.id),c=(h,p)=>`${h}:${p}`,k=new Map(o.map(h=>[c(h.type,h.objectId),h])),x=[],y=new Set;for(const h of l.membership.filter(p=>!p.rootObjectId||p.rootObjectId===p.objectId)){const p=k.get(c(h.type,h.objectId)),g={type:h.type,id:h.objectId,name:h.name};p?h.type===ie.Entity&&h.behavior===0&&p.behavior!==0&&(x.push({kind:"remove",component:g,reason:"shell → back to all assets"}),x.push({kind:"add",component:g,doNotIncludeSubcomponents:!1,reason:"re-add with all subcomponents"}),y.add(h.objectId)):(x.push({kind:"add",component:g,doNotIncludeSubcomponents:h.behavior!==0,reason:"re-add removed component"}),h.type===ie.Entity&&h.behavior===0&&y.add(h.objectId))}for(const h of l.membership.filter(p=>p.rootObjectId&&p.rootObjectId!==p.objectId))k.has(c(h.type,h.objectId))||y.has(h.rootObjectId)||x.push({kind:"add",component:{type:h.type,id:h.objectId,name:h.name},doNotIncludeSubcomponents:!1,reason:"re-add removed subcomponent"});const[_,d]=await Promise.all([l.forms.length?Dt(t,l.forms.map(h=>h.id)):Promise.resolve([]),l.views.length?Pt(t,l.views.map(h=>h.id)):Promise.resolve([])]),b=new Set;for(const h of l.forms){const p=_.find(g=>g.id===h.id);if(!p){r.push(`Form ${h.name} no longer exists; not restored.`);continue}p.formxml!==h.formxml&&(x.push({kind:"update-form",edit:{form:p,after:h.formxml,removed:[],kept:[],warnings:[]}}),b.add(p.table||h.table))}for(const h of l.views){const p=d.find(g=>g.id===h.id);if(!p){r.push(`View ${h.name} no longer exists; not restored.`);continue}p.fetchxml===h.fetchxml&&p.layoutxml===h.layoutxml||(x.push({kind:"update-view",edit:{view:p,after:{fetchxml:h.fetchxml,layoutxml:h.layoutxml},removed:[],warnings:[]}}),b.add(p.table||h.table))}return b.size&&x.push({kind:"publish",tables:[...b].filter(Boolean).sort()}),{solution:i,ops:x,notes:r}}function Mn(t){return[...new Set(t.split(/[\s,;]+/).map(l=>l.trim().toLowerCase()).filter(Boolean))]}function We(t,l,e){const u=e.toLowerCase();return t.some(i=>l?l.prefix.toLowerCase()===i||l.uniqueName.toLowerCase().startsWith(i):u.startsWith(`${i}_`))}const De=t=>[...new Set(t.map(l=>l.name))].slice(0,4).join(", ")+(t.length>4?"…":"");function Wn(t,l,e,u){var y,_;const i=(d,b)=>({cause:d,fixes:[{kind:"report",label:"Report only: open in maker portal",link:u,note:b}]}),r=t.root&&t.root.behavior===0?t.root:null,a=()=>r?{kind:"shell",label:`Convert table ${r.name} to a shell (remove + add without subcomponents)`,root:r}:null,o={kind:"remove",label:`Remove this ${_e(t.type).toLowerCase()} from the solution`},c=We(e,null,t.name),k=(d,...b)=>({cause:d,fixes:b.filter(f=>!!f)}),x=((_=(y=l.find(d=>d.id===t.id))==null?void 0:y.solution)==null?void 0:_.uniqueName)??"a managed solution";if(t.selfOwned&&t.type===ie.Entity)return k(`Table ${t.name} belongs to ${x}. Shipping it, even as a shell, needs that solution in the target.`,o,{kind:"report",label:"Report only: open in maker portal",link:u});if(t.selfOwned)return k(r?`${_e(t.type)} ${t.name} belongs to ${x} and came in with table ${r.name}, which is in the solution with all assets.`:`${_e(t.type)} ${t.name} belongs to ${x} and is included directly.`,a(),r?null:o);switch(t.type){case ie.Entity:return t.behavior===0?k(`Table added with all assets: its columns, forms and views come along, including ones that need ${De(l)}.`,a()??{kind:"shell",label:`Convert table ${t.name} to a shell`,root:{...t,behavior:0}},o):k(`The table itself requires ${De(l)}.`,o,{kind:"report",label:"Report only: open in maker portal",link:u});case ie.Attribute:return c?k(r?`Column ${t.name} comes with table ${r.name}, which is in the solution with all assets.`:`Column ${t.name} is included directly.`,a(),r?null:o):i(`Your column needs ${De(l)} (for example a lookup to that table). This is a real dependency: the target needs the app, or the column has to be changed by hand.`);case ie.Relationship:case ie.EntityRelationship:return i(`Relationship to ${De(l)}. This is a real dependency: the target needs the app, or the relationship has to be deleted by hand.`);case ie.Form:return k(`Form uses ${De(l)} (a field, subgrid, quick view or library).`,{kind:"edit-form",label:"Edit form: remove those fields (backup first)"},a(),r?null:o);case ie.View:return k(`View uses ${De(l)} (a column, condition or link-entity).`,{kind:"edit-view",label:"Edit view: strip those columns and link-entities (backup first)"},a(),r?null:o);default:return i(`${_e(t.type)} references ${De(l)}. Not edited automatically in v1.`,"Sitemap, app, ribbon, chart, process, web resource and plugin step references are fixed by hand.")}}const Zn=4,Hn=new Set(["default","active","basic"]);class Wt extends Error{constructor(){super("Diagnosis cancelled")}}const Oe=(t,l)=>`${t}:${l}`;async function Gn(t){var p,g,C;const l=t.cancelled??(()=>!1),e=await Bt(t.api,t.solution.id),u=new Set(e.map(m=>m.objectId)),i=new Map(e.map(m=>[m.rowId,m])),r=[],a=new Map;let o=0;if((p=t.onProgress)==null||p.call(t,0,e.length),await Sn(e,Zn,async m=>{var A;const v=Oe(m.type,m.objectId);let N=t.reqCache.get(v);if(!N)try{N=await En(t.api,m.objectId,m.type),t.reqCache.set(v,N)}catch(L){r.push({component:v,error:L.message??String(L)}),N=[]}a.set(m,N.filter(L=>L.requiredId&&L.requiredId!==m.objectId)),(A=t.onProgress)==null||A.call(t,++o,e.length)},l),l())throw new Wt;const c=[...new Set([...a.values()].flat().map(m=>m.requiredId).concat(e.map(m=>m.objectId)))],k=c.length?await An(t.api,c):new Map,x=new Map(t.allSolutions.map(m=>[m.id,m])),y=m=>({uniqueName:m.uniqueName,friendlyName:m.friendlyName,prefix:m.prefix,isManaged:m.isManaged}),_=m=>(k.get(m)??[]).map(v=>x.get(v)).filter(v=>!!v&&v.isManaged&&v.id!==t.solution.id&&!Hn.has(v.uniqueName.toLowerCase())),d=e.map(m=>{const v=m.rootRowId?i.get(m.rootRowId):void 0;return{type:m.type,id:m.objectId,parentId:(v==null?void 0:v.type)===ie.Entity?v.objectId:null}});for(const m of a.values())for(const v of m)d.push({type:v.requiredType,id:v.requiredId,parentId:v.requiredParentId});const b=await In(t.api,t.meta,d),f=(m,v)=>b.get(Oe(m,v))??{type:m,id:v,name:v};for(const m of e){const v=f(m.type,m.objectId);m.name=v.name,m.table=v.table,m.filteredOwner=((g=_(m.objectId).find(N=>We(t.filter,N,v.name)))==null?void 0:g.uniqueName)??null}const h=[];for(const[m,v]of a){const N=[],A=new Set,L={requiredId:m.objectId,requiredType:m.type,requiredParentId:null,requiredBaseSolutionId:null},T=[L,...v];let W=!1;for(const j of T){const te=Oe(j.requiredType,j.requiredId);if(A.has(te))continue;A.add(te);const q=f(j.requiredType,j.requiredId),ne=_(j.requiredId);if(!ne.length&&u.has(j.requiredId)||j===L&&!ne.length)continue;const U=j.requiredBaseSolutionId?x.get(j.requiredBaseSolutionId):void 0,J=(U!=null&&U.isManaged?U:void 0)??ne.find(V=>We(t.filter,V,q.name))??ne[0]??null,O=We(t.filter,J,q.name),R=!!J&&!!((C=t.targetSolutions)!=null&&C.has(J.uniqueName.toLowerCase())),Q=!!t.targetSolutions&&!!J&&!R;!O&&!Q||(j===L&&(W=!0),N.push({...q,solution:J?y(J):null,solutions:ne.map(V=>V.uniqueName),blocker:!R}))}if(!N.length)continue;const Y=f(m.type,m.objectId),E=m.type===ie.Entity?m:m.rootRowId?i.get(m.rootRowId):void 0,B=E&&E.type===ie.Entity?{...f(E.type,E.objectId),behavior:E.behavior??0}:null,s=Wn({...Y,behavior:m.behavior,root:B,selfOwned:W},N,t.filter,t.link(Y));h.push({key:Oe(m.type,m.objectId),dependent:{...Y,rootBehavior:(B==null?void 0:B.behavior)??null,rootTable:B==null?void 0:B.name,selfOwned:W},required:N.map(({blocker:j,...te})=>te),cause:s.cause,fixes:s.fixes,status:N.some(j=>j.blocker)?"blocker":"safe"})}return h.sort((m,v)=>(m.status===v.status?0:m.status==="blocker"?-1:1)||m.dependent.type-v.dependent.type||m.dependent.name.localeCompare(v.dependent.name)),{solution:t.solution,environment:t.environment,target:t.target,filter:t.filter,components:e,findings:h,errors:r,takenAt:new Date().toISOString()}}function Zt(t){let l=t==null?"":String(t);return/^[=+\-@\t\r]/.test(l)&&(l=`'${l}`),/[",\r\n]/.test(l)?`"${l.replace(/"/g,'""')}"`:l}function Kn(t){var e;const l=[["status","dependent type","dependent","table","cause","required type","required","required solution","fixes"].map(Zt).join(",")];for(const u of t.findings)for(const i of u.required)l.push([u.status,_e(u.dependent.type),u.dependent.name,u.dependent.table??u.dependent.rootTable??"",u.cause,_e(i.type),i.name,((e=i.solution)==null?void 0:e.uniqueName)??"",u.fixes.map(r=>r.kind).join(" | ")].map(Zt).join(","));return l.join(`
4
- `)+`
5
- `}function Vn(t){return JSON.stringify({kind:"sss-dependency-cleaner-findings",version:1,takenAt:t.takenAt,environment:t.environment,target:t.target,solution:{uniqueName:t.solution.uniqueName,friendlyName:t.solution.friendlyName,version:t.solution.version},filter:t.filter,findings:t.findings,errors:t.errors},null,2)}const Ht=t=>t.replace(/[^a-z0-9._-]+/gi,"_").replace(/^_+|_+$/g,"")||"solution";var ct=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ut(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Gt={exports:{}};/*!
6
-
7
- JSZip v3.10.2 - A JavaScript class for generating and reading zip files
8
- <http://stuartk.com/jszip>
9
-
10
- (c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
11
- Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
12
-
13
- JSZip uses the library pako released under the MIT license :
14
- https://github.com/nodeca/pako/blob/main/LICENSE
15
- */(function(t,l){(function(e){t.exports=e()})(function(){return function e(u,i,r){function a(k,x){if(!i[k]){if(!u[k]){var y=typeof ut=="function"&&ut;if(!x&&y)return y(k,!0);if(o)return o(k,!0);var _=new Error("Cannot find module '"+k+"'");throw _.code="MODULE_NOT_FOUND",_}var d=i[k]={exports:{}};u[k][0].call(d.exports,function(b){var f=u[k][1][b];return a(f||b)},d,d.exports,e,u,i,r)}return i[k].exports}for(var o=typeof ut=="function"&&ut,c=0;c<r.length;c++)a(r[c]);return a}({1:[function(e,u,i){var r=e("./utils"),a=e("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var k,x,y,_,d,b,f,h=[],p=0,g=c.length,C=g,m=r.getTypeOf(c)!=="string";p<c.length;)C=g-p,y=m?(k=c[p++],x=p<g?c[p++]:0,p<g?c[p++]:0):(k=c.charCodeAt(p++),x=p<g?c.charCodeAt(p++):0,p<g?c.charCodeAt(p++):0),_=k>>2,d=(3&k)<<4|x>>4,b=1<C?(15&x)<<2|y>>6:64,f=2<C?63&y:64,h.push(o.charAt(_)+o.charAt(d)+o.charAt(b)+o.charAt(f));return h.join("")},i.decode=function(c){var k,x,y,_,d,b,f=0,h=0,p="data:";if(c.substr(0,p.length)===p)throw new Error("Invalid base64 input, it looks like a data url.");var g,C=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===o.charAt(64)&&C--,c.charAt(c.length-2)===o.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(g=a.uint8array?new Uint8Array(0|C):new Array(0|C);f<c.length;)k=o.indexOf(c.charAt(f++))<<2|(_=o.indexOf(c.charAt(f++)))>>4,x=(15&_)<<4|(d=o.indexOf(c.charAt(f++)))>>2,y=(3&d)<<6|(b=o.indexOf(c.charAt(f++))),g[h++]=k,d!==64&&(g[h++]=x),b!==64&&(g[h++]=y);return g}},{"./support":30,"./utils":32}],2:[function(e,u,i){var r=e("./external"),a=e("./stream/DataWorker"),o=e("./stream/Crc32Probe"),c=e("./stream/DataLengthProbe");function k(x,y,_,d,b){this.compressedSize=x,this.uncompressedSize=y,this.crc32=_,this.compression=d,this.compressedContent=b}k.prototype={getContentWorker:function(){var x=new a(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),y=this;return x.on("end",function(){if(this.streamInfo.data_length!==y.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),x},getCompressedWorker:function(){return new a(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},k.createWorkerFrom=function(x,y,_){return x.pipe(new o).pipe(new c("uncompressedSize")).pipe(y.compressWorker(_)).pipe(new c("compressedSize")).withStreamInfo("compression",y)},u.exports=k},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,u,i){var r=e("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},i.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,u,i){var r=e("./utils"),a=function(){for(var o,c=[],k=0;k<256;k++){o=k;for(var x=0;x<8;x++)o=1&o?3988292384^o>>>1:o>>>1;c[k]=o}return c}();u.exports=function(o,c){return o!==void 0&&o.length?r.getTypeOf(o)!=="string"?function(k,x,y,_){var d=a,b=_+y;k^=-1;for(var f=_;f<b;f++)k=k>>>8^d[255&(k^x[f])];return-1^k}(0|c,o,o.length,0):function(k,x,y,_){var d=a,b=_+y;k^=-1;for(var f=_;f<b;f++)k=k>>>8^d[255&(k^x.charCodeAt(f))];return-1^k}(0|c,o,o.length,0):0}},{"./utils":32}],5:[function(e,u,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(e,u,i){var r=null;r=typeof Promise<"u"?Promise:e("lie"),u.exports={Promise:r}},{lie:37}],7:[function(e,u,i){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=e("pako"),o=e("./utils"),c=e("./stream/GenericWorker"),k=r?"uint8array":"array";function x(y,_){c.call(this,"FlateWorker/"+y),this._pako=null,this._pakoAction=y,this._pakoOptions=_,this.meta={}}i.magic="\b\0",o.inherits(x,c),x.prototype.processChunk=function(y){this.meta=y.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(k,y.data),!1)},x.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},x.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},x.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var y=this;this._pako.onData=function(_){y.push({data:_,meta:y.meta})}},i.compressWorker=function(y){return new x("Deflate",y)},i.uncompressWorker=function(){return new x("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,u,i){function r(d,b){var f,h="";for(f=0;f<b;f++)h+=String.fromCharCode(255&d),d>>>=8;return h}function a(d,b,f,h,p,g){var C,m,v=d.file,N=d.compression,A=g!==k.utf8encode,L=o.transformTo("string",g(v.name)),T=o.transformTo("string",k.utf8encode(v.name)),W=v.comment,Y=o.transformTo("string",g(W)),E=o.transformTo("string",k.utf8encode(W)),B=T.length!==v.name.length,s=E.length!==W.length,j="",te="",q="",ne=v.dir,U=v.date,J={crc32:0,compressedSize:0,uncompressedSize:0};b&&!f||(J.crc32=d.crc32,J.compressedSize=d.compressedSize,J.uncompressedSize=d.uncompressedSize);var O=0;b&&(O|=8),A||!B&&!s||(O|=2048);var R=0,Q=0;ne&&(R|=16),p==="UNIX"?(Q=798,R|=function(G,de){var be=G;return G||(be=de?16893:33204),(65535&be)<<16}(v.unixPermissions,ne)):(Q=20,R|=function(G){return 63&(G||0)}(v.dosPermissions)),C=U.getUTCHours(),C<<=6,C|=U.getUTCMinutes(),C<<=5,C|=U.getUTCSeconds()/2,m=U.getUTCFullYear()-1980,m<<=4,m|=U.getUTCMonth()+1,m<<=5,m|=U.getUTCDate(),B&&(te=r(1,1)+r(x(L),4)+T,j+="up"+r(te.length,2)+te),s&&(q=r(1,1)+r(x(Y),4)+E,j+="uc"+r(q.length,2)+q);var V="";return V+=`
16
- \0`,V+=r(O,2),V+=N.magic,V+=r(C,2),V+=r(m,2),V+=r(J.crc32,4),V+=r(J.compressedSize,4),V+=r(J.uncompressedSize,4),V+=r(L.length,2),V+=r(j.length,2),{fileRecord:y.LOCAL_FILE_HEADER+V+L+j,dirRecord:y.CENTRAL_FILE_HEADER+r(Q,2)+V+r(Y.length,2)+"\0\0\0\0"+r(R,4)+r(h,4)+L+j+Y}}var o=e("../utils"),c=e("../stream/GenericWorker"),k=e("../utf8"),x=e("../crc32"),y=e("../signature");function _(d,b,f,h){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=f,this.encodeFileName=h,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(_,c),_.prototype.push=function(d){var b=d.meta.percent||0,f=this.entriesCount,h=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,c.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:f?(b+100*(f-h-1))/f:100}}))},_.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var b=this.streamFiles&&!d.file.dir;if(b){var f=a(d,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},_.prototype.closedSource=function(d){this.accumulate=!1;var b=this.streamFiles&&!d.file.dir,f=a(d,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),b)this.push({data:function(h){return y.DATA_DESCRIPTOR+r(h.crc32,4)+r(h.compressedSize,4)+r(h.uncompressedSize,4)}(d),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},_.prototype.flush=function(){for(var d=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var f=this.bytesWritten-d,h=function(p,g,C,m,v){var N=o.transformTo("string",v(m));return y.CENTRAL_DIRECTORY_END+"\0\0\0\0"+r(p,2)+r(p,2)+r(g,4)+r(C,4)+r(N.length,2)+N}(this.dirRecords.length,f,d,this.zipComment,this.encodeFileName);this.push({data:h,meta:{percent:100}})},_.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},_.prototype.registerPrevious=function(d){this._sources.push(d);var b=this;return d.on("data",function(f){b.processChunk(f)}),d.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),d.on("error",function(f){b.error(f)}),this},_.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},_.prototype.error=function(d){var b=this._sources;if(!c.prototype.error.call(this,d))return!1;for(var f=0;f<b.length;f++)try{b[f].error(d)}catch{}return!0},_.prototype.lock=function(){c.prototype.lock.call(this);for(var d=this._sources,b=0;b<d.length;b++)d[b].lock()},u.exports=_},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,u,i){var r=e("../compressions"),a=e("./ZipFileWorker");i.generateWorker=function(o,c,k){var x=new a(c.streamFiles,k,c.platform,c.encodeFileName),y=0;try{o.forEach(function(_,d){y++;var b=function(g,C){var m=g||C,v=r[m];if(!v)throw new Error(m+" is not a valid compression method !");return v}(d.options.compression,c.compression),f=d.options.compressionOptions||c.compressionOptions||{},h=d.dir,p=d.date;d._compressWorker(b,f).withStreamInfo("file",{name:_,dir:h,date:p,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(x)}),x.entriesCount=y}catch(_){x.error(_)}return x}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,u,i){function r(){if(!(this instanceof r))return new r;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new r;for(var o in this)typeof this[o]!="function"&&(a[o]=this[o]);return a}}(r.prototype=e("./object")).loadAsync=e("./load"),r.support=e("./support"),r.defaults=e("./defaults"),r.version="3.10.2",r.loadAsync=function(a,o){return new r().loadAsync(a,o)},r.external=e("./external"),u.exports=r},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,u,i){var r=e("./utils"),a=e("./external"),o=e("./utf8"),c=e("./zipEntries"),k=e("./stream/Crc32Probe"),x=e("./nodejsUtils");function y(_){return new a.Promise(function(d,b){var f=_.decompressed.getContentWorker().pipe(new k);f.on("error",function(h){b(h)}).on("end",function(){f.streamInfo.crc32!==_.decompressed.crc32?b(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}u.exports=function(_,d){var b=this;return d=r.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),x.isNode&&x.isStream(_)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):r.prepareContent("the loaded zip file",_,!0,d.optimizedBinaryString,d.base64).then(function(f){var h=new c(d);return h.load(f),h}).then(function(f){var h=[a.Promise.resolve(f)],p=f.files;if(d.checkCRC32)for(var g=0;g<p.length;g++)h.push(y(p[g]));return a.Promise.all(h)}).then(function(f){for(var h=f.shift(),p=h.files,g=0;g<p.length;g++){var C=p[g],m=C.fileNameStr,v=r.resolve(C.fileNameStr);b.file(v,C.decompressed,{binary:!0,optimizedBinaryString:!0,date:C.date,dir:C.dir,comment:C.fileCommentStr.length?C.fileCommentStr:null,unixPermissions:C.unixPermissions,dosPermissions:C.dosPermissions,createFolders:d.createFolders}),C.dir||(b.file(v).unsafeOriginalName=m)}return h.zipComment.length&&(b.comment=h.zipComment),b})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,u,i){var r=e("../utils"),a=e("../stream/GenericWorker");function o(c,k){a.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(k)}r.inherits(o,a),o.prototype._bindStream=function(c){var k=this;(this._stream=c).pause(),c.on("data",function(x){k.push({data:x,meta:{percent:0}})}).on("error",function(x){k.isPaused?this.generatedError=x:k.error(x)}).on("end",function(){k.isPaused?k._upstreamEnded=!0:k.end()})},o.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},u.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,u,i){var r=e("readable-stream").Readable;function a(o,c,k){r.call(this,c),this._helper=o;var x=this;o.on("data",function(y,_){x.push(y)||x._helper.pause(),k&&k(_)}).on("error",function(y){x.emit("error",y)}).on("end",function(){x.push(null)})}e("../utils").inherits(a,r),a.prototype._read=function(){this._helper.resume()},u.exports=a},{"../utils":32,"readable-stream":16}],14:[function(e,u,i){u.exports={isNode:typeof Buffer<"u",newBufferFrom:function(r,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(r,a);if(typeof r=="number")throw new Error('The "data" argument must not be a number');return new Buffer(r,a)},allocBuffer:function(r){if(Buffer.alloc)return Buffer.alloc(r);var a=new Buffer(r);return a.fill(0),a},isBuffer:function(r){return Buffer.isBuffer(r)},isStream:function(r){return r&&typeof r.on=="function"&&typeof r.pause=="function"&&typeof r.resume=="function"}}},{}],15:[function(e,u,i){function r(v,N,A){var L,T=o.getTypeOf(N),W=o.extend(A||{},x);W.date=W.date||new Date,W.compression!==null&&(W.compression=W.compression.toUpperCase()),typeof W.unixPermissions=="string"&&(W.unixPermissions=parseInt(W.unixPermissions,8)),W.unixPermissions&&16384&W.unixPermissions&&(W.dir=!0),W.dosPermissions&&16&W.dosPermissions&&(W.dir=!0),W.dir&&(v=p(v)),W.createFolders&&(L=h(v))&&g.call(this,L,!0);var Y=T==="string"&&W.binary===!1&&W.base64===!1;A&&A.binary!==void 0||(W.binary=!Y),(N instanceof y&&N.uncompressedSize===0||W.dir||!N||N.length===0)&&(W.base64=!1,W.binary=!0,N="",W.compression="STORE",T="string");var E=null;E=N instanceof y||N instanceof c?N:b.isNode&&b.isStream(N)?new f(v,N):o.prepareContent(v,N,W.binary,W.optimizedBinaryString,W.base64);var B=new _(v,E,W);this.files[v]=B}var a=e("./utf8"),o=e("./utils"),c=e("./stream/GenericWorker"),k=e("./stream/StreamHelper"),x=e("./defaults"),y=e("./compressedObject"),_=e("./zipObject"),d=e("./generate"),b=e("./nodejsUtils"),f=e("./nodejs/NodejsStreamInputAdapter"),h=function(v){v.slice(-1)==="/"&&(v=v.substring(0,v.length-1));var N=v.lastIndexOf("/");return 0<N?v.substring(0,N):""},p=function(v){return v.slice(-1)!=="/"&&(v+="/"),v},g=function(v,N){return N=N!==void 0?N:x.createFolders,v=p(v),this.files[v]||r.call(this,v,null,{dir:!0,createFolders:N}),this.files[v]};function C(v){return Object.prototype.toString.call(v)==="[object RegExp]"}var m={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(v){var N,A,L;for(N in this.files)L=this.files[N],(A=N.slice(this.root.length,N.length))&&N.slice(0,this.root.length)===this.root&&v(A,L)},filter:function(v){var N=[];return this.forEach(function(A,L){v(A,L)&&N.push(L)}),N},file:function(v,N,A){if(arguments.length!==1)return v=this.root+v,r.call(this,v,N,A),this;if(C(v)){var L=v;return this.filter(function(W,Y){return!Y.dir&&L.test(W)})}var T=this.files[this.root+v];return T&&!T.dir?T:null},folder:function(v){if(!v)return this;if(C(v))return this.filter(function(T,W){return W.dir&&v.test(T)});var N=this.root+v,A=g.call(this,N),L=this.clone();return L.root=A.name,L},remove:function(v){v=this.root+v;var N=this.files[v];if(N||(v.slice(-1)!=="/"&&(v+="/"),N=this.files[v]),N&&!N.dir)delete this.files[v];else for(var A=this.filter(function(T,W){return W.name.slice(0,v.length)===v}),L=0;L<A.length;L++)delete this.files[A[L].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(v){var N,A={};try{if((A=o.extend(v||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=A.type.toLowerCase(),A.compression=A.compression.toUpperCase(),A.type==="binarystring"&&(A.type="string"),!A.type)throw new Error("No output type specified.");o.checkSupport(A.type),A.platform!=="darwin"&&A.platform!=="freebsd"&&A.platform!=="linux"&&A.platform!=="sunos"||(A.platform="UNIX"),A.platform==="win32"&&(A.platform="DOS");var L=A.comment||this.comment||"";N=d.generateWorker(this,A,L)}catch(T){(N=new c("error")).error(T)}return new k(N,A.type||"string",A.mimeType)},generateAsync:function(v,N){return this.generateInternalStream(v).accumulate(N)},generateNodeStream:function(v,N){return(v=v||{}).type||(v.type="nodebuffer"),this.generateInternalStream(v).toNodejsStream(N)}};u.exports=m},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,u,i){u.exports=e("stream")},{stream:void 0}],17:[function(e,u,i){var r=e("./DataReader");function a(o){r.call(this,o);for(var c=0;c<this.data.length;c++)o[c]=255&o[c]}e("../utils").inherits(a,r),a.prototype.byteAt=function(o){return this.data[this.zero+o]},a.prototype.lastIndexOfSignature=function(o){for(var c=o.charCodeAt(0),k=o.charCodeAt(1),x=o.charCodeAt(2),y=o.charCodeAt(3),_=this.length-4;0<=_;--_)if(this.data[_]===c&&this.data[_+1]===k&&this.data[_+2]===x&&this.data[_+3]===y)return _-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var c=o.charCodeAt(0),k=o.charCodeAt(1),x=o.charCodeAt(2),y=o.charCodeAt(3),_=this.readData(4);return c===_[0]&&k===_[1]&&x===_[2]&&y===_[3]},a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},u.exports=a},{"../utils":32,"./DataReader":18}],18:[function(e,u,i){var r=e("../utils");function a(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var c,k=0;for(this.checkOffset(o),c=this.index+o-1;c>=this.index;c--)k=(k<<8)+this.byteAt(c);return this.index+=o,k},readString:function(o){return r.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},u.exports=a},{"../utils":32}],19:[function(e,u,i){var r=e("./Uint8ArrayReader");function a(o){r.call(this,o)}e("../utils").inherits(a,r),a.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},u.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,u,i){var r=e("./DataReader");function a(o){r.call(this,o)}e("../utils").inherits(a,r),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},u.exports=a},{"../utils":32,"./DataReader":18}],21:[function(e,u,i){var r=e("./ArrayReader");function a(o){r.call(this,o)}e("../utils").inherits(a,r),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},u.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(e,u,i){var r=e("../utils"),a=e("../support"),o=e("./ArrayReader"),c=e("./StringReader"),k=e("./NodeBufferReader"),x=e("./Uint8ArrayReader");u.exports=function(y){var _=r.getTypeOf(y);return r.checkSupport(_),_!=="string"||a.uint8array?_==="nodebuffer"?new k(y):a.uint8array?new x(r.transformTo("uint8array",y)):new o(r.transformTo("array",y)):new c(y)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,u,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,u,i){var r=e("./GenericWorker"),a=e("../utils");function o(c){r.call(this,"ConvertWorker to "+c),this.destType=c}a.inherits(o,r),o.prototype.processChunk=function(c){this.push({data:a.transformTo(this.destType,c.data),meta:c.meta})},u.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,u,i){var r=e("./GenericWorker"),a=e("../crc32");function o(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,r),o.prototype.processChunk=function(c){this.streamInfo.crc32=a(c.data,this.streamInfo.crc32||0),this.push(c)},u.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,u,i){var r=e("../utils"),a=e("./GenericWorker");function o(c){a.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}r.inherits(o,a),o.prototype.processChunk=function(c){if(c){var k=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=k+c.data.length}a.prototype.processChunk.call(this,c)},u.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,u,i){var r=e("../utils"),a=e("./GenericWorker");function o(c){a.call(this,"DataWorker");var k=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(x){k.dataIsReady=!0,k.data=x,k.max=x&&x.length||0,k.type=r.getTypeOf(x),k.isPaused||k._tickAndRepeat()},function(x){k.error(x)})}r.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,k=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,k);break;case"uint8array":c=this.data.subarray(this.index,k);break;case"array":case"nodebuffer":c=this.data.slice(this.index,k)}return this.index=k,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},u.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,u,i){function r(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var c=0;c<this._listeners[a].length;c++)this._listeners[a][c].call(this,o)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var o=this;return a.on("data",function(c){o.processChunk(c)}),a.on("end",function(){o.end()}),a.on("error",function(c){o.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,o){return this.extraStreamInfo[a]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},u.exports=r},{}],29:[function(e,u,i){var r=e("../utils"),a=e("./ConvertWorker"),o=e("./GenericWorker"),c=e("../base64"),k=e("../support"),x=e("../external"),y=null;if(k.nodestream)try{y=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function _(b,f){return new x.Promise(function(h,p){var g=[],C=b._internalType,m=b._outputType,v=b._mimeType;b.on("data",function(N,A){g.push(N),f&&f(A)}).on("error",function(N){g=[],p(N)}).on("end",function(){try{var N=function(A,L,T){switch(A){case"blob":return r.newBlob(r.transformTo("arraybuffer",L),T);case"base64":return c.encode(L);default:return r.transformTo(A,L)}}(m,function(A,L){var T,W=0,Y=null,E=0;for(T=0;T<L.length;T++)E+=L[T].length;switch(A){case"string":return L.join("");case"array":return Array.prototype.concat.apply([],L);case"uint8array":for(Y=new Uint8Array(E),T=0;T<L.length;T++)Y.set(L[T],W),W+=L[T].length;return Y;case"nodebuffer":return Buffer.concat(L);default:throw new Error("concat : unsupported type '"+A+"'")}}(C,g),v);h(N)}catch(A){p(A)}g=[]}).resume()})}function d(b,f,h){var p=f;switch(f){case"blob":case"arraybuffer":p="uint8array";break;case"base64":p="string"}try{this._internalType=p,this._outputType=f,this._mimeType=h,r.checkSupport(p),this._worker=b.pipe(new a(p)),b.lock()}catch(g){this._worker=new o("error"),this._worker.error(g)}}d.prototype={accumulate:function(b){return _(this,b)},on:function(b,f){var h=this;return b==="data"?this._worker.on(b,function(p){f.call(h,p.data,p.meta)}):this._worker.on(b,function(){r.delay(f,arguments,h)}),this},resume:function(){return r.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(b){if(r.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new y(this,{objectMode:this._outputType!=="nodebuffer"},b)}},u.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,u,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var r=new ArrayBuffer(0);try{i.blob=new Blob([r],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(r),i.blob=a.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!e("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(e,u,i){for(var r=e("./utils"),a=e("./support"),o=e("./nodejsUtils"),c=e("./stream/GenericWorker"),k=new Array(256),x=0;x<256;x++)k[x]=252<=x?6:248<=x?5:240<=x?4:224<=x?3:192<=x?2:1;k[254]=k[254]=1;function y(){c.call(this,"utf-8 decode"),this.leftOver=null}function _(){c.call(this,"utf-8 encode")}i.utf8encode=function(d){return a.nodebuffer?o.newBufferFrom(d,"utf-8"):function(b){var f,h,p,g,C,m=b.length,v=0;for(g=0;g<m;g++)(64512&(h=b.charCodeAt(g)))==55296&&g+1<m&&(64512&(p=b.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),g++),v+=h<128?1:h<2048?2:h<65536?3:4;for(f=a.uint8array?new Uint8Array(v):new Array(v),g=C=0;C<v;g++)(64512&(h=b.charCodeAt(g)))==55296&&g+1<m&&(64512&(p=b.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),g++),h<128?f[C++]=h:(h<2048?f[C++]=192|h>>>6:(h<65536?f[C++]=224|h>>>12:(f[C++]=240|h>>>18,f[C++]=128|h>>>12&63),f[C++]=128|h>>>6&63),f[C++]=128|63&h);return f}(d)},i.utf8decode=function(d){return a.nodebuffer?r.transformTo("nodebuffer",d).toString("utf-8"):function(b){var f,h,p,g,C=b.length,m=new Array(2*C);for(f=h=0;f<C;)if((p=b[f++])<128)m[h++]=p;else if(4<(g=k[p]))m[h++]=65533,f+=g-1;else{for(p&=g===2?31:g===3?15:7;1<g&&f<C;)p=p<<6|63&b[f++],g--;1<g?m[h++]=65533:p<65536?m[h++]=p:(p-=65536,m[h++]=55296|p>>10&1023,m[h++]=56320|1023&p)}return m.length!==h&&(m.subarray?m=m.subarray(0,h):m.length=h),r.applyFromCharCode(m)}(d=r.transformTo(a.uint8array?"uint8array":"array",d))},r.inherits(y,c),y.prototype.processChunk=function(d){var b=r.transformTo(a.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var f=b;(b=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),b.set(f,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var h=function(g,C){var m;for((C=C||g.length)>g.length&&(C=g.length),m=C-1;0<=m&&(192&g[m])==128;)m--;return m<0||m===0?C:m+k[g[m]]>C?m:C}(b),p=b;h!==b.length&&(a.uint8array?(p=b.subarray(0,h),this.leftOver=b.subarray(h,b.length)):(p=b.slice(0,h),this.leftOver=b.slice(h,b.length))),this.push({data:i.utf8decode(p),meta:d.meta})},y.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=y,r.inherits(_,c),_.prototype.processChunk=function(d){this.push({data:i.utf8encode(d.data),meta:d.meta})},i.Utf8EncodeWorker=_},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,u,i){var r=e("./support"),a=e("./base64"),o=e("./nodejsUtils"),c=e("./external");function k(f){return f}function x(f,h){for(var p=0;p<f.length;++p)h[p]=255&f.charCodeAt(p);return h}e("setimmediate"),i.newBlob=function(f,h){i.checkSupport("blob");try{return new Blob([f],{type:h})}catch{try{var p=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return p.append(f),p.getBlob(h)}catch{throw new Error("Bug : can't construct the Blob.")}}};var y={stringifyByChunk:function(f,h,p){var g=[],C=0,m=f.length;if(m<=p)return String.fromCharCode.apply(null,f);for(;C<m;)h==="array"||h==="nodebuffer"?g.push(String.fromCharCode.apply(null,f.slice(C,Math.min(C+p,m)))):g.push(String.fromCharCode.apply(null,f.subarray(C,Math.min(C+p,m)))),C+=p;return g.join("")},stringifyByChar:function(f){for(var h="",p=0;p<f.length;p++)h+=String.fromCharCode(f[p]);return h},applyCanBeUsed:{uint8array:function(){try{return r.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return r.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}}()}};function _(f){var h=65536,p=i.getTypeOf(f),g=!0;if(p==="uint8array"?g=y.applyCanBeUsed.uint8array:p==="nodebuffer"&&(g=y.applyCanBeUsed.nodebuffer),g)for(;1<h;)try{return y.stringifyByChunk(f,p,h)}catch{h=Math.floor(h/2)}return y.stringifyByChar(f)}function d(f,h){for(var p=0;p<f.length;p++)h[p]=f[p];return h}i.applyFromCharCode=_;var b={};b.string={string:k,array:function(f){return x(f,new Array(f.length))},arraybuffer:function(f){return b.string.uint8array(f).buffer},uint8array:function(f){return x(f,new Uint8Array(f.length))},nodebuffer:function(f){return x(f,o.allocBuffer(f.length))}},b.array={string:_,array:k,arraybuffer:function(f){return new Uint8Array(f).buffer},uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return o.newBufferFrom(f)}},b.arraybuffer={string:function(f){return _(new Uint8Array(f))},array:function(f){return d(new Uint8Array(f),new Array(f.byteLength))},arraybuffer:k,uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return o.newBufferFrom(new Uint8Array(f))}},b.uint8array={string:_,array:function(f){return d(f,new Array(f.length))},arraybuffer:function(f){return f.buffer},uint8array:k,nodebuffer:function(f){return o.newBufferFrom(f)}},b.nodebuffer={string:_,array:function(f){return d(f,new Array(f.length))},arraybuffer:function(f){return b.nodebuffer.uint8array(f).buffer},uint8array:function(f){return d(f,new Uint8Array(f.length))},nodebuffer:k},i.transformTo=function(f,h){if(h=h||"",!f)return h;i.checkSupport(f);var p=i.getTypeOf(h);return b[p][f](h)},i.resolve=function(f){for(var h=f.split("/"),p=[],g=0;g<h.length;g++){var C=h[g];C==="."||C===""&&g!==0&&g!==h.length-1||(C===".."?p.pop():p.push(C))}return p.join("/")},i.getTypeOf=function(f){if(typeof f=="string")return"string";var h=Object.prototype.toString.call(f);return h==="[object Array]"?"array":r.nodebuffer&&o.isBuffer(f)?"nodebuffer":r.uint8array&&h==="[object Uint8Array]"?"uint8array":r.arraybuffer&&h==="[object ArrayBuffer]"?"arraybuffer":void 0},i.checkSupport=function(f){if(!r[f.toLowerCase()])throw new Error(f+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(f){var h,p,g="";for(p=0;p<(f||"").length;p++)g+="\\x"+((h=f.charCodeAt(p))<16?"0":"")+h.toString(16).toUpperCase();return g},i.delay=function(f,h,p){setImmediate(function(){f.apply(p||null,h||[])})},i.inherits=function(f,h){function p(){}p.prototype=h.prototype,f.prototype=new p},i.extend=function(){var f,h,p={};for(f=0;f<arguments.length;f++)for(h in arguments[f])Object.prototype.hasOwnProperty.call(arguments[f],h)&&p[h]===void 0&&(p[h]=arguments[f][h]);return p},i.prepareContent=function(f,h,p,g,C){return c.Promise.resolve(h).then(function(m){return r.blob&&(m instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(m))!==-1)?Blob.prototype.arrayBuffer!==void 0?m.arrayBuffer():typeof FileReader<"u"?new c.Promise(function(v,N){var A=new FileReader;A.onload=function(L){v(L.target.result)},A.onerror=function(L){N(L.target.error)},A.readAsArrayBuffer(m)}):c.Promise.reject(new Error(f+" is a Blob, but we have no way of reading it.")):m}).then(function(m){var v=i.getTypeOf(m);return v?(v==="arraybuffer"?m=i.transformTo("uint8array",m):v==="string"&&(C?m=a.decode(m):p&&g!==!0&&(m=function(N){return x(N,r.uint8array?new Uint8Array(N.length):new Array(N.length))}(m))),m):c.Promise.reject(new Error("Can't read the data of '"+f+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,u,i){var r=e("./reader/readerFor"),a=e("./utils"),o=e("./signature"),c=e("./zipEntry"),k=e("./support");function x(y){this.files=[],this.loadOptions=y}x.prototype={checkSignature:function(y){if(!this.reader.readAndCheckSignature(y)){this.reader.index-=4;var _=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(_)+", expected "+a.pretty(y)+")")}},isSignature:function(y,_){var d=this.reader.index;this.reader.setIndex(y);var b=this.reader.readString(4)===_;return this.reader.setIndex(d),b},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var y=this.reader.readData(this.zipCommentLength),_=k.uint8array?"uint8array":"array",d=a.transformTo(_,y);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var y,_,d,b=this.zip64EndOfCentralSize-44;0<b;)y=this.reader.readInt(2),_=this.reader.readInt(4),d=this.reader.readData(_),this.zip64ExtensibleData[y]={id:y,length:_,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var y,_;for(y=0;y<this.files.length;y++)_=this.files[y],this.reader.setIndex(_.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),_.readLocalPart(this.reader),_.handleUTF8(),_.processAttributes()},readCentralDir:function(){var y;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(y=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(y);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var y=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(y<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(y);var _=y;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(y=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(y),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var b=_-d;if(0<b)this.isSignature(_,o.CENTRAL_FILE_HEADER)||(this.reader.zero=b);else if(b<0)throw new Error("Corrupted zip: missing "+Math.abs(b)+" bytes.")},prepareReader:function(y){this.reader=r(y)},load:function(y){this.prepareReader(y),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},u.exports=x},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,u,i){var r=e("./reader/readerFor"),a=e("./utils"),o=e("./compressedObject"),c=e("./crc32"),k=e("./utf8"),x=e("./compressions"),y=e("./support");function _(d,b){this.options=d,this.loadOptions=b}_.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(d){var b,f;if(d.skip(22),this.fileNameLength=d.readInt(2),f=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(f),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((b=function(h){for(var p in x)if(Object.prototype.hasOwnProperty.call(x,p)&&x[p].magic===h)return x[p];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,b,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var b=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(b),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),d==0&&(this.dosPermissions=63&this.externalFileAttributes),d==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=r(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var b,f,h,p=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<p;)b=d.readInt(2),f=d.readInt(2),h=d.readData(f),this.extraFields[b]={id:b,length:f,value:h};d.setIndex(p)},handleUTF8:function(){var d=y.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=k.utf8decode(this.fileName),this.fileCommentStr=k.utf8decode(this.fileComment);else{var b=this.findExtraFieldUnicodePath();if(b!==null)this.fileNameStr=b;else{var f=a.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(f)}var h=this.findExtraFieldUnicodeComment();if(h!==null)this.fileCommentStr=h;else{var p=a.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(p)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var b=r(d.value);return b.readInt(1)!==1||c(this.fileName)!==b.readInt(4)?null:k.utf8decode(b.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var b=r(d.value);return b.readInt(1)!==1||c(this.fileComment)!==b.readInt(4)?null:k.utf8decode(b.readData(d.length-5))}return null}},u.exports=_},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,u,i){function r(b,f,h){this.name=b,this.dir=h.dir,this.date=h.date,this.comment=h.comment,this.unixPermissions=h.unixPermissions,this.dosPermissions=h.dosPermissions,this._data=f,this._dataBinary=h.binary,this.options={compression:h.compression,compressionOptions:h.compressionOptions}}var a=e("./stream/StreamHelper"),o=e("./stream/DataWorker"),c=e("./utf8"),k=e("./compressedObject"),x=e("./stream/GenericWorker");r.prototype={internalStream:function(b){var f=null,h="string";try{if(!b)throw new Error("No output type specified.");var p=(h=b.toLowerCase())==="string"||h==="text";h!=="binarystring"&&h!=="text"||(h="string"),f=this._decompressWorker();var g=!this._dataBinary;g&&!p&&(f=f.pipe(new c.Utf8EncodeWorker)),!g&&p&&(f=f.pipe(new c.Utf8DecodeWorker))}catch(C){(f=new x("error")).error(C)}return new a(f,h,"")},async:function(b,f){return this.internalStream(b).accumulate(f)},nodeStream:function(b,f){return this.internalStream(b||"nodebuffer").toNodejsStream(f)},_compressWorker:function(b,f){if(this._data instanceof k&&this._data.compression.magic===b.magic)return this._data.getCompressedWorker();var h=this._decompressWorker();return this._dataBinary||(h=h.pipe(new c.Utf8EncodeWorker)),k.createWorkerFrom(h,b,f)},_decompressWorker:function(){return this._data instanceof k?this._data.getContentWorker():this._data instanceof x?this._data:new o(this._data)}};for(var y=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],_=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<y.length;d++)r.prototype[y[d]]=_;u.exports=r},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,u,i){(function(r){var a,o,c=r.MutationObserver||r.WebKitMutationObserver;if(c){var k=0,x=new c(b),y=r.document.createTextNode("");x.observe(y,{characterData:!0}),a=function(){y.data=k=++k%2}}else if(r.setImmediate||r.MessageChannel===void 0)a="document"in r&&"onreadystatechange"in r.document.createElement("script")?function(){var f=r.document.createElement("script");f.onreadystatechange=function(){b(),f.onreadystatechange=null,f.parentNode.removeChild(f),f=null},r.document.documentElement.appendChild(f)}:function(){setTimeout(b,0)};else{var _=new r.MessageChannel;_.port1.onmessage=b,a=function(){_.port2.postMessage(0)}}var d=[];function b(){var f,h;o=!0;for(var p=d.length;p;){for(h=d,d=[],f=-1;++f<p;)h[f]();p=d.length}o=!1}u.exports=function(f){d.push(f)!==1||o||a()}}).call(this,typeof ct<"u"?ct:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(e,u,i){var r=e("immediate");function a(){}var o={},c=["REJECTED"],k=["FULFILLED"],x=["PENDING"];function y(p){if(typeof p!="function")throw new TypeError("resolver must be a function");this.state=x,this.queue=[],this.outcome=void 0,p!==a&&f(this,p)}function _(p,g,C){this.promise=p,typeof g=="function"&&(this.onFulfilled=g,this.callFulfilled=this.otherCallFulfilled),typeof C=="function"&&(this.onRejected=C,this.callRejected=this.otherCallRejected)}function d(p,g,C){r(function(){var m;try{m=g(C)}catch(v){return o.reject(p,v)}m===p?o.reject(p,new TypeError("Cannot resolve promise with itself")):o.resolve(p,m)})}function b(p){var g=p&&p.then;if(p&&(typeof p=="object"||typeof p=="function")&&typeof g=="function")return function(){g.apply(p,arguments)}}function f(p,g){var C=!1;function m(A){C||(C=!0,o.reject(p,A))}function v(A){C||(C=!0,o.resolve(p,A))}var N=h(function(){g(v,m)});N.status==="error"&&m(N.value)}function h(p,g){var C={};try{C.value=p(g),C.status="success"}catch(m){C.status="error",C.value=m}return C}(u.exports=y).prototype.finally=function(p){if(typeof p!="function")return this;var g=this.constructor;return this.then(function(C){return g.resolve(p()).then(function(){return C})},function(C){return g.resolve(p()).then(function(){throw C})})},y.prototype.catch=function(p){return this.then(null,p)},y.prototype.then=function(p,g){if(typeof p!="function"&&this.state===k||typeof g!="function"&&this.state===c)return this;var C=new this.constructor(a);return this.state!==x?d(C,this.state===k?p:g,this.outcome):this.queue.push(new _(C,p,g)),C},_.prototype.callFulfilled=function(p){o.resolve(this.promise,p)},_.prototype.otherCallFulfilled=function(p){d(this.promise,this.onFulfilled,p)},_.prototype.callRejected=function(p){o.reject(this.promise,p)},_.prototype.otherCallRejected=function(p){d(this.promise,this.onRejected,p)},o.resolve=function(p,g){var C=h(b,g);if(C.status==="error")return o.reject(p,C.value);var m=C.value;if(m)f(p,m);else{p.state=k,p.outcome=g;for(var v=-1,N=p.queue.length;++v<N;)p.queue[v].callFulfilled(g)}return p},o.reject=function(p,g){p.state=c,p.outcome=g;for(var C=-1,m=p.queue.length;++C<m;)p.queue[C].callRejected(g);return p},y.resolve=function(p){return p instanceof this?p:o.resolve(new this(a),p)},y.reject=function(p){var g=new this(a);return o.reject(g,p)},y.all=function(p){var g=this;if(Object.prototype.toString.call(p)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=p.length,m=!1;if(!C)return this.resolve([]);for(var v=new Array(C),N=0,A=-1,L=new this(a);++A<C;)T(p[A],A);return L;function T(W,Y){g.resolve(W).then(function(E){v[Y]=E,++N!==C||m||(m=!0,o.resolve(L,v))},function(E){m||(m=!0,o.reject(L,E))})}},y.race=function(p){var g=this;if(Object.prototype.toString.call(p)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=p.length,m=!1;if(!C)return this.resolve([]);for(var v=-1,N=new this(a);++v<C;)A=p[v],g.resolve(A).then(function(L){m||(m=!0,o.resolve(N,L))},function(L){m||(m=!0,o.reject(N,L))});var A;return N}},{immediate:36}],38:[function(e,u,i){var r={};(0,e("./lib/utils/common").assign)(r,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),u.exports=r},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,u,i){var r=e("./zlib/deflate"),a=e("./utils/common"),o=e("./utils/strings"),c=e("./zlib/messages"),k=e("./zlib/zstream"),x=Object.prototype.toString,y=0,_=-1,d=0,b=8;function f(p){if(!(this instanceof f))return new f(p);this.options=a.assign({level:_,method:b,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},p||{});var g=this.options;g.raw&&0<g.windowBits?g.windowBits=-g.windowBits:g.gzip&&0<g.windowBits&&g.windowBits<16&&(g.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var C=r.deflateInit2(this.strm,g.level,g.method,g.windowBits,g.memLevel,g.strategy);if(C!==y)throw new Error(c[C]);if(g.header&&r.deflateSetHeader(this.strm,g.header),g.dictionary){var m;if(m=typeof g.dictionary=="string"?o.string2buf(g.dictionary):x.call(g.dictionary)==="[object ArrayBuffer]"?new Uint8Array(g.dictionary):g.dictionary,(C=r.deflateSetDictionary(this.strm,m))!==y)throw new Error(c[C]);this._dict_set=!0}}function h(p,g){var C=new f(g);if(C.push(p,!0),C.err)throw C.msg||c[C.err];return C.result}f.prototype.push=function(p,g){var C,m,v=this.strm,N=this.options.chunkSize;if(this.ended)return!1;m=g===~~g?g:g===!0?4:0,typeof p=="string"?v.input=o.string2buf(p):x.call(p)==="[object ArrayBuffer]"?v.input=new Uint8Array(p):v.input=p,v.next_in=0,v.avail_in=v.input.length;do{if(v.avail_out===0&&(v.output=new a.Buf8(N),v.next_out=0,v.avail_out=N),(C=r.deflate(v,m))!==1&&C!==y)return this.onEnd(C),!(this.ended=!0);v.avail_out!==0&&(v.avail_in!==0||m!==4&&m!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(v.output,v.next_out))):this.onData(a.shrinkBuf(v.output,v.next_out)))}while((0<v.avail_in||v.avail_out===0)&&C!==1);return m===4?(C=r.deflateEnd(this.strm),this.onEnd(C),this.ended=!0,C===y):m!==2||(this.onEnd(y),!(v.avail_out=0))},f.prototype.onData=function(p){this.chunks.push(p)},f.prototype.onEnd=function(p){p===y&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=p,this.msg=this.strm.msg},i.Deflate=f,i.deflate=h,i.deflateRaw=function(p,g){return(g=g||{}).raw=!0,h(p,g)},i.gzip=function(p,g){return(g=g||{}).gzip=!0,h(p,g)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,u,i){var r=e("./zlib/inflate"),a=e("./utils/common"),o=e("./utils/strings"),c=e("./zlib/constants"),k=e("./zlib/messages"),x=e("./zlib/zstream"),y=e("./zlib/gzheader"),_=Object.prototype.toString;function d(f){if(!(this instanceof d))return new d(f);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},f||{});var h=this.options;h.raw&&0<=h.windowBits&&h.windowBits<16&&(h.windowBits=-h.windowBits,h.windowBits===0&&(h.windowBits=-15)),!(0<=h.windowBits&&h.windowBits<16)||f&&f.windowBits||(h.windowBits+=32),15<h.windowBits&&h.windowBits<48&&!(15&h.windowBits)&&(h.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new x,this.strm.avail_out=0;var p=r.inflateInit2(this.strm,h.windowBits);if(p!==c.Z_OK)throw new Error(k[p]);this.header=new y,r.inflateGetHeader(this.strm,this.header)}function b(f,h){var p=new d(h);if(p.push(f,!0),p.err)throw p.msg||k[p.err];return p.result}d.prototype.push=function(f,h){var p,g,C,m,v,N,A=this.strm,L=this.options.chunkSize,T=this.options.dictionary,W=!1;if(this.ended)return!1;g=h===~~h?h:h===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof f=="string"?A.input=o.binstring2buf(f):_.call(f)==="[object ArrayBuffer]"?A.input=new Uint8Array(f):A.input=f,A.next_in=0,A.avail_in=A.input.length;do{if(A.avail_out===0&&(A.output=new a.Buf8(L),A.next_out=0,A.avail_out=L),(p=r.inflate(A,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&T&&(N=typeof T=="string"?o.string2buf(T):_.call(T)==="[object ArrayBuffer]"?new Uint8Array(T):T,p=r.inflateSetDictionary(this.strm,N)),p===c.Z_BUF_ERROR&&W===!0&&(p=c.Z_OK,W=!1),p!==c.Z_STREAM_END&&p!==c.Z_OK)return this.onEnd(p),!(this.ended=!0);A.next_out&&(A.avail_out!==0&&p!==c.Z_STREAM_END&&(A.avail_in!==0||g!==c.Z_FINISH&&g!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(C=o.utf8border(A.output,A.next_out),m=A.next_out-C,v=o.buf2string(A.output,C),A.next_out=m,A.avail_out=L-m,m&&a.arraySet(A.output,A.output,C,m,0),this.onData(v)):this.onData(a.shrinkBuf(A.output,A.next_out)))),A.avail_in===0&&A.avail_out===0&&(W=!0)}while((0<A.avail_in||A.avail_out===0)&&p!==c.Z_STREAM_END);return p===c.Z_STREAM_END&&(g=c.Z_FINISH),g===c.Z_FINISH?(p=r.inflateEnd(this.strm),this.onEnd(p),this.ended=!0,p===c.Z_OK):g!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(A.avail_out=0))},d.prototype.onData=function(f){this.chunks.push(f)},d.prototype.onEnd=function(f){f===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},i.Inflate=d,i.inflate=b,i.inflateRaw=function(f,h){return(h=h||{}).raw=!0,b(f,h)},i.ungzip=b},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,u,i){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var k=Array.prototype.slice.call(arguments,1);k.length;){var x=k.shift();if(x){if(typeof x!="object")throw new TypeError(x+"must be non-object");for(var y in x)x.hasOwnProperty(y)&&(c[y]=x[y])}}return c},i.shrinkBuf=function(c,k){return c.length===k?c:c.subarray?c.subarray(0,k):(c.length=k,c)};var a={arraySet:function(c,k,x,y,_){if(k.subarray&&c.subarray)c.set(k.subarray(x,x+y),_);else for(var d=0;d<y;d++)c[_+d]=k[x+d]},flattenChunks:function(c){var k,x,y,_,d,b;for(k=y=0,x=c.length;k<x;k++)y+=c[k].length;for(b=new Uint8Array(y),k=_=0,x=c.length;k<x;k++)d=c[k],b.set(d,_),_+=d.length;return b}},o={arraySet:function(c,k,x,y,_){for(var d=0;d<y;d++)c[_+d]=k[x+d]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,a)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,o))},i.setTyped(r)},{}],42:[function(e,u,i){var r=e("./common"),a=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var c=new r.Buf8(256),k=0;k<256;k++)c[k]=252<=k?6:248<=k?5:240<=k?4:224<=k?3:192<=k?2:1;function x(y,_){if(_<65537&&(y.subarray&&o||!y.subarray&&a))return String.fromCharCode.apply(null,r.shrinkBuf(y,_));for(var d="",b=0;b<_;b++)d+=String.fromCharCode(y[b]);return d}c[254]=c[254]=1,i.string2buf=function(y){var _,d,b,f,h,p=y.length,g=0;for(f=0;f<p;f++)(64512&(d=y.charCodeAt(f)))==55296&&f+1<p&&(64512&(b=y.charCodeAt(f+1)))==56320&&(d=65536+(d-55296<<10)+(b-56320),f++),g+=d<128?1:d<2048?2:d<65536?3:4;for(_=new r.Buf8(g),f=h=0;h<g;f++)(64512&(d=y.charCodeAt(f)))==55296&&f+1<p&&(64512&(b=y.charCodeAt(f+1)))==56320&&(d=65536+(d-55296<<10)+(b-56320),f++),d<128?_[h++]=d:(d<2048?_[h++]=192|d>>>6:(d<65536?_[h++]=224|d>>>12:(_[h++]=240|d>>>18,_[h++]=128|d>>>12&63),_[h++]=128|d>>>6&63),_[h++]=128|63&d);return _},i.buf2binstring=function(y){return x(y,y.length)},i.binstring2buf=function(y){for(var _=new r.Buf8(y.length),d=0,b=_.length;d<b;d++)_[d]=y.charCodeAt(d);return _},i.buf2string=function(y,_){var d,b,f,h,p=_||y.length,g=new Array(2*p);for(d=b=0;d<p;)if((f=y[d++])<128)g[b++]=f;else if(4<(h=c[f]))g[b++]=65533,d+=h-1;else{for(f&=h===2?31:h===3?15:7;1<h&&d<p;)f=f<<6|63&y[d++],h--;1<h?g[b++]=65533:f<65536?g[b++]=f:(f-=65536,g[b++]=55296|f>>10&1023,g[b++]=56320|1023&f)}return x(g,b)},i.utf8border=function(y,_){var d;for((_=_||y.length)>y.length&&(_=y.length),d=_-1;0<=d&&(192&y[d])==128;)d--;return d<0||d===0?_:d+c[y[d]]>_?d:_}},{"./common":41}],43:[function(e,u,i){u.exports=function(r,a,o,c){for(var k=65535&r|0,x=r>>>16&65535|0,y=0;o!==0;){for(o-=y=2e3<o?2e3:o;x=x+(k=k+a[c++]|0)|0,--y;);k%=65521,x%=65521}return k|x<<16|0}},{}],44:[function(e,u,i){u.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,u,i){var r=function(){for(var a,o=[],c=0;c<256;c++){a=c;for(var k=0;k<8;k++)a=1&a?3988292384^a>>>1:a>>>1;o[c]=a}return o}();u.exports=function(a,o,c,k){var x=r,y=k+c;a^=-1;for(var _=k;_<y;_++)a=a>>>8^x[255&(a^o[_])];return-1^a}},{}],46:[function(e,u,i){var r,a=e("../utils/common"),o=e("./trees"),c=e("./adler32"),k=e("./crc32"),x=e("./messages"),y=0,_=4,d=0,b=-2,f=-1,h=4,p=2,g=8,C=9,m=286,v=30,N=19,A=2*m+1,L=15,T=3,W=258,Y=W+T+1,E=42,B=113,s=1,j=2,te=3,q=4;function ne(n,D){return n.msg=x[D],D}function U(n){return(n<<1)-(4<n?9:0)}function J(n){for(var D=n.length;0<=--D;)n[D]=0}function O(n){var D=n.state,$=D.pending;$>n.avail_out&&($=n.avail_out),$!==0&&(a.arraySet(n.output,D.pending_buf,D.pending_out,$,n.next_out),n.next_out+=$,D.pending_out+=$,n.total_out+=$,n.avail_out-=$,D.pending-=$,D.pending===0&&(D.pending_out=0))}function R(n,D){o._tr_flush_block(n,0<=n.block_start?n.block_start:-1,n.strstart-n.block_start,D),n.block_start=n.strstart,O(n.strm)}function Q(n,D){n.pending_buf[n.pending++]=D}function V(n,D){n.pending_buf[n.pending++]=D>>>8&255,n.pending_buf[n.pending++]=255&D}function G(n,D){var $,S,w=n.max_chain_length,I=n.strstart,P=n.prev_length,F=n.nice_match,z=n.strstart>n.w_size-Y?n.strstart-(n.w_size-Y):0,Z=n.window,X=n.w_mask,H=n.prev,ee=n.strstart+W,ce=Z[I+P-1],ae=Z[I+P];n.prev_length>=n.good_match&&(w>>=2),F>n.lookahead&&(F=n.lookahead);do if(Z[($=D)+P]===ae&&Z[$+P-1]===ce&&Z[$]===Z[I]&&Z[++$]===Z[I+1]){I+=2,$++;do;while(Z[++I]===Z[++$]&&Z[++I]===Z[++$]&&Z[++I]===Z[++$]&&Z[++I]===Z[++$]&&Z[++I]===Z[++$]&&Z[++I]===Z[++$]&&Z[++I]===Z[++$]&&Z[++I]===Z[++$]&&I<ee);if(S=W-(ee-I),I=ee-W,P<S){if(n.match_start=D,F<=(P=S))break;ce=Z[I+P-1],ae=Z[I+P]}}while((D=H[D&X])>z&&--w!=0);return P<=n.lookahead?P:n.lookahead}function de(n){var D,$,S,w,I,P,F,z,Z,X,H=n.w_size;do{if(w=n.window_size-n.lookahead-n.strstart,n.strstart>=H+(H-Y)){for(a.arraySet(n.window,n.window,H,H,0),n.match_start-=H,n.strstart-=H,n.block_start-=H,D=$=n.hash_size;S=n.head[--D],n.head[D]=H<=S?S-H:0,--$;);for(D=$=H;S=n.prev[--D],n.prev[D]=H<=S?S-H:0,--$;);w+=H}if(n.strm.avail_in===0)break;if(P=n.strm,F=n.window,z=n.strstart+n.lookahead,Z=w,X=void 0,X=P.avail_in,Z<X&&(X=Z),$=X===0?0:(P.avail_in-=X,a.arraySet(F,P.input,P.next_in,X,z),P.state.wrap===1?P.adler=c(P.adler,F,X,z):P.state.wrap===2&&(P.adler=k(P.adler,F,X,z)),P.next_in+=X,P.total_in+=X,X),n.lookahead+=$,n.lookahead+n.insert>=T)for(I=n.strstart-n.insert,n.ins_h=n.window[I],n.ins_h=(n.ins_h<<n.hash_shift^n.window[I+1])&n.hash_mask;n.insert&&(n.ins_h=(n.ins_h<<n.hash_shift^n.window[I+T-1])&n.hash_mask,n.prev[I&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=I,I++,n.insert--,!(n.lookahead+n.insert<T)););}while(n.lookahead<Y&&n.strm.avail_in!==0)}function be(n,D){for(var $,S;;){if(n.lookahead<Y){if(de(n),n.lookahead<Y&&D===y)return s;if(n.lookahead===0)break}if($=0,n.lookahead>=T&&(n.ins_h=(n.ins_h<<n.hash_shift^n.window[n.strstart+T-1])&n.hash_mask,$=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),$!==0&&n.strstart-$<=n.w_size-Y&&(n.match_length=G(n,$)),n.match_length>=T)if(S=o._tr_tally(n,n.strstart-n.match_start,n.match_length-T),n.lookahead-=n.match_length,n.match_length<=n.max_lazy_match&&n.lookahead>=T){for(n.match_length--;n.strstart++,n.ins_h=(n.ins_h<<n.hash_shift^n.window[n.strstart+T-1])&n.hash_mask,$=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart,--n.match_length!=0;);n.strstart++}else n.strstart+=n.match_length,n.match_length=0,n.ins_h=n.window[n.strstart],n.ins_h=(n.ins_h<<n.hash_shift^n.window[n.strstart+1])&n.hash_mask;else S=o._tr_tally(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++;if(S&&(R(n,!1),n.strm.avail_out===0))return s}return n.insert=n.strstart<T-1?n.strstart:T-1,D===_?(R(n,!0),n.strm.avail_out===0?te:q):n.last_lit&&(R(n,!1),n.strm.avail_out===0)?s:j}function oe(n,D){for(var $,S,w;;){if(n.lookahead<Y){if(de(n),n.lookahead<Y&&D===y)return s;if(n.lookahead===0)break}if($=0,n.lookahead>=T&&(n.ins_h=(n.ins_h<<n.hash_shift^n.window[n.strstart+T-1])&n.hash_mask,$=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),n.prev_length=n.match_length,n.prev_match=n.match_start,n.match_length=T-1,$!==0&&n.prev_length<n.max_lazy_match&&n.strstart-$<=n.w_size-Y&&(n.match_length=G(n,$),n.match_length<=5&&(n.strategy===1||n.match_length===T&&4096<n.strstart-n.match_start)&&(n.match_length=T-1)),n.prev_length>=T&&n.match_length<=n.prev_length){for(w=n.strstart+n.lookahead-T,S=o._tr_tally(n,n.strstart-1-n.prev_match,n.prev_length-T),n.lookahead-=n.prev_length-1,n.prev_length-=2;++n.strstart<=w&&(n.ins_h=(n.ins_h<<n.hash_shift^n.window[n.strstart+T-1])&n.hash_mask,$=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),--n.prev_length!=0;);if(n.match_available=0,n.match_length=T-1,n.strstart++,S&&(R(n,!1),n.strm.avail_out===0))return s}else if(n.match_available){if((S=o._tr_tally(n,0,n.window[n.strstart-1]))&&R(n,!1),n.strstart++,n.lookahead--,n.strm.avail_out===0)return s}else n.match_available=1,n.strstart++,n.lookahead--}return n.match_available&&(S=o._tr_tally(n,0,n.window[n.strstart-1]),n.match_available=0),n.insert=n.strstart<T-1?n.strstart:T-1,D===_?(R(n,!0),n.strm.avail_out===0?te:q):n.last_lit&&(R(n,!1),n.strm.avail_out===0)?s:j}function se(n,D,$,S,w){this.good_length=n,this.max_lazy=D,this.nice_length=$,this.max_chain=S,this.func=w}function ye(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=g,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*A),this.dyn_dtree=new a.Buf16(2*(2*v+1)),this.bl_tree=new a.Buf16(2*(2*N+1)),J(this.dyn_ltree),J(this.dyn_dtree),J(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(L+1),this.heap=new a.Buf16(2*m+1),J(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*m+1),J(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function fe(n){var D;return n&&n.state?(n.total_in=n.total_out=0,n.data_type=p,(D=n.state).pending=0,D.pending_out=0,D.wrap<0&&(D.wrap=-D.wrap),D.status=D.wrap?E:B,n.adler=D.wrap===2?0:1,D.last_flush=y,o._tr_init(D),d):ne(n,b)}function ze(n){var D=fe(n);return D===d&&function($){$.window_size=2*$.w_size,J($.head),$.max_lazy_match=r[$.level].max_lazy,$.good_match=r[$.level].good_length,$.nice_match=r[$.level].nice_length,$.max_chain_length=r[$.level].max_chain,$.strstart=0,$.block_start=0,$.lookahead=0,$.insert=0,$.match_length=$.prev_length=T-1,$.match_available=0,$.ins_h=0}(n.state),D}function Ae(n,D,$,S,w,I){if(!n)return b;var P=1;if(D===f&&(D=6),S<0?(P=0,S=-S):15<S&&(P=2,S-=16),w<1||C<w||$!==g||S<8||15<S||D<0||9<D||I<0||h<I)return ne(n,b);S===8&&(S=9);var F=new ye;return(n.state=F).strm=n,F.wrap=P,F.gzhead=null,F.w_bits=S,F.w_size=1<<F.w_bits,F.w_mask=F.w_size-1,F.hash_bits=w+7,F.hash_size=1<<F.hash_bits,F.hash_mask=F.hash_size-1,F.hash_shift=~~((F.hash_bits+T-1)/T),F.window=new a.Buf8(2*F.w_size),F.head=new a.Buf16(F.hash_size),F.prev=new a.Buf16(F.w_size),F.lit_bufsize=1<<w+6,F.pending_buf_size=4*F.lit_bufsize,F.pending_buf=new a.Buf8(F.pending_buf_size),F.d_buf=1*F.lit_bufsize,F.l_buf=3*F.lit_bufsize,F.level=D,F.strategy=I,F.method=$,ze(n)}r=[new se(0,0,0,0,function(n,D){var $=65535;for($>n.pending_buf_size-5&&($=n.pending_buf_size-5);;){if(n.lookahead<=1){if(de(n),n.lookahead===0&&D===y)return s;if(n.lookahead===0)break}n.strstart+=n.lookahead,n.lookahead=0;var S=n.block_start+$;if((n.strstart===0||n.strstart>=S)&&(n.lookahead=n.strstart-S,n.strstart=S,R(n,!1),n.strm.avail_out===0)||n.strstart-n.block_start>=n.w_size-Y&&(R(n,!1),n.strm.avail_out===0))return s}return n.insert=0,D===_?(R(n,!0),n.strm.avail_out===0?te:q):(n.strstart>n.block_start&&(R(n,!1),n.strm.avail_out),s)}),new se(4,4,8,4,be),new se(4,5,16,8,be),new se(4,6,32,32,be),new se(4,4,16,16,oe),new se(8,16,32,32,oe),new se(8,16,128,128,oe),new se(8,32,128,256,oe),new se(32,128,258,1024,oe),new se(32,258,258,4096,oe)],i.deflateInit=function(n,D){return Ae(n,D,g,15,8,0)},i.deflateInit2=Ae,i.deflateReset=ze,i.deflateResetKeep=fe,i.deflateSetHeader=function(n,D){return n&&n.state?n.state.wrap!==2?b:(n.state.gzhead=D,d):b},i.deflate=function(n,D){var $,S,w,I;if(!n||!n.state||5<D||D<0)return n?ne(n,b):b;if(S=n.state,!n.output||!n.input&&n.avail_in!==0||S.status===666&&D!==_)return ne(n,n.avail_out===0?-5:b);if(S.strm=n,$=S.last_flush,S.last_flush=D,S.status===E)if(S.wrap===2)n.adler=0,Q(S,31),Q(S,139),Q(S,8),S.gzhead?(Q(S,(S.gzhead.text?1:0)+(S.gzhead.hcrc?2:0)+(S.gzhead.extra?4:0)+(S.gzhead.name?8:0)+(S.gzhead.comment?16:0)),Q(S,255&S.gzhead.time),Q(S,S.gzhead.time>>8&255),Q(S,S.gzhead.time>>16&255),Q(S,S.gzhead.time>>24&255),Q(S,S.level===9?2:2<=S.strategy||S.level<2?4:0),Q(S,255&S.gzhead.os),S.gzhead.extra&&S.gzhead.extra.length&&(Q(S,255&S.gzhead.extra.length),Q(S,S.gzhead.extra.length>>8&255)),S.gzhead.hcrc&&(n.adler=k(n.adler,S.pending_buf,S.pending,0)),S.gzindex=0,S.status=69):(Q(S,0),Q(S,0),Q(S,0),Q(S,0),Q(S,0),Q(S,S.level===9?2:2<=S.strategy||S.level<2?4:0),Q(S,3),S.status=B);else{var P=g+(S.w_bits-8<<4)<<8;P|=(2<=S.strategy||S.level<2?0:S.level<6?1:S.level===6?2:3)<<6,S.strstart!==0&&(P|=32),P+=31-P%31,S.status=B,V(S,P),S.strstart!==0&&(V(S,n.adler>>>16),V(S,65535&n.adler)),n.adler=1}if(S.status===69)if(S.gzhead.extra){for(w=S.pending;S.gzindex<(65535&S.gzhead.extra.length)&&(S.pending!==S.pending_buf_size||(S.gzhead.hcrc&&S.pending>w&&(n.adler=k(n.adler,S.pending_buf,S.pending-w,w)),O(n),w=S.pending,S.pending!==S.pending_buf_size));)Q(S,255&S.gzhead.extra[S.gzindex]),S.gzindex++;S.gzhead.hcrc&&S.pending>w&&(n.adler=k(n.adler,S.pending_buf,S.pending-w,w)),S.gzindex===S.gzhead.extra.length&&(S.gzindex=0,S.status=73)}else S.status=73;if(S.status===73)if(S.gzhead.name){w=S.pending;do{if(S.pending===S.pending_buf_size&&(S.gzhead.hcrc&&S.pending>w&&(n.adler=k(n.adler,S.pending_buf,S.pending-w,w)),O(n),w=S.pending,S.pending===S.pending_buf_size)){I=1;break}I=S.gzindex<S.gzhead.name.length?255&S.gzhead.name.charCodeAt(S.gzindex++):0,Q(S,I)}while(I!==0);S.gzhead.hcrc&&S.pending>w&&(n.adler=k(n.adler,S.pending_buf,S.pending-w,w)),I===0&&(S.gzindex=0,S.status=91)}else S.status=91;if(S.status===91)if(S.gzhead.comment){w=S.pending;do{if(S.pending===S.pending_buf_size&&(S.gzhead.hcrc&&S.pending>w&&(n.adler=k(n.adler,S.pending_buf,S.pending-w,w)),O(n),w=S.pending,S.pending===S.pending_buf_size)){I=1;break}I=S.gzindex<S.gzhead.comment.length?255&S.gzhead.comment.charCodeAt(S.gzindex++):0,Q(S,I)}while(I!==0);S.gzhead.hcrc&&S.pending>w&&(n.adler=k(n.adler,S.pending_buf,S.pending-w,w)),I===0&&(S.status=103)}else S.status=103;if(S.status===103&&(S.gzhead.hcrc?(S.pending+2>S.pending_buf_size&&O(n),S.pending+2<=S.pending_buf_size&&(Q(S,255&n.adler),Q(S,n.adler>>8&255),n.adler=0,S.status=B)):S.status=B),S.pending!==0){if(O(n),n.avail_out===0)return S.last_flush=-1,d}else if(n.avail_in===0&&U(D)<=U($)&&D!==_)return ne(n,-5);if(S.status===666&&n.avail_in!==0)return ne(n,-5);if(n.avail_in!==0||S.lookahead!==0||D!==y&&S.status!==666){var F=S.strategy===2?function(z,Z){for(var X;;){if(z.lookahead===0&&(de(z),z.lookahead===0)){if(Z===y)return s;break}if(z.match_length=0,X=o._tr_tally(z,0,z.window[z.strstart]),z.lookahead--,z.strstart++,X&&(R(z,!1),z.strm.avail_out===0))return s}return z.insert=0,Z===_?(R(z,!0),z.strm.avail_out===0?te:q):z.last_lit&&(R(z,!1),z.strm.avail_out===0)?s:j}(S,D):S.strategy===3?function(z,Z){for(var X,H,ee,ce,ae=z.window;;){if(z.lookahead<=W){if(de(z),z.lookahead<=W&&Z===y)return s;if(z.lookahead===0)break}if(z.match_length=0,z.lookahead>=T&&0<z.strstart&&(H=ae[ee=z.strstart-1])===ae[++ee]&&H===ae[++ee]&&H===ae[++ee]){ce=z.strstart+W;do;while(H===ae[++ee]&&H===ae[++ee]&&H===ae[++ee]&&H===ae[++ee]&&H===ae[++ee]&&H===ae[++ee]&&H===ae[++ee]&&H===ae[++ee]&&ee<ce);z.match_length=W-(ce-ee),z.match_length>z.lookahead&&(z.match_length=z.lookahead)}if(z.match_length>=T?(X=o._tr_tally(z,1,z.match_length-T),z.lookahead-=z.match_length,z.strstart+=z.match_length,z.match_length=0):(X=o._tr_tally(z,0,z.window[z.strstart]),z.lookahead--,z.strstart++),X&&(R(z,!1),z.strm.avail_out===0))return s}return z.insert=0,Z===_?(R(z,!0),z.strm.avail_out===0?te:q):z.last_lit&&(R(z,!1),z.strm.avail_out===0)?s:j}(S,D):r[S.level].func(S,D);if(F!==te&&F!==q||(S.status=666),F===s||F===te)return n.avail_out===0&&(S.last_flush=-1),d;if(F===j&&(D===1?o._tr_align(S):D!==5&&(o._tr_stored_block(S,0,0,!1),D===3&&(J(S.head),S.lookahead===0&&(S.strstart=0,S.block_start=0,S.insert=0))),O(n),n.avail_out===0))return S.last_flush=-1,d}return D!==_?d:S.wrap<=0?1:(S.wrap===2?(Q(S,255&n.adler),Q(S,n.adler>>8&255),Q(S,n.adler>>16&255),Q(S,n.adler>>24&255),Q(S,255&n.total_in),Q(S,n.total_in>>8&255),Q(S,n.total_in>>16&255),Q(S,n.total_in>>24&255)):(V(S,n.adler>>>16),V(S,65535&n.adler)),O(n),0<S.wrap&&(S.wrap=-S.wrap),S.pending!==0?d:1)},i.deflateEnd=function(n){var D;return n&&n.state?(D=n.state.status)!==E&&D!==69&&D!==73&&D!==91&&D!==103&&D!==B&&D!==666?ne(n,b):(n.state=null,D===B?ne(n,-3):d):b},i.deflateSetDictionary=function(n,D){var $,S,w,I,P,F,z,Z,X=D.length;if(!n||!n.state||(I=($=n.state).wrap)===2||I===1&&$.status!==E||$.lookahead)return b;for(I===1&&(n.adler=c(n.adler,D,X,0)),$.wrap=0,X>=$.w_size&&(I===0&&(J($.head),$.strstart=0,$.block_start=0,$.insert=0),Z=new a.Buf8($.w_size),a.arraySet(Z,D,X-$.w_size,$.w_size,0),D=Z,X=$.w_size),P=n.avail_in,F=n.next_in,z=n.input,n.avail_in=X,n.next_in=0,n.input=D,de($);$.lookahead>=T;){for(S=$.strstart,w=$.lookahead-(T-1);$.ins_h=($.ins_h<<$.hash_shift^$.window[S+T-1])&$.hash_mask,$.prev[S&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=S,S++,--w;);$.strstart=S,$.lookahead=T-1,de($)}return $.strstart+=$.lookahead,$.block_start=$.strstart,$.insert=$.lookahead,$.lookahead=0,$.match_length=$.prev_length=T-1,$.match_available=0,n.next_in=F,n.input=z,n.avail_in=P,$.wrap=I,d},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,u,i){u.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,u,i){u.exports=function(r,a){var o,c,k,x,y,_,d,b,f,h,p,g,C,m,v,N,A,L,T,W,Y,E,B,s,j;o=r.state,c=r.next_in,s=r.input,k=c+(r.avail_in-5),x=r.next_out,j=r.output,y=x-(a-r.avail_out),_=x+(r.avail_out-257),d=o.dmax,b=o.wsize,f=o.whave,h=o.wnext,p=o.window,g=o.hold,C=o.bits,m=o.lencode,v=o.distcode,N=(1<<o.lenbits)-1,A=(1<<o.distbits)-1;e:do{C<15&&(g+=s[c++]<<C,C+=8,g+=s[c++]<<C,C+=8),L=m[g&N];t:for(;;){if(g>>>=T=L>>>24,C-=T,(T=L>>>16&255)===0)j[x++]=65535&L;else{if(!(16&T)){if(!(64&T)){L=m[(65535&L)+(g&(1<<T)-1)];continue t}if(32&T){o.mode=12;break e}r.msg="invalid literal/length code",o.mode=30;break e}W=65535&L,(T&=15)&&(C<T&&(g+=s[c++]<<C,C+=8),W+=g&(1<<T)-1,g>>>=T,C-=T),C<15&&(g+=s[c++]<<C,C+=8,g+=s[c++]<<C,C+=8),L=v[g&A];n:for(;;){if(g>>>=T=L>>>24,C-=T,!(16&(T=L>>>16&255))){if(!(64&T)){L=v[(65535&L)+(g&(1<<T)-1)];continue n}r.msg="invalid distance code",o.mode=30;break e}if(Y=65535&L,C<(T&=15)&&(g+=s[c++]<<C,(C+=8)<T&&(g+=s[c++]<<C,C+=8)),d<(Y+=g&(1<<T)-1)){r.msg="invalid distance too far back",o.mode=30;break e}if(g>>>=T,C-=T,(T=x-y)<Y){if(f<(T=Y-T)&&o.sane){r.msg="invalid distance too far back",o.mode=30;break e}if(B=p,(E=0)===h){if(E+=b-T,T<W){for(W-=T;j[x++]=p[E++],--T;);E=x-Y,B=j}}else if(h<T){if(E+=b+h-T,(T-=h)<W){for(W-=T;j[x++]=p[E++],--T;);if(E=0,h<W){for(W-=T=h;j[x++]=p[E++],--T;);E=x-Y,B=j}}}else if(E+=h-T,T<W){for(W-=T;j[x++]=p[E++],--T;);E=x-Y,B=j}for(;2<W;)j[x++]=B[E++],j[x++]=B[E++],j[x++]=B[E++],W-=3;W&&(j[x++]=B[E++],1<W&&(j[x++]=B[E++]))}else{for(E=x-Y;j[x++]=j[E++],j[x++]=j[E++],j[x++]=j[E++],2<(W-=3););W&&(j[x++]=j[E++],1<W&&(j[x++]=j[E++]))}break}}break}}while(c<k&&x<_);c-=W=C>>3,g&=(1<<(C-=W<<3))-1,r.next_in=c,r.next_out=x,r.avail_in=c<k?k-c+5:5-(c-k),r.avail_out=x<_?_-x+257:257-(x-_),o.hold=g,o.bits=C}},{}],49:[function(e,u,i){var r=e("../utils/common"),a=e("./adler32"),o=e("./crc32"),c=e("./inffast"),k=e("./inftrees"),x=1,y=2,_=0,d=-2,b=1,f=852,h=592;function p(E){return(E>>>24&255)+(E>>>8&65280)+((65280&E)<<8)+((255&E)<<24)}function g(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function C(E){var B;return E&&E.state?(B=E.state,E.total_in=E.total_out=B.total=0,E.msg="",B.wrap&&(E.adler=1&B.wrap),B.mode=b,B.last=0,B.havedict=0,B.dmax=32768,B.head=null,B.hold=0,B.bits=0,B.lencode=B.lendyn=new r.Buf32(f),B.distcode=B.distdyn=new r.Buf32(h),B.sane=1,B.back=-1,_):d}function m(E){var B;return E&&E.state?((B=E.state).wsize=0,B.whave=0,B.wnext=0,C(E)):d}function v(E,B){var s,j;return E&&E.state?(j=E.state,B<0?(s=0,B=-B):(s=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15<B)?d:(j.window!==null&&j.wbits!==B&&(j.window=null),j.wrap=s,j.wbits=B,m(E))):d}function N(E,B){var s,j;return E?(j=new g,(E.state=j).window=null,(s=v(E,B))!==_&&(E.state=null),s):d}var A,L,T=!0;function W(E){if(T){var B;for(A=new r.Buf32(512),L=new r.Buf32(32),B=0;B<144;)E.lens[B++]=8;for(;B<256;)E.lens[B++]=9;for(;B<280;)E.lens[B++]=7;for(;B<288;)E.lens[B++]=8;for(k(x,E.lens,0,288,A,0,E.work,{bits:9}),B=0;B<32;)E.lens[B++]=5;k(y,E.lens,0,32,L,0,E.work,{bits:5}),T=!1}E.lencode=A,E.lenbits=9,E.distcode=L,E.distbits=5}function Y(E,B,s,j){var te,q=E.state;return q.window===null&&(q.wsize=1<<q.wbits,q.wnext=0,q.whave=0,q.window=new r.Buf8(q.wsize)),j>=q.wsize?(r.arraySet(q.window,B,s-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(j<(te=q.wsize-q.wnext)&&(te=j),r.arraySet(q.window,B,s-j,te,q.wnext),(j-=te)?(r.arraySet(q.window,B,s-j,j,0),q.wnext=j,q.whave=q.wsize):(q.wnext+=te,q.wnext===q.wsize&&(q.wnext=0),q.whave<q.wsize&&(q.whave+=te))),0}i.inflateReset=m,i.inflateReset2=v,i.inflateResetKeep=C,i.inflateInit=function(E){return N(E,15)},i.inflateInit2=N,i.inflate=function(E,B){var s,j,te,q,ne,U,J,O,R,Q,V,G,de,be,oe,se,ye,fe,ze,Ae,n,D,$,S,w=0,I=new r.Buf8(4),P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!E||!E.state||!E.output||!E.input&&E.avail_in!==0)return d;(s=E.state).mode===12&&(s.mode=13),ne=E.next_out,te=E.output,J=E.avail_out,q=E.next_in,j=E.input,U=E.avail_in,O=s.hold,R=s.bits,Q=U,V=J,D=_;e:for(;;)switch(s.mode){case b:if(s.wrap===0){s.mode=13;break}for(;R<16;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}if(2&s.wrap&&O===35615){I[s.check=0]=255&O,I[1]=O>>>8&255,s.check=o(s.check,I,2,0),R=O=0,s.mode=2;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&O)<<8)+(O>>8))%31){E.msg="incorrect header check",s.mode=30;break}if((15&O)!=8){E.msg="unknown compression method",s.mode=30;break}if(R-=4,n=8+(15&(O>>>=4)),s.wbits===0)s.wbits=n;else if(n>s.wbits){E.msg="invalid window size",s.mode=30;break}s.dmax=1<<n,E.adler=s.check=1,s.mode=512&O?10:12,R=O=0;break;case 2:for(;R<16;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}if(s.flags=O,(255&s.flags)!=8){E.msg="unknown compression method",s.mode=30;break}if(57344&s.flags){E.msg="unknown header flags set",s.mode=30;break}s.head&&(s.head.text=O>>8&1),512&s.flags&&(I[0]=255&O,I[1]=O>>>8&255,s.check=o(s.check,I,2,0)),R=O=0,s.mode=3;case 3:for(;R<32;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}s.head&&(s.head.time=O),512&s.flags&&(I[0]=255&O,I[1]=O>>>8&255,I[2]=O>>>16&255,I[3]=O>>>24&255,s.check=o(s.check,I,4,0)),R=O=0,s.mode=4;case 4:for(;R<16;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}s.head&&(s.head.xflags=255&O,s.head.os=O>>8),512&s.flags&&(I[0]=255&O,I[1]=O>>>8&255,s.check=o(s.check,I,2,0)),R=O=0,s.mode=5;case 5:if(1024&s.flags){for(;R<16;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}s.length=O,s.head&&(s.head.extra_len=O),512&s.flags&&(I[0]=255&O,I[1]=O>>>8&255,s.check=o(s.check,I,2,0)),R=O=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&(U<(G=s.length)&&(G=U),G&&(s.head&&(n=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),r.arraySet(s.head.extra,j,q,G,n)),512&s.flags&&(s.check=o(s.check,j,G,q)),U-=G,q+=G,s.length-=G),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(U===0)break e;for(G=0;n=j[q+G++],s.head&&n&&s.length<65536&&(s.head.name+=String.fromCharCode(n)),n&&G<U;);if(512&s.flags&&(s.check=o(s.check,j,G,q)),U-=G,q+=G,n)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=8;case 8:if(4096&s.flags){if(U===0)break e;for(G=0;n=j[q+G++],s.head&&n&&s.length<65536&&(s.head.comment+=String.fromCharCode(n)),n&&G<U;);if(512&s.flags&&(s.check=o(s.check,j,G,q)),U-=G,q+=G,n)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;R<16;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}if(O!==(65535&s.check)){E.msg="header crc mismatch",s.mode=30;break}R=O=0}s.head&&(s.head.hcrc=s.flags>>9&1,s.head.done=!0),E.adler=s.check=0,s.mode=12;break;case 10:for(;R<32;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}E.adler=s.check=p(O),R=O=0,s.mode=11;case 11:if(s.havedict===0)return E.next_out=ne,E.avail_out=J,E.next_in=q,E.avail_in=U,s.hold=O,s.bits=R,2;E.adler=s.check=1,s.mode=12;case 12:if(B===5||B===6)break e;case 13:if(s.last){O>>>=7&R,R-=7&R,s.mode=27;break}for(;R<3;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}switch(s.last=1&O,R-=1,3&(O>>>=1)){case 0:s.mode=14;break;case 1:if(W(s),s.mode=20,B!==6)break;O>>>=2,R-=2;break e;case 2:s.mode=17;break;case 3:E.msg="invalid block type",s.mode=30}O>>>=2,R-=2;break;case 14:for(O>>>=7&R,R-=7&R;R<32;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}if((65535&O)!=(O>>>16^65535)){E.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&O,R=O=0,s.mode=15,B===6)break e;case 15:s.mode=16;case 16:if(G=s.length){if(U<G&&(G=U),J<G&&(G=J),G===0)break e;r.arraySet(te,j,q,G,ne),U-=G,q+=G,J-=G,ne+=G,s.length-=G;break}s.mode=12;break;case 17:for(;R<14;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}if(s.nlen=257+(31&O),O>>>=5,R-=5,s.ndist=1+(31&O),O>>>=5,R-=5,s.ncode=4+(15&O),O>>>=4,R-=4,286<s.nlen||30<s.ndist){E.msg="too many length or distance symbols",s.mode=30;break}s.have=0,s.mode=18;case 18:for(;s.have<s.ncode;){for(;R<3;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}s.lens[P[s.have++]]=7&O,O>>>=3,R-=3}for(;s.have<19;)s.lens[P[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,$={bits:s.lenbits},D=k(0,s.lens,0,19,s.lencode,0,s.work,$),s.lenbits=$.bits,D){E.msg="invalid code lengths set",s.mode=30;break}s.have=0,s.mode=19;case 19:for(;s.have<s.nlen+s.ndist;){for(;se=(w=s.lencode[O&(1<<s.lenbits)-1])>>>16&255,ye=65535&w,!((oe=w>>>24)<=R);){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}if(ye<16)O>>>=oe,R-=oe,s.lens[s.have++]=ye;else{if(ye===16){for(S=oe+2;R<S;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}if(O>>>=oe,R-=oe,s.have===0){E.msg="invalid bit length repeat",s.mode=30;break}n=s.lens[s.have-1],G=3+(3&O),O>>>=2,R-=2}else if(ye===17){for(S=oe+3;R<S;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}R-=oe,n=0,G=3+(7&(O>>>=oe)),O>>>=3,R-=3}else{for(S=oe+7;R<S;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}R-=oe,n=0,G=11+(127&(O>>>=oe)),O>>>=7,R-=7}if(s.have+G>s.nlen+s.ndist){E.msg="invalid bit length repeat",s.mode=30;break}for(;G--;)s.lens[s.have++]=n}}if(s.mode===30)break;if(s.lens[256]===0){E.msg="invalid code -- missing end-of-block",s.mode=30;break}if(s.lenbits=9,$={bits:s.lenbits},D=k(x,s.lens,0,s.nlen,s.lencode,0,s.work,$),s.lenbits=$.bits,D){E.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,$={bits:s.distbits},D=k(y,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,$),s.distbits=$.bits,D){E.msg="invalid distances set",s.mode=30;break}if(s.mode=20,B===6)break e;case 20:s.mode=21;case 21:if(6<=U&&258<=J){E.next_out=ne,E.avail_out=J,E.next_in=q,E.avail_in=U,s.hold=O,s.bits=R,c(E,V),ne=E.next_out,te=E.output,J=E.avail_out,q=E.next_in,j=E.input,U=E.avail_in,O=s.hold,R=s.bits,s.mode===12&&(s.back=-1);break}for(s.back=0;se=(w=s.lencode[O&(1<<s.lenbits)-1])>>>16&255,ye=65535&w,!((oe=w>>>24)<=R);){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}if(se&&!(240&se)){for(fe=oe,ze=se,Ae=ye;se=(w=s.lencode[Ae+((O&(1<<fe+ze)-1)>>fe)])>>>16&255,ye=65535&w,!(fe+(oe=w>>>24)<=R);){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}O>>>=fe,R-=fe,s.back+=fe}if(O>>>=oe,R-=oe,s.back+=oe,s.length=ye,se===0){s.mode=26;break}if(32&se){s.back=-1,s.mode=12;break}if(64&se){E.msg="invalid literal/length code",s.mode=30;break}s.extra=15&se,s.mode=22;case 22:if(s.extra){for(S=s.extra;R<S;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}s.length+=O&(1<<s.extra)-1,O>>>=s.extra,R-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;se=(w=s.distcode[O&(1<<s.distbits)-1])>>>16&255,ye=65535&w,!((oe=w>>>24)<=R);){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}if(!(240&se)){for(fe=oe,ze=se,Ae=ye;se=(w=s.distcode[Ae+((O&(1<<fe+ze)-1)>>fe)])>>>16&255,ye=65535&w,!(fe+(oe=w>>>24)<=R);){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}O>>>=fe,R-=fe,s.back+=fe}if(O>>>=oe,R-=oe,s.back+=oe,64&se){E.msg="invalid distance code",s.mode=30;break}s.offset=ye,s.extra=15&se,s.mode=24;case 24:if(s.extra){for(S=s.extra;R<S;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}s.offset+=O&(1<<s.extra)-1,O>>>=s.extra,R-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){E.msg="invalid distance too far back",s.mode=30;break}s.mode=25;case 25:if(J===0)break e;if(G=V-J,s.offset>G){if((G=s.offset-G)>s.whave&&s.sane){E.msg="invalid distance too far back",s.mode=30;break}de=G>s.wnext?(G-=s.wnext,s.wsize-G):s.wnext-G,G>s.length&&(G=s.length),be=s.window}else be=te,de=ne-s.offset,G=s.length;for(J<G&&(G=J),J-=G,s.length-=G;te[ne++]=be[de++],--G;);s.length===0&&(s.mode=21);break;case 26:if(J===0)break e;te[ne++]=s.length,J--,s.mode=21;break;case 27:if(s.wrap){for(;R<32;){if(U===0)break e;U--,O|=j[q++]<<R,R+=8}if(V-=J,E.total_out+=V,s.total+=V,V&&(E.adler=s.check=s.flags?o(s.check,te,V,ne-V):a(s.check,te,V,ne-V)),V=J,(s.flags?O:p(O))!==s.check){E.msg="incorrect data check",s.mode=30;break}R=O=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;R<32;){if(U===0)break e;U--,O+=j[q++]<<R,R+=8}if(O!==(4294967295&s.total)){E.msg="incorrect length check",s.mode=30;break}R=O=0}s.mode=29;case 29:D=1;break e;case 30:D=-3;break e;case 31:return-4;case 32:default:return d}return E.next_out=ne,E.avail_out=J,E.next_in=q,E.avail_in=U,s.hold=O,s.bits=R,(s.wsize||V!==E.avail_out&&s.mode<30&&(s.mode<27||B!==4))&&Y(E,E.output,E.next_out,V-E.avail_out)?(s.mode=31,-4):(Q-=E.avail_in,V-=E.avail_out,E.total_in+=Q,E.total_out+=V,s.total+=V,s.wrap&&V&&(E.adler=s.check=s.flags?o(s.check,te,V,E.next_out-V):a(s.check,te,V,E.next_out-V)),E.data_type=s.bits+(s.last?64:0)+(s.mode===12?128:0)+(s.mode===20||s.mode===15?256:0),(Q==0&&V===0||B===4)&&D===_&&(D=-5),D)},i.inflateEnd=function(E){if(!E||!E.state)return d;var B=E.state;return B.window&&(B.window=null),E.state=null,_},i.inflateGetHeader=function(E,B){var s;return E&&E.state&&2&(s=E.state).wrap?((s.head=B).done=!1,_):d},i.inflateSetDictionary=function(E,B){var s,j=B.length;return E&&E.state?(s=E.state).wrap!==0&&s.mode!==11?d:s.mode===11&&a(1,B,j,0)!==s.check?-3:Y(E,B,j,j)?(s.mode=31,-4):(s.havedict=1,_):d},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,u,i){var r=e("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],k=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];u.exports=function(x,y,_,d,b,f,h,p){var g,C,m,v,N,A,L,T,W,Y=p.bits,E=0,B=0,s=0,j=0,te=0,q=0,ne=0,U=0,J=0,O=0,R=null,Q=0,V=new r.Buf16(16),G=new r.Buf16(16),de=null,be=0;for(E=0;E<=15;E++)V[E]=0;for(B=0;B<d;B++)V[y[_+B]]++;for(te=Y,j=15;1<=j&&V[j]===0;j--);if(j<te&&(te=j),j===0)return b[f++]=20971520,b[f++]=20971520,p.bits=1,0;for(s=1;s<j&&V[s]===0;s++);for(te<s&&(te=s),E=U=1;E<=15;E++)if(U<<=1,(U-=V[E])<0)return-1;if(0<U&&(x===0||j!==1))return-1;for(G[1]=0,E=1;E<15;E++)G[E+1]=G[E]+V[E];for(B=0;B<d;B++)y[_+B]!==0&&(h[G[y[_+B]]++]=B);if(A=x===0?(R=de=h,19):x===1?(R=a,Q-=257,de=o,be-=257,256):(R=c,de=k,-1),E=s,N=f,ne=B=O=0,m=-1,v=(J=1<<(q=te))-1,x===1&&852<J||x===2&&592<J)return 1;for(;;){for(L=E-ne,W=h[B]<A?(T=0,h[B]):h[B]>A?(T=de[be+h[B]],R[Q+h[B]]):(T=96,0),g=1<<E-ne,s=C=1<<q;b[N+(O>>ne)+(C-=g)]=L<<24|T<<16|W|0,C!==0;);for(g=1<<E-1;O&g;)g>>=1;if(g!==0?(O&=g-1,O+=g):O=0,B++,--V[E]==0){if(E===j)break;E=y[_+h[B]]}if(te<E&&(O&v)!==m){for(ne===0&&(ne=te),N+=s,U=1<<(q=E-ne);q+ne<j&&!((U-=V[q+ne])<=0);)q++,U<<=1;if(J+=1<<q,x===1&&852<J||x===2&&592<J)return 1;b[m=O&v]=te<<24|q<<16|N-f|0}}return O!==0&&(b[N+O]=E-ne<<24|64<<16|0),p.bits=te,0}},{"../utils/common":41}],51:[function(e,u,i){u.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,u,i){var r=e("../utils/common"),a=0,o=1;function c(w){for(var I=w.length;0<=--I;)w[I]=0}var k=0,x=29,y=256,_=y+1+x,d=30,b=19,f=2*_+1,h=15,p=16,g=7,C=256,m=16,v=17,N=18,A=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],L=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],W=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Y=new Array(2*(_+2));c(Y);var E=new Array(2*d);c(E);var B=new Array(512);c(B);var s=new Array(256);c(s);var j=new Array(x);c(j);var te,q,ne,U=new Array(d);function J(w,I,P,F,z){this.static_tree=w,this.extra_bits=I,this.extra_base=P,this.elems=F,this.max_length=z,this.has_stree=w&&w.length}function O(w,I){this.dyn_tree=w,this.max_code=0,this.stat_desc=I}function R(w){return w<256?B[w]:B[256+(w>>>7)]}function Q(w,I){w.pending_buf[w.pending++]=255&I,w.pending_buf[w.pending++]=I>>>8&255}function V(w,I,P){w.bi_valid>p-P?(w.bi_buf|=I<<w.bi_valid&65535,Q(w,w.bi_buf),w.bi_buf=I>>p-w.bi_valid,w.bi_valid+=P-p):(w.bi_buf|=I<<w.bi_valid&65535,w.bi_valid+=P)}function G(w,I,P){V(w,P[2*I],P[2*I+1])}function de(w,I){for(var P=0;P|=1&w,w>>>=1,P<<=1,0<--I;);return P>>>1}function be(w,I,P){var F,z,Z=new Array(h+1),X=0;for(F=1;F<=h;F++)Z[F]=X=X+P[F-1]<<1;for(z=0;z<=I;z++){var H=w[2*z+1];H!==0&&(w[2*z]=de(Z[H]++,H))}}function oe(w){var I;for(I=0;I<_;I++)w.dyn_ltree[2*I]=0;for(I=0;I<d;I++)w.dyn_dtree[2*I]=0;for(I=0;I<b;I++)w.bl_tree[2*I]=0;w.dyn_ltree[2*C]=1,w.opt_len=w.static_len=0,w.last_lit=w.matches=0}function se(w){8<w.bi_valid?Q(w,w.bi_buf):0<w.bi_valid&&(w.pending_buf[w.pending++]=w.bi_buf),w.bi_buf=0,w.bi_valid=0}function ye(w,I,P,F){var z=2*I,Z=2*P;return w[z]<w[Z]||w[z]===w[Z]&&F[I]<=F[P]}function fe(w,I,P){for(var F=w.heap[P],z=P<<1;z<=w.heap_len&&(z<w.heap_len&&ye(I,w.heap[z+1],w.heap[z],w.depth)&&z++,!ye(I,F,w.heap[z],w.depth));)w.heap[P]=w.heap[z],P=z,z<<=1;w.heap[P]=F}function ze(w,I,P){var F,z,Z,X,H=0;if(w.last_lit!==0)for(;F=w.pending_buf[w.d_buf+2*H]<<8|w.pending_buf[w.d_buf+2*H+1],z=w.pending_buf[w.l_buf+H],H++,F===0?G(w,z,I):(G(w,(Z=s[z])+y+1,I),(X=A[Z])!==0&&V(w,z-=j[Z],X),G(w,Z=R(--F),P),(X=L[Z])!==0&&V(w,F-=U[Z],X)),H<w.last_lit;);G(w,C,I)}function Ae(w,I){var P,F,z,Z=I.dyn_tree,X=I.stat_desc.static_tree,H=I.stat_desc.has_stree,ee=I.stat_desc.elems,ce=-1;for(w.heap_len=0,w.heap_max=f,P=0;P<ee;P++)Z[2*P]!==0?(w.heap[++w.heap_len]=ce=P,w.depth[P]=0):Z[2*P+1]=0;for(;w.heap_len<2;)Z[2*(z=w.heap[++w.heap_len]=ce<2?++ce:0)]=1,w.depth[z]=0,w.opt_len--,H&&(w.static_len-=X[2*z+1]);for(I.max_code=ce,P=w.heap_len>>1;1<=P;P--)fe(w,Z,P);for(z=ee;P=w.heap[1],w.heap[1]=w.heap[w.heap_len--],fe(w,Z,1),F=w.heap[1],w.heap[--w.heap_max]=P,w.heap[--w.heap_max]=F,Z[2*z]=Z[2*P]+Z[2*F],w.depth[z]=(w.depth[P]>=w.depth[F]?w.depth[P]:w.depth[F])+1,Z[2*P+1]=Z[2*F+1]=z,w.heap[1]=z++,fe(w,Z,1),2<=w.heap_len;);w.heap[--w.heap_max]=w.heap[1],function(ae,Se){var tt,Re,nt,he,mt,zt,Te=Se.dyn_tree,yn=Se.max_code,yr=Se.stat_desc.static_tree,br=Se.stat_desc.has_stree,wr=Se.stat_desc.extra_bits,bn=Se.stat_desc.extra_base,rt=Se.stat_desc.max_length,gt=0;for(he=0;he<=h;he++)ae.bl_count[he]=0;for(Te[2*ae.heap[ae.heap_max]+1]=0,tt=ae.heap_max+1;tt<f;tt++)rt<(he=Te[2*Te[2*(Re=ae.heap[tt])+1]+1]+1)&&(he=rt,gt++),Te[2*Re+1]=he,yn<Re||(ae.bl_count[he]++,mt=0,bn<=Re&&(mt=wr[Re-bn]),zt=Te[2*Re],ae.opt_len+=zt*(he+mt),br&&(ae.static_len+=zt*(yr[2*Re+1]+mt)));if(gt!==0){do{for(he=rt-1;ae.bl_count[he]===0;)he--;ae.bl_count[he]--,ae.bl_count[he+1]+=2,ae.bl_count[rt]--,gt-=2}while(0<gt);for(he=rt;he!==0;he--)for(Re=ae.bl_count[he];Re!==0;)yn<(nt=ae.heap[--tt])||(Te[2*nt+1]!==he&&(ae.opt_len+=(he-Te[2*nt+1])*Te[2*nt],Te[2*nt+1]=he),Re--)}}(w,I),be(Z,ce,w.bl_count)}function n(w,I,P){var F,z,Z=-1,X=I[1],H=0,ee=7,ce=4;for(X===0&&(ee=138,ce=3),I[2*(P+1)+1]=65535,F=0;F<=P;F++)z=X,X=I[2*(F+1)+1],++H<ee&&z===X||(H<ce?w.bl_tree[2*z]+=H:z!==0?(z!==Z&&w.bl_tree[2*z]++,w.bl_tree[2*m]++):H<=10?w.bl_tree[2*v]++:w.bl_tree[2*N]++,Z=z,ce=(H=0)===X?(ee=138,3):z===X?(ee=6,3):(ee=7,4))}function D(w,I,P){var F,z,Z=-1,X=I[1],H=0,ee=7,ce=4;for(X===0&&(ee=138,ce=3),F=0;F<=P;F++)if(z=X,X=I[2*(F+1)+1],!(++H<ee&&z===X)){if(H<ce)for(;G(w,z,w.bl_tree),--H!=0;);else z!==0?(z!==Z&&(G(w,z,w.bl_tree),H--),G(w,m,w.bl_tree),V(w,H-3,2)):H<=10?(G(w,v,w.bl_tree),V(w,H-3,3)):(G(w,N,w.bl_tree),V(w,H-11,7));Z=z,ce=(H=0)===X?(ee=138,3):z===X?(ee=6,3):(ee=7,4)}}c(U);var $=!1;function S(w,I,P,F){V(w,(k<<1)+(F?1:0),3),function(z,Z,X,H){se(z),Q(z,X),Q(z,~X),r.arraySet(z.pending_buf,z.window,Z,X,z.pending),z.pending+=X}(w,I,P)}i._tr_init=function(w){$||(function(){var I,P,F,z,Z,X=new Array(h+1);for(z=F=0;z<x-1;z++)for(j[z]=F,I=0;I<1<<A[z];I++)s[F++]=z;for(s[F-1]=z,z=Z=0;z<16;z++)for(U[z]=Z,I=0;I<1<<L[z];I++)B[Z++]=z;for(Z>>=7;z<d;z++)for(U[z]=Z<<7,I=0;I<1<<L[z]-7;I++)B[256+Z++]=z;for(P=0;P<=h;P++)X[P]=0;for(I=0;I<=143;)Y[2*I+1]=8,I++,X[8]++;for(;I<=255;)Y[2*I+1]=9,I++,X[9]++;for(;I<=279;)Y[2*I+1]=7,I++,X[7]++;for(;I<=287;)Y[2*I+1]=8,I++,X[8]++;for(be(Y,_+1,X),I=0;I<d;I++)E[2*I+1]=5,E[2*I]=de(I,5);te=new J(Y,A,y+1,_,h),q=new J(E,L,0,d,h),ne=new J(new Array(0),T,0,b,g)}(),$=!0),w.l_desc=new O(w.dyn_ltree,te),w.d_desc=new O(w.dyn_dtree,q),w.bl_desc=new O(w.bl_tree,ne),w.bi_buf=0,w.bi_valid=0,oe(w)},i._tr_stored_block=S,i._tr_flush_block=function(w,I,P,F){var z,Z,X=0;0<w.level?(w.strm.data_type===2&&(w.strm.data_type=function(H){var ee,ce=4093624447;for(ee=0;ee<=31;ee++,ce>>>=1)if(1&ce&&H.dyn_ltree[2*ee]!==0)return a;if(H.dyn_ltree[18]!==0||H.dyn_ltree[20]!==0||H.dyn_ltree[26]!==0)return o;for(ee=32;ee<y;ee++)if(H.dyn_ltree[2*ee]!==0)return o;return a}(w)),Ae(w,w.l_desc),Ae(w,w.d_desc),X=function(H){var ee;for(n(H,H.dyn_ltree,H.l_desc.max_code),n(H,H.dyn_dtree,H.d_desc.max_code),Ae(H,H.bl_desc),ee=b-1;3<=ee&&H.bl_tree[2*W[ee]+1]===0;ee--);return H.opt_len+=3*(ee+1)+5+5+4,ee}(w),z=w.opt_len+3+7>>>3,(Z=w.static_len+3+7>>>3)<=z&&(z=Z)):z=Z=P+5,P+4<=z&&I!==-1?S(w,I,P,F):w.strategy===4||Z===z?(V(w,2+(F?1:0),3),ze(w,Y,E)):(V(w,4+(F?1:0),3),function(H,ee,ce,ae){var Se;for(V(H,ee-257,5),V(H,ce-1,5),V(H,ae-4,4),Se=0;Se<ae;Se++)V(H,H.bl_tree[2*W[Se]+1],3);D(H,H.dyn_ltree,ee-1),D(H,H.dyn_dtree,ce-1)}(w,w.l_desc.max_code+1,w.d_desc.max_code+1,X+1),ze(w,w.dyn_ltree,w.dyn_dtree)),oe(w),F&&se(w)},i._tr_tally=function(w,I,P){return w.pending_buf[w.d_buf+2*w.last_lit]=I>>>8&255,w.pending_buf[w.d_buf+2*w.last_lit+1]=255&I,w.pending_buf[w.l_buf+w.last_lit]=255&P,w.last_lit++,I===0?w.dyn_ltree[2*P]++:(w.matches++,I--,w.dyn_ltree[2*(s[P]+y+1)]++,w.dyn_dtree[2*R(I)]++),w.last_lit===w.lit_bufsize-1},i._tr_align=function(w){V(w,2,3),G(w,C,Y),function(I){I.bi_valid===16?(Q(I,I.bi_buf),I.bi_buf=0,I.bi_valid=0):8<=I.bi_valid&&(I.pending_buf[I.pending++]=255&I.bi_buf,I.bi_buf>>=8,I.bi_valid-=8)}(w)}},{"../utils/common":41}],53:[function(e,u,i){u.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,u,i){(function(r){(function(a,o){if(!a.setImmediate){var c,k,x,y,_=1,d={},b=!1,f=a.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(a);h=h&&h.setTimeout?h:a,c={}.toString.call(a.process)==="[object process]"?function(m){process.nextTick(function(){g(m)})}:function(){if(a.postMessage&&!a.importScripts){var m=!0,v=a.onmessage;return a.onmessage=function(){m=!1},a.postMessage("","*"),a.onmessage=v,m}}()?(y="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",C,!1):a.attachEvent("onmessage",C),function(m){a.postMessage(y+m,"*")}):a.MessageChannel?((x=new MessageChannel).port1.onmessage=function(m){g(m.data)},function(m){x.port2.postMessage(m)}):f&&"onreadystatechange"in f.createElement("script")?(k=f.documentElement,function(m){var v=f.createElement("script");v.onreadystatechange=function(){g(m),v.onreadystatechange=null,k.removeChild(v),v=null},k.appendChild(v)}):function(m){setTimeout(g,0,m)},h.setImmediate=function(m){typeof m!="function"&&(m=new Function(""+m));for(var v=new Array(arguments.length-1),N=0;N<v.length;N++)v[N]=arguments[N+1];var A={callback:m,args:v};return d[_]=A,c(_),_++},h.clearImmediate=p}function p(m){delete d[m]}function g(m){if(b)setTimeout(g,0,m);else{var v=d[m];if(v){b=!0;try{(function(N){var A=N.callback,L=N.args;switch(L.length){case 0:A();break;case 1:A(L[0]);break;case 2:A(L[0],L[1]);break;case 3:A(L[0],L[1],L[2]);break;default:A.apply(o,L)}})(v)}finally{p(m),b=!1}}}}function C(m){m.source===a&&typeof m.data=="string"&&m.data.indexOf(y)===0&&g(+m.data.slice(y.length))}})(typeof self>"u"?r===void 0?this:r:self)}).call(this,typeof ct<"u"?ct:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Gt);var Yn=Gt.exports;const Jn=Xn(Yn),Ze=(t,l)=>{const e=t==null?void 0:t.getAttribute(l);return e==null||e===""?null:e};function Kt(t){const l=Number(Ze(t,"type")??0),e=Ze(t,"solution");return{type:l,typeName:_e(l),schemaName:Ze(t,"schemaName"),displayName:Ze(t,"displayName"),id:Ze(t,"id"),solution:e&&e.replace(/\s*\([\d.]+\)\s*$/,"").trim()||null,parentSchemaName:Ze(t,"parentSchemaName")}}const $e=t=>t.schemaName??t.displayName??t.id??"(unnamed)";function Qn(t){const l=new DOMParser().parseFromString(t,"application/xml");if(l.getElementsByTagName("parsererror").length)throw new Error("solution.xml: invalid XML");const e=l.querySelector("ImportExportXml > SolutionManifest");if(!e)throw new Error("solution.xml: SolutionManifest not found");const u=r=>{var a,o;return((o=(a=e.querySelector(r))==null?void 0:a.textContent)==null?void 0:o.trim())??""},i=Array.from(e.querySelectorAll(":scope > MissingDependencies > MissingDependency")).map(r=>({required:Kt(r.querySelector(":scope > Required")),dependent:Kt(r.querySelector(":scope > Dependent"))}));return{uniqueName:u(":scope > UniqueName"),version:u(":scope > Version"),managed:u(":scope > Managed")!=="0"&&u(":scope > Managed")!=="",missing:i}}function er(t,l,e){const u=new Map;for(const i of t){const r=i.required,a=We(l,null,$e(r))||!!r.solution&&We(l,{uniqueName:r.solution,prefix:""},$e(r)),o=!!r.solution&&!!(e!=null&&e.has(r.solution.toLowerCase()));if(!a&&!(e&&r.solution&&!o))continue;const c=i.dependent,k=`${c.type}:${(c.id??$e(c)).toLowerCase()}:${c.parentSchemaName??""}`,x=u.get(k)??{key:k,dependent:c,required:[],status:"safe"};x.required.some(y=>y.type===r.type&&$e(y)===$e(r))||x.required.push({...r,safe:o}),o||(x.status="blocker"),u.set(k,x)}return[...u.values()].sort((i,r)=>(i.status===r.status?0:i.status==="blocker"?-1:1)||i.dependent.type-r.dependent.type||$e(i.dependent).localeCompare($e(r.dependent)))}async function tr(t,l,e,u){let i;try{i=await Jn.loadAsync(l)}catch{throw new Error(`${t}: not a zip file`)}const r=i.file(/^solution\.xml$/i)[0];if(!r)throw new Error(`${t}: solution.xml not found (is this a solution export?)`);const a=Qn(await r.async("string"));return{fileName:t,uniqueName:a.uniqueName,version:a.version,managed:a.managed,total:a.missing.length,groups:er(a.missing,e,u)}}const Vt=()=>window,je=()=>Vt().toolboxAPI,Xt=()=>Vt().dataverseAPI,Yt=()=>{var t;return!!((t=je())!=null&&t.connections)&&!!Xt()};async function Jt(){var i,r;const t=je();if(!(t!=null&&t.connections))return[];const l=[],e=await t.connections.getActiveConnection().catch(()=>null);e&&l.push({target:"primary",conn:e});const u=await((r=(i=t.connections).getSecondaryConnection)==null?void 0:r.call(i).catch(()=>null));return u&&l.push({target:"secondary",conn:u}),l}function nr(t){var l,e;try{(e=(l=je())==null?void 0:l.events)==null||e.on((u,i)=>{typeof(i==null?void 0:i.event)=="string"&&i.event.startsWith("connection:")&&t()})}catch{}}async function rr(t){var u,i,r,a;const l=je();let e=(u=window.matchMedia)!=null&&u.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light";if((i=l==null?void 0:l.utils)!=null&&i.getCurrentTheme)try{e=await l.utils.getCurrentTheme()}catch{}t(e);try{(r=l==null?void 0:l.events)==null||r.on((o,c)=>{var k;if((c==null?void 0:c.event)==="settings:updated"){const x=(k=c.data)==null?void 0:k.theme;(x==="light"||x==="dark")&&t(x)}})}catch{}l||(a=window.matchMedia)==null||a.call(window,"(prefers-color-scheme: dark)").addEventListener("change",o=>t(o.matches?"dark":"light"))}async function we(t,l,e="info"){var i;const u=je();if((i=u==null?void 0:u.utils)!=null&&i.showNotification)try{await u.utils.showNotification({title:t,body:l,type:e,duration:4e3});return}catch{}console[e==="error"?"error":"log"](`${t}: ${l}`)}async function Qt(t,l,e="application/json"){var a;const u=je();if((a=u==null?void 0:u.fileSystem)!=null&&a.saveFile)return!!await u.fileSystem.saveFile(t,l);const i=URL.createObjectURL(new Blob([l],{type:e})),r=document.createElement("a");return r.href=i,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e3),!0}function ir(t){if(t instanceof Uint8Array)return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);const l=t;if(l&&l.type==="Buffer"&&Array.isArray(l.data))return Uint8Array.from(l.data);if(Array.isArray(t))return Uint8Array.from(t);throw new Error("Unsupported binary payload from host")}function en(t,l){return new Promise(e=>{const u=document.createElement("input");u.type="file",u.accept=t,u.multiple=l,u.addEventListener("change",()=>e(Array.from(u.files??[]))),u.addEventListener("cancel",()=>e([])),u.click()})}async function or(t){var u;const l=je();if((u=l==null?void 0:l.fileSystem)!=null&&u.selectPath){const i=await l.fileSystem.selectPath({type:"file",title:t.title,filters:[{name:t.extensions.map(a=>a.toUpperCase()).join(" / "),extensions:t.extensions},{name:"All files",extensions:["*"]}]});if(!i)return[];const r=await l.fileSystem.readBinary(i);return[{name:i.split(/[\\/]/).pop()??i,data:ir(r)}]}const e=await en(t.extensions.map(i=>`.${i}`).join(","),!!t.multiple);return Promise.all(e.map(async i=>({name:i.name,data:new Uint8Array(await i.arrayBuffer())})))}async function ar(t){var u;const l=je();if((u=l==null?void 0:l.fileSystem)!=null&&u.selectPath){const i=await l.fileSystem.selectPath({type:"file",title:t.title,filters:[{name:t.extensions.join("/"),extensions:t.extensions}]});return i?{name:i.split(/[\\/]/).pop()??i,text:await l.fileSystem.readText(i)}:null}const[e]=await en(t.extensions.map(i=>`.${i}`).join(","),!1);return e?{name:e.name,text:await e.text()}:null}let Ve=[],Pe=[],Le=null,St=new jt;const tn=new Map;let Xe,re=null;const Ne=new Map;let ke=null,xe=[],Ye=!1,Je=null,Fe=null,Ct=0,Et=!1,At=!1,le=null;const He=()=>Xt(),ve=()=>Ve.find(t=>t.target==="primary"),nn=()=>Ve.find(t=>t.target==="secondary"),Qe=t=>!!t&&(t.conn.environment==="Production"||/\bprod/i.test(t.conn.name)),dt=()=>{var e;const t=((e=ve())==null?void 0:e.conn.url)??"";let l=tn.get(t);return l||tn.set(t,l=new Map),l},ft=(t,l)=>!!t&&!!l&&t.replace(/\/+$/,"").toLowerCase()===l.replace(/\/+$/,"").toLowerCase(),rn=t=>t.map(l=>`${l.target}:${l.conn.id}:${l.conn.url}`).join("|"),on=async()=>(await Jt().catch(()=>[])).find(t=>t.target==="primary"),et=()=>{ke=null,xe=[],Ye=!1,Je=null,Fe=null},It=()=>{const t=Mn(K("#filter").value);return t.length?t:kn};function Ee(t){const l=K("#status");l.hidden=!t,l.textContent=t??""}function an(t,l){const e=M("span",{class:"dot"});return t.conn.environmentColor&&(e.style.background=t.conn.environmentColor),M("span",{class:"connchip",title:t.conn.url},e,M("span",{class:"env"},t.conn.name),M("span",{class:"kind"},`${l} · ${t.conn.environment}`))}function sn(){const t=ve(),l=re==null?void 0:re.solution;return!t||!l?"https://make.powerapps.com/":Xe?`https://make.powerapps.com/environments/${Xe}/solutions/${l.id}`:`${t.conn.url.replace(/\/+$/,"")}/tools/solution/edit.aspx?id=${l.id}`}async function ln(){const t=rn(Ve);Ve=await Jt(),St=new jt,Xe=void 0,rn(Ve)!==t&&(Ct++,re=null,Ne.clear(),et(),le=null,K("#fix-results").replaceChildren(),K("#restore-results").replaceChildren(),K("#restore-file").textContent="",Ge(),qe());const l=K("#conn");l.replaceChildren();const e=ve(),u=nn();e&&l.append(an(e,"dev")),u&&l.append(an(u,"target")),e||l.append(M("span",{class:"caption"},Yt()?"No connection. Pick a primary (dev) connection in ToolBox.":"Standalone: Offline tab only."));const i=He();if(Pe=[],Le=null,i&&e){Ee("Loading solutions…");try{Pe=await wt(i,"primary")}catch(c){await we("Load failed",c.message,"error")}if(u)try{Le=new Set((await wt(i,"secondary")).map(c=>c.uniqueName.toLowerCase()))}catch(c){await we("Target load failed",`${u.conn.name}: ${c.message}`,"warning")}Ee(null)}const r=K("#solution"),a=r.value,o=Pe.filter(c=>!c.isManaged&&!["default","active","basic"].includes(c.uniqueName.toLowerCase()));r.replaceChildren(...o.length?o.map(c=>M("option",{value:c.id},`${c.friendlyName} (${c.uniqueName}) ${c.version}`)):[M("option",{value:""},e?"No unmanaged solutions":"No connection")]),[...r.options].some(c=>c.value===a)&&(r.value=a),K("#btn-run").disabled=!o.length}async function cn(){const t=He(),l=ve(),e=Pe.find(r=>r.id===K("#solution").value);if(!t||!l||!e||At)return;At=!0,Et=!1;const u=Ct;K("#btn-cancel").hidden=!1,K("#btn-run").disabled=!0,K("#progress").hidden=!1;const i=K("#progress-bar");try{Xe===void 0&&(Xe=await Nn(t));const r=nn(),a=await Gn({api:t,meta:St,reqCache:dt(),solution:e,allSolutions:Pe,targetSolutions:Le,filter:It(),environment:{name:l.conn.name,url:l.conn.url,environment:l.conn.environment},target:r&&Le?{name:r.conn.name,url:r.conn.url}:null,link:()=>sn(),onProgress:(o,c)=>{i.max=Math.max(c,1),i.value=o,K("#progress-text").textContent=`RetrieveRequiredComponents ${o} / ${c}`},cancelled:()=>Et});if(u!==Ct)return;re=a;for(const o of re.findings)for(const c of o.fixes)c.kind==="report"&&(c.link=sn());for(const[o,c]of[...Ne])re.findings.some(k=>k.key===o&&k.fixes.some(x=>x.kind===c))||Ne.delete(o)}catch(r){r instanceof Wt?await we("Cancelled","Diagnosis cancelled. Finished calls stay cached.","info"):await we("Diagnosis failed",r.message,"error")}finally{At=!1,K("#btn-cancel").hidden=!0,K("#btn-run").disabled=!1,K("#progress").hidden=!0}ht()}function sr(t){var e;const l=!!t.solution&&!!(Le!=null&&Le.has(t.solution.uniqueName.toLowerCase()));return M("span",{class:`req${l?" is-safe":""}`,title:t.solutions.join(", ")},M("span",{class:"sol"},((e=t.solution)==null?void 0:e.uniqueName)??"unknown solution"),`${_e(t.type)} ${t.name}`,l?" · in target":"")}function lr(t){const l=M("select",{class:"fix","aria-label":`Fix for ${t.dependent.name}`});l.append(M("option",{value:""},"No action"),...t.fixes.map(u=>M("option",{value:u.kind},u.label))),l.value=Ne.get(t.key)??"",l.addEventListener("change",()=>{l.value?Ne.set(t.key,l.value):Ne.delete(t.key),un()});const e=t.fixes.find(u=>u.kind==="report");return M("li",{class:`finding${t.status==="safe"?" is-safe":""}`,"data-key":t.key},M("div",{class:"head"},pe(_e(t.dependent.type),"neutral"),M("span",{class:"name mono"},t.dependent.name),t.dependent.table||t.dependent.rootTable?M("span",{class:"caption"},t.dependent.table??t.dependent.rootTable??""):null,t.dependent.rootBehavior===0?pe("table: all assets","warn"):null,pe(t.status==="blocker"?"blocker":"present in target",t.status==="blocker"?"bad":"ok"),l),M("div",{class:"cause"},t.cause),M("div",{class:"chips"},...t.required.map(sr)),e!=null&&e.link?M("div",{class:"caption"},e.note??""," ",M("a",{href:e.link,target:"_blank",rel:"noopener"},"Open solution in maker portal")):null)}function un(){K("#sel-count").textContent=`${Ne.size} selected`,K("#btn-to-fix").disabled=Ne.size===0}function ht(){const t=K("#findings"),l=K("#diag-summary");t.replaceChildren(),l.replaceChildren(),K("#diag-actions").hidden=!re;for(const o of["#btn-export-json","#btn-export-csv"])K(o).toggleAttribute("disabled",!re);if(!re){t.append(Be("No diagnosis yet",ve()?"Pick an unmanaged solution and run Diagnose.":"Connect a dev environment in ToolBox, or use the Offline tab."));return}const e=re,u=e.findings.filter(o=>o.status==="blocker"),i=e.findings.length-u.length,r=K("#show-safe").checked;l.append(M("div",{class:"summary"},M("strong",{},`${e.solution.friendlyName}`),`${e.components.length} components ·`,pe(`${u.length} blocker${u.length===1?"":"s"}`,u.length?"bad":"ok"),e.target?pe(`${i} present in target`,"ok"):M("span",{class:"caption"},"No target connection: every dependency matching the filter counts."),e.errors.length?pe(`${e.errors.length} lookups failed`,"warn"):null)),e.errors.length&&l.append(M("div",{class:"warnings"},`RetrieveRequiredComponents failed for ${e.errors.length} component(s): ${e.errors.slice(0,3).map(o=>`${o.component} (${o.error})`).join("; ")}`));const a=e.findings.filter(o=>r||o.status==="blocker");a.length?t.append(M("ul",{class:"findings"},...a.map(lr))):t.append(Be("No blocking dependencies",e.findings.length?"Everything found is present in the target. Tick “Show present in target” to see it.":"Nothing in this solution depends on the filtered solutions.")),un()}function Nt(t,l,e){const u=M("pre",{class:"diff","aria-label":e});for(const i of Dn(t,l))u.append(M("span",{class:i.t==="-"?"del":i.t==="+"?"add":i.t==="…"?"gap":"ctx"},i.t==="…"?"…":`${i.t} ${i.s}`));return u}function dn(t){const l=M("li",{class:"op","data-kind":t.kind},M("span",{class:"mono"},xt(t)));if((t.kind==="remove"||t.kind==="add")&&l.append(" ",M("span",{class:"why"},t.reason)),t.kind==="update-form"){const e=t.edit;Ie(l,e.removed.length?M("div",{class:"caption"},`Removes: ${e.removed.join(", ")}`):null,e.kept.length?M("div",{class:"caption"},`Kept: ${e.kept.map(u=>`${u.name} (${u.reason})`).join(", ")}`):null,e.warnings.length?M("div",{class:"warnings"},e.warnings.join(" ")):null,Nt(e.form.formxml,e.after,`formxml diff ${e.form.name}`))}if(t.kind==="update-view"){const e=t.edit;Ie(l,e.removed.length?M("div",{class:"caption"},`Removes: ${e.removed.join(", ")}`):null,e.warnings.length?M("div",{class:"warnings"},e.warnings.join(" ")):null,Nt(e.view.fetchxml,e.after.fetchxml,`fetchxml diff ${e.view.name}`),Nt(e.view.layoutxml,e.after.layoutxml,`layoutxml diff ${e.view.name}`))}return l}function fn(){return!!(re!=null&&re.solution.isManaged)}function pt(){const t=!Qe(ve())||K("#prod-ack").checked;K("#btn-confirm").disabled=!(Ye&&xe.length&&Fe&&t&&!fn()),K("#btn-backup").textContent=Ye?"1. Backup saved ✓":"1. Download backup"}function Ge(){const t=K("#fix-banners"),l=K("#fix-body");if(t.replaceChildren(),l.replaceChildren(),K("#fix-actions").hidden=!ke,pt(),Je){t.append(M("div",{class:"danger-banner",id:"preview-error"},Je)),l.append(Be("Preview refused","Change the selected fixes in Diagnose, then Preview fixes again."));return}if(!ke||!re){l.append(Be("Nothing selected","Pick a fix on one or more findings in Diagnose, then Preview fixes."));return}fn()&&t.append(M("div",{class:"danger-banner"},`${re.solution.uniqueName} is managed. Writes are refused: fix dependencies in the dev environment, in the unmanaged solution.`)),Qe(ve())&&t.append(M("div",{class:"danger-banner"},`This connection (${ve().conn.name}) looks like Production. Dependencies are fixed in dev.`)),K("#prod-ack-wrap").hidden=!Qe(ve());for(const e of ke.shells){const u=e.leaving.map(i=>{const r=M("input",{type:"checkbox","aria-label":`Keep ${i.component.name}`});return r.checked=i.keep,r.addEventListener("change",()=>{i.keep=r.checked,xe=Ft(ke),hn()}),M("label",{title:i.why},r,pe(_e(i.component.type),"neutral"),M("span",{class:"mono"},i.component.name??i.component.objectId),M("span",{class:"caption"},i.why))});l.append(M("div",{class:"card"},M("div",{class:"card-head"},M("h3",{},`Shell conversion: ${e.root.name}`),pe(`${e.leaving.filter(i=>!i.keep).length} leave`,"warn")),M("div",{class:"card-body"},M("p",{class:"caption"},"The table is removed and added back without subcomponents. Every subcomponent below leaves the solution unless ticked to re-add. Other developers may rely on them."),e.leaving.length?M("div",{class:"leaving"},...u):M("p",{class:"caption"},"No subcomponent rows."))))}ke.skipped.length&&l.append(M("div",{class:"warnings"},"Not changed: ",ke.skipped.map(e=>`${e.name} (${e.reason})`).join("; "))),l.append(M("div",{id:"ops-wrap"})),hn()}function hn(){const t=document.getElementById("ops-wrap");t&&(t.replaceChildren(M("h3",{},`${xe.length} operation${xe.length===1?"":"s"} on ${(re==null?void 0:re.solution.uniqueName)??""}`),xe.length?M("ol",{class:"ops",id:"ops"},...xe.map(dn)):Be("No operations","The selected fixes change nothing.")),pt())}async function cr(){const t=He(),l=ve();if(!t||!l||!re)return;const e=[...Ne].map(([u,i])=>({finding:re.findings.find(r=>r.key===u),fix:i})).filter(u=>u.finding&&u.finding.fixes.some(i=>i.kind===u.fix));Ee("Preparing preview…"),et(),K("#prod-ack").checked=!1,K("#fix-results").replaceChildren();try{if(!ft(l.conn.url,re.environment.url))throw new Error(`The diagnosis was run on ${re.environment.url}, the connection is now ${l.conn.url}. Run Diagnose again.`);ke=await Tn(t,St,re,e),xe=Ft(ke),Fe={id:l.conn.id,url:l.conn.url}}catch(u){et(),Je=u.message,await we("Preview failed",Je,"error")}finally{Ee(null)}document.querySelector('.tab[data-tab="fix"]').click(),Ge()}async function ur(){if(!re||!ke)return;const t=Pn(re,ke,xe);await Qt(Fn(re.solution.uniqueName),JSON.stringify(t,null,2))&&(Ye=!0,await we("Backup saved","Keep it: the Restore tab reapplies it.","success")),pt()}function pn(t){return M("table",{},M("thead",{},M("tr",{},M("th",{},"Operation"),M("th",{},"Result"))),M("tbody",{},...t.map(l=>M("tr",{},M("td",{class:"mono"},xt(l.op)),M("td",{},l.ok?pe("ok","ok"):l.skipped?pe(l.error??"skipped","neutral"):pe(l.error??"failed","bad"))))))}async function dr(){const t=He();if(!t||!re||!ke||!Ye||!xe.length||!Fe)return;const l=re.solution,e=await on();if(!e||e.conn.id!==Fe.id||!ft(e.conn.url,Fe.url)){const y=Fe.url;et(),Ge(),await we("Refused",`The plan was made on ${y}, the connection is now ${(e==null?void 0:e.conn.url)??"none"}. Nothing was written: run Diagnose and Preview again.`,"error");return}const u=await Tt(t,l.id).catch(()=>null);if(!u||u.isManaged||l.isManaged){re={...re,solution:{...re.solution,isManaged:!0}},Ge(),await we("Refused",`${l.uniqueName} is managed (or could not be read). Nothing was written.`,"error");return}K("#btn-confirm").disabled=!0;const i=re.findings.filter(y=>y.status==="blocker").map(y=>y.key),r=new Set;for(const y of xe)y.kind==="update-form"&&r.add(Oe(ie.Form,y.edit.form.id)),y.kind==="update-view"&&r.add(Oe(ie.View,y.edit.view.id)),(y.kind==="remove"||y.kind==="add")&&r.add(Oe(y.component.type,y.component.id));const a=await qt(t,xe,u.uniqueName,(y,_)=>Ee(y<_?`Applying ${y+1} / ${_}…`:null));Ee(null);const o=a.filter(y=>!y.ok&&!y.skipped).length;await we(o?"Some operations failed":"Applied",o?"Restore from the backup if needed.":`${a.length} operations done. Re-running diagnosis…`,o?"error":"success");for(const y of r)dt().delete(y);et(),Ne.clear(),Ge();const c=K("#fix-results");c.replaceChildren(M("h3",{},"Results"),pn(a)),await cn();const k=new Set(((re==null?void 0:re.findings)??[]).filter(y=>y.status==="blocker").map(y=>y.key)),x=i.filter(y=>!k.has(y)).length;c.append(M("div",{class:"summary",id:"rediag"},M("strong",{},"Re-diagnosis:"),pe(`${x} fixed`,"ok"),pe(`${i.length-x} still present`,i.length-x?"bad":"ok"),pe(`${k.size} blockers now`,k.size?"bad":"ok")))}async function fr(){const t=await ar({title:"Open Dependency Cleaner backup",extensions:["json"]});if(!t)return;K("#restore-results").replaceChildren();try{le={backup:qn(t.text),plan:null,url:null},K("#restore-file").textContent=t.name}catch(u){le=null,await we("Backup rejected",`${t.name}: ${u.message}`,"error"),qe();return}const l=He(),e=ve();if(l&&e){Ee("Comparing backup to the environment…"),le.url=e.conn.url;try{le.plan=await Un(l,le.backup,Pe.length?Pe:await wt(l,"primary"),e.conn.url)}catch(u){await we("Restore refused",u.message,"error"),qe(u.message),Ee(null);return}Ee(null)}qe()}function qe(t){var u;const l=K("#restore-body");if(l.replaceChildren(),K("#restore-actions").hidden=!(le!=null&&le.plan),K("#btn-restore-apply").disabled=!((u=le==null?void 0:le.plan)!=null&&u.ops.length),!le){l.append(Be("No backup loaded","Load a dependency-cleaner-backup-*.json file saved before a fix."));return}const e=le.backup;if(l.append(M("p",{class:"caption"},`Backup of ${e.solution.uniqueName} from ${e.environment.name}, ${e.takenAt}. ${e.membership.length} members, ${e.forms.length} forms, ${e.views.length} views.`)),t&&l.append(M("div",{class:"danger-banner",id:"restore-error"},t)),!!le.plan){for(const i of le.plan.notes)l.append(M("div",{class:"warnings"},i));Qe(ve())&&l.append(M("div",{class:"danger-banner"},`This connection (${ve().conn.name}) looks like Production.`)),l.append(le.plan.ops.length?M("ol",{class:"ops",id:"restore-ops"},...le.plan.ops.map(dn)):Be("Nothing to restore","The environment already matches the backup."))}}async function hr(){var o,c,k;const t=He();if(!t||!(le!=null&&le.plan))return;const l=le.plan,e=await on();if(!e||!ft(e.conn.url,le.url)||!ft(e.conn.url,(o=le.backup.environment)==null?void 0:o.url)){le.plan=null,qe(),await we("Refused",`The backup is from ${((c=le.backup.environment)==null?void 0:c.url)??"an unknown environment"}, the connection is now ${(e==null?void 0:e.conn.url)??"none"}. Nothing was written: load the backup again on the right connection.`,"error");return}const u=await Tt(t,l.solution.id).catch(()=>null);if(!u||u.isManaged){await we("Refused",`${l.solution.uniqueName} is managed (or could not be read). Nothing was written.`,"error");return}if(!await wn({title:"Apply restore",body:M("p",{},`${l.ops.length} operations on ${l.solution.uniqueName} in ${((k=ve())==null?void 0:k.conn.name)??""}.`),okLabel:`Apply ${l.ops.length}`,danger:Qe(ve())}))return;const r=await qt(t,l.ops,u.uniqueName,(x,y)=>Ee(x<y?`Restoring ${x+1} / ${y}…`:null));Ee(null);for(const x of l.ops)x.kind==="update-form"&&dt().delete(Oe(ie.Form,x.edit.form.id)),x.kind==="update-view"&&dt().delete(Oe(ie.View,x.edit.view.id));const a=r.filter(x=>!x.ok&&!x.skipped).length;await we(a?"Restore incomplete":"Restored",`${r.length-a} ok, ${a} failed`,a?"error":"success"),le.plan=null,qe(),K("#restore-results").replaceChildren(M("h3",{},"Restore results"),pn(r))}async function mn(t,l){const e=K("#offline-body");try{pr(await tr(t,l,It(),Le))}catch(u){e.replaceChildren(M("div",{class:"danger-banner"},u.message))}}function pr(t){const l=t.groups.filter(i=>i.status==="blocker").length,e=i=>`${i.typeName} ${$e(i)}${i.parentSchemaName?` (${i.parentSchemaName})`:""}`,u=t.groups.map(i=>M("li",{class:`finding${i.status==="safe"?" is-safe":""}`},M("div",{class:"head"},pe(i.dependent.typeName,"neutral"),M("span",{class:"name mono"},$e(i.dependent)),i.dependent.parentSchemaName?M("span",{class:"caption"},i.dependent.parentSchemaName):null,pe(i.status==="blocker"?"blocker":"present in target",i.status==="blocker"?"bad":"ok")),M("div",{class:"chips"},...i.required.map(r=>M("span",{class:`req${r.safe?" is-safe":""}`},M("span",{class:"sol"},r.solution??"unknown solution"),e(r))))));K("#offline-body").replaceChildren(M("div",{class:"summary",id:"offline-summary"},M("strong",{},`${t.uniqueName} ${t.version}`),t.managed?pe("managed","neutral"):pe("unmanaged","neutral"),`${t.total} missing dependencies in solution.xml ·`,pe(`${t.groups.length} dependents in scope`,"neutral"),pe(`${l} blocking`,l?"bad":"ok")),t.groups.length?M("ul",{class:"findings"},...u):Be("No missing dependencies in scope",`Filter: ${It().join(", ")}`))}function mr(){const t=K("#drop");t.addEventListener("dragover",l=>{l.preventDefault(),t.classList.add("is-over")}),t.addEventListener("dragleave",()=>t.classList.remove("is-over")),t.addEventListener("drop",async l=>{var u,i;l.preventDefault(),t.classList.remove("is-over");const e=(i=(u=l.dataTransfer)==null?void 0:u.files)==null?void 0:i[0];e&&await mn(e.name,new Uint8Array(await e.arrayBuffer()))}),K("#btn-open-zip").addEventListener("click",async()=>{const[l]=await or({title:"Open solution zip",extensions:["zip"]});l&&await mn(l.name,l.data)})}async function gn(t,l,e){await Qt(t,l,e)&&await we("Exported",t,"success")}function gr(){vn(),K("#btn-run").addEventListener("click",()=>void cn()),K("#btn-cancel").addEventListener("click",()=>{Et=!0}),K("#show-safe").addEventListener("change",ht),K("#btn-to-fix").addEventListener("click",()=>void cr()),K("#btn-backup").addEventListener("click",()=>void ur()),K("#prod-ack").addEventListener("change",pt),K("#btn-confirm").addEventListener("click",()=>void dr()),K("#btn-load-backup").addEventListener("click",()=>void fr()),K("#btn-restore-apply").addEventListener("click",()=>void hr()),K("#btn-export-json").addEventListener("click",()=>{re&&gn(`dependency-findings.${Ht(re.solution.uniqueName)}.json`,Vn(re),"application/json")}),K("#btn-export-csv").addEventListener("click",()=>{re&&gn(`dependency-findings.${Ht(re.solution.uniqueName)}.csv`,Kn(re),"text/csv")}),mr(),nr(()=>void ln().then(ht)),K("#host-mode").textContent=Yt()?"Running inside Power Platform ToolBox":"Standalone mode (Offline tab only)"}rr(t=>document.documentElement.setAttribute("data-theme",t)),gr(),ht(),Ge(),qe(),ln()})();