// @requirements REQ-NZ-INDIRECT REQ-PRODUCT-INDIRECT-NOTICE
import {compileLegalDocuments,createIndirectCollectionNotice} from 'notabenda/content';
import {renderIndirectCollectionNotice,formatIndirectCollectionNotice} from 'notabenda/collection/indirect';
import {renderLegalLinks} from 'notabenda';
export async function indirectCollectionFiles(base){
const files={};
for(const prefix of ['','/dark']){
const config=structuredClone(base),root=prefix+'/indirect-collection';
config.site.id='juniper-indirect-collection';config.site.locale='en-NZ';config.purposes=config.purposes.filter(p=>p.id==='enquiries');config.services=[];config.storage=[];
const purpose=config.purposes[0];purpose.name='Responding to a referral';purpose.description='We use your reply address and the topic of your enquiry to contact you about the writing work you asked a partner studio about.';purpose.dataCategories=['Reply address','Enquiry topic'];purpose.collection={source:'indirect',description:'An enquiry referred by a partner studio.',required:false,consequences:'The referred enquiry cannot be followed up without contact information.'};
for(const [kind,doc] of Object.entries(config.documents))doc.route=root+'/'+kind;
const build=compileLegalDocuments(config,{mode:'preview',stylesheetUrl:prefix?'/assets/dark.css':'/assets/notabenda.css'});
const settings={profile:'nz-ipp3a',scopeId:'studio-referral',phase:'collected',reviewStatus:'draft',wording:{title:'About your referral',intro:'A partner studio has passed your enquiry to Juniper Notes so we can follow up with you.'},collections:[{purposeId:purpose.id,dataCategories:['Reply address','Enquiry topic'],sourceDescription:'The partner studio you contacted about writing work.',authority:{kind:'not-relied-on'}}],recipientStatement:'Our enquiries team uses the referral to respond. We do not pass the referral to other organisations.',accessCorrection:{statement:'You can ask for access to your personal information or ask us to correct it. Contact our privacy team using the link below.',url:'mailto:'+config.controller.email}};
const notice=createIndirectCollectionNotice(build.artifact,settings,{mode:'preview'}),advance=createIndirectCollectionNotice(build.artifact,{...settings,phase:'advance',wording:{title:'Before your referral',intro:'A partner studio plans to pass your enquiry to Juniper Notes so we can follow up with you.'}},{mode:'preview'});
Object.assign(files,build.files);
const path=root.slice(1);
files[path+'/notice.json']=JSON.stringify(notice,null,2)+'\n';files[path+'/notice.txt']=formatIndirectCollectionNotice(notice,{allowPreview:true});
files[path+'/advance.json']=JSON.stringify(advance,null,2)+'\n';files[path+'/advance.txt']=formatIndirectCollectionNotice(advance,{allowPreview:true});
files[path+'/index.html']=`
A referred enquiry · Juniper NotesJuniper NotesIndirect collection
Notabenda · Information from another source
An enquiry passed on.
When a partner passes on an enquiry, explain what you received and how you will use it.